コード例 #1
0
    def test_has_reaction_component(self):
        statement = 'rxn(reactants(a(CHEBI:"(S)-3-hydroxy-3-methylglutaryl-CoA"),a(CHEBI:NADPH), \
                    a(CHEBI:hydron)),products(a(CHEBI:mevalonate), a(CHEBI:"CoA-SH"), a(CHEBI:"NADP(+)"))) \
                    hasReactant a(CHEBI:"(S)-3-hydroxy-3-methylglutaryl-CoA")'

        self.parser.relation.parseString(statement)

        sub_reactant_1 = abundance('CHEBI',
                                   '(S)-3-hydroxy-3-methylglutaryl-CoA')
        sub_reactant_2 = abundance('CHEBI', 'NADPH')
        sub_reactant_3 = abundance('CHEBI', 'hydron')
        sub_product_1 = abundance('CHEBI', 'mevalonate')
        sub_product_2 = abundance('CHEBI', 'CoA-SH')
        sub_product_3 = abundance('CHEBI', 'NADP(+)')

        self.assert_has_node(sub_reactant_1)
        self.assert_has_node(sub_reactant_2)
        self.assert_has_node(sub_reactant_3)
        self.assert_has_node(sub_product_1)
        self.assert_has_node(sub_product_2)
        self.assert_has_node(sub_product_3)

        sub = reaction(
            reactants=[sub_reactant_1, sub_reactant_2, sub_reactant_3],
            products=[sub_product_1, sub_product_2, sub_product_3])
        self.assert_has_node(sub)

        self.assert_has_edge(sub, sub_reactant_1, relation=HAS_REACTANT)
        self.assert_has_edge(sub, sub_reactant_2, relation=HAS_REACTANT)
        self.assert_has_edge(sub, sub_reactant_3, relation=HAS_REACTANT)
        self.assert_has_edge(sub, sub_product_1, relation=HAS_PRODUCT)
        self.assert_has_edge(sub, sub_product_2, relation=HAS_PRODUCT)
        self.assert_has_edge(sub, sub_product_3, relation=HAS_PRODUCT)
コード例 #2
0
    def test_subProcessOf(self):
        """
        3.4.6 http://openbel.org/language/web/version_2.0/bel_specification_version_2.0.html#_subprocessof
        """
        statement = 'rxn(reactants(a(CHEBI:"(S)-3-hydroxy-3-methylglutaryl-CoA"),a(CHEBI:NADPH), \
            a(CHEBI:hydron)),products(a(CHEBI:mevalonate), a(CHEBI:"CoA-SH"), a(CHEBI:"NADP(+)"))) \
            subProcessOf bp(GO:"cholesterol biosynthetic process")'

        result = self.parser.relation.parseString(statement)
        expected_result = [
            [
                REACTION,
                [
                    [
                        ABUNDANCE,
                        ['CHEBI', '(S)-3-hydroxy-3-methylglutaryl-CoA']
                    ],
                    [ABUNDANCE, ['CHEBI', 'NADPH']],
                    [ABUNDANCE, ['CHEBI', 'hydron']],
                ],
                [
                    [ABUNDANCE, ['CHEBI', 'mevalonate']],
                    [ABUNDANCE, ['CHEBI', 'CoA-SH']],
                    [ABUNDANCE, ['CHEBI', 'NADP(+)']],
                ],
            ],
            SUBPROCESS_OF,
            [BIOPROCESS, ['GO', 'cholesterol biosynthetic process']],
        ]
        self.assertEqual(expected_result, result.asList())

        sub_reactant_1 = abundance('CHEBI',
                                   '(S)-3-hydroxy-3-methylglutaryl-CoA')
        sub_reactant_2 = abundance('CHEBI', 'NADPH')
        sub_reactant_3 = abundance('CHEBI', 'hydron')
        sub_product_1 = abundance('CHEBI', 'mevalonate')
        sub_product_2 = abundance('CHEBI', 'CoA-SH')
        sub_product_3 = abundance('CHEBI', 'NADP(+)')

        self.assert_has_node(sub_reactant_1)
        self.assert_has_node(sub_reactant_2)
        self.assert_has_node(sub_reactant_3)
        self.assert_has_node(sub_product_1)
        self.assert_has_node(sub_product_2)
        self.assert_has_node(sub_product_3)

        sub = reaction([sub_reactant_1, sub_reactant_2, sub_reactant_3],
                       [sub_product_1, sub_product_2, sub_product_3])

        self.assert_has_edge(sub, sub_reactant_1, relation=HAS_REACTANT)
        self.assert_has_edge(sub, sub_reactant_2, relation=HAS_REACTANT)
        self.assert_has_edge(sub, sub_reactant_3, relation=HAS_REACTANT)
        self.assert_has_edge(sub, sub_product_1, relation=HAS_PRODUCT)
        self.assert_has_edge(sub, sub_product_2, relation=HAS_PRODUCT)
        self.assert_has_edge(sub, sub_product_3, relation=HAS_PRODUCT)

        obj = bioprocess('GO', 'cholesterol biosynthetic process')
        self.assert_has_node(obj)

        self.assert_has_edge(sub, obj, **{RELATION: SUBPROCESS_OF})
