pub struct Transcripts { /* private fields */ }Expand description
A convinience wrapper to handle large amounts of Transcripts
It allows fast lookup operation by gene or transcript name.
§Examples
use atglib::models::{TranscriptBuilder, Transcripts};
let mut transcripts = Transcripts::new();
assert_eq!(transcripts.len(), 0);
transcripts.push(TranscriptBuilder::new()
.name("NM_001203247.2")
.chrom("chr7")
.gene("EZH2")
.strand(atglib::models::Strand::Minus)
.build()
.unwrap()
);
assert_eq!(transcripts.len(), 1);
assert_eq!(transcripts.by_name("NM_001203247.2").len(), 1);
assert_eq!(transcripts.by_gene("EZH2").len(), 1);
assert!(transcripts.by_name("Foo").is_empty());
assert!(transcripts.by_gene("Bar").is_empty());Implementations§
Source§impl Transcripts
impl Transcripts
pub fn new() -> Self
pub fn with_capacity(capacity: usize) -> Self
Sourcepub fn by_name(&self, name: &str) -> Vec<&Transcript>
pub fn by_name(&self, name: &str) -> Vec<&Transcript>
Retrieve all Transcripts by their name / transcript-id
Most transcripts exist only once, but some transcripts (e.g. NM_001370371.1) are on both X- and Y-chromosome.
§Examples
assert_eq!(transcripts.by_name("NM_001203247.2").len(), 1);
assert!(transcripts.by_name("invalid_name").is_empty());Sourcepub fn by_gene(&self, gene: &str) -> Vec<&Transcript>
pub fn by_gene(&self, gene: &str) -> Vec<&Transcript>
Retrieve all Transcripts of a gene
§Examples
assert_eq!(transcripts.by_gene("EZH2").len(), 1);
assert!(transcripts.by_gene("Invalid-name").is_empty());Sourcepub fn push(&mut self, record: Transcript)
pub fn push(&mut self, record: Transcript)
Add another Transcript
§Examples
use atglib::models::{TranscriptBuilder, Transcripts};
let mut transcripts = Transcripts::new();
transcripts.push(TranscriptBuilder::new()
.name("NM_001203247.2")
.chrom("chr7")
.gene("EZH2")
.strand(atglib::models::Strand::Minus)
.build()
.unwrap()
);
transcripts.push(TranscriptBuilder::new()
.name("NM_001203247.3")
.chrom("chr7")
.gene("EZH2")
.strand(atglib::models::Strand::Minus)
.build()
.unwrap()
);
assert_eq!(transcripts.len(), 2);
assert_eq!(transcripts.by_name("NM_001203247.2").len(), 1);
assert_eq!(transcripts.by_name("NM_001203247.3").len(), 1);
assert_eq!(transcripts.by_gene("EZH2").len(), 2);Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of Transcripts in the object
Sourcepub fn as_vec(&self) -> &Vec<Transcript>
pub fn as_vec(&self) -> &Vec<Transcript>
Returns a vector of Transcripts
Sourcepub fn to_vec(self) -> Vec<Transcript>
pub fn to_vec(self) -> Vec<Transcript>
Consumes and returns a vector of Transcripts
Trait Implementations§
Source§impl Default for Transcripts
impl Default for Transcripts
Source§impl<'de> Deserialize<'de> for Transcripts
impl<'de> Deserialize<'de> for Transcripts
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl IntoIterator for Transcripts
impl IntoIterator for Transcripts
Auto Trait Implementations§
impl Freeze for Transcripts
impl RefUnwindSafe for Transcripts
impl Send for Transcripts
impl Sync for Transcripts
impl Unpin for Transcripts
impl UnwindSafe for Transcripts
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