Struct noodles::gff::reader::Reader [−][src]
pub struct Reader<R> { /* fields omitted */ }
Expand description
A GFF reader.
Implementations
Creates a GFF reader.
Examples
use noodles_gff as gff;
let data = b"##gff-version 3\n";
let mut reader = gff::Reader::new(&data[..]);
Returns a reference to the underlying reader.
Examples
use noodles_gff as gff;
let data = b"##gff-version 3\n";
let reader = gff::Reader::new(&data[..]);
let _ = reader.get_ref();
Unwraps and returns the underlying reader.
Examples
use noodles_gff as gff;
let data = b"##gff-version 3
#format: gff3
";
let mut reader = gff::Reader::new(&data[..]);
reader.read_line(&mut String::new())?;
assert_eq!(reader.into_inner(), b"#format: gff3\n");
Reads a raw GFF line.
This reads from the underlying stream until a newline is reached and appends it to the
given buffer, sans the final newline character. The buffer can subsequently be parsed as a
crate::Line
.
It is more ergonomic to read records using an iterator (see Self::lines
), but using
this method allows control of the line buffer and whether the raw line should be parsed.
If successful, the number of bytes read is returned. If the number of bytes read is 0, the stream reached EOF.
Examples
use noodles_gff as gff;
let data = b"##gff-version 3
sq0\tNOODLES\tgene\t8\t13\t.\t+\t.\tgene_id=ndls0;gene_name=gene0
";
let mut reader = gff::Reader::new(&data[..]);
let mut buf = String::new();
reader.read_line(&mut buf)?;
assert_eq!(buf, "##gff-version 3");
Returns an iterator over lines starting from the current stream position.
When using this, the caller is responsible to stop reading at either EOF or when the
FASTA
directive is read, whichever comes first.
Unlike Self::read_line
, each line is parsed as a crate::Line
.
Examples
use noodles_gff as gff;
let data = b"##gff-version 3
sq0\tNOODLES\tgene\t8\t13\t.\t+\t.\tgene_id=ndls0;gene_name=gene0
";
let mut reader = gff::Reader::new(&data[..]);
let mut lines = reader.lines();
let line = lines.next().transpose()?;
assert!(matches!(line, Some(gff::Line::Directive(_))));
let line = lines.next().transpose()?;
assert!(matches!(line, Some(gff::Line::Record(_))));
assert!(lines.next().is_none());
Returns an iterator over records starting from the current stream position.
This filters lines for only records. It stops at either EOF or when the FASTA
directive
is read, whichever comes first.
Examples
use noodles_gff as gff;
let data = b"##gff-version 3
sq0\tNOODLES\tgene\t8\t13\t.\t+\t.\tgene_id=ndls0;gene_name=gene0
";
let mut reader = gff::Reader::new(&data[..]);
let mut records = reader.records();
assert!(records.next().transpose()?.is_some());
assert!(records.next().is_none());