AmbiNuc

Enum AmbiNuc 

Source
#[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

A/G: puRine

§

Y = 10

C/T: pYrimidines

§

M = 3

A/C: aMino groups

§

K = 12

G/T: Ketones

§

W = 9

A/T: Weak interaction

§

S = 6

C/G: Strong interaction

§

B = 14

C/G/T: Not A (B comes after A)

§

D = 13

A/G/T: Not C (D comes after C)

§

H = 11

A/C/T: Not G (H comes after G)

§

V = 7

A/C/G: Not T (V comes after U/T)

§

N = 15

A/C/G/T: Nucleic acid

Implementations§

Source§

impl AmbiNuc

Source

pub const ALL: [Self; 15]

All AmbiNucs sorted in ascending order

Source

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

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

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

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

pub fn iter(self) -> Copied<Iter<'static, Nuc>>

Return iterator of Nucs that this ambiguous nucleotide could be.

The iterator is guaranteed to return things in sorted order and without duplicates, and its contents are guaranteed to recompose into this AmbiNuc via BitOr.

§Examples
use nucs::{AmbiNuc, Nuc};

assert!(AmbiNuc::B.iter().eq(Nuc::lit(b"CGT")));
Source

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 AsMut<AmbiNuc> for AmbiNuc

Source§

fn as_mut(&mut self) -> &mut AmbiNuc

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<AmbiNuc> for AmbiNuc

Source§

fn as_ref(&self) -> &AmbiNuc

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl BitOr<&AmbiNuc> for &Nuc

Source§

type Output = AmbiNuc

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: &AmbiNuc) -> Self::Output

Performs the | operation. Read more
Source§

impl BitOr<&Nuc> for &AmbiNuc

Source§

type Output = AmbiNuc

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: &Nuc) -> Self::Output

Performs the | operation. Read more
Source§

impl BitOr<AmbiNuc> for Nuc

Source§

type Output = AmbiNuc

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: AmbiNuc) -> Self::Output

Performs the | operation. Read more
Source§

impl BitOr<Nuc> for AmbiNuc

Source§

type Output = AmbiNuc

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: Nuc) -> Self::Output

Performs the | operation. Read more
Source§

impl BitOr for &AmbiNuc

Source§

type Output = AmbiNuc

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: &AmbiNuc) -> Self::Output

Performs the | operation. Read more
Source§

impl BitOr for AmbiNuc

Source§

type Output = AmbiNuc

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: AmbiNuc) -> Self::Output

Performs the | operation. Read more
Source§

impl BitOrAssign<&AmbiNuc> for AmbiNuc

Source§

fn bitor_assign(&mut self, rhs: &AmbiNuc)

Performs the |= operation. Read more
Source§

impl BitOrAssign<&Nuc> for AmbiNuc

Source§

fn bitor_assign(&mut self, rhs: &Nuc)

Performs the |= operation. Read more
Source§

impl BitOrAssign<Nuc> for AmbiNuc

Source§

fn bitor_assign(&mut self, rhs: Nuc)

Performs the |= operation. Read more
Source§

impl BitOrAssign for AmbiNuc

Source§

fn bitor_assign(&mut self, rhs: AmbiNuc)

Performs the |= operation. Read more
Source§

impl Clone for AmbiNuc

Source§

fn clone(&self) -> AmbiNuc

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AmbiNuc

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for AmbiNuc

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Nuc> for AmbiNuc

Source§

fn from(nuc: Nuc) -> Self

Converts to this type from the input type.
Source§

impl FromStr for AmbiNuc

Source§

type Err = ParseSymbolError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for AmbiNuc

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl IntoIterator for &AmbiNuc

Source§

type IntoIter = Copied<Iter<'static, Nuc>>

Which kind of iterator are we turning this into?
Source§

type Item = Nuc

The type of the elements being iterated over.
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl IntoIterator for AmbiNuc

Source§

type IntoIter = Copied<Iter<'static, Nuc>>

Which kind of iterator are we turning this into?
Source§

type Item = Nuc

The type of the elements being iterated over.
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl Nucleotide for AmbiNuc

Source§

const ALL: &[Self]

All possible nucleotides in ascending order
Source§

type Amino = AmbiAmino

Amino acid; either Amino or AmbiAmino
Source§

fn complement(self) -> Self

Return this nucleotide’s complement. Read more
Source§

fn translate<G: GeneticCode>(codon: [Self; 3], genetic_code: G) -> Self::Amino

Translate a codon into an amino acid
Source§

impl Ord for AmbiNuc

Source§

fn cmp(&self, other: &AmbiNuc) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq<AmbiNuc> for Nuc

Source§

fn eq(&self, other: &AmbiNuc) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Nuc> for AmbiNuc

Source§

fn eq(&self, other: &Nuc) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for AmbiNuc

Source§

fn eq(&self, other: &AmbiNuc) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd<AmbiNuc> for Nuc

Source§

fn partial_cmp(&self, other: &AmbiNuc) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd<Nuc> for AmbiNuc

Source§

fn partial_cmp(&self, other: &Nuc) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl PartialOrd for AmbiNuc

Source§

fn partial_cmp(&self, other: &AmbiNuc) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Symbol for AmbiNuc

Source§

type Concrete = Nuc

Concrete symbols, i.e. Nuc or Amino
Source§

type Ambiguous = AmbiNuc

Ambiguous symbols, i.e. AmbiNuc or AmbiAmino
Source§

fn to_str(self) -> &'static str

Return uppercase string representation
Source§

fn from_ascii(ascii: u8) -> Result<Self, ParseSymbolError>

Construct from (case-insensitive) ASCII representation Read more
Source§

fn to_ascii(self) -> u8

Return uppercase ASCII representation
Source§

fn lit<const N: usize>(literal: &[u8; N]) -> [Self; N]

Construct array from literal without allocating. Read more
Source§

impl TryFrom<AmbiNuc> for Nuc

Source§

type Error = AmbiNuc

The type returned in the event of a conversion error.
Source§

fn try_from(nuc: AmbiNuc) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Copy for AmbiNuc

Source§

impl Eq for AmbiNuc

Source§

impl StructuralPartialEq for AmbiNuc

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.