#[repr(u8)]pub enum AmbiNuc {
Show 15 variants
A = 1,
C = 2,
G = 4,
T = 8,
R = 5,
Y = 10,
M = 3,
K = 12,
W = 9,
S = 6,
B = 14,
D = 13,
H = 11,
V = 7,
N = 15,
}Expand description
Ambiguous nucleotide
Note that AmbiNuc always represents at least one possible nucleotide;
there is no such thing as an empty/null AmbiNuc.
For details, see: https://en.wikipedia.org/wiki/FASTA_format#Sequence_representation
Beware that AmbiNuc’s order isn’t alphabetic.
Variants§
A = 1
Adenine
C = 2
Cytosine
G = 4
Guanine
T = 8
Thymine
R = 5
Y = 10
M = 3
K = 12
W = 9
S = 6
B = 14
D = 13
H = 11
V = 7
N = 15
Implementations§
Source§impl AmbiNuc
impl AmbiNuc
Sourcepub const fn complement(self) -> Self
pub const fn complement(self) -> Self
Return ambiguous nucleotide containing complements for each potential value.
use nucs::AmbiNuc;
assert_eq!(AmbiNuc::A.complement(), AmbiNuc::T);
assert_eq!(AmbiNuc::C.complement(), AmbiNuc::G);
assert_eq!(AmbiNuc::G.complement(), AmbiNuc::C);
assert_eq!(AmbiNuc::T.complement(), AmbiNuc::A);
// D -> A|G|T -> T|C|A -> H
assert_eq!(AmbiNuc::D.complement(), AmbiNuc::H);Sourcepub const fn to_str(self) -> &'static str
pub const fn to_str(self) -> &'static str
Return uppercase string representation
§Examples
use nucs::AmbiNuc;
assert_eq!(AmbiNuc::A.to_str(), "A");
assert_eq!(AmbiNuc::N.to_str(), "N");Sourcepub const fn from_ascii(ascii: u8) -> Result<Self, ParseSymbolError>
pub const fn from_ascii(ascii: u8) -> Result<Self, ParseSymbolError>
Construct from ASCII representation
§Errors
Returns ParseSymbolError if the given byte isn’t A, B, C, D, G, H,
K, M, N, R, S, T, V, W or Y (case-insensitve).
§Examples
use nucs::AmbiNuc;
assert_eq!(AmbiNuc::from_ascii(b'A'), Ok(AmbiNuc::A));
assert!(AmbiNuc::from_ascii(b'E').is_err());Sourcepub const fn to_ascii(self) -> u8
pub const fn to_ascii(self) -> u8
Return uppercase ASCII representation
§Examples
use nucs::AmbiNuc;
assert_eq!(AmbiNuc::A.to_ascii(), b'A');
assert_eq!(AmbiNuc::N.to_ascii(), b'N');Sourcepub fn iter(self) -> Copied<Iter<'static, Nuc>>
pub fn iter(self) -> Copied<Iter<'static, Nuc>>
Return iterator of Nucs that this ambiguous nucleotide could be.
The iterator will be consistent with AmbiNuc::expansions. The same effect can be
achieved with AmbiNuc’s implementation of IntoIterator.
§Examples
use nucs::{AmbiNuc, Nuc};
assert!(AmbiNuc::B.iter().eq(Nuc::lit(b"CGT")));
assert_eq!(Vec::from_iter(AmbiNuc::B), AmbiNuc::B.expansions());Sourcepub const fn expansions(self) -> &'static [Nuc]
pub const fn expansions(self) -> &'static [Nuc]
Return slice of Nucs that this ambiguous nucleotide could be.
The slice will be non-empty, deduplicated, sorted, and its contents are guaranteed
to recompose into this AmbiNuc via BitOr.
§Examples
use nucs::{AmbiNuc, Nuc};
assert_eq!(AmbiNuc::B.expansions(), Nuc::lit(b"CGT"));
assert_eq!(Nuc::C | Nuc::G | Nuc::T, AmbiNuc::B);Sourcepub const fn lit<const N: usize>(literal: &[u8; N]) -> [AmbiNuc; N]
pub const fn lit<const N: usize>(literal: &[u8; N]) -> [AmbiNuc; N]
Construct AmbiNuc array from literal without allocating.
§Examples
use nucs::AmbiNuc;
let dna1 = AmbiNuc::lit(b"NASTYGRAM");
// ...is shorthand for...
use AmbiNuc::{N, A, S, T, Y, G, R, M};
let dna2 = [N, A, S, T, Y, G, R, A, M];
assert_eq!(dna1, dna2);§Panics
This panics if the supplied literal isn’t valid. Whitespace is NOT allowed because the returned array must have the same length.
Trait Implementations§
Source§impl BitOrAssign<&AmbiNuc> for AmbiNuc
impl BitOrAssign<&AmbiNuc> for AmbiNuc
Source§fn bitor_assign(&mut self, rhs: &AmbiNuc)
fn bitor_assign(&mut self, rhs: &AmbiNuc)
|= operation. Read moreSource§impl BitOrAssign<&Nuc> for AmbiNuc
impl BitOrAssign<&Nuc> for AmbiNuc
Source§fn bitor_assign(&mut self, rhs: &Nuc)
fn bitor_assign(&mut self, rhs: &Nuc)
|= operation. Read moreSource§impl BitOrAssign<Nuc> for AmbiNuc
impl BitOrAssign<Nuc> for AmbiNuc
Source§fn bitor_assign(&mut self, rhs: Nuc)
fn bitor_assign(&mut self, rhs: Nuc)
|= operation. Read moreSource§impl BitOrAssign for AmbiNuc
impl BitOrAssign for AmbiNuc
Source§fn bitor_assign(&mut self, rhs: AmbiNuc)
fn bitor_assign(&mut self, rhs: AmbiNuc)
|= operation. Read more