def test_pipeline(self): graph = egf_graph.copy() enrich_protein_and_rna_origins(graph) self.assertEqual( 32, # 10 protein nodes already there + complex + bp + 2*10 (genes and rnas) graph.number_of_nodes() ) # 6 already there + 5 complex hasComponent edges + new 2*10 edges self.assertEqual(31, graph.number_of_edges()) network = self.manager.insert_graph(graph) pipeline = Pipeline() pipeline.append(collapse_to_genes) query = Query( network_ids=[network.id], pipeline=pipeline ) result_graph = query.run(self.manager) self.assertEqual(12, result_graph.number_of_nodes()) # same number of nodes than there were self.assertEqual(11, result_graph.number_of_edges()) # same number of edges than there were
def test_no_seeding_no_pipeline(self): graph = egf_graph.copy() self.add_query(graph) result = self.run_query() self.assertEqual(graph.number_of_nodes(), result.number_of_nodes()) self.assertEqual(graph.number_of_edges(), result.number_of_edges())
def test_no_seeding(self): graph = egf_graph.copy() seeding = Seeding() result = seeding.run(graph) self.assertEqual(graph.number_of_nodes(), result.number_of_nodes()) self.assertEqual(graph.number_of_edges(), result.number_of_edges())
def setUp(self): self.graph = egf_graph.copy() self.original_number_nodes = self.graph.number_of_nodes() self.original_number_edges = self.graph.number_of_edges() self.manager = MockQueryManager() self.network_id = self.manager.insert_graph(self.graph).id build_delete_node_by_hash(self.manager) build_expand_node_neighborhood_by_hash(self.manager)
def test_pipeline_2(self): graph = egf_graph.copy() network = self.manager.insert_graph(graph) network_id = network.id query = Query(network_ids=[network_id]) query.append_seeding_neighbors(vcp) query.append_pipeline(get_subgraph_by_annotation_value, 'Species', '9606') result = query.run(self.manager) self.assertIsNotNone(result, msg='Query returned none') self.assertEqual(3, result.number_of_nodes())
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())
def setUp(self): self.graph = egf_graph.copy() self.original_number_nodes = self.graph.number_of_nodes() self.original_number_edges = self.graph.number_of_edges()