Skip to content

Commit

Permalink
Merge pull request #3715 from vgteam/surject-interval-crash
Browse files Browse the repository at this point in the history
Surject interval crash
  • Loading branch information
jeizenga authored Aug 13, 2022
2 parents fd97f17 + 5cbb263 commit 22ac546
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
18 changes: 12 additions & 6 deletions src/subcommand/autoindex_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ int main_autoindex(int argc, char** argv) {
bool force_phased = false;
int64_t target_mem_usage = IndexRegistry::get_system_memory() / 2;

string gfa_name;

int c;
optind = 2; // force optind past command positional argument
while (true) {
Expand Down Expand Up @@ -215,12 +217,7 @@ int main_autoindex(int argc, char** argv) {
registry.provide("Insertion Sequence FASTA", optarg);
break;
case 'g':
if (IndexRegistry::gfa_has_haplotypes(optarg)) {
registry.provide("Reference GFA w/ Haplotypes", optarg);
}
else {
registry.provide("Reference GFA", optarg);
}
gfa_name = optarg;
break;
case 'x':
registry.provide("GTF/GFF", optarg);
Expand Down Expand Up @@ -312,6 +309,15 @@ int main_autoindex(int argc, char** argv) {
}
}
}

if (!gfa_name.empty()) {
if (IndexRegistry::gfa_has_haplotypes(gfa_name)) {
registry.provide("Reference GFA w/ Haplotypes", gfa_name);
}
else {
registry.provide("Reference GFA", gfa_name);
}
}

if (print_dot) {
// don't index, just visualize the plan
Expand Down
6 changes: 3 additions & 3 deletions src/surjector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3802,7 +3802,7 @@ using namespace std;

size_t right_overhang = no_right_expansion ? 0 : (get_aligner()->longest_detectable_gap(source, path_chunk.first.second)
+ (source.sequence().end() - path_chunk.first.second));

const Position& first_pos = path_chunk.second.mapping(0).position();
if (rev_strand) {
size_t path_offset = (graph->get_position_of_step(ref_chunk.first)
Expand All @@ -3818,7 +3818,7 @@ using namespace std;
interval.first = 0;
}
else {
interval.first = min(interval.first, path_offset - left_overhang);
interval.first = min(min(interval.first, path_offset - left_overhang), path_length - 1);
}
}

Expand All @@ -3834,7 +3834,7 @@ using namespace std;
interval.first = 0;
}
else {
interval.first = min(interval.first, path_offset - right_overhang);
interval.first = min(min(interval.first, path_offset - right_overhang), path_length - 1);
}
}
else {
Expand Down

1 comment on commit 22ac546

@adamnovak
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vg CI tests complete for merge to master. View the full report here.

16 tests passed, 0 tests failed and 0 tests skipped in 12994 seconds

Please sign in to comment.