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

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);

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);

Creates a Myers instance given a pattern, using u64 as bit vector type

Creates a Myers instance given a pattern, using u128 as bit vector type

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

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Returns the “default value” for a type. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.