onelib 0.1.0

Rust implementation of the ONEcode file format
Documentation
  • Coverage
  • 71.52%
    108 out of 151 items documented0 out of 84 items with examples
  • Size
  • Source code size: 206.41 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 9.71 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 1m 4s Average build duration of successful builds.
  • all releases: 1m 12s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • wjv/onelib
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • wjv

onelib

A Rust implementation of the ONEcode file format by Gene Myers and Richard Durbin.

ONEcode is a general-purpose scientific data format supporting dual ASCII/binary representation, per-field compression (2-bit DNA, Huffman strings, delta-encoded integer lists), built-in indexing, and self-describing schemas. It was originally designed for the Vertebrate Genomes Project.

Status

Early release — not yet intended for production use. The API may change without notice.

Version 0.1.0 — feature-complete for single-threaded read/write of ASCII and binary ONEcode files, fully cross-compatible with the C reference library.

Usage

use std::io::Cursor;
use onelib::reader::OneReader;
use onelib::schema::Schema;
use onelib::writer::OneWriter;

// Define a schema.
let schema = Schema::from_text("P 3 seq\nO S 1 3 DNA\nD I 1 6 STRING\n")
    .expect("valid schema");
let entry = &schema.entries[0];

// Write a binary ONEcode file.
let mut buf = Cursor::new(Vec::new());
let mut writer = OneWriter::new(&mut buf, entry, None, true).unwrap();
writer.write_dna_line(b'S', "acgtacgt").unwrap();
writer.write_string_line(b'I', "seq1").unwrap();
writer.close().unwrap();

// Read it back.
buf.set_position(0);
let mut reader = OneReader::open(buf, None, None).unwrap();
assert!(reader.is_binary());

let line = reader.read_line().unwrap();
assert_eq!(line, Some(b'S'));
assert_eq!(reader.dna_chars(), "acgtacgt");

Building

cargo build
cargo test

Licence

BSD 3-Clause. See LICENCE for details.