Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
]),
il6,
BiologicalProcess('GO', 'cell cycle arrest'),
hydrogen_peroxide,
Protein('HGNC', 'CAT'),
Gene('HGNC', 'CAT'),
Protein('HGNC', 'HMGCR'),
BiologicalProcess('GO', 'cholesterol biosynthetic process'),
Gene('HGNC', 'APP', variants=Hgvs('c.275341G>C')),
Gene('HGNC', 'APP'),
Pathology('MESHD', 'Alzheimer Disease'),
ComplexAbundance([Protein('HGNC', 'F3'), Protein('HGNC', 'F7')]),
Protein('HGNC', 'F3'),
Protein('HGNC', 'F7'),
Protein('HGNC', 'F9'),
Protein('HGNC', 'GSK3B', variants=ProteinModification('Ph', 'Ser', 9)),
Protein('HGNC', 'GSK3B'),
Pathology('MESHD', 'Psoriasis'),
Pathology('MESHD', 'Skin Diseases'),
Reaction(
reactants=[
Abundance('CHEBI', '(3S)-3-hydroxy-3-methylglutaryl-CoA'),
Abundance('CHEBI', 'NADPH'),
Abundance('CHEBI', 'hydron')
],
products=[
Abundance('CHEBI', 'NADP(+)'),
Abundance('CHEBI', 'mevalonate')
]
),
Abundance('CHEBI', '(3S)-3-hydroxy-3-methylglutaryl-CoA'),
Abundance('CHEBI', 'NADPH'),
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')))
import unittest
from pybel.constants import FUNCTION, NAME, NAMESPACE, PROTEIN, VARIANTS, KIND, MEMBERS, FUSION, PARTNER_3P, PARTNER_5P, RANGE_3P, RANGE_5P
from pybel.dsl import (
Abundance, BiologicalProcess, ComplexAbundance, Gene, MicroRna, NamedComplexAbundance, Pathology, Protein,
ProteinModification, Reaction, Rna, ProteinFusion
)
from pybel.schema import validate_node
from pybel.testing.utils import n
HGNC = 'HGNC'
GO = 'GO'
YFG = 'YFG'
phosphorylation = ProteinModification('Ph')
protein_1 = Protein(HGNC, YFG)
protein_2 = Protein(HGNC, YFG, variants=phosphorylation)
rna_1 = Rna(HGNC, YFG)
micro_rna_1 = MicroRna(HGNC, 'YFMR')
gene_1 = Gene(HGNC, YFG)
biological_process_1 = BiologicalProcess(GO, 'YFBP')
pathology_1 = Pathology(GO, 'YFP')
abundance_1 = Abundance(n(), n())
abundance_2 = Abundance(n(), n())
reaction_1 = Reaction(reactants=[abundance_1], products=[abundance_2])
complex_1 = NamedComplexAbundance(n(), n())
enumerated_complex_1 = ComplexAbundance([
protein_1,
Protein(HGNC, n()),
])
protein_fusion = ProteinFusion(protein_1, protein_2)
Abundance('CHEBI', 'NADP(+)'),
Abundance('CHEBI', 'nitric oxide'),
ComplexAbundance([
Protein('HGNC', 'ITGAV'),
Protein('HGNC', 'ITGB3')
]),
Protein('HGNC', 'ITGAV'),
Protein('HGNC', 'ITGB3'),
Protein('HGNC', 'FADD'),
Abundance('TESTNS2', 'Abeta_42'),
Protein('TESTNS2', 'GSK3 Family'),
Protein('HGNC', 'PRKCA'),
Protein('HGNC', 'CDK5'),
Protein('HGNC', 'CASP8'),
Protein('HGNC', 'AKT1',
variants=ProteinModification(namespace='TESTNS2', name='PhosRes', code='Ser', position=473)),
Protein('HGNC', 'HRAS', variants=ProteinModification('Palm')),
BiologicalProcess('GO', 'apoptotic process'),
CompositeAbundance([
Abundance('TESTNS2', 'Abeta_42'),
Protein('HGNC', 'CASP8'),
Protein('HGNC', 'FADD')
]),
Reaction(
reactants=[Protein('HGNC', 'CDK5R1')],
products=[Protein('HGNC', 'CDK5')],
),
Protein('HGNC', 'PRKCB'),
NamedComplexAbundance('TESTNS2', 'AP-1 Complex'),
Protein('HGNC', 'PRKCE'),
Protein('HGNC', 'PRKCD'),
Protein('TESTNS2', 'CAPN Family'),
]),
Reaction(
reactants=[Protein('HGNC', 'CDK5R1')],
products=[Protein('HGNC', 'CDK5')],
),
Protein('HGNC', 'PRKCB'),
NamedComplexAbundance('TESTNS2', 'AP-1 Complex'),
Protein('HGNC', 'PRKCE'),
Protein('HGNC', 'PRKCD'),
Protein('TESTNS2', 'CAPN Family'),
Gene('TESTNS2', 'AKT1 ortholog'),
Protein('HGNC', 'HRAS'),
Protein('HGNC', 'CDK5R1'),
Protein('TESTNS2', 'PRKC'),
BiologicalProcess('GO', 'neuron apoptotic process'),
Protein('HGNC', 'MAPT', variants=ProteinModification('Ph')),
Protein('HGNC', 'MAPT'),
Gene('HGNC', 'ARRDC2'),
Gene('HGNC', 'ARRDC3'),
Gene('dbSNP', 'rs123456')
}
BEL_THOROUGH_EDGES = [
(Gene('HGNC', 'AKT1', variants=Hgvs('p.Phe508del')), akt1, {
EVIDENCE: dummy_evidence,
CITATION: citation_1,
RELATION: DIRECTLY_DECREASES,
}),
(akt1, Protein('HGNC', 'AKT1', variants=ProteinModification('Ph', 'Ser', 473)), {
RELATION: HAS_VARIANT,
}),
(akt1, Protein('HGNC', 'AKT1', variants=Hgvs('p.C40*')), {
def test_protein_pmod(self):
node = Protein(name='PLCG1', namespace='HGNC', variants=[ProteinModification(name='Ph', code='Tyr')])
self.assertEqual('p(HGNC:PLCG1, pmod(go:0006468 ! "protein phosphorylation", Tyr))', str(node))
def _help_test_pmod_full(self, statement):
result = self.parser.parseString(statement)
expected = {
KIND: PMOD,
CONCEPT: {
NAMESPACE: 'go',
NAME: 'protein phosphorylation',
IDENTIFIER: '0006468',
},
PMOD_CODE: 'Ser',
PMOD_POSITION: 473,
}
self.assertEqual(expected, ProteinModification('Ph', code='Ser', position=473))
self.assertEqual(expected, result.asDict())
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)
if mod_type is None:
logger.info("Unhandled modification type %s (%s)",
var_id, node_data)
continue
mc = ModCondition(mod_type, var.get(pc.PMOD_CODE),
var.get(pc.PMOD_POSITION))
mods.append(mc)
# FIXME These unhandled mod types should result in throwing out
# the node (raise, or return None)
elif isinstance(var, dsl.GeneModification):
logger.debug('Unhandled node variant GMOD: %s', node_data)
elif isinstance(var, dsl.Fragment):
if edge_type in {'inhibition'}:
return graph.add_inhibits(
source_bel, target_bel,
citation='', evidence='', annotations={'sbgnml_edge': edge_type},
)
if edge_type in {'stimulation', 'necessary stimulation'}:
return graph.add_activates(
source_bel, target_bel,
citation='', evidence='', annotations={'sbgnml_edge': edge_type},
)
print('##', source_bel, edge_type, target_bel)
STATE_TO_PMOD = {
'P': dsl.ProteinModification('Ph'),
'Ub': dsl.ProteinModification('Ub'),
}
SKIP_STATES = {
'activated',
}
def _states_to_bel(states):
if not states:
return
for state in states:
if state in STATE_TO_PMOD:
return STATE_TO_PMOD[state]
if state in SKIP_STATES:
return
return graph.add_inhibits(
source_bel, target_bel,
citation='', evidence='', annotations={'sbgnml_edge': edge_type},
)
if edge_type in {'stimulation', 'necessary stimulation'}:
return graph.add_activates(
source_bel, target_bel,
citation='', evidence='', annotations={'sbgnml_edge': edge_type},
)
print('##', source_bel, edge_type, target_bel)
STATE_TO_PMOD = {
'P': dsl.ProteinModification('Ph'),
'Ub': dsl.ProteinModification('Ub'),
}
SKIP_STATES = {
'activated',
}
def _states_to_bel(states):
if not states:
return
for state in states:
if state in STATE_TO_PMOD:
return STATE_TO_PMOD[state]
if state in SKIP_STATES:
return
logger.debug('unhandled state: %s', state)