refactor: add rolling buffer methods and document label constraints

Added `is_empty()`, `clear()`, and `iter()` methods to the rolling statistics buffer to enable standard traversal and state reset operations. Documented genome label constraints, specifying forbidden characters, empty label rejection, space quoting requirements, and auto-derived label bypass rules. Additionally, updated doc comments and added `#[allow(dead_code)]` attributes for `kmer_offset` and `n_kmers` fields to suppress compiler warnings while reserving them for future `--detail` coverage vector logic.
This commit is contained in:
Eric Coissac
2026-05-26 14:54:26 +02:00
parent dfa0b2bac2
commit 26ab165807
3 changed files with 19 additions and 12 deletions
+4 -3
View File
@@ -59,8 +59,8 @@ pub struct SKDesc {
/// Index of the source sequence within the batch.
pub seq_idx: u32,
/// Kmer offset of the first kmer of this superkmer within its sequence.
/// Computed as the cumulative number of kmers emitted before this superkmer
/// in the same sequence. Used for `--detail` coverage vectors.
/// Reserved for `--detail` coverage vectors (not yet consumed).
#[allow(dead_code)]
pub kmer_offset: u32,
}
@@ -76,7 +76,8 @@ pub struct QueryBatch {
pub ids: Vec<String>,
/// Raw sequence bytes (for output), in batch order.
pub seqs: Vec<Vec<u8>>,
/// Per-sequence total kmer count (kmer_count + kmer_missing).
/// Per-sequence total kmer count. Reserved for `--detail` (not yet consumed).
#[allow(dead_code)]
pub n_kmers: Vec<u32>,
/// Deduplicated superkmer map.
pub map: HashMap<RoutableSuperKmer, Vec<SKDesc>>,
-8
View File
@@ -24,10 +24,6 @@ impl<T: Copy + Default, const N: usize> Ring<T, N> {
}
}
#[inline]
fn is_empty(&self) -> bool {
self.len == 0
}
#[inline]
fn clear(&mut self) {
self.len = 0;
self.head = 0;
@@ -67,10 +63,6 @@ impl<T: Copy + Default, const N: usize> Ring<T, N> {
}
}
/// Iterate over elements front-to-back (copies, since T: Copy).
fn iter(&self) -> impl Iterator<Item = T> + '_ {
(0..self.len).map(move |i| self.buf[(self.head + i) % N])
}
}
// ── MmerItem ──────────────────────────────────────────────────────────────────