Skip to content

Commit 5a93860

Browse files
y3tsengy3tseng
authored andcommitted
fix bug on merging insertion
1 parent 753c328 commit 5a93860

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/align-util.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,7 +1410,9 @@ void mergedAlignedSeqs(Tree* tree, msa::utility* util, msa::option* option, cons
14101410
auto insertIt = insertionGroup.begin();
14111411
std::string updated_seq = "";
14121412
while (alnIdx < alnPaths[s].size()) {
1413-
if (alnIdx == insertIt->first.first) {
1413+
bool index_match = (insertIt != insertionGroup.end());
1414+
if (index_match) index_match = (alnIdx == insertIt->first.first);
1415+
if (index_match) {
14141416
if (insertIt->second.find(alnPairs[s].second->identifier) != insertIt->second.end()) {
14151417
for (int j = 0; j < insertIt->first.second; ++j) {
14161418
updated_seq.push_back(util->placedSeqs[alnPairs[s].second->identifier][seqIdx]);
@@ -1442,7 +1444,9 @@ void mergedAlignedSeqs(Tree* tree, msa::utility* util, msa::option* option, cons
14421444
int backboneLen = (option->treeFile == "") ? tree->root->msaFreq.size() : util->backboneAln.begin()->second.size();
14431445
int b_alnIdx = 0;
14441446
while (b_alnIdx < backboneLen) {
1445-
if (b_alnIdx == insertIt->first.first) {
1447+
bool index_match = (insertIt != insertionGroup.end());
1448+
if (index_match) index_match = (b_alnIdx == insertIt->first.first);
1449+
if (index_match) {
14461450
for (int j = 0; j < insertIt->first.second; ++j) backbonePath.push_back(1);
14471451
++insertIt;
14481452
}

0 commit comments

Comments
 (0)