Skip to main content

Location

Enum Location 

Source
pub enum Location {
    Range((i64, Before), (i64, After)),
    Between(i64, i64),
    Complement(Box<Location>),
    Join(Vec<Location>),
    Order(Vec<Location>),
    Bond(Vec<Location>),
    OneOf(Vec<Location>),
    External(String, Option<Box<Location>>),
    Gap(GapLength),
}
Expand description

Represents a Genbank “location”, used to specify the location of features and in the CONTIG line. See http://www.insdc.org/files/feature_table.html for a detailed description of what they mean.

Note that locations specified here must always refer to a nucleotide within the sequence. Ranges are inclusive in Genbank format, but represented as exclusive ranges, using 0-based indexing in this library. For example, 1..3 will be represented as Range((0, Before(false)), (4, After(false))).

To specify a range that wraps around on a circular sequence, Genbank files use join(x..last,1..y).

Variants§

§

Range((i64, Before), (i64, After))

Represents a range of positions, indicated with [<]x..[>]y in the Genbank file. If < or > are present, then Before or After will be true, respectively. This means that the feature starts before/extends beyond the end point. Genbank files represent locations consisting of a single position with a single number. In this library this is represented using Range, i.e. 1 becomes Range((0, Before(false)), (1, After(false))).

§

Between(i64, i64)

Represented as n^n+1: This means that the location is between the two adjacent positions specified. On a circular sequence the last and first positions are also allowed.

§

Complement(Box<Location>)

INSDC: “Find the complement of the presented sequence in the span specified by “location” (i.e., read the complement of the presented strand in its 5’-to-3’ direction)“

§

Join(Vec<Location>)

INSDC: “The indicated elements should be joined (placed end-to-end) to form one contiguous sequence”

§

Order(Vec<Location>)

INSDC: “The elements can be found in the specified order (5’ to 3’ direction), but nothing is implied about the reasonableness about joining them”

§

Bond(Vec<Location>)

§

OneOf(Vec<Location>)

§

External(String, Option<Box<Location>>)

§

Gap(GapLength)

Implementations§

Source§

impl Location

Source

pub fn simple_range(a: i64, b: i64) -> Location

Convenience constructor for this commonly used variant

Source

pub fn single(a: i64) -> Location

Source

pub fn find_bounds(&self) -> Result<(i64, i64), LocationError>

Try to get the start and end of a location. Returns the starting and finishing locations, as an exclusive range.

Source

pub fn truncate(&self, start: i64, end: i64) -> Option<Location>

Truncates this location, limiting it to the given bounds. Note: higher is exclusive. None is returned if no part of the location lies within the bounds.

Source

pub fn to_gb_format(&self) -> String

Source

pub fn from_gb_format(s: &str) -> Result<Location, GbParserError>

Trait Implementations§

Source§

impl Clone for Location

Source§

fn clone(&self) -> Location

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Location

Source§

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

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

impl Display for Location

Source§

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

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

impl PartialEq for Location

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Location

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.