Expand description
This crate is an implementation of a simple fasta and fastq parser. It handles decompression of a gzipped file. Fasta files with reads on multiple lines are supported. This crate also provides functions to iterate over kmers or their hash values.
Examples:
Iterating over the reads of a fasta file:
use fastxgz::fasta_reads;
let reads = fasta_reads("data/tests/data.fa").expect("The file cannot be opened.");
for read in reads {
println!("{}", String::from_utf8(read).unwrap());
}
Iterating over the kmers of the reads of a gzipped fastq file:
use fastxgz::fastq_reads;
use fastxgz::KmerIterator;
let reads = fastq_reads("data/tests/data.fq.gz").expect("The file cannot be opened.");
let kmers = KmerIterator::from(reads, 31);
for kmer in kmers {
println!("{}", String::from_utf8(kmer).unwrap());
}
Iterating over the hash of the kmers of the reads of a gzipped fastq file:
use fastxgz::fastq_reads;
use fastxgz::KmerIterator;
use fastxgz::HashIterator;
let reads = fastq_reads("data/tests/data.fq.gz").expect("The file cannot be opened.");
let kmers = KmerIterator::from(reads, 31);
let hashes = HashIterator::from(kmers);
for hash in hashes {
println!("{}", hash);
}
Structs§
- An iterator taking a sequence of kmers and yielding their hash.
- An iterator taking a sequence of string and yielding their kmers.
Functions§
- Return an iterator over the reads of a (potentially gzipped) fasta file. Reads can be on multiple lines.
- Return an iterator over the reads of a (potentially gzipped) fastq file.
- Return an iterator over the lines of a (potentially gzipped) file.
- Return an iterator over the reads of a (potentially gzipped) fastq file. The reads must be on a single line.