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
impl Range
pub fn name(&self) -> &String
pub fn chr(&self) -> &String
pub fn strand(&self) -> &String
pub fn start(&self) -> &i32
pub fn end(&self) -> &i32
pub fn name_mut(&mut self) -> &mut String
pub fn strand_mut(&mut self) -> &mut String
pub fn new() -> Self
Sourcepub fn from(chr: &str, start: i32, end: i32) -> Self
pub fn from(chr: &str, start: i32, end: i32) -> Self
Constructed from chr, start and end
let range = Range::from("I", 1, 100);
Sourcepub fn from_full(
name: &str,
chr: &str,
strand: &str,
start: i32,
end: i32,
) -> Self
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);
Sourcepub fn from_str(range: &str) -> Self
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");
Sourcepub fn is_valid(&self) -> bool
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());
Sourcepub fn intspan(&self) -> IntSpan
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");
Sourcepub fn trim(&self, n: i32) -> Self
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");
Sourcepub fn trim_5p(&self, n: i32) -> Self
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);
Sourcepub fn trim_3p(&self, n: i32) -> Self
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);
Sourcepub fn shift_5p(&self, n: i32) -> Self
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");
Sourcepub fn shift_3p(&self, n: i32) -> Self
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");
Sourcepub fn flank_5p(&self, n: i32) -> Self
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);
Sourcepub fn flank_3p(&self, n: i32) -> Self
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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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