Decompressor

Struct Decompressor 

Source
pub struct Decompressor {
    pub kmer_length: u32,
    pub min_match_len: u32,
    /* private fields */
}
Expand description

AGC Decompressor

Provides thread-safe read access to AGC archives. For concurrent access, use clone_for_thread() to create independent readers.

§Thread Safety

  • Decompressor is NOT Sync - cannot be shared between threads
  • Use clone_for_thread() to create independent readers (cheap - shares archive data)
  • Each clone can be used from a separate thread independently

§Example

use ragc_core::{Decompressor, DecompressorConfig};
use std::thread;

let dec = Decompressor::open("data.agc", DecompressorConfig::default())?;
let samples = dec.list_samples();

let handles: Vec<_> = samples.into_iter().map(|sample_name| {
    let mut thread_dec = dec.clone_for_thread().unwrap();
    thread::spawn(move || {
        thread_dec.get_sample(&sample_name)
    })
}).collect();

Fields§

§kmer_length: u32§min_match_len: u32

Implementations§

Source§

impl Decompressor

Source

pub fn open(archive_path: &str, config: DecompressorConfig) -> Result<Self>

Open an existing archive for decompression

Source

pub fn list_samples(&self) -> Vec<String>

Get list of samples in the archive

Source

pub fn get_compression_stats(&self) -> Vec<(String, u64, u64, usize)>

Get compression statistics for all streams Returns: Vec<(stream_name, raw_size, packed_size, num_parts)>

Source

pub fn list_contigs(&mut self, sample_name: &str) -> Result<Vec<String>>

Get list of contigs for a specific sample

Source

pub fn get_contig( &mut self, sample_name: &str, contig_name: &str, ) -> Result<Contig>

Extract a specific contig from a sample

Source

pub fn get_contig_segments_desc( &mut self, sample_name: &str, contig_name: &str, ) -> Result<Vec<SegmentDesc>>

Public: get segment descriptors for a contig

Source

pub fn get_segment_data_by_desc(&mut self, desc: &SegmentDesc) -> Result<Contig>

Public: get raw segment data for a specific segment descriptor

Source

pub fn get_reference_segment(&mut self, group_id: u32) -> Result<Contig>

Public: get the reference segment for a group (loads and caches if needed)

Source

pub fn get_sample(&mut self, sample_name: &str) -> Result<Vec<(String, Contig)>>

Extract all contigs from a sample

Source

pub fn list_samples_with_prefix(&self, prefix: &str) -> Vec<String>

Get all sample names that match a given prefix

This is useful for extracting all samples from a specific genome or haplotype.

§Example
use ragc_core::{Decompressor, DecompressorConfig};

let dec = Decompressor::open("data.agc", DecompressorConfig::default())?;

// Get all samples starting with "AAA"
let aaa_samples = dec.list_samples_with_prefix("AAA");
// Returns: ["AAA#0", "AAA#1", ...] if they exist

// Get all samples with haplotype 0
let hap0_samples = dec.list_samples_with_prefix("AAA#0");
Source

pub fn get_samples_by_prefix( &mut self, prefix: &str, ) -> Result<HashMap<String, Vec<(String, Contig)>>>

Extract multiple samples matching a prefix

Returns a HashMap mapping sample names to their contigs. Each contig is represented as (contig_name, sequence).

§Example
use ragc_core::{Decompressor, DecompressorConfig};

let mut dec = Decompressor::open("data.agc", DecompressorConfig::default())?;

// Extract all AAA samples
let aaa_samples = dec.get_samples_by_prefix("AAA")?;

for (sample_name, contigs) in aaa_samples {
    println!("Sample {}: {} contigs", sample_name, contigs.len());
    for (contig_name, sequence) in contigs {
        println!("  {}: {} bp", contig_name, sequence.len());
    }
}
Source

pub fn clone_for_thread(&self) -> Result<Self>

Clone this decompressor for use in another thread

This creates an independent reader that can be used from a different thread. The clone is lightweight as it shares the archive data structure.

§Thread Safety

Each clone is fully independent and can be used from a separate thread. The segment cache is NOT shared between clones.

§Example
use ragc_core::{Decompressor, DecompressorConfig};
use std::thread;

let dec = Decompressor::open("data.agc", DecompressorConfig::default())?;
let samples = dec.list_samples();

// Spawn threads to extract samples in parallel
let handles: Vec<_> = samples.into_iter().map(|sample_name| {
    let mut thread_dec = dec.clone_for_thread().unwrap();
    thread::spawn(move || {
        thread_dec.get_sample(&sample_name)
    })
}).collect();

// Collect results
for handle in handles {
    let result = handle.join().unwrap()?;
    // Process result...
}
Source

pub fn write_sample_fasta( &mut self, sample_name: &str, output_path: &Path, ) -> Result<()>

Write a sample to a FASTA file

Source

pub fn get_group_statistics( &mut self, ) -> Result<Vec<(u32, usize, usize, usize)>>

Get archive inspection data for debugging/comparison Returns: (group_id, num_segments, num_reference_segments, num_delta_segments)

Source

pub fn get_all_segments( &mut self, ) -> Result<Vec<(String, String, Vec<SegmentDesc>)>>

Get detailed segment information for all contigs Returns: Vec<(sample_name, contig_name, Vec)>

Source

pub fn close(self) -> Result<()>

Close the archive

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.