Beispiel #1
0
def test_name_standardize():
    n = pa._n('.*/- ^&#@$')
    assert(isinstance(n, str))
    assert(n == '__________')
    n = pa._n('14-3-3')
    assert(isinstance(n, str))
    assert(n == 'p14_3_3')
    n = pa._n('\U0001F4A9bar')
    assert(isinstance(n, str))
    assert(n == 'bar')
Beispiel #2
0
def test_name_standardize():
    n = pa._n('.*/- ^&#@$')
    assert(isinstance(n, str))
    assert(n == '__________')
    n = pa._n('14-3-3')
    assert(isinstance(n, str))
    assert(n == 'p14_3_3')
    n = pa._n('\U0001F4A9bar')
    assert(isinstance(n, str))
    assert(n == 'bar')
Beispiel #3
0
def get_create_observable(model, agent):
    site_pattern = pa.get_site_pattern(agent)
    obs_name = pa.get_agent_rule_str(agent) + '_obs'
    monomer = model.monomers[pa._n(agent.name)]
    obs = Observable(obs_name.encode('utf-8'), monomer(site_pattern))
    model.add_component(obs)
    return obs
Beispiel #4
0
def apply_condition(model, condition):
    agent = condition.quantity.entity
    monomer = model.monomers[pa._n(agent.name)]
    site_pattern = pa.get_site_pattern(agent)
    # TODO: handle modified patterns
    if site_pattern:
        logger.warning('Cannot handle initial conditions on' +
                       ' modified monomers.')
    if condition.condition_type == 'exact':
        ic_name = monomer.name + '_0'
        if condition.value.quant_type == 'number':
            pa.set_base_initial_condition(model, monomer,
                                          condition.value.value)
        else:
            logger.warning('Cannot handle non-number initial conditions')
    elif condition.condition_type == 'multiple':
        # TODO: refer to annotations for the IC name
        ic_name = monomer.name + '_0'
        model.parameters[ic_name].value *= condition.value
    elif condition.condition_type == 'decrease':
        ic_name = monomer.name + '_0'
        model.parameters[ic_name].value *= 0.9
    elif condition.condition_type == 'increase':
        ic_name = monomer.name + '_0'
        model.parameters[ic_name].value *= 1.1
    logger.info('New initial condition: %s' % model.parameters[ic_name])
Beispiel #5
0
def get_chemical_agents(stmts):
    chemicals = set()
    for stmt in stmts:
        for agent in stmt.agent_list():
            if agent is not None and ('CHEBI' in agent.db_refs or
                                      'PC' in agent.db_refs):
                chemicals.add(pysb_assembler._n(agent.name))
    return list(chemicals)
Beispiel #6
0
def get_create_observable(model, agent):
    site_pattern = pa.get_site_pattern(agent)
    obs_name = pa.get_agent_rule_str(agent) + '_obs'
    try:
        monomer = model.monomers[pa._n(agent.name)]
    except KeyError:
        raise MissingMonomerError('%s is not in the model ' % agent.name)
    try:
        monomer_state = monomer(site_pattern)
    except Exception as e:
        msg = 'Site pattern %s invalid for monomer %s' % \
            (site_pattern, monomer.name)
        raise MissingMonomerSiteError(msg)
    obs = Observable(obs_name, monomer(site_pattern))
    model.add_component(obs)
    return obs