needletail 0.2.0

FASTX parsing and k-mer methods
docs.rs failed to build needletail-0.2.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: needletail-0.5.1

Circle CI crates.io

Needletail

Needletail is a MIT-licensed, minimal-copying FASTA/FASTQ parser and k-mer processing library for Rust.

The goal is to write a fast and well-tested set of functions that more specialized bioinformatics programs can use. Needletail's goal is to be as fast as the readfq C library at parsing FASTX files and much (i.e. 25 times) faster than equivalent Python implementations at k-mer counting.

Example

extern crate needletail;
use std::env;
use needletail::{fastx};

fn main() {
  let filename: String = env::args().nth(1).unwrap();

  let mut n_bases = 0;
  let mut n_valid_kmers = 0;
  fastx::fastx_cli(&filename[..], |_| {}, |seq| {
    // seq.id is the name of the record
    // seq.seq is the base sequence
    // seq.qual is an optional quality score

    // keep track of the total number of bases
    n_bases += seq.seq.len();
    
    // keep track of the number of AAAA (or TTTT via canonicalization) in the 
    /// file (normalize makes sure ever base is capitalized for comparison)
    for (_, kmer, _) in seq.normalize(false).kmers(4, true) {
      if kmer == b"AAAA" {
        n_valid_kmers += 1;
      }
    }
  });
  println!("There are {} bases in your file.", n_bases);
  println!("There are {} AAAAs in your file.", n_valid_kmers);
}

Installation

Needletail requires rust and cargo to be installed. Please use either your local package manager (homebrew, apt-get, pacman, etc) or install these via rustup.

Once you have Rust set up, you can include needletail in your Cargo.toml file like:

[dependencies]
needletail = "^0.2.0"

To install needletail itself for development:

git clone https://github.com/onecodex/needletail
cargo test  # to run tests

Getting Help

Questions are best directed as GitHub issues. We plan to add more documentation soon, but in the meantime "doc" comments are included in the source.

Contributing

Please do! We're happy to discuss possible additions and/or accept pull requests.