def test_filter_source(): ev1 = Evidence(source_api='bel') ev2 = Evidence(source_api='biopax') ev3 = Evidence(source_api='reach') st1 = Activation(Agent('a'), Agent('b'), evidence=[ev3]) st2 = Activation(Agent('a'), Agent('b'), evidence=[ev1, ev2]) st3 = Activation(Agent('a'), Agent('b'), evidence=[ev1, ev3]) st_out = ac.filter_evidence_source([st1, st2], ['reach'], 'one') assert len(st_out) == 1 st_out = ac.filter_evidence_source([st1, st2, st3], ['reach'], 'all') assert (len(st_out) == 2) st_out = ac.filter_evidence_source([st1, st2, st3], ['bel', 'biopax'], 'one') assert (len(st_out) == 2) st_out = ac.filter_evidence_source([st1, st2, st3], ['bel', 'biopax'], 'all') assert (len(st_out) == 1) st_out = ac.filter_evidence_source([st1, st2, st3], ['bel', 'biopax'], 'none') assert (len(st_out) == 1)
def test_filter_source(): ev1 = Evidence(source_api='bel') ev2 = Evidence(source_api='biopax') ev3 = Evidence(source_api='reach') st1 = Activation(Agent('a'), Agent('b'), evidence=[ev3]) st2 = Activation(Agent('a'), Agent('b'), evidence=[ev1, ev2]) st3 = Activation(Agent('a'), Agent('b'), evidence=[ev1, ev3]) st_out = ac.filter_evidence_source([st1, st2], ['reach'], 'one') assert (len(st_out) == 1) st_out = ac.filter_evidence_source([st1, st2, st3], ['reach'], 'all') assert (len(st_out) == 2) st_out = ac.filter_evidence_source([st1, st2, st3], ['bel', 'biopax'], 'one') assert (len(st_out) == 2) st_out = ac.filter_evidence_source([st1, st2, st3], ['bel', 'biopax'], 'all') assert (len(st_out) == 1) st_out = ac.filter_evidence_source([st1, st2, st3], ['bel', 'biopax'], 'none') assert (len(st_out) == 1)
logger.info('Loading original model.') inc_model_file = os.path.join(model_path, model_name, 'model.pkl') model = IncrementalModel(inc_model_file) # Include search genes as prior genes model.prior_genes = search_genes stats = {} logger.info(time.strftime('%c')) logger.info('Preassembling original model.') model.preassemble(filters=global_filters) logger.info(time.strftime('%c')) # Original statistics stats['orig_stmts'] = len(model.get_statements()) stats['orig_assembled'] = len(model.assembled_stmts) db_stmts = ac.filter_evidence_source(model.assembled_stmts, ['biopax', 'bel'], policy='one') no_db_stmts = ac.filter_evidence_source(model.assembled_stmts, ['biopax', 'bel'], policy='none') no_db_stmts = ac.filter_belief(no_db_stmts, belief_threshold) orig_stmts = db_stmts + no_db_stmts stats['orig_final'] = len(orig_stmts) logger.info('%d final statements' % len(orig_stmts)) # Extend the model with PMIDs logger.info('----------------') logger.info(time.strftime('%c')) logger.info('Extending model.') stats['new_papers'], stats['new_abstracts'], stats['existing'] = \ extend_model(model_name, model, pmids)