Пример #1
0
    def test_expand_upstream_causal_subgraph(self):
        """Test expanding on the upstream causal subgraph."""
        a, b, c, d, e, f = [protein(namespace='test', name=i) for i in string.ascii_lowercase[:6]]
        citation, evidence = '', ''

        universe = BELGraph()
        universe.add_qualified_edge(a, b, INCREASES, citation, evidence)
        universe.add_qualified_edge(b, c, INCREASES, citation, evidence)
        universe.add_qualified_edge(d, a, ASSOCIATION, citation, evidence)
        universe.add_qualified_edge(e, a, INCREASES, citation, evidence)
        universe.add_qualified_edge(f, b, DECREASES, citation, evidence)

        subgraph = BELGraph()
        subgraph.add_qualified_edge(a, b, INCREASES, citation, evidence)

        expand_upstream_causal(universe, subgraph)

        self.assert_in_graph(a, subgraph)
        self.assertIn(FUNCTION, subgraph.node[a.as_tuple()])
        self.assertEqual(PROTEIN, subgraph.node[a.as_tuple()][FUNCTION])
        self.assert_in_graph(b, subgraph)
        self.assert_not_in_graph(c, subgraph)
        self.assert_not_in_graph(d, subgraph)
        self.assert_in_graph(e, subgraph)
        self.assert_in_graph(f, subgraph)
        self.assertIn(FUNCTION, subgraph.node[f.as_tuple()])
        self.assertEqual(PROTEIN, subgraph.node[f.as_tuple()][FUNCTION])
        self.assertEqual(4, subgraph.number_of_nodes())

        self.assert_in_edge(e, a, subgraph)
        self.assert_in_edge(a, b, subgraph)
        self.assert_in_edge(f, b, subgraph)
        self.assertEqual(2, len(subgraph[a.as_tuple()][b.as_tuple()]))
        self.assertEqual(4, subgraph.number_of_edges(), msg='\n'.join(map(str, subgraph.edges())))
Пример #2
0
    def test_expand_upstream_causal_subgraph(self):
        """Test expanding on the upstream causal subgraph."""
        a, b, c, d, e, f = [
            protein(namespace='test', name=i)
            for i in string.ascii_lowercase[:6]
        ]

        universe = BELGraph()
        universe.add_qualified_edge(a, b, INCREASES, n(), n())
        universe.add_qualified_edge(b, c, INCREASES, n(), n())
        universe.add_qualified_edge(d, a, ASSOCIATION, n(), n())
        universe.add_qualified_edge(e, a, INCREASES, n(), n())
        universe.add_qualified_edge(f, b, DECREASES, n(), n())

        subgraph = BELGraph()
        subgraph.add_qualified_edge(a, b, INCREASES, n(), n())

        expand_upstream_causal(universe, subgraph)

        self.assertIsInstance(subgraph, BELGraph)
        self.assert_all_nodes_are_base_entities(subgraph)

        self.assertIn(a, subgraph)
        self.assertIn(b, subgraph)
        self.assertNotIn(c, subgraph)
        self.assertNotIn(d, subgraph)
        self.assertIn(e, subgraph)
        self.assertIn(f, subgraph)
        self.assertEqual(4, subgraph.number_of_nodes())

        self.assert_in_edge(e, a, subgraph)
        self.assert_in_edge(a, b, subgraph)
        self.assert_in_edge(f, b, subgraph)
        self.assertEqual(2, len(subgraph[a][b]))
        self.assertEqual(4,
                         subgraph.number_of_edges(),
                         msg='\n'.join(map(str, subgraph.edges())))
Пример #3
0
    def test_expand_upstream_causal_subgraph(self):
        """Test expanding on the upstream causal subgraph."""
        a, b, c, d, e, f = [
            protein(namespace='test', name=i)
            for i in string.ascii_lowercase[:6]
        ]

        universe = BELGraph()
        universe.add_increases(a, b, citation=n(), evidence=n())
        universe.add_increases(b, c, citation=n(), evidence=n())
        universe.add_association(d, a, citation=n(), evidence=n())
        universe.add_increases(e, a, citation=n(), evidence=n())
        universe.add_decreases(f, b, citation=n(), evidence=n())

        subgraph = BELGraph()
        subgraph.add_increases(a, b, citation=n(), evidence=n())

        expand_upstream_causal(universe, subgraph)

        self.assertIsInstance(subgraph, BELGraph)
        self.assert_all_nodes_are_base_entities(subgraph)

        self.assertIn(a, subgraph)
        self.assertIn(b, subgraph)
        self.assertNotIn(c, subgraph)
        self.assertNotIn(d, subgraph)
        self.assertIn(e, subgraph)
        self.assertIn(f, subgraph)
        self.assertEqual(4, subgraph.number_of_nodes())

        self.assert_in_edge(e, a, subgraph)
        self.assert_in_edge(a, b, subgraph)
        self.assert_in_edge(f, b, subgraph)
        self.assertEqual(2, len(subgraph[a][b]))
        self.assertEqual(4,
                         subgraph.number_of_edges(),
                         msg='\n'.join(map(str, subgraph.edges())))