Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/subcommand/surject_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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<size_t>::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;
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -340,6 +343,10 @@ int main_surject(int argc, char** argv) {
case 'r':
show_progress = true;
break;

case 'B':
reference_bonus = parse<int32_t>(optarg);
break;

case 't':
set_thread_count(logger, optarg);
Expand Down Expand Up @@ -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;
Expand Down
13 changes: 10 additions & 3 deletions src/surjector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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;
}
}
Expand Down