refactor: optimize unitig iteration and graph traversal
Switches unitig processing to a lazy, fallible `try_for_each_unitig` API across partitioner layers, reducing intermediate allocations and enabling proper error propagation. Refactors de Bruijn graph traversal into a two-pass algorithm with explicit node flags, named constants, and diagnostic logging. Introduces parallel chain processing and staged performance profiling for the unitig command, and adds a memory-efficient `FromIterator` implementation for packed nucleotide sequences.
This commit is contained in:
@@ -104,9 +104,10 @@ impl KmerPartition {
|
||||
fs::create_dir_all(&layer_dir)?;
|
||||
|
||||
let mut uw = Layer::<()>::unitig_writer(&layer_dir).map_err(olm_to_sk)?;
|
||||
for unitig in g.iter_unitig() {
|
||||
uw.write(&unitig)?;
|
||||
}
|
||||
g.try_for_each_unitig(|nuc_iter| {
|
||||
let unitig: obikseq::unitig::Unitig = nuc_iter.collect();
|
||||
uw.write(&unitig)
|
||||
})?;
|
||||
uw.close()?;
|
||||
|
||||
if with_counts {
|
||||
|
||||
@@ -202,9 +202,10 @@ impl KmerPartition {
|
||||
g.compute_degrees();
|
||||
fs::create_dir_all(&new_layer_dir)?;
|
||||
let mut uw = Layer::<()>::unitig_writer(&new_layer_dir).map_err(olm_to_sk)?;
|
||||
for unitig in g.iter_unitig() {
|
||||
uw.write(&unitig)?;
|
||||
}
|
||||
g.try_for_each_unitig(|nuc_iter| {
|
||||
let unitig: obikseq::unitig::Unitig = nuc_iter.collect();
|
||||
uw.write(&unitig)
|
||||
})?;
|
||||
uw.close()?;
|
||||
Layer::<()>::build(&new_layer_dir, block_bits, evidence).map_err(olm_to_sk)?;
|
||||
g.len()
|
||||
|
||||
@@ -154,9 +154,10 @@ impl KmerPartition {
|
||||
fs::create_dir_all(&dst_layer_dir)?;
|
||||
|
||||
let mut uw = Layer::<()>::unitig_writer(&dst_layer_dir).map_err(olm_to_sk)?;
|
||||
for unitig in g.iter_unitig() {
|
||||
uw.write(&unitig)?;
|
||||
}
|
||||
g.try_for_each_unitig(|nuc_iter| {
|
||||
let unitig: obikseq::unitig::Unitig = nuc_iter.collect();
|
||||
uw.write(&unitig)
|
||||
})?;
|
||||
uw.close()?;
|
||||
drop(g);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user