Beispiel #1
0
def test_distinguish_path_polarity2():
    """Test the ability to distinguish a positive from a negative regulation."""
    Monomer('A')
    Monomer('B', ['act'], {'act': ['y', 'n']})
    Monomer('C', ['T185'], {'T185': ['u', 'p']})
    Parameter('k', 1)
    Rule('A_inhibit_B', A() + B(act='y') >> A() + B(act='n'), k)
    Rule('B_dephos_C', B(act='y') + C(T185='p') >> B(act='y') + C(T185='u'), k)
    Initial(A(), k)
    Initial(B(act='y'), k)
    Initial(C(T185='p'), k)
    Annotation(A, 'http://identifiers.org/hgnc/HGNC:1')
    Annotation(B, 'http://identifiers.org/hgnc/HGNC:2')
    Annotation(C, 'http://identifiers.org/hgnc/HGNC:3')
    Annotation('A_inhibit_B', 'A', 'rule_has_subject')
    Annotation('A_inhibit_B', 'B', 'rule_has_object')
    Annotation('B_dephos_C', 'B', 'rule_has_subject')
    Annotation('B_dephos_C', 'C', 'rule_has_object')
    C.site_annotations = [
        Annotation(('T185', 'p'), 'phosphorylation', 'is_modification'),
        Annotation('T185', 'T', 'is_residue'),
        Annotation('T185', '185', 'is_position'),
    ]
    # Create the model checker
    stmts = _path_polarity_stmt_list()
    mc = ModelChecker(model, stmts)
    results = mc.check_model()
    assert len(results) == len(stmts)
    assert isinstance(results[0], tuple)
    assert results[0][1] == True
    assert results[1][1] == False
    assert results[2][1] == True
    assert results[3][1] == True
Beispiel #2
0
def test_one_step_phosphorylation():
    # Create the statement
    a = Agent('A', db_refs={'HGNC':'1'})
    b = Agent('B', db_refs={'HGNC':'2'})
    st = Phosphorylation(a, b, 'T', '185')
    # Now create the PySB model
    Monomer('A')
    Monomer('B', ['T185'], {'T185':['u', 'p']})
    Rule('A_phos_B', A() + B(T185='u') >> A() + B(T185='p'),
         Parameter('k', 1))
    Initial(A(), Parameter('A_0', 100))
    Initial(B(T185='u'), Parameter('B_0', 100))
    # Add annotations
    Annotation(A, 'http://identifiers.org/hgnc/HGNC:1')
    Annotation(B, 'http://identifiers.org/hgnc/HGNC:2')
    Annotation('A_phos_B', 'A', 'rule_has_subject')
    Annotation('A_phos_B', 'B', 'rule_has_object')
    B.site_annotations = [
        Annotation(('T185', 'p'), 'phosphorylation', 'is_modification'),
        Annotation('T185', 'T', 'is_residue'),
        Annotation('T185', '185', 'is_position'),
    ]
    mc = ModelChecker(model, [st])
    results = mc.check_model()
    assert len(results) == 1
    assert isinstance(results[0], tuple)
    assert results[0][0] == st
    assert results[0][1] == True
Beispiel #3
0
def test_one_step_phosphorylation():
    # Create the statement
    a = Agent('A', db_refs={'HGNC': '1'})
    b = Agent('B', db_refs={'HGNC': '2'})
    st = Phosphorylation(a, b, 'T', '185')
    # Now create the PySB model
    Monomer('A')
    Monomer('B', ['T185'], {'T185': ['u', 'p']})
    Rule('A_phos_B', A() + B(T185='u') >> A() + B(T185='p'), Parameter('k', 1))
    Initial(A(), Parameter('A_0', 100))
    Initial(B(T185='u'), Parameter('B_0', 100))
    # Add annotations
    Annotation(A, 'http://identifiers.org/hgnc/HGNC:1')
    Annotation(B, 'http://identifiers.org/hgnc/HGNC:2')
    Annotation('A_phos_B', 'A', 'rule_has_subject')
    Annotation('A_phos_B', 'B', 'rule_has_object')
    B.site_annotations = [
        Annotation(('T185', 'p'), 'phosphorylation', 'is_modification'),
        Annotation('T185', 'T', 'is_residue'),
        Annotation('T185', '185', 'is_position'),
    ]
    mc = ModelChecker(model, [st])
    results = mc.check_model()
    assert len(results) == 1
    assert isinstance(results[0], tuple)
    assert results[0][0] == st
    assert results[0][1] == True
Beispiel #4
0
def test_rasgap_rasgtp_phos():
    nf1 = Agent('NF1', db_refs={'HGNC': '1'})
    ras = Agent('KRAS', db_refs={'HGNC': '2'})
    ras_g = Agent('KRAS',
                  activity=ActivityCondition('gtpbound', True),
                  db_refs={'HGNC': '2'})
    raf = Agent('BRAF',
                activity=ActivityCondition('kinase', True),
                db_refs={'HGNC': '3'})
    mek = Agent('MEK', db_refs={'HGNC': '4'})
    rasgap_stmt = RasGap(nf1, ras)
    rasgtp_stmt = RasGtpActivation(ras_g, raf, 'kinase')
    phos = Phosphorylation(raf, mek)
    stmt_to_check = Dephosphorylation(nf1, mek)
    # Assemble and check
    pysba = PysbAssembler()
    pysba.add_statements([rasgap_stmt, rasgtp_stmt, phos])
    pysba.make_model(policies='one_step')
    mc = ModelChecker(pysba.model, [stmt_to_check])
    checks = mc.check_model()
    assert len(checks) == 1
    assert checks[0][0] == stmt_to_check
    assert checks[0][1].paths == [[('NF1_deactivates_KRAS', 1),
                                   ('KRAS_activates_BRAF_kinase', -1),
                                   ('BRAF_phosphorylation_MEK_phospho', -1),
                                   ('MEK_phospho_p_obs', -1)]]
