centralize layer path construction and data loading

Replace manual directory formatting and inline matrix opening with the newly introduced `layer_dir` and `open_data` helpers from the `obilayeredmap` crate. This standardizes filesystem access, encapsulates layer naming conventions, and simplifies error handling without altering computational behavior or test suites.
This commit is contained in:
Eric Coissac
2026-08-20 14:43:10 +02:00
parent 640f29725b
commit 5a91817488
5 changed files with 49 additions and 30 deletions
+7 -7
View File
@@ -149,21 +149,21 @@ impl KmerIndex {
.unwrap_or(0);
for l in 0..n_layers {
let layer_dir = index_dir.join(format!("layer_{l}"));
if !layer_dir.exists() { continue; }
let this_layer_dir = obilayeredmap::layer_dir(&index_dir, l);
if !this_layer_dir.exists() { continue; }
n_kmers += LayerMeta::load(&layer_dir).map(|m| m.n).unwrap_or(0);
n_kmers += LayerMeta::load(&this_layer_dir).map(|m| m.n).unwrap_or(0);
let mat: Box<dyn ColumnWeights> =
if layer_dir.join("counts").exists()
&& !layer_dir.join("presence").exists()
if this_layer_dir.join("counts").exists()
&& !this_layer_dir.join("presence").exists()
{
match PersistentCompactIntMatrix::open(&layer_dir) {
match obilayeredmap::open_data::<PersistentCompactIntMatrix>(&index_dir, l) {
Ok(m) => Box::new(m),
Err(_) => continue,
}
} else {
match PersistentBitMatrix::open(&layer_dir) {
match obilayeredmap::open_data::<PersistentBitMatrix>(&index_dir, l) {
Ok(m) => Box::new(m),
Err(_) => continue,
}