pub struct Reader<R> { /* private fields */ }
Expand description
Parses GenePredExt data and creates Transcript
s.
GenePred 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::genepredext::Reader;
use atglib::models::TranscriptRead;
// create a reader from the tests GenePred file
let reader = Reader::from_file("tests/data/example.genepredext");
assert_eq!(reader.is_ok(), true);
// parse the GenePred 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 GenePred file on your local file system
§Examples
use atglib::genepredext::Reader;
use atglib::models::TranscriptRead;
// create a reader from the tests GenePred file
let reader = Reader::from_file("tests/data/example.genepredext");
assert_eq!(reader.is_ok(), true);
// parse the GenePred 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 GenePredExt source
Sourcepub fn line(&mut self) -> Option<Result<Transcript, ParseRefGeneError>>
pub fn line(&mut self) -> Option<Result<Transcript, ParseRefGeneError>>
Returns one line of a GenePred file as Transcript
Returns None
if the end of the input is reached
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 GenePred data and returns the final list of Transcripts
§Examples
use atglib::genepredext::Reader;
use atglib::models::TranscriptRead;
// create a reader from the tests GenePred file
let reader = Reader::from_file("tests/data/example.genepredext");
assert_eq!(reader.is_ok(), true);
// parse the GenePred file
let transcripts = reader
.unwrap()
.transcripts()
.unwrap();
assert_eq!(transcripts.len(), 27);
Auto Trait Implementations§
impl<R> Freeze for Reader<R>where
R: Freeze,
impl<R> RefUnwindSafe for Reader<R>where
R: RefUnwindSafe,
impl<R> Send for Reader<R>where
R: Send,
impl<R> Sync for Reader<R>where
R: Sync,
impl<R> Unpin for Reader<R>where
R: Unpin,
impl<R> UnwindSafe for Reader<R>where
R: UnwindSafe,
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