How to use the pybel.dsl.pmod function in pybel

To help you get started, we’ve selected a few pybel examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pybel / pybel / tests / test_manager_graph.py View on Github external
def test_pmod_default_simple(self, mock):
        dummy_namespace = n8()
        dummy_name = n()

        node_data = protein(namespace=dummy_namespace, name=dummy_name, variants=[pmod('Me')])
        namespaces = {dummy_namespace: [dummy_name]}
        self.help_reconstitute(node_data, namespaces, 2, 1)
github pybel / pybel / tests / test_parse / test_parse_bel.py View on Github external
def test_protein_pmod_4(self):
        """2.2.1 Test HRAS palmitoylated at an unspecified residue. Default BEL namespace"""
        statement = 'p(HGNC:HRAS,pmod(Palm))'
        result = self.parser.protein.parseString(statement)

        parent = protein('HGNC', 'HRAS')
        expected_node = parent.with_variants(pmod('Palm'))
        self.assert_has_node(expected_node)
        self.assertEqual(
            'p(HGNC:HRAS, pmod(go:0018345 ! "protein palmitoylation"))',
            self.graph.node_to_bel(expected_node),
        )

        self.assert_has_node(parent)
        self.assert_has_edge(parent, expected_node, relation=HAS_VARIANT)
github pybel / pybel / tests / test_io / test_spia.py View on Github external
def test_update_matrix_pmods(self):
        """Test updating the matrix with multiple protein modifications."""
        sub = protein(namespace='HGNC', name='A', identifier='1')
        obj = protein(namespace='HGNC', name='B', identifier='2', variants=[pmod('Ub'), pmod('Ph')])

        index = {'A', 'B'}

        test_dict = {}

        test_matrix = DataFrame(0, index=index, columns=index)

        test_dict["activation_ubiquination"] = test_matrix
        test_dict["activation_phosphorylation"] = test_matrix

        update_spia_matrices(test_dict, sub, obj, {'relation': 'increases'})

        self.assertEqual(test_dict["activation_ubiquination"]['A']['B'], 1)
        self.assertEqual(test_dict["activation_ubiquination"]['A']['A'], 0)
        self.assertEqual(test_dict["activation_ubiquination"]['B']['A'], 0)
        self.assertEqual(test_dict["activation_ubiquination"]['B']['B'], 0)
github pybel / pybel / tests / test_parse / test_parse_bel.py View on Github external
def test_protein_pmod_1(self):
        """2.2.1 Test default BEL namespace and 1-letter amino acid code:"""
        statement = 'p(HGNC:AKT1, pmod(Ph, S, 473))'
        result = self.parser.protein.parseString(statement)

        parent = protein('HGNC', 'AKT1')
        expected_node = parent.with_variants(pmod('Ph', code='Ser', position=473))
        self.assert_has_node(expected_node)
        self.assertEqual(
            'p(HGNC:AKT1, pmod(go:0006468 ! "protein phosphorylation", Ser, 473))',
            self.graph.node_to_bel(expected_node),
        )

        self.assert_has_node(parent)
        self.assert_has_edge(parent, expected_node, relation=HAS_VARIANT)
github pybel / pybel / tests / test_io / test_spia.py View on Github external
def test_update_matrix_activation_ubiquination(self):
        """Test updating the matrix with an activation ubiquitination."""
        sub = protein(namespace='HGNC', name='A', identifier='1')
        obj = protein(namespace='HGNC', name='B', identifier='2', variants=[pmod('Ub')])

        index = {'A', 'B'}

        test_dict = {}

        test_matrix = DataFrame(0, index=index, columns=index)

        test_dict["activation_ubiquination"] = test_matrix

        update_spia_matrices(test_dict, sub, obj, {'relation': 'increases'})

        self.assertEqual(test_dict["activation_ubiquination"]['A']['B'], 1)
        self.assertEqual(test_dict["activation_ubiquination"]['A']['A'], 0)
        self.assertEqual(test_dict["activation_ubiquination"]['B']['A'], 0)
        self.assertEqual(test_dict["activation_ubiquination"]['B']['B'], 0)
github pybel / pybel / tests / test_io / test_cx / examples.py View on Github external
c5 = '10866298'
e5 = 'We found that PD180970 inhibited in vivo tyrosine phosphorylation of p210Bcr-Abl (IC50 = 170 nM) and the p210BcrAbl substrates Gab2 and CrkL (IC50 = 80 nM) in human K562 chronic myelogenous leukemic cells. In vitro, PD180970 potently inhibited autophosphorylation of p210Bcr-Abl (IC50 = 5 nM) and the kinase activity of purified recombinant Abl tyrosine kinase (IC50 = 2.2 nM).'

