[−][src]Module seq_io::fastx
FASTX reading and writing
The fastx
reader guesses the sequence format based on examination of the
first non-empty line (should start with >
for FASTA and @
for FASTQ).
Once the format is known, the file is parsed according to the behaviour
described in the fasta
and fastq
.
Flavours
There are two flavours of this parser:
fastx::Reader
in this module parses FASTA and and single-line FASTQReader
infastx::multiline_qual
parses FASTA and and multi-line FASTQ.
Trait object approach
In addition to the above readers, an approach to FASTX reading using trait
objects was implemented. It can be found in the fastx::dynamic
module. The API is different, but has the advantage that it theoretically
allows integrating sequence parsers not defined in this crate.
Example
This example parses FASTQ and transcribes it to FASTA.
use seq_io::prelude::*; use seq_io::fastx::Reader; use seq_io::fastx::SeqFormat; let fastq = b"@id1 SEQUENCE + IIIIIIII @id2 SEQUENCE + IIIIIIII "; // Construct the reader let mut reader = Reader::new(&fastq[..]); // Records are written here let mut output = vec![]; while let Some(result) = reader.next() { let rec = result.unwrap(); rec.write_as(&mut output, SeqFormat::FASTA, None).unwrap(); } let fasta_equivalent = b">id1 SEQUENCE >id2 SEQUENCE "; assert_eq!(output, fasta_equivalent);
Modules
dynamic | This module provides types and functions for FASTX reading via dynamic dispatch. |
multiline_qual | FASTX reading with multi-line FASTQ support. |
Structs
Error | Parsing error |
LineStore | |
OwnedRecord | A FASTX record that ownes its data (requires allocations) |
Reader | FASTX parser |
RecordSet | Set of sequence records that owns it's buffer and knows the positions of each record. |
RecordSetIter | Iterator over record sets |
RecordsIntoIter | Iterator of |
RecordsIter | Borrowed iterator of |
RefRecord | A FASTX record that borrows data from a buffer
It implements the traits |
Enums
ErrorKind | The kind of error. Currently it has the same options as |
SeqFormat |
Traits
Record | FASTX record trait implemented by both |
Functions
recognize_format | Returns the sequence format guess based on the first character:
|
Type Definitions
Result |