コード例 #1
0
ファイル: test_canonicalization.py プロジェクト: smoe/pybel
    def test_canonicalize_variant_dsl(self):
        """Use the __str__ functions in the DSL to create BEL instead of external pybel.canonicalize."""
        self.assertEqual('var("p.Val600Glu")', str(hgvs('p.Val600Glu')))
        self.assertEqual('var("p.Val600Glu")',
                         str(protein_substitution('Val', 600, 'Glu')))

        self.assertEqual('pmod(Ph)', str(pmod('Ph')))
        self.assertEqual('pmod(TEST:Ph)', str(pmod('Ph', namespace='TEST')))
        self.assertEqual('pmod(TEST:Ph, Ser)',
                         str(pmod('Ph', namespace='TEST', code='Ser')))
        self.assertEqual(
            'pmod(TEST:Ph, Ser, 5)',
            str(pmod('Ph', namespace='TEST', code='Ser', position=5)))
        self.assertEqual(
            'pmod(GO:"protein phosphorylation", Thr, 308)',
            str(
                pmod(name='protein phosphorylation',
                     namespace='GO',
                     code='Thr',
                     position=308)))

        self.assertEqual('frag("?")', str(fragment()))
        self.assertEqual('frag("672_713")', str(fragment(start=672, stop=713)))
        self.assertEqual('frag("?", "descr")',
                         str(fragment(description='descr')))
        self.assertEqual(
            'frag("672_713", "descr")',
            str(fragment(start=672, stop=713, description='descr')))

        self.assertEqual('gmod(Me)', str(gmod('Me')))
        self.assertEqual('gmod(TEST:Me)', str(gmod('Me', namespace='TEST')))
        self.assertEqual('gmod(GO:"DNA Methylation")',
                         str(gmod('DNA Methylation', namespace='GO')))
コード例 #2
0
    def test_has_variant(self):
        statement = 'g(HGNC:AKT1) hasVariant g(HGNC:AKT1, gmod(M))'
        self.parser.relation.parseString(statement)

        expected_parent = gene('HGNC', 'AKT1')
        expected_child = expected_parent.with_variants(gmod('Me'))

        self.assert_has_node(expected_parent)
        self.assert_has_node(expected_child)

        self.assertEqual('g(HGNC:AKT1)', self.graph.node_to_bel(expected_parent))
        self.assertEqual('g(HGNC:AKT1, gmod(Me))', self.graph.node_to_bel(expected_child))

        self.assert_has_edge(expected_parent, expected_child, **{RELATION: HAS_VARIANT})
コード例 #3
0
    def _help_test_increases_methylation(self, x):
        statement = f'a(CHEBI:"lead atom") -> g(HGNC:APP, gmod({x}))'
        result = self.parser.relation.parseString(statement)
        expected_dict = {
            TARGET: {
                FUNCTION:
                GENE,
                CONCEPT: {
                    NAMESPACE: 'HGNC',
                    NAME: 'APP',
                },
                VARIANTS: [
                    {
                        KIND: GMOD,
                        CONCEPT: {
                            NAMESPACE: 'go',
                            IDENTIFIER: '0006306',
                            NAME: 'DNA methylation',
                        },
                    },
                ],
            },
            RELATION: INCREASES,
            SOURCE: {
                FUNCTION: ABUNDANCE,
                CONCEPT: {
                    NAMESPACE: 'CHEBI',
                    NAME: 'lead atom',
                },
            },
        }
        self.assertEqual(expected_dict, result.asDict())

        sub = abundance('CHEBI', 'lead atom')
        obj = gene('HGNC', 'APP', variants=gmod('Me'))

        self.assert_has_edge(sub, obj, relation=INCREASES)
コード例 #4
0
    def test_increases_methylation(self):
        """Test a causal statement with a gene modification."""
        statement = 'a(CHEBI:"lead atom") -> g(HGNC:APP, gmod(Me))'
        result = self.parser.relation.parseString(statement)
        expected_dict = {
            OBJECT: {
                FUNCTION:
                GENE,
                CONCEPT: {
                    NAMESPACE: 'HGNC',
                    NAME: 'APP',
                },
                VARIANTS: [
                    {
                        KIND: GMOD,
                        CONCEPT: {
                            NAMESPACE: BEL_DEFAULT_NAMESPACE,
                            NAME: 'Me',
                        },
                    },
                ],
            },
            RELATION: INCREASES,
            SUBJECT: {
                FUNCTION: ABUNDANCE,
                CONCEPT: {
                    NAMESPACE: 'CHEBI',
                    NAME: 'lead atom',
                },
            },
        }
        self.assertEqual(expected_dict, result.asDict())

        sub = abundance('CHEBI', 'lead atom')
        obj = gene('HGNC', 'APP', variants=gmod('Me'))

        self.assert_has_edge(sub, obj, relation=INCREASES)
コード例 #5
0
ファイル: examples.py プロジェクト: pybel/pybel-cx
example_graph.add_decreases(mthfr_c677t, mthfr, citation=c2, evidence=e2, object_modifier=activity())
example_graph.add_decreases(mthfr_a1298c, mthfr, citation=c2, evidence=e2, object_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))

rs629566 = gene('DBSNP', 'rs629566', variants=[gmod('Me')])
ndufb6_gene = gene('HGNC', 'NDUFB6')
ndufb6_rna = rna('HGNC', 'NDUFB6')

example_graph.add_unqualified_edge(ndufb6_gene, rs629566, HAS_VARIANT)
example_graph.add_negative_correlation(rs629566, ndufb6_rna, citation=c3, evidence=e3,
                                       annotations={'Confidence': 'Low', 'Number': '50'})

"""
SET Evidence = "% 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."
SET Species = 9606
SET Citation = {"Other","Genstruct Kininogen Overview","Genstruct Kininogen Overview","","",""}

bp(GOBP:"inflammatory response") increases rxn(reactants(p(HGNC:KNG1)),products(a(SCHEM:Kallidin)))
path(SDIS:"tissue damage") increases rxn(reactants(p(HGNC:KNG1)),products(a(SCHEM:Kallidin)))
a(SCHEM:Kallidin) increases cat(p(HGNC:BDKRB1))
コード例 #6
0
    node_exclusion_predicate_builder,
    node_inclusion_predicate_builder,
    not_pathology,
)
from pybel.testing.utils import n

p1 = protein(name='BRAF', namespace='HGNC')
p2 = protein(name='BRAF',
             namespace='HGNC',
             variants=[hgvs('p.Val600Glu'), pmod('Ph')])
p3 = protein(name='APP',
             namespace='HGNC',
             variants=fragment(start=672, stop=713))
p4 = protein(name='2', namespace='HGNC')

g1 = gene(name='BRAF', namespace='HGNC', variants=gmod('Me'))


class TestNodePredicates(unittest.TestCase):
    """Tests for node predicates."""
    def test_none_data(self):
        """Test permissive node predicate with a node data dictionary."""
        self.assertTrue(keep_node_permissive(p1))

    def test_none(self):
        """Test permissive node predicate with graph and tuple."""
        g = BELGraph()
        p1_tuple = g.add_node_from_data(p1)
        self.assertTrue(keep_node_permissive(g, p1_tuple))

    def test_p1_data_variants(self):
コード例 #7
0
ファイル: test_parse_bel_variants.py プロジェクト: smoe/pybel
    def setUp(self):
        identifier_parser = IdentifierParser()
        identifier_qualified = identifier_parser.identifier_qualified
        self.parser = get_gene_modification_language(identifier_qualified)

        self.expected = gmod('Me')