コード例 #3
0
def add_edges(graph: BELGraph, participants, nodes, att: Dict):
    """Add edges into the graph."""
    edge_types = att['interaction_type']

    if isinstance(participants, dict):

        reactants = {
            nodes[source_id]
            for source_id in participants['reactants']
        }

        products = {
            nodes[product_id]
            for product_id in participants['products']
        }

        reaction_node = reaction(reactants=reactants, products=products)
        graph.add_node_from_data(reaction_node)

    elif isinstance(participants, tuple):
        u = nodes[participants[0]]
        v = nodes[participants[1]]
        add_simple_edge(graph, u, v, edge_types)
コード例 #4
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(FPLX:CAPN, location(GO:intracellular))) -| reaction(reactants(p(HGNC:CDK5R1)),products(p(HGNC:CDK5)))'
        result = self.parser.relation.parseString(statement)

        expected_dict = {
            SOURCE: {
                MODIFIER: ACTIVITY,
                FUNCTION: PROTEIN,
                CONCEPT: {
                    NAMESPACE: 'FPLX',
                    NAME: 'CAPN',
                },
                LOCATION: {
                    NAMESPACE: 'GO',
                    NAME: 'intracellular'
                },
                EFFECT: activity_mapping['pep'],
            },
            RELATION: DECREASES,
            TARGET: {
                FUNCTION:
                REACTION,
                REACTANTS: [{
                    FUNCTION: PROTEIN,
                    CONCEPT: {
                        NAMESPACE: 'HGNC',
                        NAME: 'CDK5R1',
                    },
                }],
                PRODUCTS: [
                    {
                        FUNCTION: PROTEIN,
                        CONCEPT: {
                            NAMESPACE: 'HGNC',
                            NAME: 'CDK5',
                        },
                    },
                ],
            },
        }
        self.assertEqual(expected_dict, result.asDict())

        sub = protein('FPLX', 'CAPN')
        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,
            SOURCE_MODIFIER: {
                MODIFIER: ACTIVITY,
                EFFECT: activity_mapping['pep'],
                LOCATION: {
                    NAMESPACE: 'GO',
                    NAME: 'intracellular',
                }
            }
        }

        self.assertEqual(
            expected_edge_attributes[SOURCE_MODIFIER],
            activity(name='pep',
                     location=Entity(name='intracellular', namespace='GO')),
        )

        self.assert_has_edge(sub, obj, **expected_edge_attributes)
