# onelib
A Rust implementation of the [ONEcode](https://github.com/thegenemyers/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
```rust
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
```sh
cargo build
cargo test
```
## Licence
BSD 3-Clause. See [LICENCE](LICENCE) for details.