Skip to content

Commit

Permalink
Merge pull request #4 from algbio/fix-random-path
Browse files Browse the repository at this point in the history
Fix random path to not repeat ids
  • Loading branch information
elarielcl authored Mar 30, 2022
2 parents 403cff6 + 6b19157 commit c083580
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/AlignmentGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1507,8 +1507,12 @@ std::vector<size_t> AlignmentGraph::generatePath(const std::string &seq_out, con
}
std::ofstream fout(seq_out), pout(path_out);
fout << ">path_" << path[0] << "_" << path.back() << std::endl;
for (size_t i : path) {
pout << i << ' ' << nodeIDs[i] << std::endl;
int last_nodeID = -1; // Assumed not to be a valid ID
for (size_t i : path) {
if (nodeIDs[i] != last_nodeID) {
pout << i << ' ' << nodeIDs[i] << std::endl;
last_nodeID = nodeIDs[i];
}
// std::cout << i << " " << nodeIDs[i] << " " << reverse[i] << " : ";
for (size_t j = 0; j < NodeLength(i); j++) {
fout << NodeSequences(i, j);
Expand Down Expand Up @@ -1896,4 +1900,4 @@ std::vector<size_t> AlignmentGraph::getChainPath(size_t S, size_t T, long long s
tmp.push_back(S);
std::reverse(tmp.begin(), tmp.end());
return tmp;
}
}

0 comments on commit c083580

Please # to comment.