Skip to content

Commit c083580

Browse files
authored
Merge pull request #4 from algbio/fix-random-path
Fix random path to not repeat ids
2 parents 403cff6 + 6b19157 commit c083580

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/AlignmentGraph.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,8 +1507,12 @@ std::vector<size_t> AlignmentGraph::generatePath(const std::string &seq_out, con
15071507
}
15081508
std::ofstream fout(seq_out), pout(path_out);
15091509
fout << ">path_" << path[0] << "_" << path.back() << std::endl;
1510-
for (size_t i : path) {
1511-
pout << i << ' ' << nodeIDs[i] << std::endl;
1510+
int last_nodeID = -1; // Assumed not to be a valid ID
1511+
for (size_t i : path) {
1512+
if (nodeIDs[i] != last_nodeID) {
1513+
pout << i << ' ' << nodeIDs[i] << std::endl;
1514+
last_nodeID = nodeIDs[i];
1515+
}
15121516
// std::cout << i << " " << nodeIDs[i] << " " << reverse[i] << " : ";
15131517
for (size_t j = 0; j < NodeLength(i); j++) {
15141518
fout << NodeSequences(i, j);
@@ -1896,4 +1900,4 @@ std::vector<size_t> AlignmentGraph::getChainPath(size_t S, size_t T, long long s
18961900
tmp.push_back(S);
18971901
std::reverse(tmp.begin(), tmp.end());
18981902
return tmp;
1899-
}
1903+
}

0 commit comments

Comments
 (0)