Skip to content

Commit

Permalink
Merge pull request #4229 from vgteam/left-surject
Browse files Browse the repository at this point in the history
Mostly consistently left align in surject
  • Loading branch information
jeizenga committed Feb 26, 2024
2 parents 19b401f + 695d2d0 commit 67c20e9
Show file tree
Hide file tree
Showing 8 changed files with 468 additions and 283 deletions.
60 changes: 40 additions & 20 deletions src/aligner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1421,7 +1421,8 @@ void Aligner::align_pinned_multi(Alignment& alignment, vector<Alignment>& alt_al
}

void Aligner::align_global_banded(Alignment& alignment, const HandleGraph& g,
int32_t band_padding, bool permissive_banding) const {
int32_t band_padding, bool permissive_banding,
const unordered_map<handle_t, bool>* left_align_strand) const {

if (alignment.sequence().empty()) {
// we can save time by using a specialized deletion aligner for empty strings
Expand All @@ -1446,7 +1447,8 @@ void Aligner::align_global_banded(Alignment& alignment, const HandleGraph& g,
g,
band_padding,
permissive_banding,
false);
false,
left_align_strand);

band_graph.align(score_matrix, nt_table, gap_open, gap_extension);
} else if (best_score <= numeric_limits<int16_t>::max() && worst_score >= numeric_limits<int16_t>::min()) {
Expand All @@ -1455,7 +1457,8 @@ void Aligner::align_global_banded(Alignment& alignment, const HandleGraph& g,
g,
band_padding,
permissive_banding,
false);
false,
left_align_strand);

band_graph.align(score_matrix, nt_table, gap_open, gap_extension);
} else if (best_score <= numeric_limits<int32_t>::max() && worst_score >= numeric_limits<int32_t>::min()) {
Expand All @@ -1464,7 +1467,8 @@ void Aligner::align_global_banded(Alignment& alignment, const HandleGraph& g,
g,
band_padding,
permissive_banding,
false);
false,
left_align_strand);

band_graph.align(score_matrix, nt_table, gap_open, gap_extension);
} else {
Expand All @@ -1473,14 +1477,16 @@ void Aligner::align_global_banded(Alignment& alignment, const HandleGraph& g,
g,
band_padding,
permissive_banding,
false);
false,
left_align_strand);

band_graph.align(score_matrix, nt_table, gap_open, gap_extension);
}
}

void Aligner::align_global_banded_multi(Alignment& alignment, vector<Alignment>& alt_alignments, const HandleGraph& g,
int32_t max_alt_alns, int32_t band_padding, bool permissive_banding) const {
int32_t max_alt_alns, int32_t band_padding, bool permissive_banding,
const unordered_map<handle_t, bool>* left_align_strand) const {

if (alignment.sequence().empty()) {
// we can save time by using a specialized deletion aligner for empty strings
Expand All @@ -1505,7 +1511,8 @@ void Aligner::align_global_banded_multi(Alignment& alignment, vector<Alignment>&
max_alt_alns,
band_padding,
permissive_banding,
false);
false,
left_align_strand);

band_graph.align(score_matrix, nt_table, gap_open, gap_extension);
} else if (best_score <= numeric_limits<int16_t>::max() && worst_score >= numeric_limits<int16_t>::min()) {
Expand All @@ -1516,7 +1523,8 @@ void Aligner::align_global_banded_multi(Alignment& alignment, vector<Alignment>&
max_alt_alns,
band_padding,
permissive_banding,
false);
false,
left_align_strand);

band_graph.align(score_matrix, nt_table, gap_open, gap_extension);
} else if (best_score <= numeric_limits<int32_t>::max() && worst_score >= numeric_limits<int32_t>::min()) {
Expand All @@ -1527,7 +1535,8 @@ void Aligner::align_global_banded_multi(Alignment& alignment, vector<Alignment>&
max_alt_alns,
band_padding,
permissive_banding,
false);
false,
left_align_strand);