"""
SET Species = 9606
SET Citation = {"PubMed","Cancer Res 2000 Jun 15 60(12) 3127-31","10866298","","",""}

kin(p(HGNC:BCR,fus(HGNC:ABL1))) directlyIncreases p(HGNC:CRKL,pmod(P,Y))
kin(p(HGNC:BCR,fus(HGNC:ABL1))) directlyIncreases p(HGNC:GAB2,pmod(P,Y))
"""

bcr_abl1_fus = protein_fusion(partner_5p=Protein(namespace='hgnc', name='BCR'),
                              partner_3p=Protein(namespace='hgnc', name='ABL1'))
crkl_ph = Protein(namespace='hgnc', name='CRKL', variants=[pmod('Ph', 'Tyr')])
gab2_ph = Protein(namespace='hgnc', name='GAB2', variants=[pmod('Ph', 'Tyr')])

example_graph.add_directly_increases(
    bcr_abl1_fus, crkl_ph, citation=c5, evidence=e5,
    annotations={'Species': '9606', 'Confidence': 'High'},
    source_modifier=kinase_activity,
)
example_graph.add_directly_increases(
    bcr_abl1_fus, gab2_ph, citation=c5, evidence=e5, annotations={'Species': '9606'},
    source_modifier=kinase_activity,
)
github pybel / pybel / tests / test_io / test_spia.py View on Github external
def test_update_matrix_inhibition_ubiquination(self):
        """Test updating the matrix with an inhibition ubiquitination."""
        sub = protein(namespace='HGNC', name='A', identifier='1')
        obj = protein(namespace='HGNC', name='B', identifier='2', variants=[pmod('Ub')])

        index = {'A', 'B'}

        test_dict = {}

        test_matrix = DataFrame(0, index=index, columns=index)

        # Initialize matrix correctly
        self.assertEqual(test_matrix.values.all(), 0)

        test_dict["inhibition_ubiquination"] = test_matrix

        update_spia_matrices(test_dict, sub, obj, {'relation': 'decreases'})

        self.assertEqual(test_dict["inhibition_ubiquination"]['A']['B'], 1)
        self.assertEqual(test_dict["inhibition_ubiquination"]['A']['A'], 0)
github pybel / pybel / tests / test_parse / test_parse_bel.py View on Github external
def test_protein_pmod_3(self):
        """2.2.1 Test PSI-MOD namespace and 3-letter amino acid code:"""
        statement = 'p(HGNC:AKT1, pmod(MOD:PhosRes,Ser,473))'
        result = self.parser.protein.parseString(statement)

        parent = protein('HGNC', 'AKT1')
        expected_node = parent.with_variants(pmod(namespace='MOD', name='PhosRes', code='Ser', position=473))
        self.assert_has_node(expected_node)
        self.assertEqual('p(HGNC:AKT1, pmod(MOD:PhosRes, Ser, 473))', self.graph.node_to_bel(expected_node))

        self.assert_has_node(parent)
        self.assert_has_edge(parent, expected_node, relation=HAS_VARIANT)
github saezlab / pypath / src / pypath / omnipath / bel.py View on Github external
for enz_sub in self.resource:
            
            de = enz_sub.ptm.typ.startswith('de')
            mod_type = enz_sub.ptm.typ[2:] if de else enz_sub.ptm.typ
            
            mod_namespace = (
                None if mod_type in common.pmod_other_to_bel else 'OmniPath'
            )
            bel_mod_type = (
                common.pmod_other_to_bel[mod_type]
                    if mod_namespace is None else
                mod_type
            )
            mod_identifier = None if mod_namespace is None else mod_type
            mod = pybel.dsl.pmod(
                name = bel_mod_type,
                position = enz_sub.ptm.residue.number,
                code = common.aminoa_1_to_3_letter[enz_sub.ptm.residue.name],
                identifier = mod_identifier,
                namespace = mod_namespace,
            )
            
            enzyme = self._protein(enz_sub.domain.protein)
            substrate = self._protein(enz_sub.ptm.protein, variants = mod)
            predicate = pc.DIRECTLY_DECREASES if de else pc.DIRECTLY_INCREASES
            
            citations = (enz_sub.refs - {'', '-'}) or {''}
            
            for evid in enz_sub.sources | {'OmniPath'}:
                
                for cit in citations: