Skip to content

Commit

Permalink
Ensure we report malformed paths / walks properly.
Browse files Browse the repository at this point in the history
Fixes #166
  • Loading branch information
asl committed Nov 28, 2024
1 parent a793415 commit 247bbb0
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions graph/assemblygraphbuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,14 @@ namespace io {
std::vector<DeBruijnNode *> pathNodes;
pathNodes.reserve(record.segments.size());

for (const auto &node: record.segments)
pathNodes.push_back(graph.m_deBruijnGraphNodes.at(node));
for (const auto &node: record.segments) {
auto nodeIt = graph.m_deBruijnGraphNodes.find(node);
if (nodeIt == graph.m_deBruijnGraphNodes.end())
return llvm::createStringError(llvm::Twine("malformed path string for path '")
+ record.name + "', invalid node in path: " + node);

pathNodes.push_back(nodeIt.value());
}
Path p(Path::makeFromOrderedNodes(pathNodes, false));
if (p.nodes().size() != pathNodes.size()) {
// We were unable to build path through the graph, likely the input
Expand Down Expand Up @@ -611,7 +617,12 @@ namespace io {
else
return llvm::createStringError(llvm::Twine("invalid walk string: ") + node);

walkNodes.push_back(graph.m_deBruijnGraphNodes.at(nodeName));
auto nodeIt = graph.m_deBruijnGraphNodes.find(nodeName);
if (nodeIt == graph.m_deBruijnGraphNodes.end())
return llvm::createStringError(llvm::Twine("malformed path string for walk '")
+ record.SeqId + "', invalid node in path: " + node);

walkNodes.push_back(nodeIt.value());
}

Path p(Path::makeFromOrderedNodes(walkNodes, false));
Expand Down

0 comments on commit 247bbb0

Please sign in to comment.