Struct bio::pattern_matching::myers::MyersBuilder
source · [−]pub struct MyersBuilder { /* private fields */ }
Expand description
Builds a Myers instance, allowing to specify ambiguities.
Example:
This example shows how recognition of IUPAC ambiguities in patterns can be implemented:
use bio::pattern_matching::myers::MyersBuilder;
let ambigs = [
(b'M', &b"AC"[..]),
(b'R', &b"AG"[..]),
(b'W', &b"AT"[..]),
(b'S', &b"CG"[..]),
(b'Y', &b"CT"[..]),
(b'K', &b"GT"[..]),
(b'V', &b"ACGMRS"[..]),
(b'H', &b"ACTMWY"[..]),
(b'D', &b"AGTRWK"[..]),
(b'B', &b"CGTSYK"[..]),
(b'N', &b"ACGTMRWSYKVHDB"[..]),
];
let mut builder = MyersBuilder::new();
for &(base, equivalents) in &ambigs {
builder.ambig(base, equivalents);
}
let text = b"GGATGNGCGCCATAG";
let pattern = b"TRANCGG";
// * * (mismatch)
let myers = builder.build_64(pattern);
assert_eq!(myers.distance(text), 2);
Note that only ambiguities in the pattern are recognized. The reverse is not true; ambiguities
in the search text are not matched by multiple symbols in the pattern. This would require
specifying additional ambiguities (builder.ambig(b'A', b"MRWVHDN")
, etc…).
Implementations
sourceimpl MyersBuilder
impl MyersBuilder
pub fn new() -> MyersBuilder
sourcepub fn ambig<I, B>(&mut self, byte: u8, equivalents: I) -> &mut Self where
I: IntoIterator<Item = B>,
B: Borrow<u8>,
pub fn ambig<I, B>(&mut self, byte: u8, equivalents: I) -> &mut Self where
I: IntoIterator<Item = B>,
B: Borrow<u8>,
Allows to specify ambiguous symbols and their equivalents. Note that the ambiguous symbol will always be matched by itself. Explicitly including it in the equivalents is not necessary.
Example:
use bio::pattern_matching::myers::MyersBuilder;
let text = b"GGATGAGCGCCATAG";
let pattern = b"TGAGCGN";
let myers = MyersBuilder::new()
.ambig(b'N', b"ACGT")
.build_64(pattern);
assert_eq!(myers.distance(text), 0);
sourcepub fn text_wildcard(&mut self, wildcard: u8) -> &mut Self
pub fn text_wildcard(&mut self, wildcard: u8) -> &mut Self
Allows to specify a wildcard symbol, that upon appearance in the search text
shall be matched by any symbol of the pattern. Multiple wildcards are possible.
For the inverse, that is, wildcards in the pattern matching any symbol in search
text, use ambig(byte, 0..255)
.
Example:
use bio::pattern_matching::myers::MyersBuilder;
let text = b"GGATGAGCG*CATAG";
let pattern = b"TGAGCGT";
let myers = MyersBuilder::new()
.text_wildcard(b'*')
.build_64(pattern);
assert_eq!(myers.distance(text), 0);
sourcepub fn build_64<C, P>(&self, pattern: P) -> Myers<u64> where
C: Borrow<u8>,
P: IntoIterator<Item = C>,
P::IntoIter: ExactSizeIterator,
pub fn build_64<C, P>(&self, pattern: P) -> Myers<u64> where
C: Borrow<u8>,
P: IntoIterator<Item = C>,
P::IntoIter: ExactSizeIterator,
Creates a Myers instance given a pattern, using u64
as bit vector type.
Pattern length is restricted to at most 64 symbols.
sourcepub fn build<T, C, P>(&self, pattern: P) -> Myers<T> where
T: BitVec,
C: Borrow<u8>,
P: IntoIterator<Item = C>,
P::IntoIter: ExactSizeIterator,
pub fn build<T, C, P>(&self, pattern: P) -> Myers<T> where
T: BitVec,
C: Borrow<u8>,
P: IntoIterator<Item = C>,
P::IntoIter: ExactSizeIterator,
Creates a Myers instance given a pattern, using any desired type for bit vectors.
Pattern length is restricted to the size of the bit vector T
.
Example:
use bio::pattern_matching::myers::{MyersBuilder, Myers};
let myers: Myers<u32> = MyersBuilder::new()
.text_wildcard(b'*')
.build(b"TGAGCG*");
// ...
sourcepub fn build_long_64<C, P>(&self, pattern: P) -> MyersLong<u64> where
C: Borrow<u8>,
P: IntoIterator<Item = C>,
P::IntoIter: ExactSizeIterator,
pub fn build_long_64<C, P>(&self, pattern: P) -> MyersLong<u64> where
C: Borrow<u8>,
P: IntoIterator<Item = C>,
P::IntoIter: ExactSizeIterator,
Creates a long::Myers
instance given a pattern, using u64
as bit vector type.
Pattern length is not restricted regardless of the type of the bit vector.
sourcepub fn build_long<T, C, P>(&self, pattern: P) -> MyersLong<T> where
T: BitVec,
C: Borrow<u8>,
P: IntoIterator<Item = C>,
P::IntoIter: ExactSizeIterator,
pub fn build_long<T, C, P>(&self, pattern: P) -> MyersLong<T> where
T: BitVec,
C: Borrow<u8>,
P: IntoIterator<Item = C>,
P::IntoIter: ExactSizeIterator,
Creates a long::Myers
instance given a pattern, using any desired type for bit vectors.
Pattern length is not restricted regardless of the type of the bit vector.
Trait Implementations
sourceimpl Clone for MyersBuilder
impl Clone for MyersBuilder
sourcefn clone(&self) -> MyersBuilder
fn clone(&self) -> MyersBuilder
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Default for MyersBuilder
impl Default for MyersBuilder
sourcefn default() -> MyersBuilder
fn default() -> MyersBuilder
Returns the “default value” for a type. Read more
sourceimpl PartialEq<MyersBuilder> for MyersBuilder
impl PartialEq<MyersBuilder> for MyersBuilder
sourcefn eq(&self, other: &MyersBuilder) -> bool
fn eq(&self, other: &MyersBuilder) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &MyersBuilder) -> bool
fn ne(&self, other: &MyersBuilder) -> bool
This method tests for !=
.
impl Eq for MyersBuilder
impl StructuralEq for MyersBuilder
impl StructuralPartialEq for MyersBuilder
Auto Trait Implementations
impl RefUnwindSafe for MyersBuilder
impl Send for MyersBuilder
impl Sync for MyersBuilder
impl Unpin for MyersBuilder
impl UnwindSafe for MyersBuilder
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcepub fn equivalent(&self, key: &K) -> bool
pub fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
pub fn to_subset(&self) -> Option<SS>
pub fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
pub fn is_in_subset(&self) -> bool
pub fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
pub fn to_subset_unchecked(&self) -> SS
pub fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
pub fn from_subset(element: &SS) -> SP
pub fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more