def test_make_cm(): m = MRA() ekb = ekb_from_text('MEK binds MAPK1. MEK binds MAPK3.') res = m.build_model_from_ekb(ekb) pysb_model = res['model_exec'] cm = make_contact_map(pysb_model) assert len(list(cm.nodes())) == 3 assert len(list(cm.edges())) == 2
def test_make_im(): m = MRA() ekb = ekb_from_text('KRAS activates BRAF. Active BRAF binds MEK.') res = m.build_model_from_ekb(ekb) pysb_model = res['model_exec'] im = make_influence_map(pysb_model) assert len(list(im.nodes())) == 3 assert len(list(im.edges())) == 3
def test_model_undo(): m = MRA() stmts1 = [sts.Phosphorylation(sts.Agent('A'), sts.Agent('B'))] m.new_model(stmts1) res = m.model_undo() action = res.get('action') assert action is not None assert action.get('action') == 'remove_stmts' assert action.get('statements') == stmts1
def test_get_upstream(): m = MRA() egfr = sts.Agent('EGFR', db_refs={'HGNC': '3236', 'TEXT': 'EGFR'}) kras = sts.Agent('KRAS', db_refs={'HGNC': '6407', 'TEXT': 'KRAS'}) stmts = [sts.Activation(egfr, kras)] model_id = m.new_model(stmts) upstream = m.get_upstream(kras, model_id) assert(len(upstream) == 1) assert(upstream[0].name == 'EGFR')
def test_build_model_from_ekb(): m = MRA() ekb = ekb_from_text('MAP2K1 phosphorylates MAPK1.') res = m.build_model_from_ekb(ekb) assert(res.get('model')) assert(res.get('model_id') == 1) assert(res.get('model_exec')) assert(len(m.models[1]) == 1) assert(isinstance(m.models[1][0], sts.Phosphorylation)) assert(m.models[1][0].enz.name == 'MAP2K1')
def test_make_diagrams(): m = MRA() ekb = ekb_from_text('KRAS activates BRAF. Active BRAF binds MEK.') res = m.build_model_from_ekb(ekb) diagrams = res['diagrams'] assert diagrams['reactionnetwork'] assert diagrams['reactionnetwork'].endswith('.png') assert diagrams['contactmap'] assert diagrams['contactmap'].endswith('.png') assert diagrams['influencemap'] assert diagrams['influencemap'].endswith('.png')
def test_expand_model_from_ekb(): m = MRA() ekb = ekb_from_text('MAP2K1 phosphorylates MAPK1.') res = m.build_model_from_ekb(ekb) model_id = res.get('model_id') assert(res.get('model')) assert(res.get('model_id') == 1) assert(len(m.models[1]) == 1) ekb = ekb_from_text('MAP2K2 phosphorylates MAPK1.') res = m.expand_model_from_ekb(ekb, model_id) assert(res.get('model')) assert(res.get('model_id') == 2) assert(len(m.models[2]) == 2)
def test_sbgn(): m = MRA() ekb = ekb_from_text('KRAS activates BRAF.') res = m.build_model_from_ekb(ekb) ekb = ekb_from_text('NRAS activates BRAF.') res = m.expand_model_from_ekb(ekb, 1) sbgn = res['diagrams']['sbgn'] tree = ET.fromstring(sbgn) glyphs = tree.findall('s:map/s:glyph', namespaces={'s': 'http://sbgn.org/libsbgn/0.3'}) assert len(glyphs) == 6 res = m.model_undo() sbgn = res['diagrams']['sbgn'] tree = ET.fromstring(sbgn) glyphs = tree.findall('s:map/s:glyph', namespaces={'s': 'http://sbgn.org/libsbgn/0.3'}) assert len(glyphs) == 4
def test_transformations(): m = MRA() stmts1 = [sts.Phosphorylation(sts.Agent('A'), sts.Agent('B'))] m.new_model(stmts1) assert(len(m.transformations) == 1) tr = m.transformations[0] assert(tr[0] == 'add_stmts') assert(tr[1] == stmts1) assert(tr[2] is None) assert(tr[3] == 1) stmts2 = [sts.Phosphorylation(sts.Agent('C'), sts.Agent('D'))] m.extend_model(stmts2, 1) assert(len(m.transformations) == 2) tr = m.transformations[1] assert(tr[0] == 'add_stmts') assert(tr[1] == stmts2) assert(tr[2] == 1) assert(tr[3] == 2)
def test_has_mechanism(): m = MRA() stmtsj = json.dumps(stmts_json_from_text('BRAF binds MEK')) m.build_model_from_json(stmtsj) has_mechanism = m.has_mechanism(stmtsj, 1) assert has_mechanism
def test_has_mechanism(): m = MRA() ekb = ekb_from_text('BRAF binds MEK') m.build_model_from_ekb(ekb) has_mechanism = m.has_mechanism(ekb, 1) assert (has_mechanism)