def setUp(self):
        identifier_parser = ConceptParser()
        self.parser = get_gene_modification_language(
            concept_fqualified=identifier_parser.identifier_fqualified,
            concept_qualified=identifier_parser.identifier_qualified,
        )

        self.expected = GeneModification('Me')
    def test_gmod_default(self, mock):
        """Test a gene modification that uses the BEL default namespace."""
        dummy_namespace = n()
        dummy_name = n()

        node_data = Gene(namespace=dummy_namespace,
                         name=dummy_name,
                         variants=[GeneModification('Me')])
        self._help_reconstitute(node_data, 2, 1)
    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(ProteinSubstitution('Val', 600, 'Glu')))

        self.assertEqual('pmod(go:0006468 ! "protein phosphorylation")',
                         str(ProteinModification('Ph')))
        self.assertEqual('pmod(TEST:Ph)',
                         str(ProteinModification('Ph', namespace='TEST')))
        self.assertEqual(
            'pmod(TEST:Ph, Ser)',
            str(ProteinModification('Ph', namespace='TEST', code='Ser')))
        self.assertEqual(
            'pmod(TEST:Ph, Ser, 5)',
            str(
                ProteinModification('Ph',
                                    namespace='TEST',
                                    code='Ser',
                                    position=5)))
        self.assertEqual(
            'pmod(GO:"protein phosphorylation", Thr, 308)',
            str(
                ProteinModification(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(go:0006306 ! "DNA methylation")',
                         str(GeneModification('Me')))
        self.assertEqual('gmod(TEST:Me)',
                         str(GeneModification('Me', namespace='TEST')))
        self.assertEqual(
            'gmod(GO:"DNA Methylation")',
            str(GeneModification('DNA Methylation', namespace='GO')))
    def test_gmod_custom(self, mock):
        """Tests a gene modification that uses a non-default namespace"""
        dummy_namespace = 'HGNC'
        dummy_name = 'AKT1'
        dummy_mod_namespace = 'GO'
        dummy_mod_name = 'DNA Methylation'

        node_data = Gene(namespace=dummy_namespace,
                         name=dummy_name,
                         variants=[
                             GeneModification(name=dummy_mod_name,
                                              namespace=dummy_mod_namespace)
                         ])
        self._help_reconstitute(node_data, 2, 1)
Exemple #5
0
akt1 = hgnc(name='AKT1')
egfr = hgnc(name='EGFR')
fadd = hgnc(name='FADD')
casp8 = hgnc(name='CASP8')
mia = hgnc(name='MIA')

il6 = Protein('HGNC', 'IL6')

adgrb1 = Protein(namespace='HGNC', name='ADGRB1')
adgrb2 = Protein(namespace='HGNC', name='ADGRB2')
adgrb_complex = ComplexAbundance([adgrb1, adgrb2])
achlorhydria = Pathology(namespace='MESHD', name='Achlorhydria')

akt1_rna = akt1.get_rna()
akt1_gene = akt1_rna.get_gene()
akt_methylated = akt1_gene.with_variants(GeneModification('Me'))
akt1_phe_508_del = akt1_gene.with_variants(Hgvs('p.Phe508del'))

cftr = hgnc('CFTR')
cftr_protein_unspecified_variant = cftr.with_variants(HgvsUnspecified())
cftr_protein_phe_508_del = cftr.with_variants(Hgvs('p.Phe508del'))

adenocarcinoma = Pathology('MESHD', 'Adenocarcinoma')
interleukin_23_complex = NamedComplexAbundance('GO', 'interleukin-23 complex')

oxygen_atom = Abundance(namespace='CHEBI', name='oxygen atom')
hydrogen_peroxide = Abundance('CHEBI', 'hydrogen peroxide')

tmprss2_gene = Gene('HGNC', 'TMPRSS2')

tmprss2_erg_gene_fusion = GeneFusion(
Exemple #6
0
def _add_row(
    graph: BELGraph,
    relation: str,
    source_prefix: str,
    source_id: str,
    source_name: Optional[str],
    target_prefix: str,
    target_id: str,
    target_name: Optional[str],
    pubmed_id: str,
    int_detection_method: str,
    source_database: str,
    confidence: str,
) -> None:  # noqa:C901
    """Add for every PubMed ID an edge with information about relationship type, source and target.

    :param source_database: row value of column source_database
    :param graph: graph to add edges to
    :param relation: row value of column relation
    :param source_prefix: row value of source prefix
    :param source_id: row value of source id
    :param target_prefix: row value of target prefix
    :param target_id: row value of target id
    :param pubmed_id: row value of column PubMed_id
    :param int_detection_method: row value of column interaction detection method
    :param confidence: row value of confidence score column
    :return: None
    """
    if pubmed_id is None:
        pubmed_id = 'database', 'intact'

    annotations = {
        'psi-mi': relation,
        'intact-detection': int_detection_method,
        'intact-source': source_database,
        'intact-confidence': confidence,
    }

    # map double spaces to single spaces in relation string
    relation = ' '.join(relation.split())

    source_dsl = NAMESPACE_TO_DSL.get(source_prefix, pybel.dsl.Protein)
    source = source_dsl(
        namespace=source_prefix,
        identifier=source_id,
        name=source_name,
    )
    target_dsl = NAMESPACE_TO_DSL.get(target_prefix, pybel.dsl.Protein)
    target = target_dsl(
        namespace=target_prefix,
        identifier=target_id,
        name=target_name,
    )

    if relation in PROTEIN_INCREASES_MOD_DICT:
        graph.add_increases(
            source,
            target.with_variants(PROTEIN_INCREASES_MOD_DICT[relation]),
            citation=pubmed_id,
            evidence=EVIDENCE,
            annotations=annotations,
            subject_modifier=SUBJECT_ACTIVITIES.get(relation),
        )

    # dna strand elongation
    elif relation == 'psi-mi:"MI:0701"(dna strand elongation)':
        target_mod = pybel.dsl.Gene(
            namespace=target_prefix,
            identifier=target_id,
            name=target_name,
            variants=[
                GeneModification(
                    name='DNA strand elongation',
                    namespace='go',
                    identifier='0022616',
                ),
            ],
        )
        graph.add_increases(
            source,
            target_mod,
            citation=pubmed_id,
            evidence=EVIDENCE,
            annotations=annotations,
        )

    # DECREASES
    elif relation in INTACT_DECREASES_ACTIONS:
        #: dna cleavage: Covalent bond breakage of a DNA molecule leading to the formation of smaller fragments
        if relation == 'psi-mi:"MI:0572"(dna cleavage)':
            target_mod = pybel.dsl.Gene(
                namespace=target_prefix,
                identifier=source_id,
                name=target_name,
            )
            graph.add_decreases(
                source,
                target_mod,
                citation=pubmed_id,
                evidence=EVIDENCE,
                annotations=annotations,
            )
        #: rna cleavage: Any process by which an RNA molecule is cleaved at specific sites or in a regulated manner
        elif relation == 'psi-mi:"MI:0902"(rna cleavage)':
            target_mod = pybel.dsl.Rna(
                namespace=target_prefix,
                identifier=source_id,
                name=target_name,
            )
            graph.add_decreases(
                source,
                target_mod,
                citation=pubmed_id,
                evidence=EVIDENCE,
                annotations=annotations,
            )

        # cleavage
        elif relation in {
                #: Covalent bond breakage in a molecule leading to the formation of smaller molecules
                'psi-mi:"MI:0194"(cleavage reaction)',
                #: Covalent modification of a polypeptide occuring during its maturation or its proteolytic degradation
                'psi-mi:"MI:0570"(protein cleavage)',
        }:
            graph.add_decreases(
                source,
                target,
                citation=pubmed_id,
                evidence=EVIDENCE,
                annotations=annotations,
            )

        #: Reaction monitoring the cleavage (hydrolysis) or a lipid molecule
        elif relation == 'psi-mi:"MI:1355"(lipid cleavage)':
            target_mod = target.with_variants(
                pybel.dsl.ProteinModification(
                    name='lipid catabolic process',
                    namespace='go',
                    identifier='0016042',
                ), )

            graph.add_decreases(
                source,
                target_mod,
                citation=pubmed_id,
                evidence=EVIDENCE,
                annotations=annotations,
                object_modifier=pybel.dsl.activity(),
            )

        #: 'lipoprotein cleavage reaction': Cleavage of a lipid group covalently bound to a protein residue
        elif relation == 'psi-mi:"MI:0212"(lipoprotein cleavage reaction)':
            target_mod = target.with_variants(
                pybel.dsl.ProteinModification(
                    name='lipoprotein modification',
                    namespace='go',
                    identifier='0042160',
                ), )
            graph.add_decreases(
                source,
                target_mod,
                citation=pubmed_id,
                evidence=EVIDENCE,
                annotations=annotations,
                object_modifier=pybel.dsl.activity(),
            )

        # deformylation reaction
        elif relation == 'psi-mi:"MI:0199"(deformylation reaction)':
            target_mod = target.with_variants(
                pybel.dsl.ProteinModification(
                    name='protein formylation',
                    namespace='go',
                    identifier='0018256',
                ), )
            graph.add_decreases(
                source,
                target_mod,
                citation=pubmed_id,
                evidence=EVIDENCE,
                annotations=annotations,
            )
        # protein deamidation
        elif relation == 'psi-mi:"MI:2280"(deamidation reaction)':
            target_mod = target.with_variants(
                pybel.dsl.ProteinModification(
                    name='protein amidation',
                    namespace='go',
                    identifier='0018032',
                ), )
            graph.add_decreases(
                source,
                target_mod,
                citation=pubmed_id,
                evidence=EVIDENCE,
                annotations=annotations,
                object_modifier=pybel.dsl.activity(),
            )

        # protein decarboxylation
        elif relation == 'psi-mi:"MI:1140"(decarboxylation reaction)':
            target_mod = target.with_variants(
                pybel.dsl.ProteinModification(
                    name='protein carboxylation',
                    namespace='go',
                    identifier='0018214',
                ), )
            graph.add_decreases(
                source,
                target_mod,
                citation=pubmed_id,
                evidence=EVIDENCE,
                annotations=annotations,
            )
        # protein deamination:
        elif relation == 'psi-mi:"MI:0985"(deamination reaction)':
            target_mod = target.with_variants(
                pybel.dsl.ProteinModification(
                    name='amine binding',
                    namespace='go',
                    identifier='0043176',
                ), )
            graph.add_decreases(
                source,
                target_mod,
                citation=pubmed_id,
                evidence=EVIDENCE,
                annotations=annotations,
            )
        # protein modification
        elif relation in PROTEIN_DECREASES_MOD_DICT:
            target_mod = target.with_variants(
                PROTEIN_DECREASES_MOD_DICT[relation])
            graph.add_decreases(
                source,
                target_mod,
                citation=pubmed_id,
                evidence=EVIDENCE,
                annotations=annotations,
            )
        else:
            raise ValueError(
                f"The relation {relation} is not in DECREASE relations.")

    # ASSOCIATION:
    elif relation in INTACT_ASSOCIATION_ACTIONS:
        graph.add_association(
            source,
            target,
            citation=pubmed_id,
            evidence=EVIDENCE,
            annotations=annotations,
        )

    # REGULATES:
    elif relation in INTACT_REGULATES_ACTIONS:
        graph.add_regulates(
            source,
            target,
            citation=pubmed_id,
            evidence=EVIDENCE,
            annotations=annotations,
        )

    # BINDS
    elif relation in INTACT_BINDS_ACTIONS:
        graph.add_binds(
            source,
            target,
            citation=pubmed_id,
            evidence=EVIDENCE,
            annotations=annotations,
        )

    # no specified relation
    else:
        raise ValueError(
            f"Unspecified relation {relation} between {source} and {target}")