Skip to main content

Python Interface for Spatial Stochastic Biochemical Simulations

Project description

SpatialPy is a Python 3 package for simulation of spatial deterministic/stochastic reaction-diffusion-advection problems embedded in Lagrangian reference frame particle based fluid dynamics domain

This package is intended to replace the PyURDME software https://github.com/pyurdme/pyurdme and will feature both a NSM solver for RDME simulation on static domains and a sSSA-SDPD particle based fluid dynamics solver as described in the publication "A hybrid smoothed dissipative particle dynamics (SDPD) spatial stochastic simulation algorithm (sSSA) for advection–diffusion–reaction problems" by Drawert, Jacob, Li, Yi, Petzold https://www.sciencedirect.com/science/article/pii/S0021999118307101

PLEASE REGISTER AS A USER, so that we can prove SpatialPy has many users when we seek funding to support development. SpatialPy is part of the StochSS project.

PyPI - License PyPI - Python Version PyPI PyPI - Downloads

Table of contents

Installation

SpatialPy can be installed on your computer using different methods, as described below.

Using PyPI

On Linux, macOS, and Windows operating systems, you should be able to install SpatialPy with pip. Please review the official pip documentation for installation instructions and additional information.

Then, to install SpatialPy from the Python package repository, run the following command:

python3 -m pip install spatialpy --user --upgrade

Using the source code repository

As an alternative to getting it from PyPI, you can instruct pip to install SpatialPy directly from the GitHub repository:

python3 -m pip install https://github.com/StochSS/SpatialPy/archive/main.zip --user --upgrade

As a final alternative, you can first use git to clone a copy of the SpatialPy source tree from the GitHub repository to your local computer disk, and then install SpatialPy using that copy:

git clone https://github.com/StochSS/SpatialPy.git
cd SpatialPy
python3 -m pip install  .  --user --upgrade

Usage

SpatialPy provides simple object-oriented abstractions for defining a model of a biochemical system and simulating that model using efficient stochastic simulation algorithms. The basic steps to use SpatialPy are:

  1. Create a SpatialPy.Model containing molecular species, parameters, and reactions.
  2. Invoke the model's .run() method.

The run() method can be customized using keyword arguments to select different solvers, random seed, data return type and more. For more detailed examples on how to use SpatialPy, please see the Jupyter notebooks contained in the examples subdirectory.

Docker environment

You can use Docker to create a repeatable environment for developing and debugging SpatialPy. The supplied Dockerfile starts a jupyter server with SpatialPy dependencies installed.

If you have Docker Compose: docker-compose build && docker-compose up

Otherwise:

docker build -t spatialpy:latest .
docker run -v ./:/home/jovyan/spatialpy -v ./tmp:/tmp -p 8888:8888 -p 5000:5000

The SpatialPy repo is mounted into /home/jovyan so you can import it in the usual way for development (see examples).

Any changes you make to your local codebase are reflected in the docker container. Note that you DO NOT need to restart the docker container or even re-import spatialpy to see source changes take effect in jupyter notebooks.

The /tmp directory is also mounted for easy access to build and result directories.

Debugging

In order to compile the solver binary for use by the debugger, run solver.compile() with debug=True. This will inject the -g flag into the gcc command that compiles the solver, enabling gdb debug information.

You can invoke solver.run_debugger() anytime after you instantiate a solver in Python to start up a new session of gdbgui. The debugger will be available at http://127.0.0.1:5000.

Profiling

To enable profiling, both solver.compile() and solver.run() need to be invoked with profile=True. If you don't run solver.compile() explicitly, invoking solver.run() with profile=True will run compile() correctly for you.

Getting help

SpatialPy's online documentation provides more details about using the software. If you find any problem with SpatialPy or the documentation, please report it using the GitHub issue tracker for this repository. You can also contact Dr. Brian Drawert directly with questions and suggestions.

Contributing

We would be happy to receive your help and participation with enhancing SpatialPy! Please follow the guidelines described in CONTRIBUTING.md.

New developments happen primarily in the develop branch. New releases are put in the main branch.

Main Branch Develop Branch
Build Status Build Status

License

SpatialPy is licensed under the GNU General Public License version 3. Please see the file LICENSE for more information.

Authors and history

Acknowledgments

This work has been funded by National Institutes of Health (NIH) NIBIB Award No. 2R01EB014877-04A1.

SpatialPy uses numerous open-source packages, without which it would have been effectively impossible to develop this software with the resources we had. We want to acknowledge this debt. In alphabetical order, the packages are:

  • Jupyter – web application for creating documents containing code, visualizations and narrative text
  • MatplotLib – Python plotting library
  • Plotly – Graphing library for making interactive, publication-quality graphs
  • Numpy – the fundamental package for scientific computing with Python
  • Scipy – Python-based ecosystem of open-source software for mathematics, science, and engineering

Finally, we are grateful for institutional resources made available by the University of North Carolina at Asheville, the University of California at Santa Barbara, Uppsala University, and the California Institute of Technology.

           

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spatialpy-1.0.tar.gz (689.7 kB view details)

Uploaded Source

Built Distribution

spatialpy-1.0-py3-none-any.whl (752.9 kB view details)

Uploaded Python 3

File details

Details for the file spatialpy-1.0.tar.gz.

File metadata

  • Download URL: spatialpy-1.0.tar.gz
  • Upload date:
  • Size: 689.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10

File hashes

Hashes for spatialpy-1.0.tar.gz
Algorithm Hash digest
SHA256 449ef6452b5b2fe93a6d0dace6985511d867053903cb60400904d7c1494f5632
MD5 94ed0e955503099ece67181a7682f238
BLAKE2b-256 adc4deb6c4f43cd6f5fb2b5e387b9c0a81f1aaab6a28b3e9308772d864c30e73

See more details on using hashes here.

File details

Details for the file spatialpy-1.0-py3-none-any.whl.

File metadata

  • Download URL: spatialpy-1.0-py3-none-any.whl
  • Upload date:
  • Size: 752.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10

File hashes

Hashes for spatialpy-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5b0df42568afa815f2ef48c48f70a03d4e7493606e21b172c85ed8ef027b208a
MD5 03a99fe6460036ac5229b4c900a1b532
BLAKE2b-256 66787cbd5f5b88aa51e4b4ce6e4a6c6eb80871630dc87a893ad7970de4b96188

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page