Skip to content

Commit 740ceb7

Browse files
committed
Fix edge traversal bug when using networkx 2.2
1 parent 5f686c7 commit 740ceb7

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/cortexpy/constants.py

+4
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@ class EngineTraversalOrientation(Enum):
1616
original = 0
1717
reverse = 1
1818
both = 2
19+
20+
class EdgeDFSTraversalDirection(Enum):
21+
forward = 0
22+
reverse = 1

src/cortexpy/graph/interactor.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from Bio.Seq import Seq
1313
from Bio.SeqRecord import SeqRecord
1414

15-
from cortexpy.constants import EdgeTraversalOrientation
15+
from cortexpy.constants import EdgeTraversalOrientation, EdgeDFSTraversalDirection
1616
from cortexpy.graph.cortex import CortexDiGraph, ConsistentCortexDiGraph
1717
from cortexpy.graph.parser.kmer import revcomp_target_to_match_ref
1818
from cortexpy.graph.serializer.unitig import UnitigCollapser
@@ -244,14 +244,14 @@ def node_generator_from_edges(edge_generator):
244244
else:
245245
yield edge[1]
246246
elif len(edge) == 4:
247-
if edge[3] == EdgeTraversalOrientation.reverse.name:
247+
if edge[3] == EdgeDFSTraversalDirection.reverse.name:
248248
yield edge[0]
249-
elif edge[3] == EdgeTraversalOrientation.original.name:
249+
elif edge[3] == EdgeDFSTraversalDirection.forward.name:
250250
yield edge[1]
251251
else:
252-
ValueError
252+
raise ValueError('Could not make sense of edge: %s', edge)
253253
else:
254-
raise ValueError
254+
raise ValueError('Unexpected edge tuple length: %s', len(edge))
255255

256256

257257
def find_tip_from(*, n, start, graph, next_node_generator):

0 commit comments

Comments
 (0)