Exemplo n.º 1
0
    def test_flatten_reaction_3(self):
        """Test flattening a graph containing 2 reactions connected to each other."""
        two_reactions_graph = BELGraph()

        reaction_1 = Reaction(reactants=[glucose, atp], products=hk1)
        reaction_2 = Reaction(reactants=glucose_6_phosphate, products=adp)

        two_reactions_graph.add_increases(reaction_1,
                                          reaction_2,
                                          citation='X',
                                          evidence='X')

        self.assertEqual(two_reactions_graph.number_of_nodes(), 7)
        self.assertEqual(two_reactions_graph.number_of_edges(), 6)

        reaction_cartesian_expansion(two_reactions_graph)

        # TODO Fix so unqualified duplicate edges are not created (it should be the 6 edges below)
        self.assertEqual(two_reactions_graph.number_of_nodes(), 5)
        self.assertEqual(two_reactions_graph.number_of_edges(), 8)
Exemplo n.º 2
0
 def test_reaction(self):
     """Add identified reaction."""
     graph = BELGraph()
     reaction = Reaction(
         namespace='rhea',
         identifier='44104',
         reactants=[
             Abundance(namespace='chebi', identifier='17478'),
             Abundance(namespace='chebi', identifier='15377'),
             Abundance(namespace='chebi', identifier='57540'),
         ],
         products=[
             Abundance(namespace='chebi', identifier='29067'),
             Abundance(namespace='chebi', identifier='15378'),
             Abundance(namespace='chebi', identifier='57945'),
         ],
     )
     graph.add_node_from_data(reaction)
     self.assertEqual(7, graph.number_of_nodes())
     self.assertEqual(6, graph.number_of_edges())
Exemplo n.º 3
0
    def test_flatten_reaction_2(self):
        """Test flattening a qualified reaction."""
        node_increases_reaction_graph = BELGraph()

        glycolisis_step_1 = Reaction(reactants=[glucose, hk1, atp],
                                     products=[glucose_6_phosphate, adp, hk1])

        node_increases_reaction_graph.add_increases(glucose_6_phosphate,
                                                    glycolisis_step_1,
                                                    citation='X',
                                                    evidence='X')

        self.assertEqual(node_increases_reaction_graph.number_of_nodes(), 6)
        self.assertEqual(node_increases_reaction_graph.number_of_edges(), 7)

        reaction_cartesian_expansion(node_increases_reaction_graph)

        self.assertEqual(node_increases_reaction_graph.number_of_nodes(), 5)
        # TODO Fix so unqualified duplicate edges are not created (it should be the 8 edges below)
        self.assertEqual(node_increases_reaction_graph.number_of_edges(), 12)
Exemplo n.º 4
0
 def test_reaction(self):
     node = Reaction(reactants=[Abundance(namespace='CHEBI', name='A')],
                     products=[Abundance(namespace='CHEBI', name='B')])
     self.assertEqual('rxn(reactants(a(CHEBI:A)), products(a(CHEBI:B)))',
                      str(node))
Exemplo n.º 5
0
 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'),
 Pathology('MESHD', 'Psoriasis'),
 Pathology('MESHD', 'Skin Diseases'),
 Reaction(
     reactants=[
         Abundance('CHEBI', '(3S)-3-hydroxy-3-methylglutaryl-CoA'),
         Abundance('CHEBI', 'NADPH'),
         Abundance('CHEBI', 'hydron')
     ],
     products=[
         Abundance('CHEBI', 'NADP(+)'),
         Abundance('CHEBI', 'mevalonate')
     ]
 ),
 Abundance('CHEBI', '(3S)-3-hydroxy-3-methylglutaryl-CoA'),
 Abundance('CHEBI', 'NADPH'),
 Abundance('CHEBI', 'hydron'),
 Abundance('CHEBI', 'mevalonate'),
 Abundance('CHEBI', 'NADP(+)'),
 Abundance('CHEBI', 'nitric oxide'),
 ComplexAbundance([
     Protein('HGNC', 'ITGAV'),
     Protein('HGNC', 'ITGB3')
 ]),
Exemplo n.º 6
0
jun = hgnc(name='JUN')
mirna_1 = mirbase(name=n())
mirna_2 = mirbase(name=n())
pathology_1 = Pathology('DO', n())
ap1_complex = ComplexAbundance([fos, jun])

egfr_dimer = ComplexAbundance([egfr, egfr])

yfg_data = hgnc(name='YFG')
e2f4_data = hgnc(name='E2F4')
bound_ap1_e2f4 = ComplexAbundance([ap1_complex, e2f4_data])

superoxide = chebi(name='superoxide')
hydrogen_peroxide = chebi(name='hydrogen peroxide')
oxygen = chebi(name='oxygen')
superoxide_decomposition = Reaction(reactants=[superoxide],
                                    products=[hydrogen_peroxide, oxygen])


def assert_unqualified_edge(test_case, u: BaseEntity, v: BaseEntity,
                            rel: str) -> None:
    """Assert there's only one edge and get the data for it"""
    test_case.assertIn(u, test_case.graph)
    test_case.assertIn(v, test_case.graph[u])
    edges = list(test_case.graph[u][v].values())
    test_case.assertEqual(1, len(edges))
    data = edges[0]
    test_case.assertEqual(rel, data[RELATION])


class TestNetworkCache(BelReconstitutionMixin, FleetingTemporaryCacheMixin):
    def test_get_network_missing(self):
Exemplo n.º 7
0
 def test_reaction_has_contents(self):
     """Test that the construction of reaction doesn't have empty lists."""
     with self.assertRaises(ReactionEmptyException):
         Reaction([], [])