def test_causal_source(self): g = BELGraph() g.add_edge(1, 2, relation=INCREASES) g.add_edge(2, 3, relation=INCREASES) self.assertTrue(is_causal_source(g, 1)) self.assertFalse(is_causal_central(g, 1)) self.assertFalse(is_causal_sink(g, 1)) self.assertFalse(is_causal_source(g, 2)) self.assertTrue(is_causal_central(g, 2)) self.assertFalse(is_causal_sink(g, 2)) self.assertFalse(is_causal_source(g, 3)) self.assertFalse(is_causal_central(g, 3)) self.assertTrue(is_causal_sink(g, 3))
def test_causal_source(self): g = BELGraph() a, b, c = (protein(n(), n()) for _ in range(3)) g.add_increases(a, b, n(), n()) g.add_increases(b, c, n(), n()) self.assertTrue(is_causal_source(g, a)) self.assertFalse(is_causal_central(g, a)) self.assertFalse(is_causal_sink(g, a)) self.assertFalse(is_causal_source(g, b)) self.assertTrue(is_causal_central(g, b)) self.assertFalse(is_causal_sink(g, b)) self.assertFalse(is_causal_source(g, c)) self.assertFalse(is_causal_central(g, c)) self.assertTrue(is_causal_sink(g, c))
def get_causal_sink_nodes(graph, function): """Returns a set of all ABUNDANCE nodes that have an causal out-degree of 0, which likely means that the knowledge assembly is incomplete, or there is a curation error. :param pybel.BELGraph graph: A BEL graph :param str function: The BEL function to filter by :return: A set of sink ABUNDANCE nodes :rtype: set[tuple] """ return { node for node, data in graph.iter_node_data_pairs() if data[FUNCTION] == function and is_causal_sink(graph, node) }