Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mostly consistently left align in surject #4229

Merged
merged 4 commits into from
Feb 26, 2024
Merged
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
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
Loading