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

Ensure we correctly handle edges on self-conjugate nodes #165

Merged
merged 1 commit into from
Nov 2, 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
18 changes: 17 additions & 1 deletion graph/assemblygraphbuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,24 @@ namespace io {
DeBruijnNode *oppositeNodePtr = nullptr;
auto rcSeq = sequence.GetReverseComplement();
if (!sequence.empty() && !sequence.missing() && sequence == rcSeq) {
// We might already have opposite node recorded (e.g. a placeholder).
// If yes, we'd need to transfer the edges
auto [oppositeNodeStorage, inserted] = graph.m_deBruijnGraphNodes.insert(oppositeNodeName, nodePtr);
if (!inserted) {
oppositeNodePtr = *oppositeNodeStorage;

for (auto *edge : oppositeNodePtr->edges()) {
if (edge->getEndingNode() == oppositeNodePtr)
edge->setEndingNode(nodePtr);
if (edge->getStartingNode() == oppositeNodePtr)
edge->setStartingNode(nodePtr);
nodePtr->addEdge(edge);
}

*oppositeNodeStorage = nodePtr;
}

oppositeNodePtr = nodePtr;
graph.m_deBruijnGraphNodes[oppositeNodeName] = oppositeNodePtr;
} else {
oppositeNodePtr =
maybeAddSegment(getOppositeNodeName(nodeName), nodeDepth, rcSeq, graph);
Expand Down
3 changes: 3 additions & 0 deletions graph/debruijnedge.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ class DeBruijnEdge

DeBruijnNode * getStartingNode() const {return m_startingNode;}
DeBruijnNode * getEndingNode() const {return m_endingNode;}
void setStartingNode(DeBruijnNode *node) { m_startingNode = node;}
void setEndingNode(DeBruijnNode *node) { m_endingNode = node;}

GraphicsItemEdge * getGraphicsItemEdge() const {return m_graphicsItemEdge;}
DeBruijnEdge * getReverseComplement() const {return m_reverseComplement;}
bool isDrawn() const {return m_drawn;}
Expand Down
Loading