noodles_fasta/
lib.rs

1//! **noodles-fasta** handles and reading and writing of the FASTA format.
2//!
3//! FASTA is a text format with no formal specification and only has de facto rules. It typically
4//! consists of a list of records, each with a definition on the first line and a sequence in the
5//! following lines.
6//!
7//! The definition starts with a `>` (greater than) character, and directly after it is the
8//! reference sequence name. Optionally, whitespace may be used a delimiter for an extra
9//! description or metadata of the sequence. For example,
10//!
11//! ```text
12//!  reference sequence name
13//!  | |
14//! >sq0 LN:13
15//!      |   |
16//!      description
17//! ```
18//!
19//! The sequence is effectively a byte array of characters representing a base. It is typically
20//! hard wrapped at an arbitrary width. For example, the following makes up the sequence
21//! `ACGTNACTGG`.
22//!
23//! ```text
24//! ACGT
25//! NACT
26//! GG
27//! ```
28//!
29//! # Examples
30//!
31//! ## Read all records in a FASTA file
32//!
33//! ```no_run
34//! # use std::{fs::File, io::{self, BufReader}};
35//! use noodles_fasta as fasta;
36//!
37//! let mut reader = File::open("reference.fa")
38//!     .map(BufReader::new)
39//!     .map(fasta::io::Reader::new)?;
40//!
41//! for result in reader.records() {
42//!     let record = result?;
43//!     // ...
44//! }
45//! # Ok::<(), io::Error>(())
46//! ```
47
48#[cfg(feature = "async")]
49pub mod r#async;
50
51pub mod fai;
52pub mod fs;
53pub mod io;
54pub mod record;
55pub mod repository;
56pub mod sequence;
57
58#[deprecated(
59    since = "0.39.0",
60    note = "Use `noodles_fasta::io::indexed_reader` instead."
61)]
62pub use self::io::indexed_reader;
63
64#[deprecated(since = "0.39.0", note = "Use `noodles_fasta::io::reader` instead.")]
65pub use self::io::reader;
66
67#[deprecated(since = "0.39.0", note = "Use `noodles_fasta::io::writer` instead.")]
68pub use self::io::writer;
69
70pub use self::{record::Record, repository::Repository};
71
72#[deprecated(since = "0.39.0", note = "Use `noodles_fasta::fs::index` instead.")]
73pub use self::fs::index;
74
75#[deprecated(
76    since = "0.39.0",
77    note = "Use `noodles_fasta::io::IndexedReader` instead."
78)]
79pub use self::io::IndexedReader;
80
81#[deprecated(since = "0.39.0", note = "Use `noodles_fasta::io::Reader` instead.")]
82pub use self::io::Reader;
83
84#[deprecated(since = "0.39.0", note = "Use `noodles_fasta::io::Writer` instead.")]
85pub use self::io::Writer;
86
87#[cfg(feature = "async")]
88#[deprecated(
89    since = "0.45.0",
90    note = "Use `noodles_fasta::r#async::io::Reader` instead."
91)]
92pub use self::r#async::io::Reader as AsyncReader;