Beispiel #5
0
def test_none_phosphorylation_stmt():
    # Create the statement
    b = Agent('B', db_refs={'HGNC': '2'})
    st1 = Phosphorylation(None, b, 'T', '185')
    st2 = Phosphorylation(None, b, 'Y', '187')
    stmts = [st1, st2]
    # Now create the PySB model
    Monomer('A')
    Monomer('B', ['T185', 'Y187'], {'T185': ['u', 'p'], 'Y187': ['u', 'p']})
    Rule('A_phos_B', A() + B(T185='u') >> A() + B(T185='p'), Parameter('k', 1))
    Initial(A(), Parameter('A_0', 100))
    Initial(B(T185='u', Y187='p'), Parameter('B_0', 100))
    Annotation(A, 'http://identifiers.org/hgnc/HGNC:1')
    Annotation(B, 'http://identifiers.org/hgnc/HGNC:2')
    B.site_annotations = [
        Annotation(('T185', 'p'), 'phosphorylation', 'is_modification'),
        Annotation('T185', 'T', 'is_residue'),
        Annotation('T185', '185', 'is_position'),
        Annotation(('Y187', 'p'), 'phosphorylation', 'is_modification'),
        Annotation('Y187', 'Y', 'is_residue'),
        Annotation('Y187', '187', 'is_position'),
    ]
    mc = ModelChecker(model, stmts)
    results = mc.check_model()
    assert len(results) == 2
    assert isinstance(results[0], tuple)
    assert results[0][0] == st1
    assert results[0][1] == True
    assert results[1][0] == st2
    assert results[1][1] == False
Beispiel #6
0
def test_distinguish_path_polarity2():
    """Test the ability to distinguish a positive from a negative regulation."""
    Monomer('A')
    Monomer('B', ['act'], {'act' :['y', 'n']})
    Monomer('C', ['T185'], {'T185':['u', 'p']})
    Parameter('k', 1)
    Rule('A_inhibit_B', A() + B(act='y') >> A() + B(act='n'), k)
    Rule('B_dephos_C', B(act='y') + C(T185='p') >>
                       B(act='y') + C(T185='u'), k)
    Initial(A(), k)
    Initial(B(act='y'), k)
    Initial(C(T185='p'), k)
    Annotation(A, 'http://identifiers.org/hgnc/HGNC:1')
    Annotation(B, 'http://identifiers.org/hgnc/HGNC:2')
    Annotation(C, 'http://identifiers.org/hgnc/HGNC:3')
    Annotation('A_inhibit_B', 'A', 'rule_has_subject')
    Annotation('A_inhibit_B', 'B', 'rule_has_object')
    Annotation('B_dephos_C', 'B', 'rule_has_subject')
    Annotation('B_dephos_C', 'C', 'rule_has_object')
    C.site_annotations = [
            Annotation(('T185', 'p'), 'phosphorylation', 'is_modification'),
            Annotation('T185', 'T', 'is_residue'),
            Annotation('T185', '185', 'is_position'),
        ]
    # Create the model checker
    stmts = _path_polarity_stmt_list()
    mc = ModelChecker(model, stmts)
    results = mc.check_model()
    assert len(results) ==  len(stmts)
    assert isinstance(results[0], tuple)
    assert results[0][1] == True
    assert results[1][1] == False
    assert results[2][1] == True
    assert results[3][1] == True
Beispiel #7
0
def test_none_phosphorylation_stmt():
    # Create the statement
    b = Agent('B', db_refs={'HGNC':'2'})
    st1 = Phosphorylation(None, b, 'T', '185')
    st2 = Phosphorylation(None, b, 'Y', '187')
    stmts = [st1, st2]
    # Now create the PySB model
    Monomer('A')
    Monomer('B', ['T185', 'Y187'], {'T185':['u', 'p'], 'Y187': ['u', 'p']})
    Rule('A_phos_B', A() + B(T185='u') >> A() + B(T185='p'),
         Parameter('k', 1))
    Initial(A(), Parameter('A_0', 100))
    Initial(B(T185='u', Y187='p'), Parameter('B_0', 100))
    Annotation(A, 'http://identifiers.org/hgnc/HGNC:1')
    Annotation(B, 'http://identifiers.org/hgnc/HGNC:2')
    B.site_annotations = [
        Annotation(('T185', 'p'), 'phosphorylation', 'is_modification'),
        Annotation('T185', 'T', 'is_residue'),
        Annotation('T185', '185', 'is_position'),
        Annotation(('Y187', 'p'), 'phosphorylation', 'is_modification'),
        Annotation('Y187', 'Y', 'is_residue'),
        Annotation('Y187', '187', 'is_position'),
    ]
    mc = ModelChecker(model, stmts)
    results = mc.check_model()
    assert len(results) == 2
    assert isinstance(results[0], tuple)
    assert results[0][0] == st1
    assert results[0][1] == True
    assert results[1][0] == st2
    assert results[1][1] == False
Beispiel #8
0
 def check_policy(policy, result):
     pysba = PysbAssembler()
     pysba.add_statements([stmt])
     pysba.make_model(policies=policy)
     mc = ModelChecker(pysba.model, [stmt])
     checks = mc.check_model()
     assert len(checks) == 1
     assert isinstance(checks[0], tuple)
     assert checks[0][0] == stmt
     assert checks[0][1] == result
Beispiel #9
0
 def check_policy(policy, result):
     pysba = PysbAssembler()
     pysba.add_statements([stmt])
     pysba.make_model(policies=policy)
     mc = ModelChecker(pysba.model, [stmt])
     checks = mc.check_model()
     assert len(checks) == 1
     assert isinstance(checks[0], tuple)
     assert checks[0][0] == stmt
     assert checks[0][1] == result
Beispiel #10
0
def test_pysb_assembler_phospho_policies():
    a = Agent('A', db_refs={'HGNC': '1'})
    b = Agent('B', db_refs={'HGNC': '2'})
    st = Phosphorylation(a, b, 'T', '185')
    pa = PysbAssembler()
    pa.add_statements([st])
    # Try two step
    pa.make_model(policies='two_step')
    mc = ModelChecker(pa.model, [st])
    results = mc.check_model()
    assert len(results) == 1
    assert isinstance(results[0], tuple)
    assert results[0][0] == st
    assert results[0][1] == True
    # Try one step
    pa.make_model(policies='one_step')
    mc = ModelChecker(pa.model, [st])
    results = mc.check_model()
    assert len(results) == 1
    assert isinstance(results[0], tuple)
    assert results[0][0] == st
    assert results[0][1] == True
    # Try interactions_only
    pa.make_model(policies='interactions_only')
    mc = ModelChecker(pa.model, [st])
    results = mc.check_model()
    assert len(results) == 1
    assert isinstance(results[0], tuple)
    assert results[0][0] == st
    assert results[0][1] == False
