📖 Update super-kmer theory and implementation to prefer non-degenerate m-mers

- Update super-kmer definition in `kmERS.md` to specify that non-degenerate m-mers are preferred over degenerate ones (degeneracy = homopolymer).
- Refactor `superkmer.rs`: change `.canonical()` to mutate in-place and return bool.
- Add `m` field & canonical-aware minimizer position calculation to SuperKmerIter in obiskbuilder.
- Add helper functions `is_degenerate` and minimizer comparison logic to rolling_stat.rs for consistent tie-breaking.
- Minor formatting cleanup in superkmer command and chunk processing.
This commit is contained in:
Eric Coissac committed 2026-04-20 17:50:09 +02:00
1 parent b534c693ac
commit 380b5a6f94
5 files changed
+43 -22

No files matched your search

+13 -14
View File
@@ -55,8 +55,10 @@ fn detect_format(source: &str, hint: Option<&str>) -> Format {
_ => Format::Fasta,
};
}
if source.ends_with(".fq") || source.ends_with(".fastq")
|| source.ends_with(".fq.gz") || source.ends_with(".fastq.gz")
if source.ends_with(".fq")
|| source.ends_with(".fastq")
|| source.ends_with(".fq.gz")
|| source.ends_with(".fastq.gz")
{
Format::Fastq
} else {
@@ -114,22 +116,20 @@ pub fn run(args: SuperkmerArgs) {
thread::spawn(move || {
for raw_chunk in raw_rx {
let norm = match format {
Format::Fasta => {
obiread::normalize::normalize_fasta_chunk(raw_chunk, k)
}
Format::Fastq => {
obiread::normalize::normalize_fastq_chunk(raw_chunk, k)
}
Format::Fasta => obiread::normalize::normalize_fasta_chunk(raw_chunk, k),
Format::Fastq => obiread::normalize::normalize_fastq_chunk(raw_chunk, k),
};
const BATCH_SIZE: usize = 10_000;
let mut batch = Vec::with_capacity(BATCH_SIZE);
for sk in SuperKmerIter::new(&norm, k, m, level_max, theta) {
batch.push(sk);
if batch.len() == BATCH_SIZE {
sk_tx.send(std::mem::replace(
&mut batch,
Vec::with_capacity(BATCH_SIZE),
)).unwrap();
sk_tx
.send(std::mem::replace(
&mut batch,
Vec::with_capacity(BATCH_SIZE),
))
.unwrap();
}
}
if !batch.is_empty() {
@@ -151,8 +151,7 @@ pub fn run(args: SuperkmerArgs) {
for batch in sk_rx {
for (min_hash, sk) in batch {
let partition = (mix64(min_hash) % partitions) as u32;
write_scatter(&sk, &mut out, k, m, partition, min_hash)
.expect("write error");
write_scatter(&sk, &mut out, k, m, partition, min_hash).expect("write error");
}
}
out.flush().expect("flush error");