diff --git a/src/subcommand/surject_main.cpp b/src/subcommand/surject_main.cpp index 889a6d607b..cca660593a 100644 --- a/src/subcommand/surject_main.cpp +++ b/src/subcommand/surject_main.cpp @@ -83,6 +83,7 @@ void help_surject(char** argv) { << " -V, --no-validate skip checking whether alignments plausibly are" << endl << " against the provided graph" << endl << " -w, --watchdog-timeout N warn when reads take more than N seconds to surject" << endl + << " -B, --reference-bonus N add N to the score of reference paths during selection" << endl << " -r, --progress show progress" << endl << " -h, --help print this help message to stderr and exit" << endl; } @@ -168,6 +169,7 @@ int main_surject(int argc, char** argv) { bool prune_anchors = false; int64_t max_slide = Surjector::DEFAULT_MAX_SLIDE; size_t max_anchors = std::numeric_limits::max(); // As close to unlimited as makes no difference + int32_t reference_bonus = 0; bool report_supplementary = false; bool annotate_with_all_path_scores = false; bool annotate_with_graph_alignment = false; @@ -213,12 +215,13 @@ int main_surject(int argc, char** argv) { {"compression", required_argument, 0, 'C'}, {"no-validate", no_argument, 0, 'V'}, {"watchdog-timeout", required_argument, 0, 'w'}, + {"reference-bonus", required_argument, 0, 'B'}, {"progress", no_argument, 0, 'r'}, {0, 0, 0, 0} }; int option_index = 0; - c = getopt_long (argc, argv, "h?x:p:F:n:lT:g:iGmcbsuN:R:f:C:t:SPI:a:AE:LHMVw:r", + c = getopt_long (argc, argv, "h?x:p:F:n:lT:g:iGmcbsuN:R:f:C:t:SPI:a:AE:LHMVw:rB:", long_options, &option_index); // Detect the end of the options. @@ -340,6 +343,10 @@ int main_surject(int argc, char** argv) { case 'r': show_progress = true; break; + + case 'B': + reference_bonus = parse(optarg); + break; case 't': set_thread_count(logger, optarg); @@ -452,6 +459,7 @@ int main_surject(int argc, char** argv) { surjector.max_tail_length = max_tail_len; surjector.annotate_with_all_path_scores = annotate_with_all_path_scores; surjector.annotate_with_graph_alignment = annotate_with_graph_alignment; + surjector.reference_bonus = reference_bonus; if (max_graph_scale) { // We have an override surjector.max_subgraph_bases_per_read_base = *max_graph_scale; diff --git a/src/surjector.hpp b/src/surjector.hpp index 552fb504ad..dae355844f 100644 --- a/src/surjector.hpp +++ b/src/surjector.hpp @@ -194,6 +194,8 @@ using namespace std; bool annotate_with_all_path_scores = false; bool annotate_with_graph_alignment = false; + /// Score bonus to apply to alignments on reference paths during path selection + int32_t reference_bonus = 0; protected: @@ -590,11 +592,16 @@ using namespace std; // TODO: it would be possible to make this exact total_score -= total_overlap(strand_surjections.second) * get_aligner()->match; - if (total_score >= score) { + int32_t adjusted_score = total_score; + if (reference_bonus && graph->get_sense(strand_surjections.first.first) == PathSense::REFERENCE) { + adjusted_score += reference_bonus; + } + + if (adjusted_score >= score) { #ifdef debug_anchored_surject - cerr << "surjection against path " << graph->get_path_name(surjections.first.first) << " strand " << surjections.first.second << " achieves highest score (so far) of " << total_score << endl; + cerr << "surjection against path " << graph->get_path_name(strand_surjections.first.first) << " strand " << strand_surjections.first.second << " achieves highest score (so far) of " << adjusted_score << endl; #endif - score = total_score; + score = adjusted_score; best_path_strand = strand_surjections.first; } }