Struct bio_types::annot::pos::Pos

source ·
pub struct Pos<R, S> { /* private fields */ }
Expand description

Position on a particular, named sequence (e.g. a chromosome).

Parameterized over the type of the reference sequence identifier and over the strandedness of the position.

The display format for a Pos is chr:pos(+/-). A stranded position must have a (+) or a (-), while an unstranded position does not.

use bio_types::annot::pos::Pos;
use bio_types::strand::ReqStrand;
let start = Pos::new("chrIV".to_owned(), 683946, ReqStrand::Reverse);
let start_str = start.to_string();
assert_eq!(start_str, "chrIV:683946(-)");
let start_str_pos = start_str.parse()?;
assert_eq!(start, start_str_pos);

Implementations§

source§

impl<R, S> Pos<R, S>

source

pub fn new(refid: R, pos: isize, strand: S) -> Self

Construct a new sequence position

use std::rc::Rc;
use bio_types::annot::pos::Pos;
use bio_types::strand::ReqStrand;
let chr = Rc::new("chrIV".to_owned());
let start = Pos::new(chr, 683946, ReqStrand::Reverse);
source

pub fn pos(&self) -> isize

Position on the reference sequence (0-based).

source

pub fn into_stranded(self, strand: ReqStrand) -> Pos<R, ReqStrand>

Convert into a stranded sequence position on the specified strand

Trait Implementations§

source§

impl<R, T> AddAssign<T> for Pos<R, ReqStrand>where isize: AddAssign<T> + SubAssign<T>,

source§

fn add_assign(&mut self, dist: T)

Slide the reference position by an offset on the strand of the annotation.

Arguments
  • dist specifies the offset for sliding the position. A positive dist will numerically increase the position for forward-strand features and decrease it for reverse-strand features.
use bio_types::annot::pos::Pos;
use bio_types::strand::ReqStrand;
let mut start = Pos::new("chrIV".to_owned(), 683946, ReqStrand::Reverse);
assert_eq!(start.to_string(), "chrIV:683946(-)");
start += 100;
assert_eq!(start.to_string(), "chrIV:683846(-)");
source§

impl<R: Clone, S: Clone> Clone for Pos<R, S>

source§

fn clone(&self) -> Pos<R, S>

Returns a copy 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<R: Debug, S: Debug> Debug for Pos<R, S>

source§

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

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

impl<R, S> Display for Pos<R, S>where R: Display, S: Display + Clone + Into<Strand>,

source§

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

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

impl<R> From<Pos<R, NoStrand>> for Pos<R, Strand>

source§

fn from(x: Pos<R, NoStrand>) -> Self

Converts to this type from the input type.
source§

impl<R> From<Pos<R, ReqStrand>> for Pos<R, NoStrand>

source§

fn from(x: Pos<R, ReqStrand>) -> Self

Converts to this type from the input type.
source§

impl<R> From<Pos<R, ReqStrand>> for Pos<R, Strand>

source§

fn from(x: Pos<R, ReqStrand>) -> Self

Converts to this type from the input type.
source§

impl<R> From<Pos<R, Strand>> for Pos<R, NoStrand>

source§

fn from(x: Pos<R, Strand>) -> Self

Converts to this type from the input type.
source§

impl<R, S> FromStr for Pos<R, S>where R: From<String>, S: FromStr<Err = StrandError>,

§

type Err = ParseAnnotError

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<R: Hash, S: Hash> Hash for Pos<R, S>

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<R, S> Loc for Pos<R, S>

§

type RefID = R

§

type Strand = S

source§

fn refid(&self) -> &R

Name of the reference sequence (chromosome name, etc.)
source§

fn start(&self) -> isize

Starting (lowest, left-most, 5’-most) position on the reference sequence (0-based).
source§

fn length(&self) -> usize

Length of the region
source§

fn strand(&self) -> Swhere S: Copy,

Strand of the position
source§

fn pos_into<T>(&self, pos: &Pos<Self::RefID, T>) -> Option<Pos<(), T>>where Self::RefID: Eq, Self::Strand: Into<ReqStrand> + Copy, T: Neg<Output = T> + Copy,

Map a sequence position on a reference sequence into a relative position within an annotated location on the reference sequence. Read more
source§

fn pos_outof<Q, T>(&self, pos: &Pos<Q, T>) -> Option<Pos<Self::RefID, T>>where Self::RefID: Clone, Self::Strand: Into<ReqStrand> + Copy, T: Neg<Output = T> + Copy,

Map a relative position within an annotated location out of that location onto the enclosing reference sequence. Read more
source§

fn contig_intersection<T>( &self, contig: &Contig<Self::RefID, T> ) -> Option<Self>where Self::RefID: PartialEq + Clone, Self::Strand: Copy,

source§

impl<R: PartialEq, S: PartialEq> PartialEq<Pos<R, S>> for Pos<R, S>

source§

fn eq(&self, other: &Pos<R, S>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<R, S> Same for Pos<R, S>where R: Eq, S: Same,

source§

fn same(&self, p: &Self) -> bool

Indicate when two positions are the “same” – when positions have unknown/unspecified strands they can be the “same” but not equal.

source§

impl<R, T> SubAssign<T> for Pos<R, ReqStrand>where isize: AddAssign<T> + SubAssign<T>,

source§

fn sub_assign(&mut self, dist: T)

Slide the reference position by an offset on the strand of the annotation.

Arguments
  • dist specifies the offset for sliding the position. A positive dist will numerically decrease the position for forward-strand features and increase it for reverse-strand features.
use bio_types::annot::pos::Pos;
use bio_types::strand::ReqStrand;
let mut start = Pos::new("chrIV".to_owned(), 683946, ReqStrand::Reverse);
assert_eq!(start.to_string(), "chrIV:683946(-)");
start -= 100;
assert_eq!(start.to_string(), "chrIV:684046(-)");
source§

impl<R: Eq, S: Eq> Eq for Pos<R, S>

source§

impl<R, S> StructuralEq for Pos<R, S>

source§

impl<R, S> StructuralPartialEq for Pos<R, S>

Auto Trait Implementations§

§

impl<R, S> RefUnwindSafe for Pos<R, S>where R: RefUnwindSafe, S: RefUnwindSafe,

§

impl<R, S> Send for Pos<R, S>where R: Send, S: Send,

§

impl<R, S> Sync for Pos<R, S>where R: Sync, S: Sync,

§

impl<R, S> Unpin for Pos<R, S>where R: Unpin, S: Unpin,

§

impl<R, S> UnwindSafe for Pos<R, S>where R: UnwindSafe, S: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere T: Clone,

§

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 Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

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

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

§

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 Twhere U: TryFrom<T>,

§

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.