From c2332ce4aa35d3555e536fcac10201919955e267 Mon Sep 17 00:00:00 2001 From: subwaystation Date: Tue, 6 Oct 2020 15:14:22 +0200 Subject: [PATCH] handle reversing self edges in divide_handle in odgi --- bdsg/src/odgi.cpp | 16 ++++++++++++++++ bdsg/src/test_libbdsg.cpp | 4 ++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/bdsg/src/odgi.cpp b/bdsg/src/odgi.cpp index 030cbb51..fcd3dd5f 100644 --- a/bdsg/src/odgi.cpp +++ b/bdsg/src/odgi.cpp @@ -1131,6 +1131,22 @@ std::vector ODGI::divide_handle(const handle_t& handle, const std::vec for (auto& s : seqs) { handles.push_back(create_handle(s)); } + + // update the backwards references back onto this node + handle_t last_handle = handles.back(); + follow_edges(fwd_handle, false, [&](const handle_t& h) { + if (h == flip(fwd_handle)) { + // destroy_edge(last_handle, h); + create_edge(last_handle, flip(handles.back())); + } + }); + // update the forward references back onto this node + follow_edges(handle, left, [&](const handle_t& h) { + if (h == flip(handle)) { + create_edge(h, handles.front()); + } + }); + // and record their reverse, for use in path fixup std::vector rev_handles; for (auto& h : handles) { diff --git a/bdsg/src/test_libbdsg.cpp b/bdsg/src/test_libbdsg.cpp index b9173175..63b90243 100644 --- a/bdsg/src/test_libbdsg.cpp +++ b/bdsg/src/test_libbdsg.cpp @@ -1357,8 +1357,8 @@ void test_deletable_handle_graphs() { PackedGraph pg; implementations.push_back(&pg); - //ODGI og; - //implementations.push_back(&og); + ODGI og; + implementations.push_back(&og); for (DeletableHandleGraph* implementation : implementations) { DeletableHandleGraph& graph = *implementation;