refactor: rename compute_degrees and mark start nodes
Renames `compute_degrees` to `compute_degrees_and_mark_starts` across the De Bruijn graph and partitioner layers to consolidate degree calculation and start-node flagging. Introduces safe neighbor iteration methods and a debug validation block to verify graph consistency. Refactors unitig extraction to use sequential execution with a `Mutex` for safe error propagation. Fixes malformed and duplicated method calls, adds auto-generation of missing `meta.json` files, and ensures persistent matrix builders are explicitly closed to finalize metadata.
This commit is contained in:
1 parent
27088ab810
commit
5c2f48535f
6 files changed
+252
-384
No files matched your search
@@ -28,9 +28,9 @@ pub fn run(args: UnitigArgs) {
|
||||
std::process::exit(1);
|
||||
});
|
||||
|
||||
let k = idx.kmer_size();
|
||||
let n = idx.n_partitions();
|
||||
let n_genomes = idx.meta().genomes.len().max(1);
|
||||
let k = idx.kmer_size();
|
||||
let n = idx.n_partitions();
|
||||
let n_genomes = idx.meta().genomes.len().max(1);
|
||||
let use_counts = idx.meta().config.with_counts;
|
||||
|
||||
info!("unitig: building de Bruijn graph from {n} partition(s) (k={k})");
|
||||
@@ -44,22 +44,22 @@ pub fn run(args: UnitigArgs) {
|
||||
let stage = Stage::start("build graph");
|
||||
let g = (0..n)
|
||||
.into_par_iter()
|
||||
.fold(
|
||||
GraphDeBruijn::new,
|
||||
|mut local_g, i| {
|
||||
partition
|
||||
.iter_partition_kmers(i, use_counts, n_genomes, &filters, |kmer, _row| {
|
||||
local_g.push(kmer);
|
||||
})
|
||||
.unwrap_or_else(|e| {
|
||||
eprintln!("error reading partition {i}: {e}");
|
||||
std::process::exit(1);
|
||||
});
|
||||
pb.inc(1);
|
||||
local_g
|
||||
},
|
||||
)
|
||||
.reduce(GraphDeBruijn::new, |mut a, b| { a.merge(b); a });
|
||||
.fold(GraphDeBruijn::new, |mut local_g, i| {
|
||||
partition
|
||||
.iter_partition_kmers(i, use_counts, n_genomes, &filters, |kmer, _row| {
|
||||
local_g.push(kmer);
|
||||
})
|
||||
.unwrap_or_else(|e| {
|
||||
eprintln!("error reading partition {i}: {e}");
|
||||
std::process::exit(1);
|
||||
});
|
||||
pb.inc(1);
|
||||
local_g
|
||||
})
|
||||
.reduce(GraphDeBruijn::new, |mut a, b| {
|
||||
a.merge(b);
|
||||
a
|
||||
});
|
||||
pb.finish_and_clear();
|
||||
rep.push(stage.stop());
|
||||
|
||||
@@ -67,13 +67,13 @@ pub fn run(args: UnitigArgs) {
|
||||
|
||||
// ── Phase 2 : compute degrees (in-memory, no progress needed) ────────────
|
||||
let stage = Stage::start("compute degrees");
|
||||
g.compute_degrees();
|
||||
g.compute_degrees_and_mark_starts();
|
||||
rep.push(stage.stop());
|
||||
|
||||
// ── Phase 3 : enumerate unitigs and write as FASTA ───────────────────────
|
||||
let pb = spinner("unitig");
|
||||
let pb = spinner("unitig");
|
||||
let out = Mutex::new(BufWriter::new(io::stdout()));
|
||||
let j = AtomicUsize::new(0);
|
||||
let j = AtomicUsize::new(0);
|
||||
|
||||
let stage = Stage::start("enumerate unitigs");
|
||||
g.for_each_unitig(|nuc_iter| {
|
||||
|
||||
Reference in new issue
Block a user