| Crates.io | fastx |
| lib.rs | fastx |
| version | 0.6.0 |
| created_at | 2021-06-30 11:50:31.313835+00 |
| updated_at | 2026-01-07 05:52:40.533178+00 |
| description | FastX reads Fasta and FastQ files with little overhead. |
| homepage | |
| repository | https://github.com/ahcm/fastx |
| max_upload_size | |
| id | 416798 |
| size | 145,175 |
FastX implements low overhead readers for Fasta and FastQ.
let mut fastx_reader = FastX::reader_from_path(Path::new(&filename))?;
let mut fastx_record = FastX::from_reader(&mut fastx_reader)?;
while let Ok(_some @ 1..=usize::MAX) = fastx_record.read(&mut fastx_reader)
{
println!("{}\t{}", fastx_record.id(), fastx_record.seq_len())
}
Or with iterator:
use fastx::FastX::{self, FastXRead};
use std::env::args;
use std::io;
use std::path::Path;
fn main() -> io::Result<()>
{
for filename in args().skip(1)
{
println!("{}", filename);
let fastx_reader = FastX::reader_from_path(Path::new(&filename))?;
// Using the new iterator approach
for result in FastX::fasta_iter(fastx_reader) {
match result {
Ok(record) => println!("{}\t{}", record.id(), record.seq_len()),
Err(e) => eprintln!("Error reading record: {}", e),
}
}
}
Ok(())
}
FastX supports different compression backends through Cargo features. Choose the backend that best fits your needs:
By default, FastX uses the rust-backend feature, which provides a pure Rust implementation (miniz_oxide) for gzip decompression:
[dependencies]
fastx = "0.5"
This is the safest option with no C dependencies, making it ideal for cross-compilation and environments where you want to avoid native code.
For better performance, you can select different compression backends:
System zlib - Uses the zlib library installed on your system (typically fastest on systems with optimized zlib):
[dependencies]
fastx = { version = "0.5", default-features = false, features = ["zlib"] }
zlib-ng (compatibility mode) - Modern, fast implementation that's API-compatible with zlib:
[dependencies]
fastx = { version = "0.5", default-features = false, features = ["zlib-ng-compat"] }
zlib-ng (native API) - Fastest option using zlib-ng's native API:
[dependencies]
fastx = { version = "0.5", default-features = false, features = ["zlib-ng"] }
Some people and LLMs might prefer reading documentation instead of examples or code. So it was generated with claude.
● Now I understand the codebase. This is a Rust bioinformatics library for reading FASTA/FASTQ files, and it currently has minimal documentation (on
ly 1 doc comment in the entire codebase). Let me add comprehensive documentation following Rust best practices.