Struct Range

Source
pub struct Range {
    pub name: String,
    pub chr: String,
    pub strand: String,
    pub start: i32,
    pub end: i32,
}

Fields§

§name: String§chr: String§strand: String§start: i32§end: i32

Implementations§

Source§

impl Range

Source

pub fn name(&self) -> &String

Source

pub fn chr(&self) -> &String

Source

pub fn strand(&self) -> &String

Source

pub fn start(&self) -> &i32

Source

pub fn end(&self) -> &i32

Source

pub fn name_mut(&mut self) -> &mut String

Source

pub fn strand_mut(&mut self) -> &mut String

Source

pub fn new() -> Self

Source

pub fn from(chr: &str, start: i32, end: i32) -> Self

Constructed from chr, start and end

let range = Range::from("I", 1, 100);
Source

pub fn from_full( name: &str, chr: &str, strand: &str, start: i32, end: i32, ) -> Self

Constructed from chr, start and end

let range = Range::from_full("S288c", "I", "-", 1, 100);
Source

pub fn from_str(range: &str) -> Self

Constructed from string

let range = Range::from_str("I:1-100");
let range = Range::from_str("I:100");
let range = Range::from_str("S288c.I(-):27070-29557");
Source

pub fn is_valid(&self) -> bool

Valid or not

let range = Range::from("I", 1, 100);
assert!(range.is_valid());
let range = Range::from_str("I:100");
assert!(range.is_valid());
let range = Range::from_str("invalid");
assert!(!range.is_valid());
Source

pub fn intspan(&self) -> IntSpan

IntSpan

let range = Range::from("I", 1, 100);
assert_eq!(range.intspan().to_string(), "1-100");
let range = Range::from_str("I:100");
assert_eq!(range.intspan().to_string(), "100");
Source

pub fn trim(&self, n: i32) -> Self

Trim both ends

let range = Range::from_str("I:100-200");
assert_eq!(range.trim(30).to_string(), "I:130-170");
assert_eq!(range.trim(70).is_valid(), false);
assert_eq!(range.trim(-30).to_string(), "I:70-230");
Source

pub fn trim_5p(&self, n: i32) -> Self

Trim 5p end

let range = Range::from_str("I(+):100-200");
assert_eq!(range.trim_5p(30).to_string(), "I(+):130-200");
let range = Range::from_str("I(-):100-200");
assert_eq!(range.trim_5p(30).to_string(), "I(-):100-170");
assert_eq!(range.trim_5p(-30).to_string(), "I(-):100-230");
assert_eq!(range.trim_5p(120).is_valid(), false);
Source

pub fn trim_3p(&self, n: i32) -> Self

Trim 3p end

let range = Range::from_str("I(+):100-200");
assert_eq!(range.trim_3p(30).to_string(), "I(+):100-170");
let range = Range::from_str("I(-):100-200");
assert_eq!(range.trim_3p(30).to_string(), "I(-):130-200");
assert_eq!(range.trim_3p(120).is_valid(), false);
Source

pub fn shift_5p(&self, n: i32) -> Self

Shift to 5p end

let range = Range::from_str("I(+):100-200");
assert_eq!(range.shift_5p(30).to_string(), "I(+):70-170");
assert_eq!(range.shift_5p(-30).to_string(), "I(+):130-230");
let range = Range::from_str("I(-):100-200");
assert_eq!(range.shift_5p(30).to_string(), "I(-):130-230");
Source

pub fn shift_3p(&self, n: i32) -> Self

Shift to 3p end

let range = Range::from_str("I(+):100-200");
assert_eq!(range.shift_3p(30).to_string(), "I(+):130-230");
assert_eq!(range.shift_3p(-30).to_string(), "I(+):70-170");
let range = Range::from_str("I(-):100-200");
assert_eq!(range.shift_3p(30).to_string(), "I(-):70-170");
Source

pub fn flank_5p(&self, n: i32) -> Self

Flanking region of the 5p end. A negative value for ‘n’ indicates positions within the range.

let range = Range::from_str("I(+):100-200");
assert_eq!(range.flank_5p(30).to_string(), "I(+):70-99");
assert_eq!(range.flank_5p(-30).to_string(), "I(+):100-129");
assert_eq!(range.flank_5p(0).is_valid(), false);
let range = Range::from_str("I(-):100-200");
assert_eq!(range.flank_5p(30).to_string(), "I(-):201-230");
assert_eq!(range.flank_5p(-30).to_string(), "I(-):171-200");
assert_eq!(range.flank_5p(0).is_valid(), false);
Source

pub fn flank_3p(&self, n: i32) -> Self

Flanking region of the 3p end

let range = Range::from_str("I(+):100-200");
assert_eq!(range.flank_3p(30).to_string(), "I(+):201-230");
assert_eq!(range.flank_3p(-30).to_string(), "I(+):171-200");
assert_eq!(range.flank_3p(0).is_valid(), false);
let range = Range::from_str("I(-):100-200");
assert_eq!(range.flank_3p(30).to_string(), "I(-):70-99");
assert_eq!(range.flank_3p(-30).to_string(), "I(-):100-129");
assert_eq!(range.flank_3p(0).is_valid(), false);

Trait Implementations§

Source§

impl Clone for Range

Source§

fn clone(&self) -> Range

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 Debug for Range

Source§

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

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

impl Default for Range

Source§

fn default() -> Range

Returns the “default value” for a type. Read more
Source§

impl Display for Range

To string

let range = Range::from("I", 1, 100);
assert_eq!(range.to_string(), "I:1-100");
let range = Range::from("I", 100, 100);
assert_eq!(range.to_string(), "I:100");
Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Range

§

impl RefUnwindSafe for Range

§

impl Send for Range

§

impl Sync for Range

§

impl Unpin for Range

§

impl UnwindSafe for Range

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.