1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
//! 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`](crate::fasta) and [`fastq`](crate::fastq). //! //! # Flavours //! //! There are two flavours of this parser: //! //! * [`fastx::Reader`](crate::fastx::Reader) in this module parses FASTA and //! and single-line FASTQ //! * [`Reader`](crate::fastx::multiline_qual::Reader) in //! [`fastx::multiline_qual`](crate::fastx::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`](crate::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. //! //! ```rust //! use seq_io::prelude::*; //! use seq_io::fastx::Reader; //! use seq_io::fastx::SeqFormat; //! //! # fn main() { //! 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); //! # } //! ``` #[macro_use] mod error; #[macro_use] mod record; #[macro_use] pub mod dynamic; #[macro_use] mod reader; pub mod multiline_qual; mod position; mod recognition; pub use self::error::*; pub use self::position::*; pub use self::reader::*; pub use self::recognition::*; pub use self::record::*;