From 719aa5d2131328da7114e9d27f833e70a4bf65de Mon Sep 17 00:00:00 2001 From: Glenn Hickey Date: Mon, 1 Mar 2021 10:24:13 -0500 Subject: [PATCH] throw error and abort before writing invalid reverse-strand rGFA step --- src/gfa.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gfa.cpp b/src/gfa.cpp index ab4b4455af1..e755d39a68d 100644 --- a/src/gfa.cpp +++ b/src/gfa.cpp @@ -2,6 +2,7 @@ #include #include "utility.hpp" #include "path.hpp" +#include namespace vg { @@ -30,6 +31,12 @@ void graph_to_gfa(const PathHandleGraph* graph, ostream& out, const set& graph->for_each_step_in_path(path_handle, [&](step_handle_t step_handle) { handle_t handle = graph->get_handle_of_step(step_handle); nid_t node_id = graph->get_id(handle); + if (graph->get_is_reverse(handle)) { + stringstream ss; + ss << "error [gfa]: unable to write rGFA tags for path " << path_name << " because node " + << node_id << " is traversed on its reverse strand. rGFA only supports the forward strand." << endl; + throw runtime_error(ss.str()); + } if (node_offsets.count(node_id)) { cerr << "warning [gfa]: multiple selected rgfa paths found on node " << node_id << ": keeping tags for " << graph->get_path_name(node_offsets[node_id].first) << " and ignoring those for " << path_name << endl;