logo
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. Pattern length is restricted to at most 64 symbols.

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*");
// ...

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.

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

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 !=.

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

Compare self to key and return true if they are equal.

Performs the conversion.

Performs the conversion.

Should always be Self

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

Checks if self is actually part of its subset T (and can be converted to it).

Use with care! Same as self.to_subset but without any property checks. Always succeeds.

The inclusion map: converts self to the equivalent element of its superset.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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.