def test_bind(): fname = sys._getframe().f_code.co_name + '.xml' txt = 'The receptor tyrosine kinase EGFR binds the growth factor ligand EGF.' tp = trips_api.process_text(txt, fname, False) assert(len(tp.statements) == 1) st = tp.statements[0] assert(is_complex(st)) assert(len(st.members) == 2) assert(has_hgnc_ref(st.members[0])) assert(has_hgnc_ref(st.members[1])) os.remove(fname)
def test_bind(): fname = sys._getframe().f_code.co_name + '.xml' txt = 'The receptor tyrosine kinase EGFR binds the growth factor ligand EGF.' tp = trips_api.process_text(txt, fname, False) assert (len(tp.statements) == 1) st = tp.statements[0] assert (is_complex(st)) assert (len(st.members) == 2) assert (has_hgnc_ref(st.members[0])) assert (has_hgnc_ref(st.members[1])) os.remove(fname)
def test_complex_bind2(): fname = sys._getframe().f_code.co_name + '.xml' txt = 'RAF binds to the RAS-GTP complex.' tp = trips_api.process_text(txt, fname, False) assert (len(tp.statements) == 1) st = tp.statements[0] assert (is_complex(st)) assert (len(st.members) == 2) assert (st.members[0].name == 'RAF') assert (st.members[1].name == 'RAS') assert (len(st.members[1].bound_conditions) == 1) assert (st.members[1].bound_conditions[0].agent.name == 'GTP') os.remove(fname)
def test_bound_mod(): fname = sys._getframe().f_code.co_name + '.xml' txt = 'The adaptor protein GRB2 can bind EGFR that is phosphorylated on tyrosine.' tp = trips_api.process_text(txt, fname, False) assert (len(tp.statements) == 1) st = tp.statements[0] assert (is_complex(st)) assert (len(st.members) == 2) assert (has_hgnc_ref(st.members[0])) assert (has_hgnc_ref(st.members[1])) assert (st.members[1].mods) assert ('PhosphorylationTyrosine' in st.members[1].mods) os.remove(fname)
def test_bound_mod(): fname = sys._getframe().f_code.co_name + '.xml' txt = 'The adaptor protein GRB2 can bind EGFR that is phosphorylated on tyrosine.' tp = trips_api.process_text(txt, fname, False) assert(len(tp.statements) == 1) st = tp.statements[0] assert(is_complex(st)) assert(len(st.members) == 2) assert(has_hgnc_ref(st.members[0])) assert(has_hgnc_ref(st.members[1])) assert(st.members[1].mods) assert('PhosphorylationTyrosine' in st.members[1].mods) os.remove(fname)
def text_to_sbgn(text=None, trips_xml=None): if (text is None and trips_xml is None) or (text is not None and trips_xml is not None): raise ValueError("Must provide ONE of 'text' or 'trips_xml'") elif text is not None: tp = trips_api.process_text(text) elif trips_xml is not None: tp = trips_api.process_xml(trips_xml) else: raise RuntimeError("Unexpected or impossible combination of arguments") sa = SBGNAssembler() sa.add_statements(tp.statements) sbgn_output = sa.make_sbgn() return sbgn_output
def test_bound_phosphorylate(): fname = sys._getframe().f_code.co_name + '.xml' txt = 'RAF, bound to RAF, phosphorylates MEK1.' tp = trips_api.process_text(txt, fname, False) assert(len(tp.statements) == 1) st = tp.statements[0] assert(is_phosphorylation(st)) assert(st.enz is not None) assert(st.enz.name == 'RAF') assert(st.sub is not None) assert(st.sub.name == 'MAP2K1') assert(st.mod == 'Phosphorylation') os.remove(fname)
def test_complex_bind2(): fname = sys._getframe().f_code.co_name + '.xml' txt = 'RAF binds to the RAS-GTP complex.' tp = trips_api.process_text(txt, fname, False) assert(len(tp.statements) == 1) st = tp.statements[0] assert(is_complex(st)) assert(len(st.members) == 2) assert(st.members[0].name == 'RAF') assert(st.members[1].name == 'RAS') assert(len(st.members[1].bound_conditions) == 1) assert(st.members[1].bound_conditions[0].agent.name == 'GTP') os.remove(fname)
def test_act_mod(): fname = sys._getframe().f_code.co_name + '.xml' txt = 'MEK1, phosphorylated at Ser218 and Ser222, is activated.' tp = trips_api.process_text(txt, fname, False) assert(len(tp.statements) == 1) st = tp.statements[0] assert(is_actmod(st)) assert(st.monomer is not None) assert(st.monomer.name == 'MAP2K1') assert(st.monomer.mod == ['PhosphorylationSerine', 'PhosphorylationSerine']) assert(st.monomer.mod_pos == ['218', '222']) assert(st.relationship == 'increases') os.remove(fname)
def test_complex_bind(): fname = sys._getframe().f_code.co_name + '.xml' txt = 'The EGFR-EGF complex binds another EGFR-EGF complex.' tp = trips_api.process_text(txt, fname, False) assert(len(tp.statements) == 1) st = tp.statements[0] assert(is_complex(st)) assert(len(st.members) == 2) assert(has_hgnc_ref(st.members[0])) assert(has_hgnc_ref(st.members[1])) assert(st.members[0].bound_conditions) assert(st.members[1].bound_conditions) os.remove(fname)
def test_bound_phosphorylate(): fname = sys._getframe().f_code.co_name + '.xml' txt = 'RAF, bound to RAF, phosphorylates MEK1.' tp = trips_api.process_text(txt, fname, False) assert (len(tp.statements) == 1) st = tp.statements[0] assert (is_phosphorylation(st)) assert (st.enz is not None) assert (st.enz.name == 'RAF') assert (st.sub is not None) assert (st.sub.name == 'MAP2K1') assert (st.mod == 'Phosphorylation') os.remove(fname)
def test_complex_bind(): fname = sys._getframe().f_code.co_name + '.xml' txt = 'The EGFR-EGF complex binds another EGFR-EGF complex.' tp = trips_api.process_text(txt, fname, False) assert (len(tp.statements) == 1) st = tp.statements[0] assert (is_complex(st)) assert (len(st.members) == 2) assert (has_hgnc_ref(st.members[0])) assert (has_hgnc_ref(st.members[1])) assert (st.members[0].bound_conditions) assert (st.members[1].bound_conditions) os.remove(fname)
def test_transphosphorylate2(): fname = sys._getframe().f_code.co_name + '.xml' txt = 'EGFR, bound to EGFR, transphosphorylates itself on a tyrosine residue.' tp = trips_api.process_text(txt, fname, False) assert(len(tp.statements) == 1) st = tp.statements[0] assert(is_transphosphorylation(st)) assert(st.enz is not None) assert(st.enz.name == 'EGFR') assert(has_hgnc_ref(st.enz)) assert(st.mod == 'PhosphorylationTyrosine') assert(len(st.enz.bound_conditions) == 1) assert(st.enz.bound_conditions[0].agent.name == 'EGFR') os.remove(fname)
def test_transphosphorylate2(): fname = sys._getframe().f_code.co_name + '.xml' txt = 'EGFR, bound to EGFR, transphosphorylates itself on a tyrosine residue.' tp = trips_api.process_text(txt, fname, False) assert (len(tp.statements) == 1) st = tp.statements[0] assert (is_transphosphorylation(st)) assert (st.enz is not None) assert (st.enz.name == 'EGFR') assert (has_hgnc_ref(st.enz)) assert (st.mod == 'PhosphorylationTyrosine') assert (len(st.enz.bound_conditions) == 1) assert (st.enz.bound_conditions[0].agent.name == 'EGFR') os.remove(fname)
def test_bound_to3(): fname = sys._getframe().f_code.co_name + '.xml' txt = 'SOS1, bound to GRB2 binds RAS.' tp = trips_api.process_text(txt, fname, False) assert (len(tp.statements) == 1) st = tp.statements[0] assert (is_complex(st)) assert (len(st.members) == 2) assert (st.members[0].name == 'SOS1') assert (has_hgnc_ref(st.members[0])) assert (st.members[1].name == 'RAS') assert (len(st.members[0].bound_conditions) == 1) assert (st.members[0].bound_conditions[0].agent.name == 'GRB2') os.remove(fname)
def test_dephosphorylate(): fname = sys._getframe().f_code.co_name + '.xml' txt = 'DUSP6 dephosphorylates ERK2 at Tyr187.' tp = trips_api.process_text(txt, fname, False) assert(len(tp.statements) == 1) st = tp.statements[0] assert(is_dephosphorylation(st)) assert(st.enz is not None) assert(st.enz.name == 'DUSP6') assert(st.sub is not None) assert(st.sub.name == 'MAPK1') assert(st.mod == 'PhosphorylationTyrosine') assert(st.mod_pos == '187') os.remove(fname)
def test_bound_to3(): fname = sys._getframe().f_code.co_name + '.xml' txt = 'SOS1, bound to GRB2 binds RAS.' tp = trips_api.process_text(txt, fname, False) assert(len(tp.statements) == 1) st = tp.statements[0] assert(is_complex(st)) assert(len(st.members) == 2) assert(st.members[0].name == 'SOS1') assert(has_hgnc_ref(st.members[0])) assert(st.members[1].name == 'RAS') assert(len(st.members[0].bound_conditions) == 1) assert(st.members[0].bound_conditions[0].agent.name == 'GRB2') os.remove(fname)
def test_dephosphorylate(): fname = sys._getframe().f_code.co_name + '.xml' txt = 'DUSP6 dephosphorylates ERK2 at Tyr187.' tp = trips_api.process_text(txt, fname, False) assert (len(tp.statements) == 1) st = tp.statements[0] assert (is_dephosphorylation(st)) assert (st.enz is not None) assert (st.enz.name == 'DUSP6') assert (st.sub is not None) assert (st.sub.name == 'MAPK1') assert (st.mod == 'PhosphorylationTyrosine') assert (st.mod_pos == '187') os.remove(fname)
def text_to_sbgn(text=None, trips_xml=None): if ((text is None and trips_xml is None) or (text is not None and trips_xml is not None)): raise ValueError("Must provide ONE of 'text' or 'trips_xml'") elif text is not None: tp = trips_api.process_text(text) elif trips_xml is not None: tp = trips_api.process_xml(trips_xml) else: raise RuntimeError("Unexpected or impossible combination of arguments") sa = SBGNAssembler() sa.add_statements(tp.statements) sbgn_output = sa.make_model() return sbgn_output
def test_act_mod(): fname = sys._getframe().f_code.co_name + '.xml' txt = 'MEK1, phosphorylated at Ser218 and Ser222, is activated.' tp = trips_api.process_text(txt, fname, False) assert (len(tp.statements) == 1) st = tp.statements[0] assert (is_actmod(st)) assert (st.monomer is not None) assert (st.monomer.name == 'MAP2K1') assert (st.monomer.mod == [ 'PhosphorylationSerine', 'PhosphorylationSerine' ]) assert (st.monomer.mod_pos == ['218', '222']) assert (st.relationship == 'increases') os.remove(fname)
def test_not_bound_to(): fname = sys._getframe().f_code.co_name + '.xml' txt = 'BRAF that is not bound to Vemurafenib binds MEK1.' tp = trips_api.process_text(txt, fname, False) assert(len(tp.statements) == 1) st = tp.statements[0] assert(is_complex(st)) assert(len(st.members) == 2) assert(st.members[0].name == 'BRAF') assert(has_hgnc_ref(st.members[0])) assert(st.members[1].name == 'MAP2K1') assert(has_hgnc_ref(st.members[1])) assert(len(st.members[0].bound_conditions) == 1) assert(st.members[0].bound_conditions[0].agent.name.lower() == 'vemurafenib') assert(st.members[0].bound_conditions[0].is_bound == False) os.remove(fname)
def test_not_bound_to(): fname = sys._getframe().f_code.co_name + '.xml' txt = 'BRAF that is not bound to Vemurafenib binds MEK1.' tp = trips_api.process_text(txt, fname, False) assert (len(tp.statements) == 1) st = tp.statements[0] assert (is_complex(st)) assert (len(st.members) == 2) assert (st.members[0].name == 'BRAF') assert (has_hgnc_ref(st.members[0])) assert (st.members[1].name == 'MAP2K1') assert (has_hgnc_ref(st.members[1])) assert (len(st.members[0].bound_conditions) == 1) assert ( st.members[0].bound_conditions[0].agent.name.lower() == 'vemurafenib') assert (st.members[0].bound_conditions[0].is_bound == False) os.remove(fname)
def test_not_bound_to2(): fname = sys._getframe().f_code.co_name + '.xml' txt = 'BRAF, not bound to Vemurafenib, phosphorylates MEK1.' tp = trips_api.process_text(txt, fname, False) assert(len(tp.statements) == 1) st = tp.statements[0] assert(is_phosphorylation(st)) assert(st.enz is not None) assert(st.sub is not None) assert(st.enz.name == 'BRAF') assert(has_hgnc_ref(st.enz)) assert(st.sub.name == 'MAP2K1') assert(has_hgnc_ref(st.sub)) assert(len(st.enz.bound_conditions) == 1) assert(st.enz.bound_conditions[0].agent.name.lower() == 'vemurafenib') assert(st.enz.bound_conditions[0].is_bound == False) os.remove(fname)
def test_not_bound_to2(): fname = sys._getframe().f_code.co_name + '.xml' txt = 'BRAF, not bound to Vemurafenib, phosphorylates MEK1.' tp = trips_api.process_text(txt, fname, False) assert (len(tp.statements) == 1) st = tp.statements[0] assert (is_phosphorylation(st)) assert (st.enz is not None) assert (st.sub is not None) assert (st.enz.name == 'BRAF') assert (has_hgnc_ref(st.enz)) assert (st.sub.name == 'MAP2K1') assert (has_hgnc_ref(st.sub)) assert (len(st.enz.bound_conditions) == 1) assert (st.enz.bound_conditions[0].agent.name.lower() == 'vemurafenib') assert (st.enz.bound_conditions[0].is_bound == False) os.remove(fname)
def test_trips_processor_online(): """Smoke test to see if imports and executes without error. Doesn't check for correctness of parse or of assembled model.""" pa = PysbAssembler() tp = trips_api.process_text('BRAF phosphorylates MEK1 at Ser222.') pa.add_statements(tp.statements)
def make_statements(text): """Given text, return a list of INDRA statements.""" from indra.trips import trips_api tp = trips_api.process_text(text) return tp.statements
from indra.biopax import biopax_api from indra.trips import trips_api from indra_to_kami import nodes_to_kami, IndraKamiConverter import indra.statements import json # Get a biopax processor from a biopax query #bp = biopax_api.process_pc_pathsfromto(['BRAF'], ['MAP2K1']) #bp.get_phosphorylation() tp = trips_api.process_text('MEK2 phosphorylates ERK1 at Thr-202 and Tyr-204') ikc = IndraKamiConverter() nodes = set([]) # Collect the nodes to generate from the INDRA statements for stmt in tp.statements: if isinstance(stmt, indra.statements.Phosphorylation): new_nodes = ikc.phosphorylation(stmt) nodes.update(new_nodes) # Create the JSON output output = nodes_to_kami(nodes) json_str = json.dumps(output, indent=2) with open('indra_to_kami_example1.json', 'w') as f: f.write(json_str)
def make_statements(text): from indra.trips import trips_api tp = trips_api.process_text(text) return tp.statements