band_graph.align(score_matrix, nt_table, gap_open, gap_extension);
} else {
Expand All @@ -1538,7 +1547,8 @@ void Aligner::align_global_banded_multi(Alignment& alignment, vector<Alignment>&
max_alt_alns,
band_padding,
permissive_banding,
false);
false,
left_align_strand);

band_graph.align(score_matrix, nt_table, gap_open, gap_extension);
}
Expand Down Expand Up @@ -2095,7 +2105,8 @@ void QualAdjAligner::align_pinned_multi(Alignment& alignment, vector<Alignment>&
}

void QualAdjAligner::align_global_banded(Alignment& alignment, const HandleGraph& g,
int32_t band_padding, bool permissive_banding) const {
int32_t band_padding, bool permissive_banding,
const unordered_map<handle_t, bool>* left_align_strand) const {

if (alignment.sequence().empty()) {
// we can save time by using a specialized deletion aligner for empty strings
Expand All @@ -2118,7 +2129,8 @@ void QualAdjAligner::align_global_banded(Alignment& alignment, const HandleGraph
g,
band_padding,
permissive_banding,
true);
true,
left_align_strand);

band_graph.align(score_matrix, nt_table, gap_open, gap_extension);
} else if (best_score <= numeric_limits<int16_t>::max() && worst_score >= numeric_limits<int16_t>::min()) {
Expand All @@ -2127,7 +2139,8 @@ void QualAdjAligner::align_global_banded(Alignment& alignment, const HandleGraph
g,
band_padding,
permissive_banding,
true);
true,
left_align_strand);

band_graph.align(score_matrix, nt_table, gap_open, gap_extension);
} else if (best_score <= numeric_limits<int32_t>::max() && worst_score >= numeric_limits<int32_t>::min()) {
Expand All @@ -2136,7 +2149,8 @@ void QualAdjAligner::align_global_banded(Alignment& alignment, const HandleGraph
g,
band_padding,
permissive_banding,
true);
true,
left_align_strand);

band_graph.align(score_matrix, nt_table, gap_open, gap_extension);
} else {
Expand All @@ -2145,14 +2159,16 @@ void QualAdjAligner::align_global_banded(Alignment& alignment, const HandleGraph
g,
band_padding,
permissive_banding,
true);
true,
left_align_strand);

band_graph.align(score_matrix, nt_table, gap_open, gap_extension);
}
}

void QualAdjAligner::align_global_banded_multi(Alignment& alignment, vector<Alignment>& alt_alignments, const HandleGraph& g,
int32_t max_alt_alns, int32_t band_padding, bool permissive_banding) const {
int32_t max_alt_alns, int32_t band_padding, bool permissive_banding,
const unordered_map<handle_t, bool>* left_align_strand) const {

if (alignment.sequence().empty()) {
// we can save time by using a specialized deletion aligner for empty strings
Expand All @@ -2177,7 +2193,8 @@ void QualAdjAligner::align_global_banded_multi(Alignment& alignment, vector<Alig
max_alt_alns,
band_padding,
permissive_banding,
true);
true,
left_align_strand);

band_graph.align(score_matrix, nt_table, gap_open, gap_extension);
} else if (best_score <= numeric_limits<int16_t>::max() && worst_score >= numeric_limits<int16_t>::min()) {
Expand All @@ -2188,7 +2205,8 @@ void QualAdjAligner::align_global_banded_multi(Alignment& alignment, vector<Alig
max_alt_alns,
band_padding,
permissive_banding,
true);
true,
left_align_strand);

band_graph.align(score_matrix, nt_table, gap_open, gap_extension);
} else if (best_score <= numeric_limits<int32_t>::max() && worst_score >= numeric_limits<int32_t>::min()) {
Expand All @@ -2199,7 +2217,8 @@ void QualAdjAligner::align_global_banded_multi(Alignment& alignment, vector<Alig
max_alt_alns,
band_padding,
permissive_banding,
true);
true,
left_align_strand);

band_graph.align(score_matrix, nt_table, gap_open, gap_extension);
} else {
Expand All @@ -2210,7 +2229,8 @@ void QualAdjAligner::align_global_banded_multi(Alignment& alignment, vector<Alig
max_alt_alns,
band_padding,
permissive_banding,
true);
true,
left_align_strand);

