Thanks to visit codestin.com
Credit goes to lib.rs

1 unstable release

Uses new Rust 2024

0.1.0 Apr 23, 2026

#1086 in Text processing

BSD-3-Clause

205KB
4.5K SLoC

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.

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.

Dependencies

~8–13MB
~149K SLoC