superphy / prairiedog

next-gen pangenome graphs for predictive genomics
Other
0 stars 0 forks source link

Test test_graph_connected_repeats_full_path() should fine 2 connecting edges #74

Closed kevinkle closed 5 years ago

kevinkle commented 5 years ago
=================================== FAILURES ===================================
______________ test_graph_connected_repeats_full_path[lemongraph] ______________

g = <prairiedog.lemon_graph.LGGraph object at 0x7f3a05e25860>

    def test_graph_connected_repeats_full_path(g: Graph):
        n1 = Node(value="ABC")
        n2 = Node(value="BCD")
        n3 = Node(value="CDE")
        g.upsert_node(n1)
        g.upsert_node(n2)
        g.upsert_node(n3)
        e1 = Edge(src="ABC", tgt="BCD", edge_value=0)
        g.add_edge(e1)
        e2 = Edge(src="BCD", tgt="CDE", edge_value=1)
        g.add_edge(e2)
        e3 = Edge(src="CDE", tgt="ABC", edge_value=2)
        g.add_edge(e3)
        e4 = Edge(src="ABC", tgt="BCD", edge_value=3)
        g.add_edge(e4)
        e5 = Edge(src="BCD", tgt="CDE", edge_value=4)
        g.add_edge(e5)
        g.save()

>       paths, _ = g.path('ABC', 'CDE')

tests/test_connected.py:335: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
prairiedog/lemon_graph.py:272: in path
    path_nodes = self._find_path(src_edge, tgt_edge, txn)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <prairiedog.lemon_graph.LGGraph object at 0x7f3a05e25860>
edge_a = <prairiedog.edge.Edge object at 0x7f3a05e27f28>
edge_b = <prairiedog.edge.Edge object at 0x7f3a05e2a2b0>
txn = <LemonGraph.Transaction object at 0x7f3a05e27f60>

    def _find_path(self, edge_a: Edge, edge_b: Edge, txn) -> typing.Tuple[
            Node]:
        query = 'n()'
        i = edge_a.edge_value
        # This will only add 1 edge if edge_a.incr == edge_b.incr
        while i <= edge_b.edge_value:
            query += '->@e(type="{}",value="{}")->n()'.format(
                edge_a.edge_type, i
            )
            i += 1
        log.debug("Using query {}".format(query))

        chains = tuple(txn.query(query))
        log.debug("Got chains {}".format(chains))
        # There should only be one chain per path
>       assert len(chains) == 1
E       AssertionError

prairiedog/lemon_graph.py:231: AssertionError
------------------------------ Captured log setup ------------------------------
lemon_graph.py              33 DEBUG    Creating LemonGraph with backing file /tmp/tmp9fmda0es
------------------------------ Captured log call -------------------------------
graph.py                   119 DEBUG    Found connecting edge(s):
graph.py                   121 DEBUG    prairiedog.edge.Edge with vars {'tgt': 2, 'edge_value': 3, 'edge_type': 'e', 'labels': None, 'src': 1, 'db_id': 7}
lemon_graph.py             211 INFO     Found 1 connections between ABC and CDE
lemon_graph.py             213 DEBUG    src_edges are (<prairiedog.edge.Edge object at 0x7f3a05e27f28>,)
lemon_graph.py             251 DEBUG    Finding path between ABC and CDE with source edge prairiedog.edge.Edge with vars {'tgt': 2, 'edge_value': 3, 'edge_type': 'e', 'labels': None, 'src': 1, 'db_id': 7}
lemon_graph.py             256 DEBUG    Using query e(type="e")->@n(value="CDE")
lemon_graph.py             258 DEBUG    Got tgt_edges (({'ID': 5, 'type': 'e', 'value': '1', 'srcID': 2, 'tgtID': 3},), ({'ID': 8, 'type': 'e', 'value': '4', 'srcID': 2, 'tgtID': 3},))
lemon_graph.py             261 DEBUG    tgt_edges after unraveling (<prairiedog.edge.Edge object at 0x7f3a05e2a2b0>, <prairiedog.edge.Edge object at 0x7f3a05e2a278>)
lemon_graph.py             269 DEBUG    Checking for 2 target edges
lemon_graph.py             271 DEBUG    Checking for target edge prairiedog.edge.Edge with vars {'tgt': 3, 'edge_value': 1, 'edge_type': 'e', 'labels': None, 'src': 2, 'db_id': 5}
lemon_graph.py             226 DEBUG    Using query n()
lemon_graph.py             229 DEBUG    Got chains (({'ID': 1, 'type': 'n', 'value': 'ABC'},), ({'ID': 2, 'type': 'n', 'value': 'BCD'},), ({'ID': 3, 'type': 'n', 'value': 'CDE'},))

The error would be in graph.py

kevinkle commented 5 years ago

Fixed in https://github.com/superphy/prairiedog/pull/71