Beispiel #11
0
def test_consumption_rule():
    pvd = Agent('Pervanadate', db_refs={'HGNC': '1'})
    erk = Agent('MAPK1', db_refs={'HGNC': '2'})
    stmt = Phosphorylation(pvd, erk, 'T', '185')
    # Now make the model
    Monomer('Pervanadate', ['b'])
    Monomer('DUSP', ['b'])
    Monomer('MAPK1', ['b', 'T185'], {'T185': ['u', 'p']})
    Rule('Pvd_binds_DUSP',
         Pervanadate(b=None) + DUSP(b=None) >> Pervanadate(b=1) % DUSP(b=1),
         Parameter('k1', 1))
    Rule('Pvd_binds_DUSP_rev',
         Pervanadate(b=1) % DUSP(b=1) >> Pervanadate(b=None) + DUSP(b=None),
         Parameter('k2', 1))
    Rule(
        'DUSP_binds_MAPK1_phosT185',
        DUSP(b=None) + MAPK1(b=None, T185='p') >>
        DUSP(b=1) % MAPK1(b=1, T185='p'), Parameter('k3', 1))
    Rule(
        'DUSP_binds_MAPK1_phosT185_rev',
        DUSP(b=1) % MAPK1(b=1, T185='p') >>
        DUSP(b=None) + MAPK1(b=None, T185='p'), Parameter('k4', 1))
    Rule(
        'DUSP_dephos_MAPK1_at_T185',
        DUSP(b=1) % MAPK1(b=1, T185='p') >>
        DUSP(b=None) % MAPK1(b=None, T185='u'), Parameter('k5', 1))
    Annotation(Pervanadate, 'http://identifiers.org/hgnc/HGNC:1')
    Annotation(MAPK1, 'http://identifiers.org/hgnc/HGNC:2')
    Annotation('Pvd_binds_DUSP', 'Pervanadate', 'rule_has_subject')
    Annotation('Pvd_binds_DUSP', 'Pervanadate', 'rule_has_object')
    Annotation('Pvd_binds_DUSP', 'DUSP', 'rule_has_subject')
    Annotation('Pvd_binds_DUSP', 'DUSP', 'rule_has_object')
    Annotation('Pvd_binds_DUSP_rev', 'Pervanadate', 'rule_has_subject')
    Annotation('Pvd_binds_DUSP_rev', 'Pervanadate', 'rule_has_object')
    Annotation('Pvd_binds_DUSP_rev', 'DUSP', 'rule_has_subject')
    Annotation('Pvd_binds_DUSP_rev', 'DUSP', 'rule_has_object')
    Annotation('DUSP_dephos_MAPK1_at_T185', 'DUSP', 'rule_has_subject')
    Annotation('DUSP_dephos_MAPK1_at_T185', 'MAPK1', 'rule_has_object')
    MAPK1.site_annotations = [
        Annotation(('T185', 'p'), 'phosphorylation', 'is_modification'),
        Annotation('T185', 'T', 'is_residue'),
        Annotation('T185', '185', 'is_position'),
    ]
    # Now check the model against the statement
    mc = ModelChecker(model, [stmt])
    checks = mc.check_model()
    assert len(checks) == 1
    assert isinstance(checks[0], tuple)
    assert checks[0][0] == stmt
    pr = checks[0][1]
    assert pr.paths == [[('Pvd_binds_DUSP', 1),
                         ('DUSP_binds_MAPK1_phosT185', -1),
                         ('DUSP_dephos_MAPK1_at_T185', -1),
                         ('MAPK1_T185_p_obs', 1)]]
Beispiel #12
0
def test_consumption_rule():
    pvd = Agent('Pervanadate', db_refs={'HGNC': '1'})
    erk = Agent('MAPK1', db_refs={'HGNC': '2'})
    stmt = Phosphorylation(pvd, erk, 'T', '185')
    # Now make the model
    Monomer('Pervanadate', ['b'])
    Monomer('DUSP', ['b'])
    Monomer('MAPK1', ['b', 'T185'], {'T185': ['u', 'p']})
    Rule('Pvd_binds_DUSP',
         Pervanadate(b=None) + DUSP(b=None) >>
         Pervanadate(b=1) % DUSP(b=1),
         Parameter('k1', 1))
    Rule('Pvd_binds_DUSP_rev',
         Pervanadate(b=1) % DUSP(b=1) >>
         Pervanadate(b=None) + DUSP(b=None),
         Parameter('k2', 1))
    Rule('DUSP_binds_MAPK1_phosT185',
         DUSP(b=None) + MAPK1(b=None, T185='p') >>
         DUSP(b=1) % MAPK1(b=1, T185='p'),
         Parameter('k3', 1))
    Rule('DUSP_binds_MAPK1_phosT185_rev',
         DUSP(b=1) % MAPK1(b=1, T185='p') >>
         DUSP(b=None) + MAPK1(b=None, T185='p'),
         Parameter('k4', 1))
    Rule('DUSP_dephos_MAPK1_at_T185',
         DUSP(b=1) % MAPK1(b=1, T185='p') >>
         DUSP(b=None) % MAPK1(b=None, T185='u'),
         Parameter('k5', 1))
    Annotation(Pervanadate, 'http://identifiers.org/hgnc/HGNC:1')
    Annotation(MAPK1, 'http://identifiers.org/hgnc/HGNC:2')
    Annotation('Pvd_binds_DUSP', 'Pervanadate', 'rule_has_subject')
    Annotation('Pvd_binds_DUSP', 'Pervanadate', 'rule_has_object')
    Annotation('Pvd_binds_DUSP', 'DUSP', 'rule_has_subject')
    Annotation('Pvd_binds_DUSP', 'DUSP', 'rule_has_object')
    Annotation('Pvd_binds_DUSP_rev', 'Pervanadate', 'rule_has_subject')
    Annotation('Pvd_binds_DUSP_rev', 'Pervanadate', 'rule_has_object')
    Annotation('Pvd_binds_DUSP_rev', 'DUSP', 'rule_has_subject')
    Annotation('Pvd_binds_DUSP_rev', 'DUSP', 'rule_has_object')
    Annotation('DUSP_dephos_MAPK1_at_T185', 'DUSP', 'rule_has_subject')
    Annotation('DUSP_dephos_MAPK1_at_T185', 'MAPK1', 'rule_has_object')
    MAPK1.site_annotations = [
            Annotation(('T185', 'p'), 'phosphorylation', 'is_modification'),
            Annotation('T185', 'T', 'is_residue'),
            Annotation('T185', '185', 'is_position'),
        ]
    # Now check the model against the statement
    mc = ModelChecker(model, [stmt])
    checks = mc.check_model()
    assert len(checks) == 1
    assert isinstance(checks[0], tuple)
    assert checks[0][0] == stmt
    assert checks[0][1] == True