band_graph.align(score_matrix, nt_table, gap_open, gap_extension);
}
Expand Down
18 changes: 12 additions & 6 deletions src/aligner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,17 @@ namespace vg {
/// permissive banding auto detects the width of band needed so that paths can travel
/// through every node in the graph
virtual void align_global_banded(Alignment& alignment, const HandleGraph& g,
int32_t band_padding = 0, bool permissive_banding = true) const = 0;
int32_t band_padding = 0, bool permissive_banding = true,
const unordered_map<handle_t, bool>* left_align_strand = nullptr) const = 0;

/// store top scoring global alignments in the vector in descending score order up to a maximum number
/// of alternate alignments (including the optimal alignment). if there are fewer than the maximum
/// number of alignments in the return value, then the vector contains all possible alignments. the
/// optimal alignment will be stored in both the vector and the original alignment object
virtual void align_global_banded_multi(Alignment& alignment, vector<Alignment>& alt_alignments,
const HandleGraph& g, int32_t max_alt_alns, int32_t band_padding = 0,
bool permissive_banding = true) const = 0;
bool permissive_banding = true,
const unordered_map<handle_t, bool>* left_align_strand = nullptr) const = 0;
/// xdrop aligner
virtual void align_xdrop(Alignment& alignment, const HandleGraph& g, const vector<MaximalExactMatch>& mems,
bool reverse_complemented, uint16_t max_gap_length = default_xdrop_max_gap_length) const = 0;
Expand Down Expand Up @@ -358,14 +360,16 @@ namespace vg {
/// permissive banding auto detects the width of band needed so that paths can travel
/// through every node in the graph
void align_global_banded(Alignment& alignment, const HandleGraph& g,
int32_t band_padding = 0, bool permissive_banding = true) const;
int32_t band_padding = 0, bool permissive_banding = true,
const unordered_map<handle_t, bool>* left_align_strand = nullptr) const;

/// store top scoring global alignments in the vector in descending score order up to a maximum number
/// of alternate alignments (including the optimal alignment). if there are fewer than the maximum
/// number of alignments in the return value, then the vector contains all possible alignments. the
/// optimal alignment will be stored in both the vector and the original alignment object
void align_global_banded_multi(Alignment& alignment, vector<Alignment>& alt_alignments, const HandleGraph& g,
int32_t max_alt_alns, int32_t band_padding = 0, bool permissive_banding = true) const;
int32_t max_alt_alns, int32_t band_padding = 0, bool permissive_banding = true,
const unordered_map<handle_t, bool>* left_align_strand = nullptr) const;

/// xdrop aligner
void align_xdrop(Alignment& alignment, const HandleGraph& g, const vector<MaximalExactMatch>& mems,
Expand Down Expand Up @@ -428,11 +432,13 @@ namespace vg {

void align(Alignment& alignment, const HandleGraph& g, bool traceback_aln) const;
void align_global_banded(Alignment& alignment, const HandleGraph& g,
int32_t band_padding = 0, bool permissive_banding = true) const;
int32_t band_padding = 0, bool permissive_banding = true,
const unordered_map<handle_t, bool>* left_align_strand = nullptr) const;
void align_pinned(Alignment& alignment, const HandleGraph& g, bool pin_left, bool xdrop = false,
uint16_t xdrop_max_gap_length = default_xdrop_max_gap_length) const;
void align_global_banded_multi(Alignment& alignment, vector<Alignment>& alt_alignments, const HandleGraph& g,
int32_t max_alt_alns, int32_t band_padding = 0, bool permissive_banding = true) const;
int32_t max_alt_alns, int32_t band_padding = 0, bool permissive_banding = true,
const unordered_map<handle_t, bool>* left_align_strand = nullptr) const;
void align_pinned_multi(Alignment& alignment, vector<Alignment>& alt_alignments, const HandleGraph& g,
bool pin_left, int32_t max_alt_alns) const;

Expand Down
Loading

2 comments on commit 67c20e9

@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 16923 seconds

@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 branch v1.55.0. View the full report here.

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

Please sign in to comment.