Nuc

Enum Nuc 

Source
#[repr(u8)]
pub enum Nuc { A = 1, C = 2, G = 4, T = 8, }
Expand description

Concrete nucleotide

Nucs are ordered by the value of their ASCII representation.

Variants§

§

A = 1

Adenine

§

C = 2

Cytosine

§

G = 4

Guanine

§

T = 8

Thymine

Implementations§

Source§

impl Nuc

Source

pub const ALL: [Self; 4]

All Nucs sorted in ascending order

Source

pub const fn complement(self) -> Self

Swap A and T, as well as C and G.

§Examples
use nucs::Nuc;

assert_eq!(Nuc::A.complement(), Nuc::T);
assert_eq!(Nuc::C.complement(), Nuc::G);
assert_eq!(Nuc::G.complement(), Nuc::C);
assert_eq!(Nuc::T.complement(), Nuc::A);
Source

pub const fn to_str(self) -> &'static str

Return uppercase string representation

§Examples
use nucs::Nuc;

assert_eq!(Nuc::A.to_str(), "A");
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, C, G or T (case-insensitive).

§Examples
use nucs::Nuc;

assert_eq!(Nuc::from_ascii(b'A'), Ok(Nuc::A));
assert!(Nuc::from_ascii(b'B').is_err());
Source

pub const fn to_ascii(self) -> u8

Return uppercase ASCII representation

§Examples
use nucs::Nuc;

assert_eq!(Nuc::A.to_ascii(), b'A');
Source

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

Construct Nuc array from literal without allocating.

§Examples
use nucs::Nuc;

let dna1 = Nuc::lit(b"TACT");
// ...is shorthand for...
use Nuc::{T, A, C};
let dna2 = [T, A, C, T];

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<Nuc> for Nuc

Source§

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

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

impl AsRef<Nuc> for Nuc

Source§

fn as_ref(&self) -> &Nuc

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 &Nuc

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 Nuc

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 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 Clone for Nuc

Source§

fn clone(&self) -> Nuc

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 Nuc

Source§

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

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

impl Display for Nuc

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 Nuc

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 Nuc

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 Nucleotide for Nuc

Source§

const ALL: &[Self]

All possible nucleotides in ascending order
Source§

type Amino = Amino

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 Nuc

Source§

fn cmp(&self, other: &Nuc) -> 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 Nuc

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 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 Nuc

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 Symbol for Nuc

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 Nuc

Source§

impl Eq for Nuc

Source§

impl StructuralPartialEq for Nuc

Auto Trait Implementations§

§

impl Freeze for Nuc

§

impl RefUnwindSafe for Nuc

§

impl Send for Nuc

§

impl Sync for Nuc

§

impl Unpin for Nuc

§

impl UnwindSafe for Nuc

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.