Beispiel #13
0
def test_check_ubiquitination():
    xiap = Agent('XIAP', db_refs={'HGNC': '592'})
    casp3 = Agent('CASP3', db_refs={'HGNC': '1504'})
    stmt = Ubiquitination(xiap, casp3)
    pysba = PysbAssembler()
    pysba.add_statements([stmt])
    pysba.make_model(policies='one_step')
    mc = ModelChecker(pysba.model, [stmt])
    checks = mc.check_model()
    assert len(checks) == 1
    assert isinstance(checks[0], tuple)
    assert checks[0][0] == stmt
    assert checks[0][1] == True
Beispiel #14
0
def test_check_ubiquitination():
    xiap = Agent('XIAP', db_refs={'HGNC': '592'})
    casp3 = Agent('CASP3', db_refs={'HGNC': '1504'})
    stmt = Ubiquitination(xiap, casp3)
    pysba = PysbAssembler()
    pysba.add_statements([stmt])
    pysba.make_model(policies='one_step')
    mc = ModelChecker(pysba.model, [stmt])
    checks = mc.check_model()
    assert len(checks) == 1
    assert isinstance(checks[0], tuple)
    assert checks[0][0] == stmt
    assert checks[0][1] == True
Beispiel #15
0
def test_check_rule_subject1():
    mek = Agent('MEK1', db_refs={'HGNC': '6840'})
    erk = Agent('ERK2', db_refs={'HGNC': '6871'})
    stmt = Phosphorylation(mek, erk)
    pysba = PysbAssembler()
    pysba.add_statements([stmt])
    pysba.make_model(policies='one_step')
    # Check against stmt: should not validate ERK phosphorylates ERK
    stmt_to_check = Phosphorylation(erk, erk)
    mc = ModelChecker(pysba.model, [stmt_to_check])
    checks = mc.check_model()
    assert len(checks) == 1
    assert checks[0][0] == stmt_to_check
    assert checks[0][1] == False
Beispiel #16
0
 def check_stmts(stmts):
     pa = PysbAssembler()
     pa.add_statements(stmts)
     pa.make_model(policies='one_step')
     stmts_to_check = [
             Activation(egfr, kras, 'gtpbound'),
             Activation(egfr, braf, 'kinase')
         ]
     mc = ModelChecker(pa.model, stmts_to_check)
     results = mc.check_model()
     assert len(results) == len(stmts_to_check)
     assert isinstance(results[0], tuple)
     assert results[0][1] == True
     assert results[1][1] == True
Beispiel #17
0
 def check_stmts(stmts):
     pa = PysbAssembler()
     pa.add_statements(stmts)
     pa.make_model(policies='one_step')
     stmts_to_check = [
         Activation(egfr, kras, 'gtpbound'),
         Activation(egfr, braf, 'kinase')
     ]
     mc = ModelChecker(pa.model, stmts_to_check)
     results = mc.check_model()
     assert len(results) == len(stmts_to_check)
     assert isinstance(results[0], tuple)
     assert results[0][1] == True
     assert results[1][1] == True
Beispiel #18
0
def test_check_rule_subject1():
    mek = Agent('MEK1', db_refs={'HGNC': '6840'})
    erk = Agent('ERK2', db_refs={'HGNC': '6871'})
    stmt = Phosphorylation(mek, erk)
    pysba = PysbAssembler()
    pysba.add_statements([stmt])
    pysba.make_model(policies='one_step')
    # Check against stmt: should not validate ERK phosphorylates ERK
    stmt_to_check = Phosphorylation(erk, erk)
    mc = ModelChecker(pysba.model, [stmt_to_check])
    checks = mc.check_model()
    assert len(checks) == 1
    assert checks[0][0] == stmt_to_check
    assert checks[0][1] == False
Beispiel #19
0
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
Beispiel #20
0
def test_activation_annotations():
    # Create the statement
    a = Agent('MEK1', db_refs={'HGNC': '6840'})
    b = Agent('ERK2', db_refs={'HGNC': '6871'})
    st1 = Phosphorylation(a, b, 'T', '185')
    st2 = Activation(a, b)
    st3 = Activation(a, b, 'kinase')
    # Now create the PySB model
    Monomer('A_monomer')
    Monomer('B_monomer', ['Thr185', 'Y187'], {
        'Thr185': ['un', 'phos'],
        'Y187': ['u', 'p']
    })
    Rule(
        'A_phos_B',
        A_monomer() + B_monomer(Thr185='un') >>
        A_monomer() + B_monomer(Thr185='phos'), Parameter('k', 1))
    Initial(A_monomer(), Parameter('A_0', 100))
    Initial(B_monomer(Thr185='un', Y187='u'), Parameter('B_0', 100))
    # Add agent grounding
    Annotation(A_monomer, 'http://identifiers.org/hgnc/HGNC:6840')
    Annotation(B_monomer, 'http://identifiers.org/hgnc/HGNC:6871')
    Annotation(B_monomer, {'Thr185': 'phos'}, 'has_active_pattern')
    Annotation('A_phos_B', 'A_monomer', 'rule_has_subject')
    Annotation('A_phos_B', 'B_monomer', 'rule_has_object')
    # Add annotations to the sites/states of the Monomer itself
    B_annot = [
        Annotation('Thr185', 'T', 'is_residue'),
        Annotation('Thr185', '185', 'is_position'),
        Annotation(('Thr185', 'phos'), 'phosphorylation', 'is_modification'),
        Annotation('Y187', 'Y', 'is_residue'),
        Annotation('Y187', '187', 'is_position'),
        Annotation(('Y187', 'p'), 'phosphorylation', 'is_modification'),
    ]
    B_monomer.site_annotations = B_annot
    mc = ModelChecker(model, [st1, st2, st3])
    results = mc.check_model()
    assert len(results) == 3
    assert isinstance(results[0], tuple)
    assert results[0][0] == st1
    assert results[0][1].paths == [[('A_phos_B', 1),
                                    ('B_monomer_Thr185_phos_obs', 1)]]
    assert results[1][0] == st2
    assert results[1][1].paths == [[('A_phos_B', 1),
                                    ('B_monomer_Thr185_phos_obs', 1)]]
    assert results[2][0] == st3
    assert results[1][1].paths == [[('A_phos_B', 1),
                                    ('B_monomer_Thr185_phos_obs', 1)]]
