コード例 #1
0
    def test_neighborhoods(self):
        """Test expansion on the neighborhood of given nodes.

        The edge between PTPN6/CD33ph should not be added.
        """
        graph = BELGraph()
        graph.add_node_from_data(cd33)
        graph.add_node_from_data(syk)
        self.assertEqual(2, graph.number_of_nodes())

        _sialic_acid_graph = sialic_acid_graph.copy()
        expand_nodes_neighborhoods(universe=_sialic_acid_graph,
                                   graph=graph,
                                   nodes=[cd33, syk])

        self.assertNotIn(shp1, graph[cd33_phosphorylated])
        self.assertNotIn(shp2, graph[cd33_phosphorylated])

        self.assertEqual(9,
                         graph.number_of_nodes(),
                         msg='wrong number of nodes: {}'.format(list(graph)))
        self.assertEqual(8,
                         graph.number_of_edges(),
                         msg='wrong number of edges')
        self.assertIn(sialic_acid, graph)
        self.assertIn(sialic_acid_cd33_complex, graph)
        self.assertIn(cd33_phosphorylated, graph)
コード例 #2
0
    def test_neighborhood(self):
        """Test expansion around the neighborhood of CD33 in the sialic acid graph given node."""
        graph = BELGraph()
        graph.add_node_from_data(cd33)
        self.assertEqual(1, graph.number_of_nodes())

        _sialic_acid_graph = sialic_acid_graph.copy()
        expand_node_neighborhood(graph=graph,
                                 universe=_sialic_acid_graph,
                                 node=cd33)

        self.assertEqual(
            {cd33, sialic_acid, sialic_acid_cd33_complex, cd33_phosphorylated},
            set(graph),
        )
コード例 #3
0
    def test_neighborhood_with_successors(self):
        """Test expansion on the successors of a given node."""
        graph = BELGraph()
        graph.add_node_from_data(cd33)
        graph.add_node_from_data(cd33_phosphorylated)
        self.assertEqual(2, graph.number_of_nodes())

        _sialic_acid_graph = sialic_acid_graph.copy()
        expand_node_successors(universe=_sialic_acid_graph,
                               graph=graph,
                               node=cd33)

        self.assertEqual(
            {sialic_acid_cd33_complex, sialic_acid, cd33_phosphorylated, cd33},
            set(graph),
        )
コード例 #4
0
    def test_neighborhood_with_predecessors(self):
        """Test expansion on the predecessors of a given node."""
        graph = BELGraph()
        graph.add_node_from_data(cd33)
        graph.add_node_from_data(sialic_acid_cd33_complex)
        self.assertEqual(3, graph.number_of_nodes())

        _sialic_acid_graph = sialic_acid_graph.copy()
        expand_node_predecessors(universe=_sialic_acid_graph,
                                 graph=graph,
                                 node=cd33)

        self.assertEqual(4, graph.number_of_nodes())
        self.assertIn(sialic_acid, graph)
        self.assertIn(sialic_acid_cd33_complex, graph)
        self.assertIn(cd33_phosphorylated, graph)
コード例 #5
0
ファイル: test_query.py プロジェクト: smoe/pybel
    def test_seeding_with_pipeline(self):
        test_network_1 = self.manager.insert_graph(sialic_acid_graph.copy())

        query = Query(network_ids=[test_network_1.id])
        query.append_seeding_neighbors([trem2, dap12, shp2])
        query.append_pipeline(expand_nodes_neighborhoods, [trem2, dap12, shp2])
        result = query.run(self.manager)
        self.assertIsNotNone(result, msg='Query returned none')
        self.assertIsInstance(result, BELGraph)

        self.assertIn(trem2, result)
        self.assertIn(dap12, result)
        self.assertIn(shp2, result)
        self.assertIn(syk, result)
        self.assertIn(cd33_phosphorylated, result)

        self.assertEqual(5, result.number_of_nodes())
        self.assertEqual(4, result.number_of_edges())
コード例 #6
0
ファイル: test_query.py プロジェクト: johnbachman/pybel-tools
    def test_query_multiple_networks(self):
        egf_network = self.manager.insert_graph(sialic_acid_graph.copy())
        sialic_acid_network = self.manager.insert_graph(egf_graph.copy())

        query = Query()
        query.append_network(egf_network.id)
        query.append_network(sialic_acid_network.id)
        query.append_seeding_neighbors([syk.as_tuple()])
        query.append_pipeline(infer_central_dogma)

        result = query.run(self.manager, in_place=False)
        self.assertIsNotNone(result, msg='Query returned none')

        self.assertIn(shp1.as_tuple(), result)
        self.assertIn(shp2.as_tuple(), result)
        self.assertIn(trem2.as_tuple(), result)
        self.assertIn(dap12.as_tuple(), result)

        self.assertEqual(15, result.number_of_nodes())
        self.assertEqual(14, result.number_of_edges())
コード例 #7
0
ファイル: test_query.py プロジェクト: plin1112/pybel
    def test_query_multiple_networks(self):
        sialic_acid_graph_id = self.manager.insert_graph(sialic_acid_graph.copy()).id
        egf_graph_id = self.manager.insert_graph(egf_graph.copy()).id

        query = Query()
        query.append_network(sialic_acid_graph_id)
        query.append_network(egf_graph_id)
        query.append_seeding_neighbors([syk])
        query.append_pipeline(enrich_protein_and_rna_origins)

        result = query.run(self.manager)
        self.assertIsNotNone(result, msg='Query returned none')

        self.assertIn(shp1, result)
        self.assertIn(shp2, result)
        self.assertIn(trem2, result)
        self.assertIn(dap12, result)

        self.assertEqual(15, result.number_of_nodes())
        self.assertEqual(14, result.number_of_edges())
コード例 #8
0
 def setUp(self):
     self.sialic_acid_graph = sialic_acid_graph.copy()
コード例 #9
0
ファイル: test_enrich.py プロジェクト: pybel/pybel-tools
 def setUp(self):
     self.sialic_acid_graph = sialic_acid_graph.copy()
     self.single_reaction_graph = single_reaction_graph.copy()
     self.single_composite_graph = single_composite_graph.copy()
     self.single_complex_graph = single_complex_graph.copy()