def test_evidence_assembly(): ev1 = Evidence(pmid='1') ev2 = Evidence(pmid='2') ev3 = Evidence(pmid='3') Evidence(pmid='4') st1 = Activation(Agent('a'), Agent('b'), evidence=[ev1]) st2 = Inhibition(Agent('a'), Agent('c'), evidence=[ev1, ev2, ev3]) sa = SifAssembler([st1, st2]) sa.make_model() assert len(sa.graph.nodes()) == 3 assert len(sa.graph.edges()) == 2 sa.set_edge_weights('support_pmid')
from indra.util import _require_python3 from indra.assemblers.sif import SifAssembler import indra.tools.assemble_corpus as ac stmts = ac.load_statements('output/preassembled.pkl') stmts = ac.filter_belief(stmts, 0.95) stmts = ac.filter_direct(stmts) sa = SifAssembler(stmts) sa.make_model(True, True, False) sa.set_edge_weights('support_all') fname = 'model_high_belief_v2.sif' with open(fname, 'wt') as fh: for s, t, d in sa.graph.edges(data=True): source = sa.graph.nodes[s]['name'] target = sa.graph.nodes[t]['name'] fh.write('%s %f %s\n' % (source, d['weight'], target))