Beispiel #21
0
def test_activate_via_mod():
    mek = Agent('MEK1', db_refs={'HGNC': '6840'})
    erk = Agent('ERK2', db_refs={'HGNC': '6871'})
    erka = Agent('ERK2',
                 mods=[ModCondition('phosphorylation', 'T', '185')],
                 db_refs={'HGNC': '6871'})
    st1 = Phosphorylation(mek, erk, 'T', '185')
    st2 = ActiveForm(erka, 'activity', True)
    st3 = Activation(mek, erk)
    pa = PysbAssembler()
    pa.add_statements([st1, st2])
    pa.make_model()
    mc = ModelChecker(pa.model, [st3])
    checks = mc.check_model()
    # Make sure it checks out to True
    assert (checks[0][1].path_found)
Beispiel #22
0
def test_rasgap_activation():
    nf1 = Agent('NF1', db_refs={'HGNC':'1'})
    ras = Agent('KRAS', db_refs={'HGNC':'2'})
    rasgap_stmt = RasGap(nf1, ras)
    act_stmt = Inhibition(nf1, ras, 'gtpbound')
    # Check that the activation is satisfied by the RasGap
    pysba = PysbAssembler()
    pysba.add_statements([rasgap_stmt])
    pysba.make_model(policies='one_step')
    mc = ModelChecker(pysba.model, [act_stmt])
    checks = mc.check_model()
    assert len(checks) == 1
    assert checks[0][0] == act_stmt
    assert checks[0][1] == True
    # TODO TODO TODO
    """
Beispiel #23
0
def test_rasgap_activation():
    nf1 = Agent('NF1', db_refs={'HGNC': '1'})
    ras = Agent('KRAS', db_refs={'HGNC': '2'})
    rasgap_stmt = RasGap(nf1, ras)
    act_stmt = Inhibition(nf1, ras, 'gtpbound')
    # Check that the activation is satisfied by the RasGap
    pysba = PysbAssembler()
    pysba.add_statements([rasgap_stmt])
    pysba.make_model(policies='one_step')
    mc = ModelChecker(pysba.model, [act_stmt])
    checks = mc.check_model()
    assert len(checks) == 1
    assert checks[0][0] == act_stmt
    assert checks[0][1] == True
    # TODO TODO TODO
    """
Beispiel #24
0
def test_check_activation():
    a = Agent('A')
    b = Agent('B')
    c = Agent('C')
    st1 = Activation(a, b)
    st2 = Inhibition(b, c, 'kinase')
    stmts = [st1, st2]
    # Create the model
    pa = PysbAssembler()
    pa.add_statements(stmts)
    pa.make_model(policies='one_step')
    mc = ModelChecker(pa.model, stmts)
    results = mc.check_model()
    assert len(results) == len(stmts)
    assert isinstance(results[0], tuple)
    assert results[0][1] == True
    assert results[1][1] == True
Beispiel #25
0
def test_rasgef_rasgtp():
    sos = Agent('SOS1', db_refs={'HGNC':'1'})
    ras = Agent('KRAS', activity=ActivityCondition('gtpbound', True),
                db_refs={'HGNC':'2'})
    raf = Agent('BRAF', db_refs={'HGNC':'3'})
    rasgef_stmt = RasGef(sos, ras)
    rasgtp_stmt = RasGtpActivation(ras, raf, 'kinase')
    act_stmt = Activation(sos, raf, 'kinase')
    # Check that the activation is satisfied by the RasGef
    pysba = PysbAssembler()
    pysba.add_statements([rasgef_stmt, rasgtp_stmt])
    pysba.make_model(policies='one_step')
    mc = ModelChecker(pysba.model, [act_stmt])
    checks = mc.check_model()
    assert len(checks) == 1
    assert checks[0][0] == act_stmt
    assert checks[0][1] == True
Beispiel #26
0
def test_check_activation():
    a = Agent('A')
    b = Agent('B')
    c = Agent('C')
    st1 = Activation(a, b)
    st2 = Inhibition(b, c, 'kinase')
    stmts = [st1, st2]
    # Create the model
    pa = PysbAssembler()
    pa.add_statements(stmts)
    pa.make_model(policies='one_step')
    mc = ModelChecker(pa.model, stmts)
    results = mc.check_model()
    assert len(results) ==  len(stmts)
    assert isinstance(results[0], tuple)
    assert results[0][1] == True
    assert results[1][1] == True
