def test_composite(self): il23 = NamedComplexAbundance(namespace='GO', name='interleukin-23 complex') il6 = Protein(namespace='HGNC', name='IL6') node_data = CompositeAbundance([il23, il6]) self.graph.add_node_from_data(node_data) self.assertIn(node_data, self.graph) self.assertEqual(3, self.graph.number_of_nodes()) self.assertIn(il6, self.graph, msg='Nodes:\n'.format('\n'.join(map(str, self.graph)))) self.assertIn(il23, self.graph) self.assertEqual(2, self.graph.number_of_edges()) self.assertIn(node_data, self.graph[il6]) edges = list(self.graph[il6][node_data].values()) self.assertEqual(1, len(edges)) data = edges[0] self.assertEqual(PART_OF, data[RELATION]) self.assertIn(node_data, self.graph[il23]) edges = list(self.graph[il23][node_data].values()) self.assertEqual(1, len(edges)) data = edges[0] self.assertEqual(PART_OF, data[RELATION])
def test_list_abundance_has_contents(self): """Test that the construction of list abundance doesn't have empty lists.""" with self.assertRaises(ListAbundanceEmptyException): ComplexAbundance([]) with self.assertRaises(ListAbundanceEmptyException): CompositeAbundance([])
def test_composite(self, mock): interleukin_23_complex = NamedComplexAbundance( 'GO', 'interleukin-23 complex') il6 = hgnc(name='IL6') interleukin_23_and_il6 = CompositeAbundance( [interleukin_23_complex, il6]) self._help_reconstitute(interleukin_23_and_il6, 3, 2)
def test_remove_isolated_list_abundances(self): """Test removing isolated list abundances.""" g = BELGraph() p1, p2 = [Protein('HGNC', n()) for _ in range(2)] node = CompositeAbundance([p1, p2]) g.add_node_from_data(node) self.assertEqual(3, g.number_of_nodes()) remove_isolated_list_abundances(g) self.assertEqual(2, g.number_of_nodes()) self.assertIn(p1, g) self.assertIn(p2, g)
def test_composite_abundance(self): node = CompositeAbundance(members=[ Protein(namespace='HGNC', name='FOS'), Protein(namespace='HGNC', name='JUN') ]) self.assertEqual('composite(p(HGNC:FOS), p(HGNC:JUN))', str(node))
akt1_rna, Rna('HGNC', 'AKT1', variants=[Hgvs('c.1521_1523delCTT'), Hgvs('p.Phe508del')]), Gene('HGNC', 'NCF1'), ComplexAbundance([ Gene('HGNC', 'NCF1'), Protein('HGNC', 'HBP1') ]), Protein('HGNC', 'HBP1'), ComplexAbundance([Protein('HGNC', 'FOS'), Protein('HGNC', 'JUN')]), Protein('HGNC', 'FOS'), Protein('HGNC', 'JUN'), Rna('HGNC', 'CFTR', variants=Hgvs('r.1521_1523delcuu')), Rna('HGNC', 'CFTR'), Rna('HGNC', 'CFTR', variants=Hgvs('r.1653_1655delcuu')), CompositeAbundance([ interleukin_23_complex, il6 ]), il6, BiologicalProcess('GO', 'cell cycle arrest'), hydrogen_peroxide, Protein('HGNC', 'CAT'), Gene('HGNC', 'CAT'), Protein('HGNC', 'HMGCR'), BiologicalProcess('GO', 'cholesterol biosynthetic process'), Gene('HGNC', 'APP', variants=Hgvs('c.275341G>C')), Gene('HGNC', 'APP'), Pathology('MESHD', 'Alzheimer Disease'), ComplexAbundance([Protein('HGNC', 'F3'), Protein('HGNC', 'F7')]), Protein('HGNC', 'F3'), Protein('HGNC', 'F7'), Protein('HGNC', 'F9'),
def test_empty_composite(self): """Test that an empty complex causes a failure.""" with self.assertRaises(ValueError): CompositeAbundance(members=[])
Rna('HGNC', 'AKT1', variants=[Hgvs('c.1521_1523delCTT'), Hgvs('p.Phe508del')]), Gene('HGNC', 'NCF1'), ComplexAbundance([Gene('HGNC', 'NCF1'), Protein('HGNC', 'HBP1')]), Protein('HGNC', 'HBP1'), ComplexAbundance([Protein('HGNC', 'FOS'), Protein('HGNC', 'JUN')]), Protein('HGNC', 'FOS'), Protein('HGNC', 'JUN'), Rna('HGNC', 'CFTR', variants=Hgvs('r.1521_1523delcuu')), Rna('HGNC', 'CFTR'), Rna('HGNC', 'CFTR', variants=Hgvs('r.1653_1655delcuu')), CompositeAbundance([interleukin_23_complex, il6]), il6, BiologicalProcess('GO', 'cell cycle arrest'), hydrogen_peroxide, Protein('HGNC', 'CAT'), Gene('HGNC', 'CAT'), Protein('HGNC', 'HMGCR'), BiologicalProcess('GO', 'cholesterol biosynthetic process'), Gene('HGNC', 'APP', variants=Hgvs('c.275341G>C')), Gene('HGNC', 'APP'), Pathology('MESHD', 'Alzheimer Disease'), ComplexAbundance([Protein('HGNC', 'F3'), Protein('HGNC', 'F7')]), Protein('HGNC', 'F3'), Protein('HGNC', 'F7'), Protein('HGNC', 'F9'), Protein('HGNC', 'GSK3B', variants=ProteinModification('Ph', 'Ser', 9)), Protein('HGNC', 'GSK3B'),