Example #1
0
def get_model(is_netfree=False, without_reset=False, seeds=None):
    if any([
            not isinstance(rr, ecell4.core.ReactionRule)
            for rr in REACTION_RULES
    ]):
        from ecell4.ode import ODENetworkModel
        m = ODENetworkModel()
    elif seeds is not None or is_netfree:
        m = ecell4.core.NetfreeModel()
    else:
        m = ecell4.core.NetworkModel()

    for sp in SPECIES_ATTRIBUTES:
        m.add_species_attribute(sp)
    for rr in REACTION_RULES:
        m.add_reaction_rule(rr)
    for param in PARAMETERS:
        m.add_parameter(param)

    if not without_reset:
        reset_model()

    if seeds is not None:
        return m.expand(seeds)

    return m
Example #2
0
def get_model(is_netfree=False, without_reset=False, seeds=None):
    """
    Generate a model with parameters in the global scope, ``SPECIES_ATTRIBUTES``
    and ``REACTIONRULES``.

    Parameters
    ----------
    is_netfree : bool, optional
        Return ``NetfreeModel`` if True, and ``NetworkModel`` if else.
        Default is False.
    without_reset : bool, optional
        Do not reset the global variables after the generation if True.
        Default is False.
    seeds : list, optional
        A list of seed ``Species`` for expanding the model.
        If this is not None, generate a ``NetfreeModel`` once, and return a
        ``NetworkModel``, which is an expanded form of that with the given seeds.
        Default is None.

    Returns
    -------
    model : NetworkModel, NetfreeModel, or ODENetworkModel

    """
    if any([not isinstance(rr, ecell4.core.ReactionRule) for rr in REACTION_RULES]):
       from ecell4.ode import ODENetworkModel
       m = ODENetworkModel()
    elif seeds is not None or is_netfree:
        m = ecell4.core.NetfreeModel()
    else:
        m = ecell4.core.NetworkModel()

    for sp in SPECIES_ATTRIBUTES:
        m.add_species_attribute(sp)
    for rr in REACTION_RULES:
        m.add_reaction_rule(rr)
    for param in PARAMETERS:
        m.add_parameter(param)

    if not without_reset:
        reset_model()

    if seeds is not None:
        return m.expand(seeds)

    return m
Example #3
0
def get_model(is_netfree=False, without_reset=False, seeds=None):
    if any([not isinstance(rr, ecell4.core.ReactionRule) for rr in REACTION_RULES]):
       from ecell4.ode import ODENetworkModel
       m = ODENetworkModel()
    elif seeds is not None or is_netfree:
        m = ecell4.core.NetfreeModel()
    else:
        m = ecell4.core.NetworkModel()

    for sp in SPECIES_ATTRIBUTES:
        m.add_species_attribute(sp)
    for rr in REACTION_RULES:
        m.add_reaction_rule(rr)
    for param in PARAMETERS:
        m.add_parameter(param)

    if not without_reset:
        reset_model()

    if seeds is not None:
        return m.expand(seeds)

    return m