Beispiel #27
0
def test_rasgef_activation():
    sos = Agent('SOS1', db_refs={'HGNC': '1'})
    ras = Agent('KRAS', db_refs={'HGNC': '2'})
    rasgef_stmt = RasGef(sos, ras)
    act_stmt = Activation(sos, ras, 'gtpbound')
    # Check that the activation is satisfied by the RasGef
    pysba = PysbAssembler()
    pysba.add_statements([rasgef_stmt])
    pysba.make_model(policies='one_step')
    mc = ModelChecker(pysba.model, [act_stmt])
    checks = mc.check_model()
    assert len(checks) == 1
    assert checks[0][0] == act_stmt
    assert checks[0][1].paths == [[('SOS1_activates_KRAS', 1),
                                   ('KRAS_gtpbound_active_obs', 1)]]
    # TODO TODO TODO
    """
Beispiel #28
0
def test_observables():
    mek = Agent('MEK1', db_refs={'HGNC': '6840'})
    erk = Agent('ERK2', db_refs={'HGNC': '6871'})
    erkp = Agent('ERK2',
                 mods=[ModCondition('phosphorylation', 'T', '185')],
                 db_refs={'HGNC': '6871'})
    st1 = Phosphorylation(mek, erk, 'T', '185')
    st2 = ActiveForm(erkp, 'activity', True)
    st3 = Activation(mek, erk)
    pa = PysbAssembler()
    pa.add_statements([st1, st2])
    pa.make_model()
    mc = ModelChecker(pa.model, [st1, st3], agent_obs=[erkp])
    checks = mc.check_model()
    assert checks[0][1].path_found
    assert checks[1][1].path_found
    # Only 1 observable should be created
    assert len(mc.model.observables) == 1
Beispiel #29
0
def test_rasgef_rasgtp():
    sos = Agent('SOS1', db_refs={'HGNC': '1'})
    ras = Agent('KRAS',
                activity=ActivityCondition('gtpbound', True),
                db_refs={'HGNC': '2'})
    raf = Agent('BRAF', db_refs={'HGNC': '3'})
    rasgef_stmt = RasGef(sos, ras)
    rasgtp_stmt = RasGtpActivation(ras, raf, 'kinase')
    act_stmt = Activation(sos, raf, 'kinase')
    # Check that the activation is satisfied by the RasGef
    pysba = PysbAssembler()
    pysba.add_statements([rasgef_stmt, rasgtp_stmt])
    pysba.make_model(policies='one_step')
    mc = ModelChecker(pysba.model, [act_stmt])
    checks = mc.check_model()
    assert len(checks) == 1
    assert checks[0][0] == act_stmt
    assert checks[0][1] == True
Beispiel #30
0
def test_grounded_modified_enzyme():
    """Check if the model checker can use semantic annotations to match mods
    on the enzyme, not just the substrate, of a phosphorylation statement."""
    mek_s202 = Agent('MEK1', mods=[ModCondition('phosphorylation', 'S', '202')],
                     db_refs={'HGNC': '6840'})
    mek_phos = Agent('MEK1', mods=[ModCondition('phosphorylation', None, None)],
                     db_refs={'HGNC': '6840'})
    erk = Agent('ERK2', db_refs={'HGNC': '6871'})
    stmt_to_model = Phosphorylation(mek_s202, erk, None, None)
    stmt_to_check = Phosphorylation(mek_phos, erk, None, None)
    pa = PysbAssembler()
    pa.add_statements([stmt_to_model])
    pa.make_model(policies='one_step')
    mc = ModelChecker(pa.model, [stmt_to_check])
    results = mc.check_model()
    assert len(results) == 1
    assert results[0][0] == stmt_to_check
    assert results[0][1] == True
Beispiel #31
0
def test_two_step_phosphorylation():
    # Create the statement
    a = Agent('A', db_refs={'HGNC': '1'})
    b = Agent('B', db_refs={'HGNC': '2'})
    st = Phosphorylation(a, b, 'T', '185')
    # Now create the PySB model
    Monomer('A', ['b', 'other'], {'other': ['u', 'p']})
    Monomer('B', ['b', 'T185'], {'T185': ['u', 'p']})
    Rule('A_bind_B',
         A(b=None) + B(b=None, T185='u') >> A(b=1) % B(b=1, T185='u'),
         Parameter('kf', 1))
    Rule('A_bind_B_rev',
         A(b=1) % B(b=1, T185='u') >> A(b=None) + B(b=None, T185='u'),
         Parameter('kr', 1))
    Rule('A_phos_B',
         A(b=1) % B(b=1, T185='u') >> A(b=None) + B(b=None, T185='p'),
         Parameter('kcat', 1))
    Initial(A(b=None, other='p'), Parameter('Ap_0', 100))
    Initial(A(b=None, other='u'), Parameter('Au_0', 100))
    Initial(B(b=None, T185='u'), Parameter('B_0', 100))
    # Add annotations
    Annotation(A, 'http://identifiers.org/hgnc/HGNC:1')
    Annotation(B, 'http://identifiers.org/hgnc/HGNC:2')
    Annotation('A_phos_B', 'A', 'rule_has_subject')
    Annotation('A_phos_B', 'B', 'rule_has_object')
    B.site_annotations = [
        Annotation(('T185', 'p'), 'phosphorylation', 'is_modification'),
        Annotation('T185', 'T', 'is_residue'),
        Annotation('T185', '185', 'is_position'),
    ]
    #with open('model_rxn.dot', 'w') as f:
    #    f.write(render_reactions.run(model))
    #with open('species_2step.dot', 'w') as f:
    #    f.write(species_graph.run(model))
    #generate_equations(model)
    # Now check the model
    mc = ModelChecker(model, [st])
    results = mc.check_model()
    assert len(results) == 1
    assert isinstance(results[0], tuple)
    assert results[0][0] == st
    pr = results[0][1]
    assert pr.paths == [[('A_phos_B', 1), ('B_T185_p_obs', 1)]]
Beispiel #32
0
def test_rasgef_rasgtp_phos():
    sos = Agent('SOS1', db_refs={'HGNC':'1'})
    ras = Agent('KRAS', activity=ActivityCondition('gtpbound', True),
                db_refs={'HGNC':'2'})
    raf = Agent('BRAF', db_refs={'HGNC':'3'})
    mek = Agent('MEK', db_refs={'HGNC': '4'})
    rasgef_stmt = RasGef(sos, ras)
    rasgtp_stmt = RasGtpActivation(ras, raf, 'kinase')
    phos = Phosphorylation(raf, mek)
    stmt_to_check = Phosphorylation(sos, mek)
    # Assemble and check
    pysba = PysbAssembler()
    pysba.add_statements([rasgef_stmt, rasgtp_stmt, phos])
    pysba.make_model(policies='one_step')
    mc = ModelChecker(pysba.model, [stmt_to_check])
    checks = mc.check_model()
    assert len(checks) == 1
    assert checks[0][0] == stmt_to_check
    assert checks[0][1] == True
Beispiel #33
0
def test_check_activation():
    a = Agent('A', db_refs={'HGNC': '1'})
    b = Agent('B', db_refs={'HGNC': '2'})
    c = Agent('C', db_refs={'HGNC': '3'})
    st1 = Activation(a, b)
    st2 = Inhibition(b, c, 'kinase')
    stmts = [st1, st2]
    # Create the model
    pa = PysbAssembler()
    pa.add_statements(stmts)
    pa.make_model(policies='one_step')
    mc = ModelChecker(pa.model, stmts)
    results = mc.check_model()
    assert len(results) == len(stmts)
    assert isinstance(results[0], tuple)
    assert results[0][1].paths == [[('A_activates_B_activity', 1),
                                    ('B_activity_active_obs', 1)]]
    assert results[1][1].paths == [[('B_deactivates_C_kinase', 1),
                                    ('C_kinase_active_obs', -1)]]
Beispiel #34
0
def test_invalid_modification():
    # Override the shutoff of self export in psyb_assembler
    # Create the statement
    a = Agent('A')
    b = Agent('B')
    st = Phosphorylation(a, b, 'T', '185')
    # Now create the PySB model
    Monomer('A')
    Monomer('B', ['Y187'], {'Y187': ['u', 'p']})
    Rule('A_phos_B', A() + B(Y187='u') >> A() + B(Y187='p'), Parameter('k', 1))
    #Initial(A(), Parameter('A_0', 100))
    #Initial(B(T187='u'), Parameter('B_0', 100))
    #with open('model_rxn.dot', 'w') as f:
    #    f.write(render_reactions.run(model))
    #with open('species_1step.dot', 'w') as f:
    #    f.write(species_graph.run(model))
    # Now check the model
    mc = ModelChecker(model, [st])
    results = mc.check_model()
Beispiel #35
0
def test_rasgef_rasgtp_phos():
    sos = Agent('SOS1', db_refs={'HGNC': '1'})
    ras = Agent('KRAS',
                activity=ActivityCondition('gtpbound', True),
                db_refs={'HGNC': '2'})
    raf = Agent('BRAF', db_refs={'HGNC': '3'})
    mek = Agent('MEK', db_refs={'HGNC': '4'})
    rasgef_stmt = RasGef(sos, ras)
    rasgtp_stmt = RasGtpActivation(ras, raf, 'kinase')
    phos = Phosphorylation(raf, mek)
    stmt_to_check = Phosphorylation(sos, mek)
    # Assemble and check
    pysba = PysbAssembler()
    pysba.add_statements([rasgef_stmt, rasgtp_stmt, phos])
    pysba.make_model(policies='one_step')
    mc = ModelChecker(pysba.model, [stmt_to_check])
    checks = mc.check_model()
    assert len(checks) == 1
    assert checks[0][0] == stmt_to_check
    assert checks[0][1] == True
Beispiel #36
0
def test_grounded_modified_enzyme():
    """Check if the model checker can use semantic annotations to match mods
    on the enzyme, not just the substrate, of a phosphorylation statement."""
    mek_s202 = Agent('MEK1',
                     mods=[ModCondition('phosphorylation', 'S', '202')],
                     db_refs={'HGNC': '6840'})
    mek_phos = Agent('MEK1',
                     mods=[ModCondition('phosphorylation', None, None)],
                     db_refs={'HGNC': '6840'})
    erk = Agent('ERK2', db_refs={'HGNC': '6871'})
    stmt_to_model = Phosphorylation(mek_s202, erk, None, None)
    stmt_to_check = Phosphorylation(mek_phos, erk, None, None)
    pa = PysbAssembler()
    pa.add_statements([stmt_to_model])
    pa.make_model(policies='one_step')
    mc = ModelChecker(pa.model, [stmt_to_check])
    results = mc.check_model()
    assert len(results) == 1
    assert results[0][0] == stmt_to_check
    assert results[0][1] == True
Beispiel #37
0
def test_invalid_modification():
     # Override the shutoff of self export in psyb_assembler
     # Create the statement
     a = Agent('A')
     b = Agent('B')
     st = Phosphorylation(a, b, 'T', '185')
     # Now create the PySB model
     Monomer('A')
     Monomer('B', ['Y187'], {'Y187':['u', 'p']})
     Rule('A_phos_B', A() + B(Y187='u') >> A() + B(Y187='p'),
          Parameter('k', 1))
     #Initial(A(), Parameter('A_0', 100))
     #Initial(B(T187='u'), Parameter('B_0', 100))
     #with open('model_rxn.dot', 'w') as f:
     #    f.write(render_reactions.run(model))
     #with open('species_1step.dot', 'w') as f:
     #    f.write(species_graph.run(model))
     # Now check the model
     mc = ModelChecker(model, [st])
     results = mc.check_model()
Beispiel #38
0
def test_phosphorylation_annotations():
    # Create the statement
    a = Agent('MEK1', db_refs={'HGNC': '6840'})
    b = Agent('ERK2', db_refs={'HGNC': '6871'})
    st1 = Phosphorylation(a, b, 'T', '185')
    st2 = Phosphorylation(a, b, None, None)
    st3 = Phosphorylation(a, b, 'Y', '187')
    # Now create the PySB model
    Monomer('A_monomer')
    Monomer('B_monomer', ['Thr185', 'Y187'],
            {'Thr185':['un', 'phos'], 'Y187': ['u', 'p']})
    Rule('A_phos_B', A_monomer() + B_monomer(Thr185='un') >>
                     A_monomer() + B_monomer(Thr185='phos'),
         Parameter('k', 1))
    Initial(A_monomer(), Parameter('A_0', 100))
    Initial(B_monomer(Thr185='un', Y187='u'), Parameter('B_0', 100))
    # Add agent grounding
    Annotation(A_monomer, 'http://identifiers.org/hgnc/HGNC:6840')
    Annotation(B_monomer, 'http://identifiers.org/hgnc/HGNC:6871')
    Annotation('A_phos_B', 'A_monomer', 'rule_has_subject')
    Annotation('A_phos_B', 'B_monomer', 'rule_has_object')
    # Add annotations to the sites/states of the Monomer itself
    B_annot = [
        Annotation('Thr185', 'T', 'is_residue'),
        Annotation('Thr185', '185', 'is_position'),
        Annotation(('Thr185', 'phos'), 'phosphorylation', 'is_modification'),
        Annotation('Y187', 'Y', 'is_residue'),
        Annotation('Y187', '187', 'is_position'),
        Annotation(('Y187', 'p'), 'phosphorylation', 'is_modification'),
    ]
    B_monomer.site_annotations = B_annot
    mc = ModelChecker(model, [st1, st2, st3])
    results = mc.check_model()
    assert len(results) == 3
    assert isinstance(results[0], tuple)
    assert results[0][0] == st1
    assert results[0][1] == True
    assert results[1][0] == st2
    assert results[1][1] == True
    assert results[2][0] == st3
    assert results[2][1] == False
Beispiel #39
0
def test_rasgap_rasgtp():
    nf1 = Agent('NF1', db_refs={'HGNC': '1'})
    ras = Agent('KRAS', db_refs={'HGNC': '2'})
    ras_g = Agent('KRAS',
                  activity=ActivityCondition('gtpbound', True),
                  db_refs={'HGNC': '2'})
    raf = Agent('BRAF', db_refs={'HGNC': '3'})
    rasgap_stmt = RasGap(nf1, ras)
    rasgtp_stmt = RasGtpActivation(ras_g, raf, 'kinase')
    act_stmt = Inhibition(nf1, raf, 'kinase')
    # Check that the activation is satisfied by the RasGap
    pysba = PysbAssembler()
    pysba.add_statements([rasgap_stmt, rasgtp_stmt])
    pysba.make_model(policies='one_step')
    mc = ModelChecker(pysba.model, [act_stmt])
    checks = mc.check_model()
    assert len(checks) == 1
    assert checks[0][0] == act_stmt
    assert checks[0][1].paths == [[('NF1_deactivates_KRAS', 1),
                                   ('KRAS_activates_BRAF_kinase', -1),
                                   ('BRAF_kinase_active_obs', -1)]]
Beispiel #40
0
def test_two_step_phosphorylation():
    # Create the statement
    a = Agent('A', db_refs={'HGNC':'1'})
    b = Agent('B', db_refs={'HGNC':'2'})
    st = Phosphorylation(a, b, 'T', '185')
    # Now create the PySB model
    Monomer('A', ['b', 'other'], {'other':['u','p']})
    Monomer('B', ['b', 'T185'], {'T185':['u', 'p']})
    Rule('A_bind_B', A(b=None) + B(b=None, T185='u') >>
                     A(b=1) % B(b=1, T185='u'), Parameter('kf', 1))
    Rule('A_bind_B_rev', A(b=1) % B(b=1, T185='u') >>
                         A(b=None) + B(b=None, T185='u'), Parameter('kr', 1))
    Rule('A_phos_B', A(b=1) % B(b=1, T185='u') >>
                     A(b=None) + B(b=None, T185='p'),
                 Parameter('kcat', 1))
    Initial(A(b=None, other='p'), Parameter('Ap_0', 100))
    Initial(A(b=None, other='u'), Parameter('Au_0', 100))
    Initial(B(b=None, T185='u'), Parameter('B_0', 100))
    # Add annotations
    Annotation(A, 'http://identifiers.org/hgnc/HGNC:1')
    Annotation(B, 'http://identifiers.org/hgnc/HGNC:2')
    Annotation('A_phos_B', 'A', 'rule_has_subject')
    Annotation('A_phos_B', 'B', 'rule_has_object')
    B.site_annotations = [
        Annotation(('T185', 'p'), 'phosphorylation', 'is_modification'),
        Annotation('T185', 'T', 'is_residue'),
        Annotation('T185', '185', 'is_position'),
    ]
    #with open('model_rxn.dot', 'w') as f:
    #    f.write(render_reactions.run(model))
    #with open('species_2step.dot', 'w') as f:
    #    f.write(species_graph.run(model))
    #generate_equations(model)
    # Now check the model
    mc = ModelChecker(model, [st])
    results = mc.check_model()
    assert len(results) == 1
    assert isinstance(results[0], tuple)
    assert results[0][0] == st
    assert results[0][1] == True
Beispiel #41
0
def test_pysb_assembler_phospho_policies():
    a = Agent('A', db_refs={'HGNC': '1'})
    b = Agent('B', db_refs={'HGNC': '2'})
    st = Phosphorylation(a, b, 'T', '185')
    pa = PysbAssembler()
    pa.add_statements([st])
    # Try two step
    pa.make_model(policies='two_step')
    mc = ModelChecker(pa.model, [st])
    results = mc.check_model()
    assert len(results) == 1
    assert isinstance(results[0], tuple)
    assert results[0][0] == st
    assert results[0][1] == True
    # Try one step
    pa.make_model(policies='one_step')
    mc = ModelChecker(pa.model, [st])
    results = mc.check_model()
    assert len(results) == 1
    assert isinstance(results[0], tuple)
    assert results[0][0] == st
    assert results[0][1] == True
    # Try interactions_only
    pa.make_model(policies='interactions_only')
    mc = ModelChecker(pa.model, [st])
    results = mc.check_model()
    assert len(results) == 1
    assert isinstance(results[0], tuple)
    assert results[0][0] == st
    assert results[0][1] == False
Beispiel #42
0
def test_model_check_data():
    # Create a set of statements
    a = Agent('A', db_refs={'HGNC': '1'})
    b = Agent('B', db_refs={'HGNC': '2'})
    b_phos = Agent('B',
                   mods=[ModCondition('phosphorylation')],
                   db_refs={'HGNC': '2'})
    c = Agent('C', db_refs={'HGNC': '3'})
    c_phos = Agent('C',
                   mods=[ModCondition('phosphorylation')],
                   db_refs={'HGNC': '3'})
    d = Agent('D', db_refs={'HGNC': '4'})
    d_phos = Agent('D',
                   mods=[ModCondition('phosphorylation')],
                   db_refs={'HGNC': '4'})

    # Two paths from A to D: One going through B and another through C
    st1 = Phosphorylation(a, b)
    st2 = Phosphorylation(b_phos, d)
    st3 = Phosphorylation(a, c)
    st4 = Phosphorylation(c_phos, d)
    # Statements/Data agents for checking
    stmt_to_check = Phosphorylation(a, d)
    agent_obs = [b_phos, c_phos, d_phos]
    # Make model
    pa = PysbAssembler()
    pa.add_statements([st1, st2, st3, st4])
    pa.make_model(policies='one_step')
    mc = ModelChecker(pa.model, [stmt_to_check], agent_obs)
    results = mc.check_model(max_paths=5)
    mc.get_im().draw('im.pdf', prog='dot')
    # Create observable
    assert len(results) == 1
    pr = results[0][1]
    res = pr.paths[0:2]
    assert len(res) == 2
    p1 = [('A_phosphorylation_B_phospho', 1),
          ('B_phospho_phosphorylation_D_phospho', 1), ('D_phospho_p_obs', 1)]
    assert p1 in res
    p2 = [('A_phosphorylation_C_phospho', 1),
          ('C_phospho_phosphorylation_D_phospho', 1), ('D_phospho_p_obs', 1)]
    assert p2 in res
    # Now, a vector linking agents with values, expressed at first as
    # +/- 1
    # This data should ensure that the path through B should be more highly
    # ranked than the path through C
    data = {b_phos: 1, c_phos: -1, d_phos: 1}
    paths = results[0][1].paths
    scored_paths = mc.score_paths(paths, data)
    assert scored_paths[0][0] == p1
    assert scored_paths[0][1] == 0
    assert scored_paths[1][0] == p2
Beispiel #43
0
    model = pa.make_model()

    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: