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 Selfwhere
I: IntoIterator<Item = B>,
B: Borrow<u8>,
pub fn ambig<I, B>(&mut self, byte: u8, equivalents: I) -> &mut Selfwhere
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
sourcepub fn build_128<C, P>(&self, pattern: P) -> Myers<u128>where
C: Borrow<u8>,
P: IntoIterator<Item = C>,
P::IntoIter: ExactSizeIterator,
pub fn build_128<C, P>(&self, pattern: P) -> Myers<u128>where
C: Borrow<u8>,
P: IntoIterator<Item = C>,
P::IntoIter: ExactSizeIterator,
Creates a Myers instance given a pattern, using u128
as bit vector type
sourcepub fn build<'a, T, C, P>(&self, pattern: P) -> Myers<T>where
T: BitVec,
C: Borrow<u8>,
P: IntoIterator<Item = C>,
P::IntoIter: ExactSizeIterator,
pub fn build<'a, 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
Example:
use bio::pattern_matching::myers::{MyersBuilder, Myers};
let myers: Myers<u32> = MyersBuilder::new()
.text_wildcard(b'*')
.build(b"TGAGCG*");
// ...
Trait Implementations
sourceimpl Clone for MyersBuilder
impl Clone for MyersBuilder
sourcefn clone(&self) -> MyersBuilder
fn clone(&self) -> MyersBuilder
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more