Expand description
Common data structures and utilities for AGC genome compression.
This crate provides the foundational types and utilities used across the ragc project:
- Archive I/O - Reading and writing AGC archive format
- Collection metadata - Managing samples, contigs, and segment descriptors
- Variable-length integers - Space-efficient encoding/decoding
- Hash functions - MurmurHash implementations for k-mer hashing
- Stream naming - Archive version-aware stream identification
§Examples
§Creating and reading an archive
use ragc_common::Archive;
// Create a new archive for writing
let mut archive = Archive::new_writer();
archive.open("output.agc").expect("Failed to create archive");
// Register a stream and add data
let stream_id = archive.register_stream("my_stream");
let data = b"Hello, AGC!";
archive.add_part(stream_id, data, data.len() as u64).expect("Failed to add data");
archive.close().expect("Failed to close archive");
// Read it back
let mut archive = Archive::new_reader();
archive.open("output.agc").expect("Failed to open archive");
let stream_id = archive.get_stream_id("my_stream").expect("Stream not found");
let (data, _) = archive.get_part_by_id(stream_id, 0).expect("Failed to read data");
assert_eq!(&data, b"Hello, AGC!");§Variable-length integer encoding
use ragc_common::{write_varint, read_varint};
use std::io::Cursor;
let mut buffer = Vec::new();
write_varint(&mut buffer, 12345).expect("Failed to encode");
let mut cursor = Cursor::new(&buffer);
let (value, bytes_read) = read_varint(&mut cursor).expect("Failed to decode");
assert_eq!(value, 12345);§Using hash functions
use ragc_common::MurMur64Hash;
let kmer_value = 0x12345678u64;
let hash = MurMur64Hash::hash(kmer_value);Re-exports§
pub use types::Base;pub use types::Contig;pub use types::PackedBlock;pub use types::AGC_FILE_MAJOR;pub use types::AGC_FILE_MINOR;pub use types::AGC_VER_BUGFIX;pub use types::AGC_VER_MAJOR;pub use types::AGC_VER_MINOR;pub use types::CONTIG_SEPARATOR;pub use hash::MurMur32Hash;pub use hash::MurMur64Hash;pub use hash::MurMurPair64Hash;pub use hash::MurMurStringsHash;pub use varint::decode_varint;pub use varint::encode_varint;pub use varint::read_fixed_u64;pub use varint::read_varint;pub use varint::write_fixed_u64;pub use varint::write_varint;pub use archive::Archive;pub use collection::zigzag_decode;pub use collection::zigzag_decode_i64;pub use collection::zigzag_encode;pub use collection::zigzag_encode_i64;pub use collection::CollectionV3;pub use collection::CollectionVarInt;pub use collection::ContigDesc;pub use collection::SampleDesc;pub use collection::SegmentDesc;pub use stream_naming::int_to_base64;pub use stream_naming::stream_base;pub use stream_naming::stream_delta_ext;pub use stream_naming::stream_delta_name;pub use stream_naming::stream_prefix;pub use stream_naming::stream_ref_ext;pub use stream_naming::stream_ref_name;