Esempio n. 1
0
    def test_missing_information(self):
        """Test that entity and abundance functions raise on missing name/identifier."""
        with self.assertRaises(ValueError):
            entity(namespace='test')

        with self.assertRaises(ValueError):
            protein(namespace='test')
Esempio n. 2
0
    def test_object_has_translocation(self):
        """p(HGNC: EGF) increases tloc(p(HGNC: VCP), GOCCID: 0005634, GOCCID: 0005737)"""
        g = BELGraph()
        u_node = protein(name='EFG', namespace='HGNC')
        v_node = protein(name='VCP', namespace='HGNC')
        u = g.add_node_from_data(u_node)
        v = g.add_node_from_data(v_node)

        g.add_qualified_edge(
            u_node,
            v_node,
            relation=INCREASES,
            citation='10855792',
            evidence=
            "Although found predominantly in the cytoplasm and, less abundantly, in the nucleus, VCP can be "
            "translocated from the nucleus after stimulation with epidermal growth factor.",
            annotations={'Species': '9606'},
            object_modifier=translocation(from_loc=entity(
                namespace='GO', identifier='0005634'),
                                          to_loc=entity(namespace='GO',
                                                        identifier='0005737')))

        self.assertFalse(is_translocated(g, u))
        self.assertFalse(is_degraded(g, u))
        self.assertFalse(has_activity(g, u))
        self.assertFalse(has_causal_in_edges(g, u))
        self.assertTrue(has_causal_out_edges(g, u))

        self.assertTrue(is_translocated(g, v))
        self.assertFalse(is_degraded(g, v))
        self.assertFalse(has_activity(g, v))
        self.assertTrue(has_causal_in_edges(g, v))
        self.assertFalse(has_causal_out_edges(g, v))
Esempio n. 3
0
    def test_subject_degradation_location(self):
        self.assertEqual(self.add_edge(subject_modifier=degradation()),
                         self.add_edge(subject_modifier=degradation()))

        self.assertEqual(
            self.add_edge(subject_modifier=degradation(
                location=entity(name='somewhere', namespace='GOCC'))),
            self.add_edge(subject_modifier=degradation(
                location=entity(name='somewhere', namespace='GOCC'))))

        self.assertNotEqual(
            self.add_edge(subject_modifier=degradation()),
            self.add_edge(subject_modifier=degradation(
                location=entity(name='somewhere', namespace='GOCC'))))
Esempio n. 4
0
    def _help_test_non_standard_namespace(self, statement):
        result = self.parser.parseString(statement)

        expected = {
            KIND: PMOD,
            IDENTIFIER: entity('MOD', 'PhosRes'),
            PMOD_CODE: 'Ser',
            PMOD_POSITION: 473
        }

        self.assertEqual(expected, pmod(name='PhosRes', namespace='MOD', code='Ser', position=473))
        self.assertEqual(expected, result.asDict())
Esempio n. 5
0
    def test_decreases(self):
        """Test parsing a decreases relation with a reaction.

        3.1.3 http://openbel.org/language/web/version_2.0/bel_specification_version_2.0.html#Xdecreases
        """
        statement = 'pep(p(SFAM:"CAPN Family", location(GOCC:intracellular))) -| reaction(reactants(p(HGNC:CDK5R1)),products(p(HGNC:CDK5)))'
        result = self.parser.relation.parseString(statement)

        expected_dict = {
            SUBJECT: {
                MODIFIER: ACTIVITY,
                TARGET: {
                    FUNCTION: PROTEIN,
                    NAMESPACE: 'SFAM',
                    NAME: 'CAPN Family',
                    LOCATION: {
                        NAMESPACE: 'GOCC',
                        NAME: 'intracellular'
                    }
                },
                EFFECT: {
                    NAME: 'pep',
                    NAMESPACE: BEL_DEFAULT_NAMESPACE
                },
            },
            RELATION: 'decreases',
            OBJECT: {
                FUNCTION: REACTION,
                REACTANTS: [{
                    FUNCTION: PROTEIN,
                    NAMESPACE: 'HGNC',
                    NAME: 'CDK5R1'
                }],
                PRODUCTS: [{
                    FUNCTION: PROTEIN,
                    NAMESPACE: 'HGNC',
                    NAME: 'CDK5'
                }]
            }
        }
        self.assertEqual(expected_dict, result.asDict())

        sub = protein('SFAM', 'CAPN Family')
        self.assert_has_node(sub)

        obj_member_1 = protein('HGNC', 'CDK5R1')
        self.assert_has_node(obj_member_1)

        obj_member_2 = protein('HGNC', 'CDK5')
        self.assert_has_node(obj_member_2)

        obj = reaction(reactants=[obj_member_1], products=[obj_member_2])
        self.assert_has_node(obj)

        self.assert_has_edge(obj, obj_member_1, relation=HAS_REACTANT)
        self.assert_has_edge(obj, obj_member_2, relation=HAS_PRODUCT)

        expected_edge_attributes = {
            RELATION: DECREASES,
            SUBJECT: {
                MODIFIER: ACTIVITY,
                EFFECT: {
                    NAME: 'pep',
                    NAMESPACE: BEL_DEFAULT_NAMESPACE,
                },
                LOCATION: {
                    NAMESPACE: 'GOCC',
                    NAME: 'intracellular',
                }
            }
        }

        self.assertEqual(
            expected_edge_attributes[SUBJECT],
            activity(name='pep',
                     location=entity(name='intracellular', namespace='GOCC')))

        self.assert_has_edge(sub, obj, **expected_edge_attributes)