add PhantomData import for generic type safety

- Added `use std::marker::PhantomData;` to prepare for generic scheduler implementations
- Ensures type safety and avoids unused lifetime/type parameters warnings
This commit is contained in:
Eric Coissac
2026-04-27 23:27:42 +02:00
parent ebbfe35cbc
commit 4c19882f03
10 changed files with 328 additions and 271 deletions
+16 -12
View File
@@ -168,39 +168,43 @@ mod tests {
.collect()
}
// k=11, m=5 — valeurs minimales du projet (k ∈ [11,31])
const K: usize = 11;
const M: usize = 5;
#[test]
fn single_segment_one_superkmer() {
let out = run_nofilter(b"ACGTACGT\x00", 4, 2);
let out = run_nofilter(b"ACGTACGTACGTACGTACGT\x00", K, M);
assert!(!out.is_empty());
let total: Vec<u8> = out.into_iter().flatten().collect();
assert!(total.len() >= 4);
assert!(total.len() >= K);
}
#[test]
fn segment_shorter_than_k_emits_nothing() {
let out = run_nofilter(b"ACG\x00", 4, 2);
let out = run_nofilter(b"ACGTACGT\x00", K, M);
assert_eq!(out, Vec::<Vec<u8>>::new());
}
#[test]
fn empty_input_emits_nothing() {
let out = run_nofilter(b"", 4, 2);
let out = run_nofilter(b"", K, M);
assert_eq!(out, Vec::<Vec<u8>>::new());
}
#[test]
fn two_segments_both_emitted() {
let out = run_nofilter(b"ACGTACGT\x00TTTTTTTT\x00", 4, 2);
let out = run_nofilter(b"ACGTACGTACGTACGT\x00TGCATGCATGCATGCA\x00", K, M);
assert!(!out.is_empty());
}
#[test]
fn low_complexity_kmer_is_rejected() {
let out_pass = run_nofilter(b"AAAAAAAAACGT\x00", 4, 2);
let out_pass = run_nofilter(b"AAAAAAAAAAAACGTACGTACGT\x00", K, M);
assert!(!out_pass.is_empty());
let rope = make_rope(b"AAAAAAAA\x00");
let out_reject: Vec<Vec<u8>> = SuperKmerIter::new(&rope, 4, 2, 6, 0.9)
let rope = make_rope(b"AAAAAAAAAAAAAAAAAAAA\x00");
let out_reject: Vec<Vec<u8>> = SuperKmerIter::new(&rope, K, M, 6, 0.9)
.map(|sk| sk.to_ascii())
.collect();
assert!(out_reject.is_empty());
@@ -208,12 +212,12 @@ mod tests {
#[test]
fn multi_slice_rope() {
let data = b"ACGTACGTACGT\x00";
let data = b"ACGTACGTACGTACGTACGT\x00";
let mid = data.len() / 2;
let mut rope = Rope::new(None);
rope.push(data[..mid].to_vec());
rope.push(data[mid..].to_vec());
let out: Vec<Vec<u8>> = SuperKmerIter::new(&rope, 4, 2, 1, 0.0)
let out: Vec<Vec<u8>> = SuperKmerIter::new(&rope, K, M, 1, 0.0)
.map(|sk| sk.to_ascii())
.collect();
assert!(!out.is_empty());
@@ -221,8 +225,8 @@ mod tests {
#[test]
fn yields_minimizer_value() {
let rope = make_rope(b"ACGTACGT\x00");
let results: Vec<SuperKmer> = SuperKmerIter::new(&rope, 4, 2, 1, 0.0).collect();
let rope = make_rope(b"ACGTACGTACGTACGTACGT\x00");
let results: Vec<SuperKmer> = SuperKmerIter::new(&rope, K, M, 1, 0.0).collect();
assert!(!results.is_empty());
}
}
+8
View File
@@ -14,3 +14,11 @@ pub(crate) mod rolling_stat;
pub use iter::SuperKmerIter;
pub use scratch::SuperKmerScratch;
use obikrope::Rope;
use obikseq::superkmer::SuperKmer;
/// Collect all super-kmers from a normalised rope chunk.
pub fn build_superkmers(rope: Rope, k: usize, m: usize, level_max: usize, theta: f64) -> Vec<SuperKmer> {
SuperKmerIter::new(&rope, k, m, level_max, theta).collect()
}