How to use the pybel.dsl.Gene 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 / test_manager_graph.py View on Github external
def test_fusion_specified(self, mock):
        node_data = GeneFusion(
            Gene('HGNC', 'TMPRSS2'),
            Gene('HGNC', 'ERG'),
            EnumeratedFusionRange('c', 1, 79),
            EnumeratedFusionRange('c', 312, 5034),
        )
        self._help_reconstitute(node_data, 1, 0)
github pybel / pybel / tests / test_io / test_import.py View on Github external
def test_annotations_with_multilist(self):
        self.add_default_provenance()

        statements = [
            'SET TestAnnotation1 = {"A","B"}',
            'SET TestAnnotation2 = "X"',
            'SET TestAnnotation3 = {"D","E"}',
            'g(TESTNS:1) -> g(TESTNS:2)'
        ]
        self.parser.parse_lines(statements)

        test_node_1_dict = Gene(namespace='TESTNS', name='1')
        test_node_2_dict = Gene(namespace='TESTNS', name='2')

        self.assertEqual(2, self.parser.graph.number_of_nodes())
        self.assertIn(test_node_1_dict, self.graph)
        self.assertIn(test_node_2_dict, self.graph)

        self.assertEqual(1, self.parser.graph.number_of_edges())

        kwargs = {
            ANNOTATIONS: {
                'TestAnnotation1': {'A': True, 'B': True},
                'TestAnnotation2': {'X': True},
                'TestAnnotation3': {'D': True, 'E': True}
            },
            CITATION: test_citation_dict
        }
        self.assert_has_edge(test_node_1_dict, test_node_2_dict, **kwargs)
github pybel / pybel / tests / test_manager / test_manager_graph.py View on Github external
def test_multiple_variants(self):
        node_data = Gene('HGNC', 'AKT1', variants=[
            Hgvs('p.Phe508del'), Hgvs('p.Phe509del')
        ])
        node_parent_data = node_data.get_parent()
        node_parent_tuple = node_parent_data

        self.graph.add_node_from_data(node_data)
        self.assertIn(node_data, self.graph)
        self.assertIn(node_parent_tuple, self.graph)
        self.assertEqual(2, self.graph.number_of_nodes())
        self.assertEqual(1, self.graph.number_of_edges())
github pybel / pybel / tests / test_io / test_import.py View on Github external
def test_annotations_with_list(self):
        self.add_default_provenance()

        statements = [
            'SET TestAnnotation1 = {"A","B"}',
            'SET TestAnnotation2 = "X"',
            'g(TESTNS:1) -> g(TESTNS:2)'
        ]
        self.parser.parse_lines(statements)

        test_node_1_dict = Gene(namespace='TESTNS', name='1')
        test_node_2_dict = Gene(namespace='TESTNS', name='2')

        self.assertEqual(2, self.parser.graph.number_of_nodes())
        self.assertIn(test_node_1_dict, self.graph)
        self.assertIn(test_node_2_dict, self.graph)

        self.assertEqual(1, self.parser.graph.number_of_edges())

        kwargs = {
            ANNOTATIONS: {
                'TestAnnotation1': {'A': True, 'B': True},
                'TestAnnotation2': {'X': True}
            },
            CITATION: test_citation_dict
        }
        self.assert_has_edge(test_node_1_dict, test_node_2_dict, **kwargs)
github pybel / pybel / tests / test_manager / test_manager_graph.py View on Github external
def test_multiple_variants(self, mock):
        node_data = Gene(namespace='HGNC', name='AKT1', variants=[
            Hgvs('p.Phe508del'),
            Hgvs('p.Phe509del')
        ])
        self._help_reconstitute(node_data, 2, 1)
