Code Monkey home page Code Monkey logo

nafcodec's Introduction

πŸ“¦πŸ§¬ nafcodec Stars

Rust coder/decoder for Nucleotide Archive Format (NAF) files.

Actions Codecov License Source Mirror Crate Documentation Changelog GitHub issues

πŸ—ΊοΈ Overview

Nucleotide Archive Format is a file format proposed in Kryukov et al.[1] in 2019 for storing compressed nucleotide or protein sequences combining 4-bit encoding and Zstandard compression. NAF files can be compressed and decompressed using the original C implementation.

This crate provides a Rust implementation of a NAF decoder, from scratch, using nom for parsing the binary format, and zstd for handling Zstandard decompression. It provides a complete API that allows iterating over the contents of a NAF file.

This is the Rust version, there is a Python package available as well.

πŸ“‹ Features

  • streaming decoder: The decoder is implemented using different readers each accessing a region of the compressed file, allowing to stream records without having to decode full blocks.
  • optional decoding: Allow the decoder to skip the decoding of certains fields, such as ignoring quality strings when they are not needed.
  • flexible encoder: The encoder is implemented using an abstract storage interface for temporary data, which allows to keep sequence in memory or inside a temporary folder.

πŸ”Œ Usage

Use a Decoder to iterate over the contents of a Nucleotide Archive Format, reading from any BufRead + Seek implementor:

let mut decoder = nafcodec::Decoder::from_path("../data/LuxC.naf")
    .expect("failed to open nucleotide archive");

for result in decoder {
    let record = result.unwrap();
    // .. do something with the record .. //
}

All fields of the obtained Record are optional, and actually depend on the kind of data that was compressed. The decoder can be configured through a DecoderBuilder to ignore some fields to make decompression faster, even if they are present in the source archive:

let mut decoder = nafcodec::DecoderBuilder::new()
    .quality(false)
    .with_path("../data/phix.naf")
    .expect("failed to open nucleotide archive");

// the archive contains quality strings...
assert!(decoder.header().flags().test(nafcodec::Flag::Quality));

// ... but we configured the decoder to ignore them
for result in decoder {
    let record = result.unwrap();
    assert!(record.quality.is_none())
}

πŸ’­ Feedback

⚠️ Issue Tracker

Found a bug ? Have an enhancement request ? Head over to the GitHub issue tracker if you need to report or ask something. If you are filing in on a bug, please include as much information as you can about the issue, and try to recreate the same bug in a simple, easily reproducible situation.

πŸ“‹ Changelog

This project adheres to Semantic Versioning and provides a changelog in the Keep a Changelog format.

βš–οΈ License

This library is provided under the open-source MIT license. The NAF specification is in the public domain.

This project is in no way not affiliated, sponsored, or otherwise endorsed by the original NAF authors. It was developed by Martin Larralde during his PhD project at the European Molecular Biology Laboratory in the Zeller team.

πŸ“š References

  • [1] Kirill Kryukov, Mahoko Takahashi Ueda, So Nakagawa, Tadashi Imanishi. "Nucleotide Archival Format (NAF) enables efficient lossless reference-free compression of DNA sequences". Bioinformatics, Volume 35, Issue 19, October 2019, Pages 3826–3828. doi:10.1093/bioinformatics/btz144

nafcodec's People

Contributors

althonos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

j-schlesinger

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.