pub struct Reader<R> { /* private fields */ }Expand description
Parses RefGene data and creates Transcripts.
RefGene data can be read from a file, stdin or remote sources
All sources are supported that provide a std::io::Read implementation.
§Examples
use atglib::refgene::Reader;
use atglib::models::TranscriptRead;
// create a reader from the tests RefGene file
let reader = Reader::from_file("tests/data/example.refgene");
assert_eq!(reader.is_ok(), true);
// parse the RefGene file
let transcripts = reader
.unwrap()
.transcripts()
.unwrap();
assert_eq!(transcripts.len(), 27);Implementations§
Source§impl Reader<File>
impl Reader<File>
Sourcepub fn from_file<P: AsRef<Path>>(path: P) -> Result<Self, ReadWriteError>
pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Self, ReadWriteError>
Creates a Reader instance that reads from a File
Use this method when you want to read from a RefGene file on your local file system
§Examples
use atglib::refgene::Reader;
use atglib::models::TranscriptRead;
// create a reader from the tests RefGene file
let reader = Reader::from_file("tests/data/example.refgene");
assert_eq!(reader.is_ok(), true);
// parse the RefGene file
let transcripts = reader
.unwrap()
.transcripts()
.unwrap();
assert_eq!(transcripts.len(), 27);Source§impl<R: Read> Reader<R>
impl<R: Read> Reader<R>
Sourcepub fn new(reader: R) -> Self
pub fn new(reader: R) -> Self
creates a new Reader instance from any std::io::Read object
Use this method when you want to read from stdin or from a remote source, e.g. via HTTP
Sourcepub fn with_capacity(capacity: usize, reader: R) -> Self
pub fn with_capacity(capacity: usize, reader: R) -> Self
Creates a new Reader instance with a known capcity
Use this when you know the size of your RefGene source
Sourcepub fn line(&mut self) -> Option<Result<Transcript, ParseRefGeneError>>
pub fn line(&mut self) -> Option<Result<Transcript, ParseRefGeneError>>
Returns one line of a RefGene file as Transcript
This method should rarely be used. GTF files can contain unordered records and handling lines individually is rarely desired.
Trait Implementations§
Source§impl<R: Read> TranscriptRead for Reader<R>
impl<R: Read> TranscriptRead for Reader<R>
Source§fn transcripts(&mut self) -> Result<Transcripts, ReadWriteError>
fn transcripts(&mut self) -> Result<Transcripts, ReadWriteError>
Reads in RefGene data and returns the final list of Transcripts
§Examples
use atglib::refgene::Reader;
use atglib::models::TranscriptRead;
// create a reader from the tests RefGene file
let reader = Reader::from_file("tests/data/example.refgene");
assert_eq!(reader.is_ok(), true);
// parse the RefGene file
let transcripts = reader
.unwrap()
.transcripts()
.unwrap();
assert_eq!(transcripts.len(), 27);