Struct Reader

Source
pub struct Reader<R> { /* private fields */ }
Expand description

Parses GenePredExt data and creates Transcripts.

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>

Source

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>

Source

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

Source

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

Source

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>

Source§

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> 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> 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, 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.