Example #1
0
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
Example #2
0
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
Example #3
0
def test_get_upstream():
    m = MRA()
    egfr = sts.Agent('EGFR', db_refs={'HGNC': '3236', 'TEXT': 'EGFR'})
    kras = sts.Agent('KRAS', db_refs={'HGNC': '6407', 'TEXT': 'KRAS'})
    stmts = [sts.Activation(egfr, kras)]
    model_id = m.new_model(stmts)
    upstream = m.get_upstream(kras, model_id)
    assert(len(upstream) == 1)
    assert(upstream[0].name == 'EGFR')
Example #4
0
def test_respond_build_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')
Example #5
0
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
Example #6
0
def test_respond_model_get_upstream():
    mm = MRA_Module(testing=True)
    egfr = sts.Agent('EGFR', db_refs={'HGNC': '3236', 'TEXT': 'EGFR'})
    kras = sts.Agent('KRAS', db_refs={'HGNC': '6407', 'TEXT': 'KRAS'})
    stmts = [sts.Activation(egfr, kras)]
    model_id = mm.mra.new_model(stmts)
    kras_term = ekb_from_agent(kras)
    msg = KQMLList('MODEL-GET-UPSTREAM')
    msg.sets('target', kras_term)
    msg.set('model-id', str(model_id))
    reply = mm.respond_model_get_upstream(msg)
    ups = reply.get('upstream')
    assert(len(ups) == 1)
Example #7
0
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)
Example #8
0
def complex_assemble_one_step(stmt, model, agent_set):
    pairs = itertools.combinations(stmt.members, 2)
    for pair in pairs:
        agent1 = pair[0]
        agent2 = pair[1]
        param_name = agent1.name[0].lower() + \
                     agent2.name[0].lower() + '_bind'
        kf_bind = get_create_parameter(model, 'kf_' + param_name, 1e-6)
        kr_bind = get_create_parameter(model, 'kr_' + param_name, 1e-6)

        # Make a rule name
        name_components = []
        for m in pair:
            for bc in m.bound_conditions:
                if bc.is_bound:
                    name_components.append(m.name + '_' + bc.agent.name)
                else:
                    name_components.append(m.name + '_n' + bc.agent.name)
            else:
                name_components.append(m.name)

        # Construct full patterns of each agent with conditions
        rule_name = '_'.join(name_components) + '_bind'
        agent1_pattern = get_complex_pattern(model, agent1, agent_set)
        agent2_pattern = get_complex_pattern(model, agent2, agent_set)
        agent1_bs = get_binding_site_name(agent2.name)
        agent2_bs = get_binding_site_name(agent1.name)
        r = Rule(rule_name, agent1_pattern(**{agent1_bs: None}) + \
                            agent2_pattern(**{agent2_bs: None}) >>
                            agent1_pattern(**{agent1_bs: 1}) % \
                            agent2_pattern(**{agent2_bs: 1}),
                            kf_bind)
        add_rule_to_model(model, r)

        # In reverse reaction, assume that dissocition is unconditional
        rule_name = '_'.join(name_components) + '_dissociate'
        agent1_uncond = get_complex_pattern(model, ist.Agent(agent1.name),
                                            agent_set)
        agent2_uncond = get_complex_pattern(model, ist.Agent(agent2.name),
                                            agent_set)
        r = Rule(rule_name, agent1_uncond(**{agent1_bs: 1}) % \
                            agent2_uncond(**{agent2_bs: 1}) >>
                            agent1_uncond(**{agent1_bs: None}) + \
                            agent2_uncond(**{agent2_bs: None}),
                            kr_bind)
        add_rule_to_model(model, r)
Example #9
0
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)
Example #10
0
    def _make_agent(agent_str):
        """Makes an ungrounded Agent object from a string specifying an
        entity.

        Parameters
        ----------
        agent_str : str
            A string specifying the agent

        Returns
        -------
        agent : indra.statements.Agent
            An ungrounded Agent object referring to the specified text
        """
        return ist.Agent(agent_str, db_refs={'TEXT': agent_str})
Example #11
0
 def create_build(self):
     self.bioagent.mra.explain = \
         sts.Activation(sts.Agent('KRAS', db_refs={'HGNC': '6407'}),
                        sts.Agent('JUN', db_refs={'HGNC': '6204'}))
     return _get_build_model_request('KRAS activates MEK.')
Example #12
0
 def create_build(self):
     self.bioagent.mra.explain = \
         sts.Inhibition(sts.Agent('KRAS', db_refs={'HGNC': '6407'}),
                        sts.Agent('MEK', db_refs={'FPLX': 'MEK'}))
     return _get_build_model_request('KRAS activates BRAF')
Example #13
0
def test_agent_to_ekb():
    egfr = sts.Agent('EGFR', db_refs={'HGNC': '3236', 'TEXT': 'EGFR'})
    term = ekb_from_agent(egfr)
    egfr_out = get_target(term)
    assert(isinstance(egfr_out, sts.Agent))
    assert(egfr_out.name == 'EGFR')