refactor: decouple unitig index generation and add exact evidence
Decouple index generation by introducing `build_unitig_idx()` for retroactive `.idx` creation and optional immediate writing on close. Add `open_sequential()` for index-less iteration while enforcing index requirements for random access. Refactor the MPHF layer to pre-generate the unitig index for parallel random access, integrate `rayon` for k-mer processing, and enforce mapping integrity via duplicate slot validation. Additionally, implement `build_exact_evidence()` to reconstruct evidence from existing artifacts, and update tests to leverage the new index generation and simplified k-mer iteration helpers.
This commit is contained in:
1 parent
8478072b78
commit
24afd74e2f
6 files changed
+167
-35
No files matched your search
@@ -18,6 +18,7 @@ fn write_read(seqs: &[&[u8]]) -> (tempfile::TempDir, UnitigFileReader) {
|
||||
w.write(&make_unitig(s)).unwrap();
|
||||
}
|
||||
w.close().unwrap();
|
||||
super::build_unitig_idx(&path, super::DEFAULT_BLOCK_BITS).unwrap();
|
||||
let r = UnitigFileReader::open(&path).unwrap();
|
||||
(dir, r)
|
||||
}
|
||||
@@ -31,6 +32,7 @@ fn roundtrip_empty_index() {
|
||||
let path = dir.path().join("unitigs.bin");
|
||||
let w = UnitigFileWriter::create(&path).unwrap();
|
||||
w.close().unwrap();
|
||||
super::build_unitig_idx(&path, super::DEFAULT_BLOCK_BITS).unwrap();
|
||||
let r = UnitigFileReader::open(&path).unwrap();
|
||||
assert_eq!(r.len(), 0);
|
||||
}
|
||||
@@ -145,6 +147,7 @@ fn iter_kmers_empty_file() {
|
||||
let dir = tempdir().unwrap();
|
||||
let path = dir.path().join("unitigs.bin");
|
||||
UnitigFileWriter::create(&path).unwrap().close().unwrap();
|
||||
super::build_unitig_idx(&path, super::DEFAULT_BLOCK_BITS).unwrap();
|
||||
let r = UnitigFileReader::open(&path).unwrap();
|
||||
assert_eq!(r.iter_kmers().count(), 0);
|
||||
}
|
||||
@@ -280,6 +283,7 @@ fn write_read_bb(seqs: &[&[u8]], block_bits: u8) -> (tempfile::TempDir, UnitigFi
|
||||
w.write(&make_unitig(s)).unwrap();
|
||||
}
|
||||
w.close().unwrap();
|
||||
super::build_unitig_idx(&path, block_bits).unwrap();
|
||||
let r = UnitigFileReader::open(&path).unwrap();
|
||||
(dir, r)
|
||||
}
|
||||
@@ -293,6 +297,7 @@ fn block_bits_stored_and_read_back() {
|
||||
let w = UnitigFileWriter::create_with_block_bits(&path, bb).unwrap();
|
||||
assert_eq!(w.block_bits(), bb);
|
||||
w.close().unwrap();
|
||||
super::build_unitig_idx(&path, bb).unwrap();
|
||||
let r = UnitigFileReader::open(&path).unwrap();
|
||||
assert_eq!(r.block_bits(), bb, "block_bits={bb} not preserved");
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user