Add unitig streaming iterators and estimate CLI subcommand
Introduce `iter_unitigs` methods across the index cache, content layer, MphfLayer, and typed layer to stream whole reconstructed sequences directly from underlying storage without decomposing into k-mers. Add a corresponding low-level streaming iterator in obiskio for thread-safe, lazy reads from memory-mapped files. Include a new CLI subcommand to compute and display approximate false-positive rates based on provided indexing parameters.
This commit is contained in:
1 parent
5048f43eea
commit
fb31a35c76
9 files changed
+124
-1
No files matched your search
@@ -208,6 +208,31 @@ impl UnitigFileReader {
|
||||
self.iter_chunks_sequential()
|
||||
}
|
||||
|
||||
/// Same streamed sequence as [`iter_unitigs`](Self::iter_unitigs), but
|
||||
/// owning a clone of `self` instead of borrowing it — `Send + 'static`,
|
||||
/// so it can be handed to a threaded consumer without first collecting
|
||||
/// the layer's unitigs into memory. Same shape as
|
||||
/// [`iter_indexed_canonical_kmers_owned`](Self::iter_indexed_canonical_kmers_owned),
|
||||
/// stopping short of decomposing into k-mers.
|
||||
pub fn iter_unitigs_owned(
|
||||
self: &Arc<Self>,
|
||||
) -> impl Iterator<Item = (usize, Unitig)> + Send + 'static {
|
||||
let this = Arc::clone(self);
|
||||
let k = this.k;
|
||||
let n = this.n_unitigs;
|
||||
let mut offset = 0usize;
|
||||
(0..n).map(move |chunk_id| {
|
||||
let mmap = &*this.mmap;
|
||||
let seql = mmap[offset] as usize + k;
|
||||
let byte_len = (seql + 3) / 4;
|
||||
let bytes = mmap[offset + 1..offset + 1 + byte_len]
|
||||
.to_vec()
|
||||
.into_boxed_slice();
|
||||
offset += 1 + byte_len;
|
||||
(chunk_id, Unitig::new((seql % 4) as u8, bytes))
|
||||
})
|
||||
}
|
||||
|
||||
pub fn iter_kmers(&self) -> impl Iterator<Item = Kmer> + '_ {
|
||||
self.iter_chunks_sequential()
|
||||
.flat_map(|(_, u)| u.into_kmers())
|
||||
|
||||
Reference in new issue
Block a user