Crate fastxgz

source ·
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/test.fa").expect("The file cannot be opened.");
for read in reads {
    println!("{}", read);
}

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/test.fq.gz").expect("The file cannot be opened.");
let kmers = KmerIterator::from(reads, 31);
for kmer in kmers {
    println!("{}", kmer);
}

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/test.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

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.