コード例 #5
0
ファイル: examples.py プロジェクト: pybel/pybel-cx
cat(p(HGNC:BDKRB1)) increases cat(p(SFAM:"PLA2 Family"))
"""

c4 = {
    CITATION_TYPE: CITATION_TYPE_OTHER,
    CITATION_REFERENCE: 'Genstruct Reference',
}
e4 = '% Entrez Gene summary: Rat: SUMMARY: precursor protein of kinin which is found in plasma; cysteine protease inhibitor and a major acute phase reactant [RGD] OMIM summary: (summary is not available from this source) kininogens; Endogenous peptides present in most body fluids. Certain enzymes convert them to active kinins which are involved in inflammation, blood clotting, complement reactions, etc. Kininogens belong to the cystatin superfamily. They are cysteine proteinase inhibitors. High-molecular-weight kininogen (hmwk) is split by plasma kallikrein to produce bradykinin. Low-molecular-weight kininogen (lmwk) is split by tissue kallikrein to produce kallidin. kinins; Inflammatory mediators that cause dilation of blood vessels and altered vascular permeability.  Kinins are small peptides produced from kininogen by kallikrein and are broken down by kininases. Act on phospholipase and increase arachidonic acid release and thus prostaglandin (PGE2) production. bradykinin; Vasoactive nonapeptide (RPPGFSPFR) formed by action of proteases on kininogens. Very similar to kallidin (which has the same sequence but with an additional N terminal lysine). Bradykinin is a very potent vasodilator and increases permeability of post capillary venules, it acts on endothelial cells to activate phospholipase A2. It is also spasmogenic for some smooth muscle and will cause pain. kallidin; Decapeptide (lysyl bradykinin, amino acid sequence KRPPGFSPFR) produced in kidney. Like bradykinin, an inflammatory mediator (a kinin), causes dilation of renal blood vessels and increased water excretion.'
e4 = str(hash(e4))

bdkrb1 = protein('HGNC', 'BDKRB1')
inflammatory_process = bioprocess('GO', 'inflammatory process')
kng1 = protein('HGNC', 'KNG1')
kallidin = abundance('CHEBI', 'Kallidin')
pla2_family = protein('SFAM', 'PLA2 Family')
kng1_to_kallidin = reaction(reactants=[kng1], products=[kallidin])

example_graph.add_increases(inflammatory_process, kng1_to_kallidin, citation=c4, evidence=e4)
example_graph.add_increases(kallidin, bdkrb1, citation=c4, evidence=e4, object_modifier=catalytic_activity)
example_graph.add_increases(bdkrb1, pla2_family, citation=c4, evidence=e4, subject_modifier=catalytic_activity,
                            object_modifier=catalytic_activity)

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))
コード例 #6
0
ファイル: test_pybel_assembler.py プロジェクト: steppi/indra
phos_dsl = pmod('Ph', 'Ser', 218)
ub_dsl = pmod('Ub', 'Ser', 218)
egfr_phos_dsl = pmod('Ph', 'Tyr', 1173)

braf_dsl = protein(namespace='HGNC', name='BRAF', identifier='1097')
map2k1_dsl = protein(namespace='HGNC', name='MAP2K1', identifier='6840')
tp53_dsl = protein(namespace='HGNC', name='TP53', identifier='11998')
mdm2_dsl = protein(namespace='HGNC', name='MDM2', identifier='6973')
egfr_dsl = protein(namespace='HGNC', name='EGFR', identifier='3236')

chebi_17534 = abundance(namespace='CHEBI', name='D-glucose',
                        identifier='17634')
chebi_4170 = abundance(namespace='CHEBI', name='D-glucopyranose 6-phosphate',
                       identifier='4170')
chebi_17534_to_4170 = reaction(chebi_17534, chebi_4170)

grb2_dsl = protein(namespace='HGNC', name='GRB2', identifier='4566')
sos1_dsl = protein(namespace='HGNC', name='SOS1', identifier='11187')
sos1_phosphorylated_dsl = sos1_dsl.with_variants(pmod('Ph'))
kras_node = protein(namespace='HGNC', name='KRAS', identifier='6407')

egfr_grb2_sos1_complex_dsl = complex_abundance([
    egfr_dsl,
    grb2_dsl,
    sos1_dsl,
])

egfr_grb2_sos1_phos_complex_dsl = complex_abundance([
    egfr_dsl,
    grb2_dsl,
コード例 #7
0
ファイル: test_canonicalization.py プロジェクト: smoe/pybel
 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))
コード例 #8
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)
コード例 #9
0
    return hgnc_client.get_hgnc_id(gene_name)


phos_dsl = pmod('Ph', 'Ser', 218)
ub_dsl = pmod('Ub', 'Ser', 218)
egfr_phos_dsl = pmod('Ph', 'Tyr', 1173)

braf_dsl = protein(namespace='HGNC', name='BRAF')
map2k1_dsl = protein(namespace='HGNC', name='MAP2K1')
tp53_dsl = protein(namespace='HGNC', name='TP53')
mdm2_dsl = protein(namespace='HGNC', name='MDM2')
egfr_dsl = protein(namespace='HGNC', name='EGFR')

chebi_17534 = abundance(namespace='CHEBI', name='17634')
chebi_4170 = abundance(namespace='CHEBI', name='4170')
chebi_17534_to_4170 = reaction(chebi_17534, chebi_4170)

grb2_dsl = protein(namespace='HGNC', name='GRB2')
sos1_dsl = protein(namespace='HGNC', name='SOS1')
sos1_phosphorylated_dsl = sos1_dsl.with_variants(pmod('Ph'))
kras_node = protein(namespace='HGNC', name='KRAS')

egfr_grb2_sos1_complex_dsl = complex_abundance([
    egfr_dsl,
    grb2_dsl,
    sos1_dsl,
])

egfr_grb2_sos1_phos_complex_dsl = complex_abundance([
    egfr_dsl,
    grb2_dsl,
コード例 #10
0
def add_reaction_edges(graph, reaction_dict, nodes):
    """Add reaction nodes and edges from reactants to products and enzymes to reactions to BEL Graph.

    :param pybel.BELGraph graph: BEL Graph
    :param dict reaction_dict: dictionary of reaction IDs and reactant and product IDs
    :param dict nodes: dictionary of BEL nodes
    """
    for k, v in reaction_dict.items():

        # Get BEL gene node(s)
        enzyme = nodes[k]

        # Get compound nodes
        for source, target, reaction_type in v:

            reactants_list = []
            products_list = []

            # Get reactant compound node
            for source_id in source:
                substrate = nodes[source_id]
                reactants_list.append(substrate)

            # Get product compound node
            for target_id in target:
                product = nodes[target_id]
                products_list.append(product)

                for reactant_compound in reactants_list:
                    for product_compound in products_list:

                        # If multiple compounds represent a reactant or a product, add reaction BEL nodes to graph
                        if isinstance(reactants_list, list) and isinstance(
                                products_list, list):
                            reaction_node = reaction(
                                reactants=reactant_compound,
                                products=product_compound)
                            graph.add_node_from_data(reaction_node)

                        # If multiple compounds represent a reactant, add reaction BEL node to graph
                        elif isinstance(
                                reactants_list,
                                list) and not isinstance(products_list, list):
                            for reactant_compound in reactants_list:
                                reaction_node = reaction(
                                    reactants=reactant_compound,
                                    products=products_list)
                                graph.add_node_from_data(reaction_node)

                        # If multiple compounds represent a product, add reaction BEL node to graph
                        elif not isinstance(reactants_list,
                                            list) and isinstance(
                                                products_list, list):
                            for product_compound in products_list:
                                reaction_node = reaction(
                                    reactants=reactants_list,
                                    products=product_compound)
                                graph.add_node_from_data(reaction_node)

                        # If reactant and product is represented by a single compound, add reaction BEL node to graph
                        else:
                            reaction_node = reaction(reactants=reactants_list,
                                                     products=products_list)
                            graph.add_node_from_data(reaction_node)

                # If enzyme is a list of genes, add edges between all enzymes and reactions
                if isinstance(enzyme, list):
                    for gene_type in enzyme:
                        add_simple_edge(graph, gene_type, reaction_node,
                                        reaction_type)
                else:
                    add_simple_edge(graph, enzyme, reaction_node,
                                    reaction_type)