Commits on Nov 9, 2018
  1. Fix Python 3.7 libsbml install on travis (#388)

    alubbock committed Nov 9, 2018
Commits on Oct 19, 2018
  1. BngSimulator: respect cleanup flag in `__init__` (#385)

    alubbock committed Oct 19, 2018
    * BngSimulator: respect cleanup flag in __init__
    The cleanup flag in BngSimulator's __init__() was being ignored. It is
    now treated as a default, which can be overriden on a per simulation
    basis in run() if required.
Commits on Oct 18, 2018
  1. Validate cupsoda init kwargs and integrator opts (#383)

    alubbock committed Oct 18, 2018
    * Validate cupsoda init kwargs and integrator opts
    Previously, unrecognised kwargs and integrator options were
    silently ignored. Now a ValueError is raised if they are not
    * Fix cupsoda unit test
  2. Validate init kwargs to StochkitSimulator (#382)

    alubbock committed Oct 18, 2018
    Previously, unrecognised kwargs would be silently ignored. Now a
    ValueError is raised if they are not recognised.
  3. Validate init kwargs to ScipyOdeSimulator (#381)

    alubbock committed Oct 18, 2018
    Previously, unrecognised kwargs would be silently ignored. Now a
    ValueError is raised if they are not recognised.
  4. Tab completion of components in IPython, Notebook (#380)

    alubbock committed Oct 18, 2018
    Implement ComponentSet.__dir__(), which enables tab completion of
    component names at an IPython prompt and in Jupyter Notebook.
  5. Fix BNGSimulator when tspan doesn't start at 0 (#379)

    alubbock committed Oct 18, 2018
    BNG requires the t_start argument, even when supplying sample_times.
    This was causing t=0 to get added to the simulation even when using
    tspan starting after 0. Now fixed.
  6. Fix Simulator initials_dict when set by array (#377)

    alubbock committed Oct 18, 2018
    The `Simulator` class method `initials_dict` returns initial conditions
    as a dictionary, mostly for use by network-free simulators like NFsim.
    When initial conditions are set by an array or by a list, species which
    were not explicitly set using `Initial()` in the model are ignored.
    This would only affect users of the `BngSimulator`, which uses this
    method, or anyone who called this method directly after setting
    initials with an array or list.
    This PR fixes the issue by returning a dictionary with values from the
    array. This requires a species list for the model, so a `ValueError`
    is raised where this is not available/`generate_equations` hasn't been
    called yet.
Commits on Oct 17, 2018
  1. Fix StochKit export on Python 3 with lxml installed (#375)

    alubbock committed Oct 17, 2018
    This previously failed because lxml outputted bytes, which
    needs conversion into a UTF-8 string on Python 3.
  2. Default module name when __name__ not set (#374)

    alubbock committed Oct 17, 2018
    * Set module name when __name__ is not set
    The module/function name is captured by PySB when Components
    are defined, but in some interpreters the __name__ attribute
    is not set for interactive sessions. To avoid an error, this
    introduces a default value of __unnamed__.
Commits on Oct 16, 2018
  1. Additonal function support when exporting to BNG (#373)

    alubbock committed Oct 16, 2018
    * Boolean 'And' and 'Or' Expression support in BNG
    * Support more functions in BNG
    Added _pi and _e constants; abs, min, max functions.
    * Floor/Ceiling translations for BNG
Commits on Jul 23, 2018
  1. Fix core documentation: add necessary whitespace (#369)

    alubbock committed Jul 23, 2018
  2. LibSBML model exporter (#367)

    alubbock committed Jul 23, 2018
    * LibSBML model exporter
    This replaces the original SBML exporter with a libsbml-based one.
    New features include compartment and expression support, and
    conversion between SBML levels/versions (L3V2 by default).
    Exports are tested with libroadrunner.
  3. Test on Python 3.7 on Travis (#368)

    alubbock committed Jul 23, 2018
Commits on Jun 7, 2018
  1. Fix Python and PySB flat exporters, add tests (#366)

    alubbock committed Jun 7, 2018
    * Python 3 compatibility in Python exporter
    * Unit tests for Python and PySB flat exporters
    * A few small fixes to get the tests running
Commits on Jun 6, 2018
  1. BNG line numbers in DEBUG log (#365)

    alubbock committed Jun 6, 2018
    BNG errors and warnings often given line numbers referring to the BNGL
    file. This PR adds line numbers to the BNGL output shown in PySB's
    DEBUG log.
Commits on May 31, 2018
  1. Capture BNG errors into PySB exception (#363)

    alubbock committed May 31, 2018
    BioNetGen errors sent to STDOUT are now captured and included
    in the `BngInterfaceError` raised in PySB, to aid debugging.
  2. Filtering for ComponentSets (#340)

    alubbock committed May 31, 2018
    `ComponentSet.filter()` can be used to filter a ComponentSet by properties
    of its Components - filtering by name, pattern, module name, value, or rule
    rate is supported. Some examples:
    >>> from pysb.examples.earm_1_0 import model
    >>> from pysb.pattern import Name, Pattern, Module, Function
    >>> m = model.monomers
    # Find parameters exactly equal to 10000:
    >>> model.parameters.filter(lambda c: c.value == 1e4) 
     Parameter('pC3_0', 10000.0),
     Parameter('pC6_0', 10000.0),
    # Find rules with a forward rate < 1e-8, using a custom function:
    >>> model.rules.filter(lambda c: c.rate_forward.value < 1e-8)
     Rule('bind_pC3_Apop', Apop(b=None) + pC3(b=None) | Apop(b=1) %
            pC3(b=1), kf25, kr25),
    # We can also use some built in predicates for more complex matching
    # scenarios, including combining multiple predicates.
    # Find rules with a name beginning with "inhibit" that contain cSmac:
    >>> model.rules.filter(Name('^inhibit') & Pattern(m.cSmac()))
     Rule('inhibit_cSmac_by_XIAP', cSmac(b=None) + XIAP(b=None) |
            cSmac(b=1) % XIAP(b=1), kf28, kr28),
    # Find rules with any form of Bax (i.e. Bax, aBax, mBax):
    >>> model.rules.filter(Pattern(m.Bax) | Pattern(m.aBax) | Pattern(m.MBax))
     Rule('bind_Bax_tBid', tBid(b=None) + Bax(b=None) |
          tBid(b=1) % Bax(b=1), kf12, kr12),
     Rule('produce_aBax_via_tBid', tBid(b=1) % Bax(b=1) >>
          tBid(b=None) + aBax(b=None), kc12),
     Rule('transloc_MBax_aBax', aBax(b=None) |
          MBax(b=None), kf13, kr13),
     Rule('inhibit_MBax_by_Bcl2', MBax(b=None) + Bcl2(b=None) |
          MBax(b=1) % Bcl2(b=1), kf14, kr14),
     Rule('dimerize_MBax_to_Bax2', MBax(b=None) + MBax(b=None) |
          Bax2(b=None), kf15, kr15),
    # Count the number of parameter that don't start with kf (note the ~
    # negation operator):
    >>> len(model.parameters.filter(~Name('^kf')))
    # Get components not defined in this module (file). In this case,
    # everything is defined in one file, but for multi-file models this
    # becomes more useful:
    >>> model.components.filter(~Module('^pysb.examples.earm_1_0$'))
    # Count the number of rules defined in the 'catalyze' function:
    >>> len(model.rules.filter(Function('^catalyze$')))
Commits on May 30, 2018
  1. Validate site and state names (#352)

    alubbock committed May 30, 2018
    Site names, state names and state values are now validated against the
    regex '[_a-z][_a-z0-9]*\Z'.
    Imports from BNG or SBML with numeric state values are patched with
    leading underscores (a log message is generated per monomer when this
    Export to Kappa with invalid state values '_*[0-9]*$' are patched
    with a leading '__state' (a log message is generated per monomer when
    this occurs). This requires the Kappa format_* functions have access
    to the model to identify which state values have been changed, so
    they're now methods of KappaGenerator. I've left one line wrappers for
    each of the original top level functions to maintain API compatibility.
  2. Tests for PySB exporters (#357)

    alubbock committed May 30, 2018
    This PR tests all PySB example models against all the available
    exporters. It's heavily based on @keszybz's approach in #113.
    I've also implemented explicit ExpressionsNotSupported and
    CompartmentsNotSupported exceptions for the exporters which
    don't support those features.
    Fixes: #154
    Fixes: #73
  3. Update Dockerfile and related instructions (#359)

    alubbock committed May 30, 2018
Commits on Apr 12, 2018
  1. Allow state=None in rule patterns (#356)

    alubbock committed Apr 12, 2018
    None should be allowed in MonomerPatterns, to allow for models like
    the following:
        Monomer('A', ['phospho'], {'phospho': ['u', 'p']})
        A(phospho=None) + A(phospho=None) >> A(phospho=1) % A(phospho=1)
    states in *species*, not in *patterns*. Such patterns are already detected
    as un-concrete, so they are forbidden in initials.
    Thanks to @bgyori for spotting and reporting this.
Commits on Apr 11, 2018
  1. Forbid defining a state as None (#348)

    alubbock committed Apr 11, 2018
    A state, as opposed to a bond, should not be able to be defined as
    None. Doing so causes an error in BNG: "reaction list cannot be read
    because of errors". This commit adds a check for this condition
    and a unit test.
  2. Enforce synthesis products are concrete (#354)

    alubbock committed Apr 11, 2018
    This PR introduces a check at rule instantiation that every
    ComplexPattern is concrete for synthesis rules.
Commits on Apr 9, 2018
  1. Catch Cython/weave compiler error on Windows (#353)

    alubbock committed Apr 9, 2018
    If Cython or weave cannot find a working compiler on Windows, one
    error than can occur is ValueError: Symbol table not found, generated
    by numpy/distutils/ This commit catches this
    error and treats the compiler as non-functional, logging the occurence
    as a DEBUG log message.
  2. On demand observable trajectory calculation (#337)

    alubbock committed Apr 9, 2018
    * Pattern matcher for PySB components and model test suite
    * More documentation on pattern matching functions
    * Add some tests for pattern matcher
    * Pattern matcher updates from @jmuhlich's feedback
    * Pattern matcher functions are now top-level in pysb.pattern
    * Add `matches` methods for ComplexPatterns and ReactionPatterns
    * `ComplexPattern.is_equivalent_to` now always does exact comparison
    * Compartment and ReactionPattern matching tests
    * More unit and doctests for pattern matching
    * Make Complex._as_graph() private for now
    Add underscore prefix to make as_graph() private, as we may change
    the internal implementation of pattern graph at a later date.
    * Bond wilcard only matches bonds, not Components
    * ANY and WILD were switched in _as_graph()
    * Dynamic observable calculation
    * Update documentation and py3 compatibility
    * Remove duplicated function from rebase
    * Improve SimulationResult.observable docstring
  3. Simplify installation instructions (#347)

    alubbock committed Apr 9, 2018
    Now that PySB and its dependencies including BioNetGen are on
    Anaconda, the installation procedure is much simpler.
    I've also added Cython to the list of recommended packages.
  4. Expressions must be created from sympy.Expr (#350)

    alubbock committed Apr 9, 2018
    * Expressions must be created from sympy.Expr
    The BNGL and SBML importers were creating Expressions from ints and
    floats, which are better represented as Parameters. This PR
    performs this conversion within the importers where applicable.
    Fixes: #349
    * Check numeric types using numbers.Number
  5. Fix kappa generator using certain expressions (#346)

    alubbock committed Apr 9, 2018
    The kappa generator was incorrectly substituting parameter names in
    expressions if one parameter was a substring of the other. This
    replaces the string replacement with the sympy printer.
    Fixes: #345
  6. Deprecate <> operator for reversible rules (#344)

    alubbock committed Apr 9, 2018
    PySB v1.6.0 was just released, with the <> reversible rule operator
    issuing a PendingDeprecationWarning. This commit changes that to a
    DeprecationWarning, which should be included in the next release.
Commits on Mar 7, 2018
  1. Fix Kappa 4 multiple agent synthesis (#339)

    alubbock committed Mar 7, 2018
    In Kappa 4, a Ghost agent (placeholder 'dot') must be used to make
    the two sides of a reaction rule match. For example, the following
    two agent synthesis rule:
        Rule('synthesize_A_and_B', M() + None + None >> M() + A() + B(), k)
    This was previously failing (one None was silently dropped). This
    has been fixed by modifying ReactionPattern.__add__ and implementing
    __radd__. The only caveat is with multiple leading Nones, which will
    need to be in parentheses to avoid a TypeError from adding two Nones:
        None + (None + M())
    This should also be avoidable by reordering the agents to put the
    Nones last, as in the original example.
    Fixes: #338
Commits on Mar 6, 2018
  1. Use more anaconda binaries on CI builds (#341)

    alubbock committed Mar 6, 2018
    * Use Anaconda for more requirements on Travis
    This reduces our travis build time significantly.
    * Use more anaconda packages for Appveyor build
    * Minimal fixes to get tests working
  2. More sphinx mocks to fix simulator docs (#336)

    alubbock committed Mar 6, 2018
    * More sphinx mocks to fix simulator docs
    * Add nose and to sphinx mocks
Commits on Jan 25, 2018
  1. Kappa 4 support, expression improvements (#334)

    alubbock committed Jan 25, 2018
    * Kappa 4 support, Kappa expression improvements
    This PR introduces support for Kappa 4 and drops support for
    Kappa 3. Note that Kappa now requires agents on the reactant
    side to correspond to agents on the product side of a rule 
    (i.e. order is preserved). The "dot" agent is implemented in
    PySB as `None`, and is necessary in
    [certain situations documented in the Kappa Manual](
    For example, the following Kappa rule:
        // Agent A spawns a copy of agent B
        A(),. -> A(),B() @ 'r'
    would be implemented in PySB as:
        Rule('spawnB', A() + None >> A() + B(), r)
    This PR also improves Expression support for Kappa, implementing
    `log`, `exp`, `min`, `max`, `sin`, `cos`, `tan`, `mod` and `sqrt`
    functions, if expressions via sympy's `Piecewise`, and the `pi` and
    `E` constants.
    When using BioNetGen, `None` in a reaction pattern is translated
    to the null symbol `0`.
    Fixes: #333
    Fixes: #288
  2. Cython support for ScipyOdeSimulator (#320)

    alubbock committed Jan 25, 2018
    Adds Cython support to ScipyOdeSimulator. This is useful because our
    current ODE compilation backend (weave) does not support Python 3;
    Cython does.
    The ODE compilation system backend can be specified by a new
    `eqn_mode` argument: `cython`, `weave`, `theano` or `python`.
    If left as None (default), the system will try to use `weave`,
    then `cython`, then `python`.
    If the auto-detect falls back on `python` mode, a warning is shown
    that the simulation may be slow, and recommends the user install
    `cython` or `weave`.