def test_prune_influence_map(): kin = Agent('Kin', db_refs={'HGNC': '1'}) phos = Agent('Phos', db_refs={'HGNC': '2'}) subs = Agent('Substrate', db_refs={'HGNC': '3'}) st1 = Phosphorylation(kin, subs) st2 = Dephosphorylation(phos, subs) pa = PysbAssembler() pa.add_statements([st1, st2]) pa.make_model(policies='one_step') mc = ModelChecker(pa.model, [st1]) mc.prune_influence_map() im = mc.get_im() assert len(im.nodes()) == 3 assert len(im.edges()) == 2
with open('korkut_pysb.pkl', 'wb') as f: print("Pickling PySB model") pickle.dump(pa.model, f) """ with open('korkut_pysb.pkl', 'rb') as f: print("Unpickling PySB model") model = pickle.load(f) # Preprocess and assemble the pysb model #model = assemble_pysb(combined_stmts, data_genes, '') rerun = True if rerun: mc = ModelChecker(model, all_data_stmts, agent_obs) mc.prune_influence_map() # Iterate over each drug/ab statement subset results = [] for drug_name, ab_dict in data_stmts.items(): agent_values = agent_data[drug_name] for ab, stmt_list in ab_dict.items(): value = data_values[drug_name][ab] # For each subset, check statements; if any of them checks # out, we're good and can move on to the next group print("-- Checking the effect of %s on %s --" % (drug_name, ab)) relation = 'positive' if value > 1 else 'negative' path_found = 0 paths = [] for stmt in stmt_list: print("Checking: %s" % stmt)