Variant

Struct Variant 

Source
pub struct Variant<N: Nucleotide> { /* private fields */ }
Expand description

A single nucleotide variant.

Implementations§

Source§

impl<N: Nucleotide> Variant<N>
where <N as FromStr>::Err: Debug + Display,

Source

pub fn try_new( coordinate: impl Into<Coordinate<Base>>, reference_nucleotide: impl Into<N>, alternate_nucleotide: impl Into<N>, ) -> Result<Self, Error<N>>

Attempts to create a new Variant.

§Examples
use omics_coordinate::base::Coordinate;
use omics_coordinate::system::Base;
use omics_molecule::polymer::dna;
use omics_variation::snv::Variant;

let variant = Variant::<dna::Nucleotide>::try_new(
    "seq0:+:1".parse::<Coordinate>()?,
    dna::Nucleotide::A,
    dna::Nucleotide::T,
)?;
Source

pub fn coordinate(&self) -> &Coordinate<Base>

Gets the Coordinate for this Variant.

§Examples
use omics_coordinate::Strand;
use omics_coordinate::base::Coordinate;
use omics_coordinate::system::Base;
use omics_molecule::polymer::dna;
use omics_variation::snv::Variant;

let variant = Variant::<dna::Nucleotide>::try_new(
    "seq0:+:1".parse::<Coordinate>()?,
    dna::Nucleotide::A,
    dna::Nucleotide::T,
)?;

assert_eq!(variant.coordinate().contig().as_str(), "seq0");
assert_eq!(variant.coordinate().strand(), Strand::Positive);
assert_eq!(variant.coordinate().position().get(), 1);
Source

pub fn reference(&self) -> &N

Gets the reference nucleotide as a Nucleotide from the Variant.

§Examples
use omics_coordinate::base::Coordinate;
use omics_coordinate::system::Base;
use omics_molecule::polymer::dna;
use omics_variation::snv::Variant;

let variant = "seq0:+:1:A:T".parse::<Variant<dna::Nucleotide>>()?;
assert_eq!(variant.reference(), &dna::Nucleotide::A);
Source

pub fn alternate(&self) -> &N

Gets the alternate nucleotide as a Nucleotide from the Variant.

§Examples
use omics_coordinate::base::Coordinate;
use omics_coordinate::system::Base;
use omics_molecule::polymer::dna;
use omics_variation::snv::Variant;

let variant = "seq0:+:1:A:T".parse::<Variant<dna::Nucleotide>>()?;
assert_eq!(variant.alternate(), &dna::Nucleotide::T);

Trait Implementations§

Source§

impl<N: Debug + Nucleotide> Debug for Variant<N>

Source§

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

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

impl<N: Nucleotide> Display for Variant<N>
where <N as FromStr>::Err: Debug + Display,

Source§

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

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

impl<N: Nucleotide> FromStr for Variant<N>
where <N as FromStr>::Err: Debug + Display,

Source§

type Err = Error<N>

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

Auto Trait Implementations§

§

impl<N> Freeze for Variant<N>
where N: Freeze,

§

impl<N> RefUnwindSafe for Variant<N>
where N: RefUnwindSafe,

§

impl<N> Send for Variant<N>
where N: Send,

§

impl<N> Sync for Variant<N>
where N: Sync,

§

impl<N> Unpin for Variant<N>
where N: Unpin,

§

impl<N> UnwindSafe for Variant<N>
where N: UnwindSafe,

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