Skip to main content

NucleotideCoordinate

Enum NucleotideCoordinate 

Source
pub enum NucleotideCoordinate {
    Known {
        anchor: NucleotideAnchor,
        coordinate: i32,
        offset: i32,
    },
    Unknown,
}
Expand description

Nucleotide coordinate written as a known position or ?.

Known coordinates keep the sign written in the HGVS string. For example, c.-1 becomes coordinate() == Some(-1), while c.*1 becomes coordinate() == Some(1). CDS-anchored intronic positions keep the same primary coordinate plus a signed secondary offset, e.g. c.-106+2 becomes coordinate() == Some(-106) and offset() == Some(2).

§Examples

use tinyhgvs::{NucleotideAnchor, VariantDescription, parse_hgvs};

let five_prime = parse_hgvs("NM_007373.4:c.-1C>T").unwrap();
let three_prime = parse_hgvs("NM_001272071.2:c.*1C>T").unwrap();
let five_prime_intronic = parse_hgvs("NM_001385026.1:c.-106+2T>A").unwrap();

match five_prime.description {
    VariantDescription::Nucleotide(description) => {
        assert_eq!(description.location.start().unwrap().anchor(), Some(NucleotideAnchor::RelativeCdsStart));
        assert_eq!(description.location.start().unwrap().coordinate(), Some(-1));
        assert_eq!(description.location.start().unwrap().offset(), Some(0));
    }
    _ => unreachable!("expected nucleotide variant"),
}

match three_prime.description {
    VariantDescription::Nucleotide(description) => {
        assert_eq!(description.location.start().unwrap().anchor(), Some(NucleotideAnchor::RelativeCdsEnd));
        assert_eq!(description.location.start().unwrap().coordinate(), Some(1));
        assert_eq!(description.location.start().unwrap().offset(), Some(0));
    }
    _ => unreachable!("expected nucleotide variant"),
}

match five_prime_intronic.description {
    VariantDescription::Nucleotide(description) => {
        assert_eq!(description.location.start().unwrap().anchor(), Some(NucleotideAnchor::RelativeCdsStart));
        assert_eq!(description.location.start().unwrap().coordinate(), Some(-106));
        assert_eq!(description.location.start().unwrap().offset(), Some(2));
    }
    _ => unreachable!("expected nucleotide variant"),
}

Variants§

§

Known

Known nucleotide coordinate with anchor and optional offset.

Fields

§coordinate: i32
§offset: i32
§

Unknown

Unknown nucleotide coordinate written as ?.

Implementations§

Source§

impl NucleotideCoordinate

Source

pub fn known(anchor: NucleotideAnchor, coordinate: i32, offset: i32) -> Self

Builds a known nucleotide coordinate.

Source

pub fn is_known(&self) -> bool

Returns true when this coordinate is known.

Source

pub fn is_unknown(&self) -> bool

Returns true when this coordinate is written as ?.

Source

pub fn anchor(&self) -> Option<NucleotideAnchor>

Returns the anchor when this coordinate is known.

Source

pub fn coordinate(&self) -> Option<i32>

Returns the primary coordinate when it is known.

Source

pub fn offset(&self) -> Option<i32>

Returns the offset when this coordinate is known.

Source

pub fn is_intronic(&self) -> bool

Returns true for intronic coordinates such as 357+1, -106+2, and *639-1.

Source

pub fn is_cds_start_anchored(&self) -> bool

Returns true if variant’s location is relative to the CDS start, such as c.-1 and c.-106+2.

Source

pub fn is_cds_end_anchored(&self) -> bool

Returns true if variant’s location is relative to the CDS end, such as c.*1 and c.*639-1.

Source

pub fn is_five_prime_utr(&self) -> bool

Returns true for exonic 5’ UTR coordinates such as c.-81.

Source

pub fn is_three_prime_utr(&self) -> bool

Returns true for exonic 3’ UTR coordinates such as c.*24.

Trait Implementations§

Source§

impl Clone for NucleotideCoordinate

Source§

fn clone(&self) -> NucleotideCoordinate

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 NucleotideCoordinate

Source§

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

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

impl PartialEq for NucleotideCoordinate

Source§

fn eq(&self, other: &NucleotideCoordinate) -> 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 Copy for NucleotideCoordinate

Source§

impl Eq for NucleotideCoordinate

Source§

impl StructuralPartialEq for NucleotideCoordinate

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