Converting Biosimulators spatial simulation outputs into a Simularium-compliant format.
Project description
Biosimulators_simularium
Converting Biosimulators spatial simulation outputs into a Simularium-compliant format.
PLEASE NOTE: If you are using Apple silicon or Windows, you MUST use the Building from Source installation. Currently, smoldyn is only available on PyPI cleanly on Linux.
Installation with Python(PyPI) (Recommended)
The easiest way to interact with Biosimulators_simularium
is via the Python Package Index and a
virtual environment.
poetry use python3.10
We recommend installing and using Conda:
After you have created the environment...
conda create -n biosimularium python=3.10
conda activate biosimularium
pip install biosimulators-simularium
To verify successful platform installation...
python3
import biosimulators_simularium as biosimularium
biosimularium.__version__
should display the most recent version with no errors.
Installation (Building from Source) (Preferred)
The preferred build-from-source method involves using Python Poetry. Please ensure that this
is globally installed on your machine. The preferred method of installation from source
is through the use of the install-deps.sh
script that is included at the root of this
repo. Follow the instructions below to install the environment on your machine (mac):
git clone https://github.com/biosimulators/biosimulators-simularium.git
cd Biosimulators_simularium
chmod +x ./install.sh
./install.sh
- OPTIONAL:
poetry shell
python3
import biosimulators_simularium
If there are no errors, you are all set!
Installation (Building from Source) (Alternative)
BEFORE STARTING: This application uses Smoldyn to generate simulation data. Please install Smoldyn into your local environment. Instructions below use the Mac silicon install and Python 3.10. More information on installing Smoldyn can be found here
-
Set up a virtual environment. We recommend using Conda:
conda create -n biosimularium python=3.10
-
conda activate biosimularium
-
cd {REPO DESTINATION}
-
git clone https://github.com/biosimulators/biosimulators-simularium.git
-
cd Biosimulators_simularium
-
pip install -e .
-
FOR MAC ONLY: Download Smoldyn for your Mac (Silicon or Intel): https://www.smoldyn.org/download.html
cd /path/to/your/download/of/smoldyn-2.72-mac
sudo -H ./install.sh
-
OTHERWISE:
pip install smoldyn
A Jupyter Notebook will soon be available which is based off of the simulariumio tutorial series. This will give users the ability to have a tool that quickly generates simularium files with the click of a button based on a valid COMBINE/OMEX archive.
Getting-Started Example:
Generating a 3d stochastic particle diffusion simulation visualization is as easy as:
- Defining the filepath to an unpacked directory/archive in which a Smoldyn model resides and defining the name of simularium file. We also want to save the simularium file in JSON format:
from biosimulators_simularium import generate_simularium_file
archive_root = 'biosimulators_simularium/tests/fixtures/archives/MinE'
simularium_fn = 'simulation'
is_json = True
- Generating a simularium file from the model file housed in the
archive_root
:
generate_simularium_file(
working_dir=archive_root,
simularium_filename=simularium_fn,
use_json=is_json
)
import os
assert os.path.exists(os.path.join(archive_root, simularium_fn)))
Here is another, slightly more complex example in which agent parameters such as molecular mass and density are defined:
"""Generating a simularium file for the MinE Smoldyn model."""
import os
from biosimulators_simularium import generate_simularium_file
# define the working dir: here we use a dir from the tests library as an example.
working_dir = 'biosimulators_simularium/tests/fixtures/crowding'
# define the simularium filepath (using the working dir as root in this case)
simularium_fn = os.path.join(working_dir, 'simplified-api-output')
# define the path to the smoldyn model file which in this case is assumed to be in the working dir
model_fp = os.path.join(working_dir, 'model.txt')
# define agent parameters (for this example, we randomly select masses)
red_molecular_mass = 11004
green_molecular_mass = 12424
# create a parameter mapping that maps simulation species type names to respective density and molecular_mass
agent_params = {
'red': {
'density': 1.0,
'molecular_mass': red_molecular_mass,
},
'green': {
'density': 1.0,
'molecular_mass': green_molecular_mass,
}
}
# generate a simularium file from the given parameters
generate_simularium_file(
working_dir=working_dir,
simularium_filename=simularium_fn,
agent_params=agent_params,
model_fp=model_fp
)
# test the existence of a simularium file
try:
assert os.path.exists(simularium_fn)
print(f'{simularium_fn} has been successfully generated.')
except:
AssertionError('A simularium file could not be generated.')
Consider also this MinE simulation where we use the params function to extract parameters of agents from the Smoldyn model file:
import os
from biosimulators_simularium.simulation_data import generate_agent_params_for_minE
from biosimulators_simularium.exec import generate_simularium_file
# define the working dir
working_dir = 'biosimulators_simularium/tests/fixtures/MinE'
# define the simularium filepath (using the working dir as root in this case)
simularium_fn = os.path.join(working_dir, 'simplified-api-output')
model_fp = os.path.join(working_dir, 'model.txt')
base_mass = 12100
density = 1.0
agent_params = generate_agent_params_for_minE(model_fp, base_mass, density)
generate_simularium_file(
working_dir=working_dir,
simularium_filename=simularium_fn,
agent_params=agent_params,
model_fp=model_fp
)
try:
assert os.path.exists(simularium_fn)
print(f'{simularium_fn} has been successfully generated.')
except:
AssertionError('A simularium file could not be generated.')
You may then navigate to https://simularium.allencell.org/viewer and drag/drop the newly generated simularium file into the GUI window.
We welcome any and all collaborations and/or raising of issues:
To report an issue, please visit our Github issues page.
To contact us, please send an email to apatrie@uchc.edu or info@biosimulators.org
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file biosimulators_simularium-0.6.3.tar.gz
.
File metadata
- Download URL: biosimulators_simularium-0.6.3.tar.gz
- Upload date:
- Size: 50.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.3 Darwin/23.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2bba41243beddc799b300cb252848484e69a05edf168d7c87286fe66406597df |
|
MD5 | b20d1fbfe7c92ba492bc157d08d04d51 |
|
BLAKE2b-256 | da907a12884a862e6896748e0cf21b63c126f8a58a40058bcd82736a65be27e2 |
File details
Details for the file biosimulators_simularium-0.6.3-py3-none-any.whl
.
File metadata
- Download URL: biosimulators_simularium-0.6.3-py3-none-any.whl
- Upload date:
- Size: 51.6 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.3 Darwin/23.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8c7090f02b5bbb4500166a926bc11b1eda99b29c67fceee846a394b0a1a2cdf |
|
MD5 | a220a0cb0c14200d3fd15b94aa203e33 |
|
BLAKE2b-256 | 25d595233662a8dc18ec28084b52e4e1d1faf4b496dd5b4d17b370c2b3d463bb |