Skip to content

Commit

Permalink
Merge f95d7e2 into 1eee9ca
Browse files Browse the repository at this point in the history
  • Loading branch information
alubbock committed Aug 30, 2016
2 parents 1eee9ca + f95d7e2 commit ec34535
Show file tree
Hide file tree
Showing 17 changed files with 899 additions and 405 deletions.
6 changes: 3 additions & 3 deletions doc/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -482,10 +482,10 @@ you are using iPython, you can press tab twice after "m.mymodel" to
tab complete and see all the possible options).


Now, we will import the *PyLab* and PySB integrator module. Enter
Now, we will import the *PyLab* and PySB simulator module. Enter
the commands as shown below::

>>> from pysb.integrate import odesolve
>>> from pysb.simulator.scipy import ScipyOdeSolver
>>> import pylab as pl

We have now loaded the integration engine and the graph engine into
Expand Down Expand Up @@ -523,7 +523,7 @@ These are the points at which we will get data for each ODE from the
integrator. With this, we can now run our simulation. Enter the
following commands to run the simulation::

>>> yout = odesolve(m.model, t)
>>> yout = ScipyOdeSolver.execute(m.model, tspan=t)

To verify that the simulation run you can see the content of the
*yout* object. For example, check for the content of the *Bid*
Expand Down
9 changes: 5 additions & 4 deletions pysb/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,11 +505,12 @@ def is_equivalent_to(self, other):
# so some sort of canonicalization of that numbering is necessary.
if not isinstance(other, ComplexPattern):
raise Exception("Can only compare ComplexPattern to another ComplexPattern")
mp_order = lambda mp: (mp[0], mp[1].keys(), mp[2])
return (self.compartment == other.compartment and
sorted((repr(mp.monomer), mp.site_conditions, mp.compartment)
for mp in self.monomer_patterns) ==
sorted((repr(mp.monomer), mp.site_conditions, mp.compartment)
for mp in other.monomer_patterns))
sorted([(repr(mp.monomer), mp.site_conditions, mp.compartment)
for mp in self.monomer_patterns], key=mp_order) ==
sorted([(repr(mp.monomer), mp.site_conditions, mp.compartment)
for mp in other.monomer_patterns], key=mp_order))

def copy(self):
"""
Expand Down
4 changes: 2 additions & 2 deletions pysb/examples/hello_pysb.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@

if __name__ == '__main__':
from pylab import linspace, plot, xlabel, ylabel, show
from pysb.integrate import odesolve
from pysb.simulator import ScipyOdeSimulator
print(__doc__)
# Simulate the model through 40 seconds
time = linspace(0, 40, 100)
print("Simulating...")
x = odesolve(model, time)
x = ScipyOdeSimulator.execute(model, tspan=time)
# Plot the trajectory of LR
plot(time, x['LR'])
xlabel('Time (seconds)')
Expand Down
4 changes: 2 additions & 2 deletions pysb/examples/run_bax_pore.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

from __future__ import print_function
from pylab import *
from pysb.integrate import odesolve
from pysb.simulator.scipy import ScipyOdeSimulator

from bax_pore import model


t = linspace(0, 100)
print("Simulating...")
x = odesolve(model, t)
x = ScipyOdeSimulator.execute(model, tspan=t)

p = plot(t, c_[x['BAX4'], x['BAX4_inh']])
figlegend(p, ['BAX4', 'BAX4_inh'], 'upper left')
Expand Down
4 changes: 2 additions & 2 deletions pysb/examples/run_bax_pore_sequential.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from __future__ import print_function
from pylab import *
from pysb.integrate import odesolve
from pysb.simulator.scipy import ScipyOdeSimulator

from bax_pore_sequential import model, max_size

Expand All @@ -12,7 +12,7 @@
# vector of time points happens to help with the integration
t = logspace(-3, 5) # 1e-3 to 1e5
print("Simulating...")
x = odesolve(model, t)
x = ScipyOdeSimulator.execute(model, tspan=t)

# Plot trajectory of each pore
for i in range(1, max_size + 1):
Expand Down
6 changes: 3 additions & 3 deletions pysb/examples/run_earm_1_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
al. 2008)."""

from __future__ import print_function
from pysb.integrate import odesolve
from pysb.simulator import ScipyOdeSimulator
from pylab import *

from earm_1_0 import model
Expand Down Expand Up @@ -41,7 +41,7 @@ def fig_4a():
model.parameters['L_0'].value = Ls[i]

print(" L_0 = %g" % Ls[i])
x = odesolve(model, t)
x = ScipyOdeSimulator.execute(model, tspan=t)

fs[i] = (x['PARP_unbound'][0] - x['PARP_unbound'][-1]) / x['PARP_unbound'][0]
dP = 60 * (x['PARP_unbound'][:-1] - x['PARP_unbound'][1:]) / (dt * x['PARP_unbound'][0]) # in minutes
Expand All @@ -67,7 +67,7 @@ def fig_4b():
print("Simulating model for figure 4B...")

t = linspace(0, 6*3600, 6*60+1) # 6 hours
x = odesolve(model, t)
x = ScipyOdeSimulator.execute(model, tspan=t)

x_norm = c_[x['Bid_unbound'], x['PARP_unbound'], x['mSmac_unbound']]
x_norm = 1 - x_norm / x_norm[0, :] # gets away without max() since first values are largest
Expand Down
4 changes: 2 additions & 2 deletions pysb/examples/run_kinase_cascade.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/usr/bin/env python

from __future__ import print_function
from pysb.integrate import odesolve
from pysb.simulator import ScipyOdeSimulator
from pylab import linspace, plot, legend, show

from kinase_cascade import model


tspan = linspace(0, 1200)
print("Simulating...")
yfull = odesolve(model, tspan)
yfull = ScipyOdeSimulator.execute(model, tspan=tspan)
plot(tspan, yfull['ppMEK'], label='ppMEK')
plot(tspan, yfull['ppERK'], label='ppERK')
legend(loc='upper left')
Expand Down
5 changes: 3 additions & 2 deletions pysb/examples/run_robertson.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@

from __future__ import print_function
from pylab import *
from pysb.integrate import odesolve
from pysb.simulator import ScipyOdeSimulator

from robertson import model

# We will integrate from t=0 to t=40
t = linspace(0, 40)
# Simulate the model
print("Simulating...")
y = odesolve(model, t, rtol=1e-4, atol=[1e-8, 1e-14, 1e-6])
y = ScipyOdeSimulator.execute(model, tspan=t, rtol=1e-4,
atol=[1e-8, 1e-14, 1e-6])
# Gather the observables of interest into a matrix
yobs = array([y[obs] for obs in ('A_total', 'B_total', 'C_total')]).T
# Plot normalized trajectories
Expand Down
4 changes: 2 additions & 2 deletions pysb/examples/run_tyson_oscillator.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from pysb.examples.tyson_oscillator import model
from pysb.integrate import odesolve
import numpy as np
from pysb.simulator import ScipyOdeSimulator
import matplotlib.pyplot as plt

t = np.linspace(0, 100, 10001)
x = odesolve(model, t)
x = ScipyOdeSimulator.execute(model, tspan=t)

plt.plot(t, x['CT'], lw=2, label='CT') # Good validation of mass balance for cdc2, should be constant at 1
plt.plot(t, x['YT'], lw=2, label='YT')
Expand Down
Empty file added pysb/expressions.py
Empty file.

0 comments on commit ec34535

Please sign in to comment.