github pybel / pybel / tests / constant_helper.py View on Github external
),
    (Protein('HGNC', 'GSK3B'), Protein('HGNC', 'GSK3B', variants=ProteinModification('Ph', 'Ser', 9)), {
        RELATION: HAS_VARIANT,
    }),
    (Pathology('MESHD', 'Psoriasis'), Pathology('MESHD', 'Skin Diseases'), {
        RELATION: IS_A,
    }),
    (
        Protein('HGNC', 'HBP1'),
        ComplexAbundance([Gene('HGNC', 'NCF1'), Protein('HGNC', 'HBP1')]),
        {
            RELATION: PART_OF,
        },
    ),
    (
        Gene('HGNC', 'NCF1'),
        ComplexAbundance([Gene('HGNC', 'NCF1'), Protein('HGNC', 'HBP1')]),
        {
            RELATION: PART_OF,
        },
    ),
    (
        Protein('HGNC', 'FOS'),
        ComplexAbundance([Protein('HGNC', 'FOS'), Protein('HGNC', 'JUN')]),
        {
            RELATION: PART_OF,
        }
    ),
    (
        Protein('HGNC', 'JUN'),
        ComplexAbundance([Protein('HGNC', 'FOS'), Protein('HGNC', 'JUN')]),
        {
github pybel / pybel / tests / test_io / test_pynpa.py View on Github external
import pandas as pd

from pybel import BELGraph
from pybel.dsl import ComplexAbundance, Gene, Protein, Rna
from pybel.io.pynpa import to_npa_dfs, to_npa_layers
from pybel.struct.getters import get_tf_pairs
from pybel.testing.utils import n

g1 = Gene('hgnc', '1')
r1 = Rna('hgnc', '1')
p1 = Protein('hgnc', '1')
g2 = Gene('hgnc', '2')
r2 = Rna('hgnc', '2')
p2 = Protein('hgnc', '2')
g3 = Gene('hgnc', '3')
p3 = Protein('hgnc', '3')


class TestPyNPA(unittest.TestCase):
    """Tests for PyNPA."""

    def setUp(self) -> None:
        """Set up a small test graph."""
        self.graph = BELGraph()
        self.graph.add_increases(ComplexAbundance([p1, g2]), r2, citation=n(), evidence=n())
        self.graph.add_increases(p2, p3, citation=n(), evidence=n())

    def test_get_tf_pairs(self):
        """Test getting transcription factor-target pairs."""
        tf_pairs = set(get_tf_pairs(self.graph))
        self.assertLess(0, len(tf_pairs), msg='No TF pairs pairs found')
github pybel / pybel / tests / test_manager / test_manager_graph.py View on Github external
def test_fusion_specified(self, mock):
        node_data = GeneFusion(
            Gene('HGNC', 'TMPRSS2'),
            Gene('HGNC', 'ERG'),
            EnumeratedFusionRange('c', 1, 79),
            EnumeratedFusionRange('c', 312, 5034),
        )
        self._help_reconstitute(node_data, 1, 0)
github pybel / pybel / tests / test_io / test_import.py View on Github external
def test_regex_match(self):
        line = 'g(dbSNP:rs10234) -- g(dbSNP:rs10235)'
        self.add_default_provenance()
        self.parser.parseString(line)
        self.assertIn(Gene('dbSNP', 'rs10234'), self.parser.graph)
        self.assertIn(Gene('dbSNP', 'rs10235'), self.parser.graph)
github sorgerlab / indra / indra / sources / bel / processor.py View on Github external
Returns
    -------
    mods : List[ModCondition]
        A list of modifications to the given abundance
    muts : List[MutCondition]
        A list of mutations to the given abundance
    """
    mods = []
    muts = []
    variants = node_data.get(pc.VARIANTS)
    if not variants:
        return mods, muts

    for var in variants:
        if isinstance(var, dsl.Hgvs):
            if isinstance(node_data, dsl.Gene):
                logger.debug('Unhandled genetic variant: %s', node_data)
                continue

            hgvs_str = var.variant
            position, res_from, res_to = _parse_mutation(hgvs_str)
            if position is None and res_from is None and res_to is None:
                logger.info("Could not parse HGVS string %s", hgvs_str)
            else:
                mut_cond = MutCondition(position, res_from, res_to)
                muts.append(mut_cond)

        elif isinstance(var, dsl.ProteinModification):
            var_ns = var.entity.namespace
            if var_ns == pc.BEL_DEFAULT_NAMESPACE:
                var_id = var.entity.name
                mod_type = _pybel_indra_pmod_map.get(var_id)