Struct nafcodec::DecoderBuilder
source · pub struct DecoderBuilder { /* private fields */ }
Expand description
A builder to configure and initialize a Decoder
.
The fields to decode are opt-out: by default, the Decoder
will
extract all available fields found in the archive into each Record
.
Use the provided methods to avoid decoding uneeded fields.
For instance, to read a nucleotide archive and only extract sequences names, skipping decoding of sequences:
let decoder = nafcodec::DecoderBuilder::new()
.sequence(false)
.quality(false)
.with_path("../data/phix.naf")
.unwrap();
for record in decoder.map(Result::unwrap) {
println!(">{}", record.id.unwrap());
}
Implementations§
source§impl DecoderBuilder
impl DecoderBuilder
sourcepub fn new() -> Self
pub fn new() -> Self
Create a new decoder builder with default parameters.
By default, all fields are extracted if they are available in the header.
sourcepub fn from_flags<F: Into<Flags>>(flags: F) -> Self
pub fn from_flags<F: Into<Flags>>(flags: F) -> Self
Create a new decoder builder from the given flags.
This constructor can be used as a shortcut to setup decoding of a subset of supported fields. For instance, to read only the sequence identifiers and quality lines from an archive:
let mut decoder = DecoderBuilder::from_flags(Flag::Id | Flag::Quality)
.with_path("../data/phix.naf")
.unwrap();
let record = decoder.next().unwrap().unwrap();
assert!(record.sequence.is_none());
assert!(record.quality.is_some());
sourcepub fn buffer_size(&mut self, buffer_size: usize) -> &mut Self
pub fn buffer_size(&mut self, buffer_size: usize) -> &mut Self
The buffer size to use while reading.
Note that Decoder
uses a lot of buffered I/O, and that more than
one buffer will be created. Nevertheless, a higher value will reduce
the necessity to seek the reader while reading the different blocks.
By default, a buffer size of 4KiB is used for each internal buffer.
sourcepub fn id(&mut self, id: bool) -> &mut Self
pub fn id(&mut self, id: bool) -> &mut Self
Whether or not to decode the sequence identifiers if available.
sourcepub fn comment(&mut self, comment: bool) -> &mut Self
pub fn comment(&mut self, comment: bool) -> &mut Self
Whether or not to decode the sequence comment if available.
sourcepub fn sequence(&mut self, sequence: bool) -> &mut Self
pub fn sequence(&mut self, sequence: bool) -> &mut Self
Whether or not to decode the sequence string if available.
sourcepub fn quality(&mut self, quality: bool) -> &mut Self
pub fn quality(&mut self, quality: bool) -> &mut Self
Whether or not to decode the quality string if available.
sourcepub fn mask(&mut self, mask: bool) -> &mut Self
pub fn mask(&mut self, mask: bool) -> &mut Self
Whether or not to perform region masking in the output sequence.
sourcepub fn with_bytes<'data, 'z>(
&self,
bytes: &'data [u8]
) -> Result<Decoder<'z, BufReader<Cursor<&'data [u8]>>>, Error>
pub fn with_bytes<'data, 'z>( &self, bytes: &'data [u8] ) -> Result<Decoder<'z, BufReader<Cursor<&'data [u8]>>>, Error>
Consume the builder to get a decoder reading data from the given buffer.
Trait Implementations§
source§impl Clone for DecoderBuilder
impl Clone for DecoderBuilder
source§fn clone(&self) -> DecoderBuilder
fn clone(&self) -> DecoderBuilder
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more