Skip to content

Commit 8ac1faf

Browse files
committed
Introduce frugal mode
1 parent 354f7c4 commit 8ac1faf

15 files changed

Lines changed: 54 additions & 24 deletions

File tree

src/common/alignment/kmer_mapper.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,6 @@ class KmerMapper : public omnigraph::GraphActionHandler<Graph> {
161161
}
162162

163163
Kmer Substitute(const Kmer &kmer) const {
164-
VERIFY(this->IsAttached());
165164
const auto *rawval = mapping_.find(kmer);
166165
if (rawval == nullptr)
167166
return kmer;

src/common/configs/config_struct.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,7 @@ void load_launch_info(debruijn_config &cfg, boost::property_tree::ptree const &p
724724

725725
load(cfg.rr_enable, pt, "rr_enable");
726726
load(cfg.gfa11, pt, "gfa11");
727+
load(cfg.frugal, pt, "frugal");
727728

728729
load(cfg.temp_bin_reads_dir, pt, "temp_bin_reads_dir");
729730

@@ -880,10 +881,16 @@ void load(debruijn_config &cfg, const std::vector<std::filesystem::path> &cfg_fn
880881
cfg.pe_params.param_set.scaffolder_options.enabled = false;
881882
}
882883

883-
cfg.need_mapping = cfg.developer_mode || cfg.correct_mismatches ||
884-
cfg.gap_closer_enable || cfg.rr_enable ||
885-
cfg.ss_coverage_splitter.enabled;
886-
884+
// K-mer mapper is always attached in developer mode or in the case when read
885+
// mapping would be needed (unless in frugal mode).
886+
cfg.need_mapping = cfg.developer_mode ||
887+
(!cfg.frugal &&
888+
(cfg.correct_mismatches || // uses k-mer mapper directly
889+
cfg.gap_closer_enable || // maps reads
890+
cfg.rr_enable || // maps reads
891+
cfg.ss_coverage_splitter.enabled // maps reads
892+
)
893+
);
887894
cfg.output_dir = cfg.output_base / ("K" + std::to_string(cfg.K));
888895

889896
cfg.output_saves = cfg.output_dir / "saves";

src/common/configs/config_struct.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ struct debruijn_config {
517517
time_tracing tt;
518518

519519
bool need_mapping;
520+
bool frugal = false;
520521

521522
debruijn_config() :
522523
use_single_reads(false) {

src/common/pipeline/graph_pack_helpers.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
//* See file LICENSE for details.
66
//***************************************************************************
77

8+
#include "graph_pack_helpers.h"
89
#include "graph_pack.hpp"
910

10-
#include "genomic_info.hpp"
11-
1211
#include "alignment/edge_index.hpp"
1312
#include "alignment/kmer_mapper.hpp"
1413
#include "alignment/long_read_storage.hpp"
@@ -46,14 +45,17 @@ void EnsureIndex(GraphPack& gp) {
4645
index.Attach();
4746
}
4847

49-
void EnsureBasicMapping(GraphPack& gp) {
50-
auto &kmer_mapper = gp.get_mutable<KmerMapper<Graph>>();
51-
52-
VERIFY(kmer_mapper.IsAttached());
48+
void EnsureBasicMapping(GraphPack& gp, bool check_mapper) {
5349
EnsureIndex(gp);
54-
INFO("Normalizing k-mer map. Total " << kmer_mapper.size() << " kmers to process");
55-
kmer_mapper.Normalize();
56-
INFO("Normalizing done");
50+
51+
if (check_mapper) {
52+
auto &kmer_mapper = gp.get_mutable<KmerMapper<Graph>>();
53+
VERIFY(kmer_mapper.IsAttached());
54+
55+
INFO("Normalizing k-mer map. Total " << kmer_mapper.size() << " kmers to process");
56+
kmer_mapper.Normalize();
57+
INFO("Normalizing done");
58+
}
5759
}
5860

5961
void EnsureQuality(GraphPack& gp) {

src/common/pipeline/graph_pack_helpers.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ void FillQuality(graph_pack::GraphPack& gp);
1616
void ClearQuality(graph_pack::GraphPack& gp);
1717

1818
void EnsureIndex(graph_pack::GraphPack& gp);
19-
void EnsureBasicMapping(graph_pack::GraphPack& gp);
19+
void EnsureBasicMapping(graph_pack::GraphPack& gp,
20+
bool check_mapper = true);
2021
void EnsureQuality(graph_pack::GraphPack& gp);
2122
void EnsurePos(graph_pack::GraphPack& gp);
2223
void EnsureDebugInfo(graph_pack::GraphPack& gp);

src/common/stages/ss_edge_split.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void SSEdgeSplit::run(graph_pack::GraphPack& gp, const char *) {
2525
return;
2626
}
2727

28-
EnsureBasicMapping(gp);
28+
EnsureBasicMapping(gp, !cfg::get().frugal);
2929

3030
for (size_t i = 0; i < cfg::get().ds.reads.lib_count(); ++i) {
3131
auto &lib = cfg::get_writable().ds.reads[i];

src/projects/hpcspades/pipeline.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ static void AddSimplificationStages(spades::StageManager &SPAdes) {
180180

181181
SPAdes.add<debruijn_graph::SimplificationCleanup>();
182182

183-
if (cfg::get().correct_mismatches)
183+
if (cfg::get().correct_mismatches && !cfg::get().frugal)
184184
SPAdes.add<debruijn_graph::MismatchCorrectionMPI>();
185185

186186
if (cfg::get().ss_coverage_splitter.enabled)

src/projects/spades/configs/config.info

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ min_edge_length_for_is_count 0
5151
; Whether GFA v1.2 (jump links) or GFA v1.1 (scaffold segments) graphs is written
5252
gfa11 false
5353

54+
; Enable / Disable memory frugal mode
55+
frugal false
56+
5457
;preserve raw paired index after distance estimation
5558
preserve_raw_paired_index false
5659

src/projects/spades/hybrid_aligning.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ void HybridLibrariesAligning::run(graph_pack::GraphPack& gp, const char*) {
356356
path_storage, gap_storage,
357357
cfg::get().max_threads, cfg::get().pb);
358358
} else {
359-
EnsureBasicMapping(gp);
359+
EnsureBasicMapping(gp, !cfg::get().frugal);
360360
gap_closing::GapTrackingListener mapping_listener(graph, gap_storage);
361361
INFO("Processing reads from hybrid library " << lib_id);
362362

src/projects/spades/pair_info_count.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ void PairInfoCountBase::execute(graph_pack::GraphPack &gp, const char *,
153153
const MapLibBase &map_lib_func,
154154
size_t num_readers) {
155155
InitRRIndices(gp);
156-
EnsureBasicMapping(gp);
156+
EnsureBasicMapping(gp, !cfg::get().frugal);
157157

158158
const auto &graph = gp.get<Graph>();
159159

0 commit comments

Comments
 (0)