def test_get_matching_statements(): braf = sts.Agent('BRAF', db_refs={'HGNC': '1097'}) matching = {} for fplx in ['BE', 'FPLX']: raf = sts.Agent('RAF', db_refs={fplx: 'RAF'}) map2k1 = sts.Agent('MAP2K1', db_refs={'HGNC': '6840'}) mek = sts.Agent('MEK', db_refs={fplx: 'MEK'}) stmts = [ sts.Phosphorylation(braf, mek), sts.Phosphorylation(raf, map2k1) ] stmt_ref = sts.Phosphorylation(braf, map2k1) matching[fplx] = _get_matching_stmts(stmts, stmt_ref) assert any([len(matching[fplx]) == 2 for fplx in ['BE', 'FPLX']]),\ "Expected 2 matching for at least one name, got matching: %s" % (matching)
def test_respond_expand_model_from_json(): mm = MRA_Module(testing=True) st = sts.Phosphorylation(sts.Agent('MEK'), sts.Agent('ERK')) msg = KQMLList('BUILD-MODEL') msg.sets('description', json.dumps(sts.stmts_to_json([st]))) msg.sets('format', 'indra_json') reply = mm.respond_build_model(msg) assert (reply.get('model')) assert (reply.get('model-id') == '1') st = sts.Phosphorylation(sts.Agent('RAF'), sts.Agent('MEK')) msg = KQMLList('EXPAND-MODEL') msg.sets('description', json.dumps(sts.stmts_to_json([st]))) msg.sets('format', 'indra_json') msg.set('model-id', '1') reply = mm.respond_expand_model(msg) assert (reply.get('model')) assert (reply.get('model-id') == '2')
def test_get_matching_statements(): braf = sts.Agent('BRAF', db_refs={'HGNC': '1097'}) map2k1 = sts.Agent('MAP2K1', db_refs={'HGNC': '6840'}) stmt_ref = sts.Phosphorylation(braf, map2k1) idp = _get_matching_stmts(stmt_ref) matching = idp.statements assert len(matching) > 1, \ "Expected > 1 matching, got matching: %s" % matching
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_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_get_matching_statements(): if not CAN_CHECK_STATEMENTS: raise SkipTest("Database api not accessible.") braf = sts.Agent('BRAF', db_refs={'HGNC': '1097'}) map2k1 = sts.Agent('MAP2K1', db_refs={'HGNC': '6840'}) stmt_ref = sts.Phosphorylation(braf, map2k1) idp = _get_matching_stmts(stmt_ref) matching = idp.statements assert len(matching) > 1, \ "Expected > 1 matching, got matching: %s" % matching