Skip to content

Commit 60beaaf

Browse files
committed
correctly update edges in subgraph
1 parent fc985d6 commit 60beaaf

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

include/kreeq.h

+2
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ class DBG : public Kmap<DBG, UserInputKreeq, uint64_t, DBGkmer, DBGkmer32> { //
243243

244244
void bestFirst(); // best-first search traversal
245245

246+
void removeMissingEdges();
247+
246248
void summary(ParallelMap32color& DBGsubgraph);
247249

248250
ParallelMap32color traversalPass(ParallelMap32color* candidates, std::array<uint16_t, 2> mapRange);

src/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ int main(int argc, char **argv) {
377377
case 'h': // help
378378
printf("kreeq subgraph [options]\n");
379379
printf("\nOptions:\n");
380-
printf("\t-c --coverage-cutoff coverage cutoff.\n");
380+
printf("\t-c --coverage-cutoff exclude nodes and edges below or equal to the cutoff (default: 0).\n");
381381
printf("\t-d --database DBG database.\n");
382382
printf("\t-f --input-sequence sequence input file (fasta).\n");
383383
printf("\t--traversal-algorithm <string> the approach used for graph search (best-first/traversal, default: best-first).\n");

src/subgraph.cpp

+30
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ void DBG::subgraph() {
171171
fprintf(stderr, "Cannot find input algorithm (%s). Terminating.\n", userInput.travAlgorithm.c_str());
172172
exit(EXIT_FAILURE);
173173
}
174+
lg.verbose("Remove missing edges");
175+
removeMissingEdges();
174176
lg.verbose("Computing summary graph");
175177
summary(*DBGsubgraph);
176178
lg.verbose("Generating GFA");
@@ -576,6 +578,34 @@ void DBG::buildNextKmer(uint8_t* nextKmer, uint64_t hash, uint8_t nextBase, bool
576578
}
577579
}
578580

581+
void DBG::removeMissingEdges() {
582+
583+
bool isFw;
584+
585+
for (auto &node : *DBGsubgraph) { // loop through all nodes
586+
587+
for (uint8_t i = 0; i<4; ++i) { // forward edges
588+
if (node.second.fw[i] > userInput.covCutOff) {
589+
uint8_t nextKmer[k];
590+
buildNextKmer(nextKmer, node.first, i, true); // compute next node
591+
uint64_t key = hash(nextKmer, &isFw);
592+
auto found = DBGsubgraph->find(key);
593+
if (found == DBGsubgraph->end()) {
594+
node.second.fw[i] = 0;
595+
}
596+
}
597+
if (node.second.bw[i] > userInput.covCutOff) { // backward edges
598+
uint8_t nextKmer[k];
599+
buildNextKmer(nextKmer, node.first, i, false); // compute next node
600+
uint64_t key = hash(nextKmer, &isFw);
601+
auto found = DBGsubgraph->find(key);
602+
if (found == DBGsubgraph->end()) {
603+
node.second.bw[i] = 0;
604+
}
605+
}
606+
}
607+
}
608+
}
579609

580610

581611

0 commit comments

Comments
 (0)