def test_regulate_amount4_subj_act(): mek = protein(name='MAP2K1', namespace='HGNC') erk = protein(name='MAPK1', namespace='HGNC') g = BELGraph() g.add_increases(mek, erk, subject_modifier=activity(name='tscript'), evidence="Some evidence.", citation='123456') pbp = bel.process_pybel_graph(g) assert pbp.statements assert len(pbp.statements) == 1 assert isinstance(pbp.statements[0], IncreaseAmount) subj = pbp.statements[0].subj assert subj.name == 'MAP2K1' assert isinstance(subj.activity, ActivityCondition) assert subj.activity.activity_type == 'transcription' assert subj.activity.is_active assert len(pbp.statements[0].evidence) == 1 g = BELGraph() g.add_increases(mek, erk, subject_modifier=activity(name='act'), evidence="Some evidence.", citation='123456') pbp = bel.process_pybel_graph(g) assert pbp.statements assert len(pbp.statements) == 1 assert isinstance(pbp.statements[0], IncreaseAmount) subj = pbp.statements[0].subj assert subj.name == 'MAP2K1' assert isinstance(subj.activity, ActivityCondition) assert subj.activity.activity_type == 'activity' assert subj.activity.is_active assert len(pbp.statements[0].evidence) == 1
def test_conversion(): enz = protein(name='PLCG1', namespace='HGNC') react_1 = abundance('SCHEM', '1-Phosphatidyl-D-myo-inositol 4,5-bisphosphate') p1 = abundance('SCHEM', 'Diacylglycerol') p2 = abundance('SCHEM', 'Inositol 1,4,5-trisphosphate') rxn = reaction( reactants=react_1, products=[p1, p2], ) g = BELGraph() g.add_directly_increases(enz, rxn, subject_modifier=activity(name='activity'), evidence="Some evidence.", citation='123456') pbp = bel.process_pybel_graph(g) assert pbp.statements assert len(pbp.statements) == 1 stmt = pbp.statements[0] assert isinstance(stmt, Conversion) assert stmt.subj.name == 'PLCG1' assert stmt.subj.activity.activity_type == 'activity' assert stmt.subj.activity.is_active is True assert len(stmt.obj_from) == 1 assert isinstance(stmt.obj_from[0], Agent) assert stmt.obj_from[0].name == '1-Phosphatidyl-D-myo-inositol ' \ '4,5-bisphosphate' assert len(stmt.obj_to) == 2 # why do these not appear in alphabetical order? # PyBEL sorts the nodes based on their BEL, and # Inositol 1,4,5-trisphosphate gets quoted. assert stmt.obj_to[0].name == 'Inositol 1,4,5-trisphosphate' assert stmt.obj_to[1].name == 'Diacylglycerol' assert len(stmt.evidence) == 1
def test_phosphorylation_one_site_with_evidence(): mek = protein(name='MAP2K1', namespace='HGNC') erk = protein(name='MAPK1', namespace='HGNC', variants=[pmod('Ph', position=185, code='Thr')]) g = BELGraph() ev_text = 'Some evidence.' ev_pmid = '123456' edge_hash = g.add_directly_increases(mek, erk, evidence=ev_text, citation=ev_pmid, annotations={"TextLocation": 'Abstract'}) pbp = bel.process_pybel_graph(g) assert pbp.statements assert len(pbp.statements) == 1 assert isinstance(pbp.statements[0], Phosphorylation) assert pbp.statements[0].residue == 'T' assert pbp.statements[0].position == '185' enz = pbp.statements[0].enz sub = pbp.statements[0].sub assert enz.name == 'MAP2K1' assert enz.mods == [] assert sub.name == 'MAPK1' assert sub.mods == [] # Check evidence assert len(pbp.statements[0].evidence) == 1 ev = pbp.statements[0].evidence[0] assert ev.source_api == 'bel' assert ev.source_id == edge_hash assert ev.pmid == ev_pmid assert ev.text == ev_text assert ev.annotations == {'bel': 'p(HGNC:MAP2K1) directlyIncreases ' 'p(HGNC:MAPK1, pmod(Ph, Thr, 185))'} assert ev.epistemics == {'direct': True, 'section_type': 'abstract'}
def test_regulate_amount1_prot_obj(): mek = protein(name='MAP2K1', namespace='HGNC') erk = protein(name='MAPK1', namespace='HGNC') g = BELGraph() g.add_increases(mek, erk, evidence="Some evidence.", citation='123456') pbp = bel.process_pybel_graph(g) assert pbp.statements assert len(pbp.statements) == 1 assert isinstance(pbp.statements[0], IncreaseAmount) assert len(pbp.statements[0].evidence) == 1
def test_regulate_amount2_rna_obj(): # FIXME: Create a transcription-specific statement for p->rna mek = protein(name='MAP2K1', namespace='HGNC') erk = rna(name='MAPK1', namespace='HGNC') g = BELGraph() g.add_increases(mek, erk, evidence="Some evidence.", citation='123456') pbp = bel.process_pybel_graph(g) assert pbp.statements assert len(pbp.statements) == 1 assert isinstance(pbp.statements[0], IncreaseAmount) assert len(pbp.statements[0].evidence) == 1
def test_controlled_transloc_loc_cond(): """Controlled translocations are currently not handled.""" subj = protein(name='MAP2K1', namespace='HGNC') obj = protein(name='MAPK1', namespace='HGNC') g = BELGraph() transloc = translocation(from_loc=Entity('GOCC', 'intracellular'), to_loc=Entity('GOCC', 'extracellular space')) g.add_increases(subj, obj, object_modifier=transloc, evidence="Some evidence.", citation='123456') pbp = bel.process_pybel_graph(g) assert not pbp.statements
def test_regulate_amount3_deg(): # FIXME: Create a stability-specific statement for p->deg(p(Foo)) mek = protein(name='MAP2K1', namespace='HGNC') erk = protein(name='MAPK1', namespace='HGNC') g = BELGraph() g.add_increases(mek, erk, object_modifier=degradation(), evidence="Some evidence.", citation='123456') pbp = bel.process_pybel_graph(g) assert pbp.statements assert len(pbp.statements) == 1 assert isinstance(pbp.statements[0], DecreaseAmount) assert len(pbp.statements[0].evidence) == 1
def test_activation_bioprocess(): bax = protein(name='BAX', namespace='HGNC') apoptosis = bioprocess(name='apoptosis', namespace='GOBP') g = BELGraph() g.add_increases(bax, apoptosis, evidence="Some evidence.", citation='123456') pbp = bel.process_pybel_graph(g) assert pbp.statements assert len(pbp.statements) == 1 stmt = pbp.statements[0] assert isinstance(stmt, Activation) assert stmt.subj.name == 'BAX' assert stmt.obj.name == 'apoptosis' assert stmt.obj.db_refs == {} # FIXME: Update when GO lookup is implemented assert len(pbp.statements[0].evidence) == 1
def test_subject_transloc_loc_cond(): """Translocations of the subject are treated as location conditions on the subject (using the to_loc location as the condition)""" subj = protein(name='MAP2K1', namespace='HGNC') obj = protein(name='MAPK1', namespace='HGNC') transloc = translocation(from_loc=Entity('GOCC', 'intracellular'), to_loc=Entity('GOCC', 'extracellular space')) g = BELGraph() g.add_increases(subj, obj, subject_modifier=transloc, evidence="Some evidence.", citation='123456') pbp = bel.process_pybel_graph(g) assert pbp.statements assert len(pbp.statements) == 1 stmt = pbp.statements[0] assert isinstance(stmt, IncreaseAmount) assert stmt.subj.name == 'MAP2K1' assert stmt.subj.location == 'extracellular space' assert stmt.obj.name == 'MAPK1'
def test_gap(): sos = protein(name='RASA1', namespace='HGNC') kras = protein(name='KRAS', namespace='HGNC') g = BELGraph() g.add_directly_decreases(sos, kras, subject_modifier=activity(name='activity'), object_modifier=activity(name='gtp'), evidence="Some evidence.", citation='123456') pbp = bel.process_pybel_graph(g) assert pbp.statements assert len(pbp.statements) == 1 stmt = pbp.statements[0] assert isinstance(stmt, Gap) assert stmt.gap.name == 'RASA1' assert stmt.ras.name == 'KRAS' assert stmt.gap.activity.activity_type == 'activity' assert stmt.gap.activity.is_active is True assert stmt.ras.activity is None assert len(pbp.statements[0].evidence) == 1
def test_indirect_gef_is_activation(): sos = protein(name='SOS1', namespace='HGNC') kras = protein(name='KRAS', namespace='HGNC') g = BELGraph() g.add_increases(sos, kras, subject_modifier=activity(name='activity'), object_modifier=activity(name='gtp'), evidence="Some evidence.", citation='123456') pbp = bel.process_pybel_graph(g) assert pbp.statements assert len(pbp.statements) == 1 stmt = pbp.statements[0] assert isinstance(stmt, Activation) assert stmt.subj.name == 'SOS1' assert stmt.obj.name == 'KRAS' assert stmt.subj.activity.activity_type == 'activity' assert stmt.subj.activity.is_active is True assert stmt.obj.activity is None assert stmt.obj_activity == 'gtpbound' assert len(pbp.statements[0].evidence) == 1
def test_gtpactivation(): kras = protein(name='KRAS', namespace='HGNC') braf = protein(name='BRAF', namespace='HGNC') g = BELGraph() g.add_directly_increases(kras, braf, subject_modifier=activity(name='gtp'), object_modifier=activity(name='kin'), evidence="Some evidence.", citation='123456') pbp = bel.process_pybel_graph(g) assert pbp.statements assert len(pbp.statements) == 1 stmt = pbp.statements[0] assert isinstance(stmt, GtpActivation) assert stmt.subj.name == 'KRAS' assert stmt.subj.activity.activity_type == 'gtpbound' assert stmt.subj.activity.is_active is True assert stmt.obj.name == 'BRAF' assert stmt.obj.activity is None assert stmt.obj_activity == 'kinase' assert len(stmt.evidence) == 1
def test_phosphorylation_two_sites(): mek = protein(name='MAP2K1', namespace='HGNC') erk = protein(name='MAPK1', namespace='HGNC', variants=[pmod('Ph', position=185, code='Thr'), pmod('Ph', position=187, code='Tyr')]) g = BELGraph() g.add_directly_increases(mek, erk, evidence="Some evidence.", citation='123456') pbp = bel.process_pybel_graph(g) assert pbp.statements assert len(pbp.statements) == 2 stmt1 = pbp.statements[0] stmt2 = pbp.statements[1] assert stmt1.residue == 'T' assert stmt1.position == '185' assert stmt2.residue == 'Y' assert stmt2.position == '187' assert stmt1.sub.mods == [] assert stmt2.sub.mods == [] assert len(pbp.statements[0].evidence) == 1
def test_regulate_activity(): mek = protein(name='MAP2K1', namespace='HGNC') erk = protein(name='MAPK1', namespace='HGNC') g = BELGraph() g.add_increases(mek, erk, subject_modifier=activity(name='kin'), object_modifier=activity(name='kin'), evidence="Some evidence.", citation='123456') pbp = bel.process_pybel_graph(g) assert pbp.statements assert len(pbp.statements) == 1 assert isinstance(pbp.statements[0], Activation) subj = pbp.statements[0].subj assert subj.name == 'MAP2K1' assert isinstance(subj.activity, ActivityCondition) assert subj.activity.activity_type == 'kinase' assert subj.activity.is_active obj = pbp.statements[0].obj assert obj.name == 'MAPK1' assert obj.activity is None assert pbp.statements[0].obj_activity == 'kinase' assert len(pbp.statements[0].evidence) == 1
def test_subject_transloc_active_form(): """ActiveForms where the subject is a translocation--should draw on the to-location of the subject.""" subj = protein(name='MAP2K1', namespace='HGNC') obj = protein(name='MAP2K1', namespace='HGNC') transloc = translocation(from_loc=Entity('GOCC', 'intracellular'), to_loc=Entity('GOCC', 'extracellular space')) g = BELGraph() g.add_increases(subj, obj, subject_modifier=transloc, object_modifier=activity(name='kin'), evidence="Some evidence.", citation='123456') pbp = bel.process_pybel_graph(g) assert pbp.statements assert len(pbp.statements) == 1 stmt = pbp.statements[0] assert isinstance(stmt, ActiveForm) assert stmt.agent.name == 'MAP2K1' assert stmt.agent.location == 'extracellular space' assert stmt.agent.activity is None assert stmt.activity == 'kinase' assert stmt.is_active is True
def test_active_form(): p53_pmod = protein(name='TP53', namespace='HGNC', variants=[pmod('Ph', position=33, code='Ser')]) p53_obj = protein(name='TP53', namespace='HGNC') g = BELGraph() g.add_increases(p53_pmod, p53_obj, object_modifier=activity(name='tscript'), evidence="Some evidence.", citation='123456') pbp = bel.process_pybel_graph(g) assert pbp.statements assert len(pbp.statements) == 1 stmt = pbp.statements[0] assert isinstance(stmt, ActiveForm) assert stmt.activity == 'transcription' assert stmt.is_active is True ag = stmt.agent assert ag.name == 'TP53' assert len(ag.mods) == 1 mc = ag.mods[0] assert mc.mod_type == 'phosphorylation' assert mc.residue == 'S' assert mc.position == '33' assert len(pbp.statements[0].evidence) == 1
def test_complex_stmt_with_activation(): raf = protein(name='BRAF', namespace='HGNC') mek = protein(name='MAP2K1', namespace='HGNC') erk = protein(name='MAPK1', namespace='HGNC') cplx = complex_abundance([raf, mek]) g = BELGraph() g.add_directly_increases(cplx, erk, object_modifier=activity(name='kin'), evidence="Some evidence.", citation='123456') pbp = bel.process_pybel_graph(g) assert pbp.statements assert len(pbp.statements) == 2 stmt1 = pbp.statements[0] assert isinstance(stmt1, Complex) assert len(stmt1.agent_list()) == 2 assert sorted([ag.name for ag in stmt1.agent_list()]) == ['BRAF', 'MAP2K1'] assert stmt1.evidence stmt2 = pbp.statements[1] assert isinstance(stmt2, Activation) assert stmt2.subj.name == 'BRAF' assert stmt2.subj.bound_conditions[0].agent.name == 'MAP2K1' assert stmt2.obj.name == 'MAPK1' assert stmt2.obj.activity is None assert stmt2.obj_activity == 'kinase'
def test_process_pybel(): pbp = bel.process_pybel_graph(egf_graph) assert pbp.statements