How to use the pybel.dsl.abundance 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_struct / test_filters / test_node_predicates.py View on Github external
def test_node_inclusion_data(self):
        g = BELGraph()

        u = protein(name='S100b', namespace='MGI')
        v = abundance(name='nitric oxide', namespace='CHEBI')
        w = abundance(name='cortisol', namespace='CHEBI', identifier='17650')

        g.add_node_from_data(u)
        g.add_node_from_data(v)
        g.add_node_from_data(w)

        f = node_inclusion_predicate_builder([u])

        self.assertTrue(f(u))
        self.assertFalse(f(v))
        self.assertFalse(f(w))

        f = node_inclusion_predicate_builder([u, v])

        self.assertTrue(f(u))
        self.assertTrue(f(v))
        self.assertFalse(f(w))
github pybel / pybel / tests / test_parse / test_parse_bel_relations.py View on Github external
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)
github pybel / pybel / tests / test_parse / test_parse_bel_relations.py View on Github external
expected = [
            COMPOSITE,
            [PROTEIN, ['HGNC', 'CASP8']],
            [PROTEIN, ['HGNC', 'FADD']],
            [ABUNDANCE, ['CHEBI', 'Abeta_42']]
        ]
        self.assertEqual(expected, result.asList())

        sub_member_1 = protein('HGNC', 'CASP8')
        self.assert_has_node(sub_member_1)

        sub_member_2 = protein('HGNC', 'FADD')
        self.assert_has_node(sub_member_2)

        sub_member_3 = abundance('CHEBI', 'Abeta_42')
        self.assert_has_node(sub_member_3)

        sub = composite_abundance([sub_member_1, sub_member_2, sub_member_3])
        self.assert_has_node(sub)

        self.assert_has_edge(sub_member_1, sub, relation=PART_OF)
        self.assert_has_edge(sub_member_2, sub, relation=PART_OF)
github pybel / pybel / tests / test_parse / test_parse_bel.py View on Github external
NAME: 'Abeta_42',
                },
            },
            RELATION: DIRECTLY_INCREASES,
            TARGET: {
                FUNCTION: ABUNDANCE,
                CONCEPT: {
                    NAMESPACE: 'CHEBI',
                    NAME: 'calcium(2+)',
                },
                MODIFIER: TRANSLOCATION,
            }
        }
        self.assertEqual(expected_dict, result.asDict())

        sub = abundance('CHEBI', 'Abeta_42')
        self.assert_has_node(sub)

        obj = abundance('CHEBI', 'calcium(2+)')
        self.assert_has_node(obj)

        expected_annotations = {
            RELATION: DIRECTLY_INCREASES,
            TARGET_MODIFIER: {
                MODIFIER: TRANSLOCATION,
            }
        }

        self.assert_has_edge(sub, obj, **expected_annotations)
github pybel / pybel / tests / test_parse / test_parse_bel_relations.py View on Github external
[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)
github pybel / pybel / tests / test_struct / test_filters / test_node_predicates.py View on Github external
def test_node_exclusion_tuples(self):
        g = BELGraph()

        u = protein(name='S100b', namespace='MGI')
        v = abundance(name='nitric oxide', namespace='CHEBI')
        w = abundance(name='cortisol', namespace='CHEBI', identifier='17650')

        g.add_node_from_data(u)
        g.add_node_from_data(v)
        g.add_node_from_data(w)

        f = node_exclusion_predicate_builder([u])

        self.assertFalse(f(g, u))
        self.assertTrue(f(g, v))
        self.assertTrue(f(g, w))

        f = node_exclusion_predicate_builder([u, v])

        self.assertFalse(f(g, u))
        self.assertFalse(f(g, v))
        self.assertTrue(f(g, w))
github pybel / pybel / tests / test_parse / test_parse_bel.py View on Github external
def setUp(self):
        self.parser.clear()
        self.parser.general_abundance.setParseAction(self.parser.handle_term)

        self.expected_node = abundance(namespace='CHEBI', name='oxygen atom', identifier='CHEBI:25805')
        self.expected_canonical_bel = 'a(CHEBI:"CHEBI:25805" ! "oxygen atom")'
github pybel / pybel / tests / test_parse / test_parse_bel_relations.py View on Github external
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)
github pybel / pybel / tests / test_parse / test_parse_bel_relations.py View on Github external
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)
github pybel / pybel / tests / test_io / test_cx / examples.py View on Github external
g(HGNC:MTHFR,sub(C,677,T)) =| p(HGNC:MTHFR)
g(HGNC:MTHFR,sub(A,1298,C)) =| p(HGNC:MTHFR)
g(HGNC:MTHFR,sub(C,677,T)) neg a(CHEBI:"folic acid")
g(HGNC:MTHFR,sub(C,677,T)) pos path(MESH:"Alzheimer Disease")
"""

c2 = '21119889'
e2 = "Two common MTHFR polymorphisms, namely 677C>T (Ala222Val) and 1298A>C (Glu429Ala), are known to reduce MTHFR activity. \
It has been shown that the MTHFR 677T allele is associated with increased total plasma Hcy levels (tHcy) and decreased serum folate levels, mainly in 677TT homozygous subjects.\
the MTHFR 677C>T polymorphism as a candidate AD risk factor"
e2 = str(hash(e2))

mthfr = Protein(namespace='hgnc', name='MTHFR')
mthfr_c677t = Protein(namespace='hgnc', name='MTHFR', variants=[protein_substitution('Ala', 222, 'Val')])
mthfr_a1298c = Protein(namespace='hgnc', name='MTHFR', variants=[protein_substitution('Glu', 429, 'Ala')])
folic_acid = abundance('CHEBI', 'folic acid')
alzheimer_disease = pathology('MESH', 'Alzheimer Disease')

example_graph.add_decreases(mthfr_c677t, mthfr, citation=c2, evidence=e2, target_modifier=activity())
example_graph.add_decreases(mthfr_a1298c, mthfr, citation=c2, evidence=e2, target_modifier=activity())
example_graph.add_negative_correlation(mthfr_c677t, folic_acid, citation=c2, evidence=e2)
example_graph.add_positive_correlation(mthfr_c677t, alzheimer_disease, citation=c2, evidence=e2)

c3 = '17948130'
e3 = 'A polymorphism in the NDUFB6 promoter region that creates a possible DNA methylation site (rs629566, A/G) was ' \
     'associated with a decline in muscle NDUFB6 expression with age. Although young subjects with the rs629566 G/G ' \
     'genotype exhibited higher muscle NDUFB6 expression, this genotype was associated with reduced expression in' \
     ' elderly subjects. This was subsequently explained by the finding of increased DNA methylation in the promoter ' \
     'of elderly, but not young, subjects carrying the rs629566 G/G genotype. Furthermore, the degree of DNA' \
     ' methylation correlated negatively with muscle NDUFB6 expression, which in turn was associated with insulin ' \
     'sensitivity.'
e3 = str(hash(e3))