### Install GillesPy2 from GitHub Source: https://gillespy2.readthedocs.io/en/latest/getting_started/installation/installation.html Install the package directly from the source repository using pip. ```bash python3 -m pip install git+https@github.com:GillesPy2/GillesPy2.git --user --upgrade ``` -------------------------------- ### Clone and install GillesPy2 from source Source: https://gillespy2.readthedocs.io/en/latest/getting_started/installation/installation.html Clone the repository locally and perform an installation from the source directory. ```bash git clone --recursive https@github.com:GillesPy2/GillesPy2.git cd GillesPy2 python3 -m pip install . --user --upgrade ``` -------------------------------- ### Install GillesPy2 via PyPI Source: https://gillespy2.readthedocs.io/en/latest/getting_started/installation/installation.html Use pip to install or upgrade the package from the Python Package Index. ```bash python3 -m pip install gillespy2 --user --upgrade ``` -------------------------------- ### Run Model Simulation Source: https://gillespy2.readthedocs.io/en/latest/getting_started/basic_usage/basic_usage.html Instantiates the model and executes the simulation for a specified number of trajectories. ```python model = Dimerization() results = model.run(number_of_trajectories=10) ``` -------------------------------- ### gillespy2.solvers.cpp.build Package Overview Source: https://gillespy2.readthedocs.io/en/latest/classes/gillespy2.solvers.cpp.build.html Overview of the build subpackage within the C++ solvers module of GillesPy2. ```APIDOC ## Package: gillespy2.solvers.cpp.build ### Description This package contains the build infrastructure for C++ solvers in GillesPy2. It handles the compilation and generation of simulation engines. ### Submodules - **build_engine**: Manages the construction of the simulation engine. - **expression**: Handles mathematical expression parsing for C++. - **make**: Manages build system interactions. - **template_gen**: Generates source code templates for solvers. ``` -------------------------------- ### Run Stochastic Simulation (SSA) Source: https://gillespy2.readthedocs.io/en/latest/tutorials/tut_toggle_switch/tut_toggle_switch.html Instantiate the defined model and run it using the default SSA algorithm by calling the run() method without specifying a solver. ```python model = ToggleSwitch() s_results = model.run() ``` -------------------------------- ### gillespy2.solvers Package Overview Source: https://gillespy2.readthedocs.io/en/latest/_sources/classes/gillespy2.solvers.rst.txt Overview of the gillespy2.solvers package structure and available solver modules. ```APIDOC ## gillespy2.solvers Package ### Description The gillespy2.solvers package serves as the central module for managing simulation solvers in the GillesPy2 framework. It organizes solvers into specific implementations based on the underlying computational engine. ### Subpackages - **gillespy2.solvers.cpp**: C++ based solver implementations. - **gillespy2.solvers.numpy**: NumPy based solver implementations. - **gillespy2.solvers.stochkit**: StochKit based solver implementations. - **gillespy2.solvers.utilities**: Helper utilities for solver operations. ``` -------------------------------- ### Run simulation with Hybrid Switching solver Source: https://gillespy2.readthedocs.io/en/latest/getting_started/basic_usage/basic_usage.html Executes the model using the Tau-Hybrid algorithm. ```python # Create an instance of the model object, then run the simulation. model = AutomaticSwitchExample() results = model.run(algorithm="Tau-Hybrid") ``` -------------------------------- ### Run Deterministic Simulation (ODE) Source: https://gillespy2.readthedocs.io/en/latest/tutorials/tut_toggle_switch/tut_toggle_switch.html Execute the same model using a deterministic ODE solver by passing the 'ODE' string to the algorithm keyword argument in the run() method. ```python d_results = model.run(algorithm="ODE") ``` -------------------------------- ### gillespy2.solvers.utilities Package Source: https://gillespy2.readthedocs.io/en/latest/classes/gillespy2.solvers.html Details the modules within the gillespy2.solvers.utilities package, containing utility functions for solvers. ```APIDOC ## gillespy2.solvers.utilities Package ### Description This package contains utility functions for solver operations. ### Submodules - **gillespy2.solvers.utilities.Tau module** - **gillespy2.solvers.utilities.cpp_support_test module** - **gillespy2.solvers.utilities.solverutils module** ``` -------------------------------- ### Define a model for hybrid simulation Source: https://gillespy2.readthedocs.io/en/latest/_sources/getting_started/basic_usage/basic_usage.rst.txt Initializes a GillesPy2 model with parameters, species, and reactions suitable for hybrid simulation. ```Python import gillespy2 # Define the model. def AutomaticSwitchExample(parameter_values=None): # First call the gillespy2.Model initializer. model = gillespy2.Model(name="Automatic Switch Example") # Define parameters. k1 = gillespy2.Parameter(name='k1', expression=3e-4) k2 = gillespy2.Parameter(name='k2', expression=0.5e-2) k3 = gillespy2.Parameter(name='k3', expression=2e-1) model.add_parameter([k1,k2,k3]) # Define species. A = gillespy2.Species(name='A', initial_value=400) B = gillespy2.Species(name='B', initial_value=10000) C = gillespy2.Species(name='C', initial_value=10000) model.add_species([A, B, C]) # Define reactions. r1 = gillespy2.Reaction(name="r1", rate=k1, reactants={A:1,B:1}, products={B:1,C:1}) r2 = gillespy2.Reaction(name="r2", rate=k2, reactants={B:1}, products={}) r3 = gillespy2.Reaction(name="r3", rate=k3, reactants={C:1}, products={A:1}) model.add_reaction([r1,r2,r3]) # Set the timespan for the simulation. tspan = gillespy2.TimeSpan.linspace(t=600, num_points=601) model.timespan(tspan) return model ``` -------------------------------- ### gillespy2.solvers.stochkit Package Source: https://gillespy2.readthedocs.io/en/latest/classes/gillespy2.solvers.html Details the modules within the gillespy2.solvers.stochkit package, likely for integrating with StochKit solvers. ```APIDOC ## gillespy2.solvers.stochkit Package ### Description This package facilitates integration with StochKit solvers. ### Submodules - **gillespy2.solvers.stochkit.stochkit_solvers module** ``` -------------------------------- ### gillespy2.solvers.cpp Package Source: https://gillespy2.readthedocs.io/en/latest/classes/gillespy2.solvers.html Details the subpackages and modules within the gillespy2.solvers.cpp package, which likely contains C++ implementations for solvers. ```APIDOC ## gillespy2.solvers.cpp Package ### Description This package contains C++ implementations for various solvers. ### Subpackages - **gillespy2.solvers.cpp.build package**: Contains modules for building C++ solver components. - **gillespy2.solvers.cpp.build.build_engine module** - **gillespy2.solvers.cpp.build.expression module** - **gillespy2.solvers.cpp.build.make module** - **gillespy2.solvers.cpp.build.template_gen module** ### Submodules - **gillespy2.solvers.cpp.c_decoder module** - **gillespy2.solvers.cpp.c_solver module** - **gillespy2.solvers.cpp.ode_c_solver module** - **gillespy2.solvers.cpp.ssa_c_solver module** - **gillespy2.solvers.cpp.tau_hybrid_c_solver module** - **gillespy2.solvers.cpp.tau_leaping_c_solver module** ``` -------------------------------- ### Execute hybrid simulation Source: https://gillespy2.readthedocs.io/en/latest/_sources/getting_started/basic_usage/basic_usage.rst.txt Runs the model using the Tau-Hybrid algorithm by specifying the solver keyword argument. ```Python # Create an instance of the model object, then run the simulation. model = AutomaticSwitchExample() results = model.run(algorithm="Tau-Hybrid") ``` -------------------------------- ### Import GillesPy2 Source: https://gillespy2.readthedocs.io/en/latest/tutorials/tut_toggle_switch/tut_toggle_switch.html Import the necessary GillesPy2 library at the beginning of your Python script. ```python import gillespy2 ``` -------------------------------- ### gillespy2.stochss package Source: https://gillespy2.readthedocs.io/en/latest/classes/gillespy2.stochss.html Documentation for the stochss subpackage within GillesPy2, which handles export functionality for the StochSS platform. ```APIDOC ## gillespy2.stochss package ### Description The stochss package provides modules for exporting GillesPy2 models to the StochSS (Stochastic Simulation Service) platform. ### Submodules - **gillespy2.stochss.StochSSexport**: Module containing functionality to export models for use in StochSS. ``` -------------------------------- ### gillespy2.sbml Package Structure Source: https://gillespy2.readthedocs.io/en/latest/classes/gillespy2.sbml.html Overview of the submodules within the gillespy2.sbml package. ```APIDOC ## gillespy2.sbml Package This package provides functionality for working with SBML (Systems Biology Markup Language). ### Submodules * **gillespy2.sbml.SBMLexport**: Module for exporting models to SBML format. * **gillespy2.sbml.SBMLimport**: Module for importing models from SBML format. ``` -------------------------------- ### Define Toggle Switch Model in GillesPy2 Source: https://gillespy2.readthedocs.io/en/latest/tutorials/tut_toggle_switch/tut_toggle_switch.html Define a biochemical model, such as a genetic toggle switch, using GillesPy2's Model, Parameter, Species, and Reaction classes. This includes setting initial values, parameters, and reaction propensities. ```python def ToggleSwitch(parameter_values=None): # Initialize the model. gillespy2.Model(name="toggle_switch") # Define parameters. alpha1 = gillespy2.Parameter(name='alpha1', expression=1) alpha2 = gillespy2.Parameter(name='alpha2', expression=1) beta = gillespy2.Parameter(name='beta', expression=2.0) gamma = gillespy2.Parameter(name='gamma', expression=2.0) mu = gillespy2.Parameter(name='mu', expression=1.0) model.add_parameter([alpha1, alpha2, beta, gamma, mu]) # Define molecular species. U = gillespy2.Species(name='U', initial_value=10) V = gillespy2.Species(name='V', initial_value=10) model.add_species([U, V]) # Define reactions. cu = gillespy2.Reaction(name="r1", reactants={}, products={U:1}, propensity_function="alpha1/(1+pow(V,beta))") cv = gillespy2.Reaction(name="r2", reactants={}, products={V:1}, propensity_function="alpha2/(1+pow(U,gamma))") du = gillespy2.Reaction(name="r3", reactants={U:1}, products={}, rate=mu) dv = gillespy2.Reaction(name="r4", reactants={V:1}, products={}, rate=mu) model.add_reaction([cu, cv, du, dv]) tspan = gillespy2.TimeSpan.linspace(t=100, num_points=101) model.timespan(tspan) return model ``` -------------------------------- ### gillespy2.solvers.numpy Package Source: https://gillespy2.readthedocs.io/en/latest/classes/gillespy2.solvers.html Details the modules within the gillespy2.solvers.numpy package, which likely provides NumPy-based solver implementations. ```APIDOC ## gillespy2.solvers.numpy Package ### Description This package provides solver implementations using NumPy. ### Submodules - **gillespy2.solvers.numpy.CLE_solver module** - **gillespy2.solvers.numpy.ode_solver module** - **gillespy2.solvers.numpy.ssa_solver module** - **gillespy2.solvers.numpy.tau_hybrid_solver module** - **gillespy2.solvers.numpy.tau_leaping_solver module** ``` -------------------------------- ### gillespy2.core.sortableobject Source: https://gillespy2.readthedocs.io/en/latest/genindex.html Documentation for the sortableobject module within the gillespy2.core package. ```APIDOC ## Module: gillespy2.core.sortableobject ### Description This module provides the base functionality for sortable objects within the GillesPy2 framework. ### Classes - **SortableObject** (class) - A base class designed to support sorting operations within the package. ``` -------------------------------- ### Plot Simulation Results Source: https://gillespy2.readthedocs.io/en/latest/getting_started/basic_usage/basic_usage.html Visualizes the generated trajectories for monomer and dimer species using Matplotlib. ```python import matplotlib.pyplot as plt for index in range(0, 10): trajectory = results[index] plt.plot(trajectory['time'], trajectory['monomer'], 'r') plt.plot(trajectory['time'], trajectory['dimer'], 'b') ``` -------------------------------- ### Plot simulation results Source: https://gillespy2.readthedocs.io/en/latest/getting_started/basic_usage/basic_usage.html Visualizes the species population over time using matplotlib. ```python plt.figure(figsize=(15, 10)) for species in results[0]: if species == 'time': continue plt.plot(results[0]['time'], results[0][species], label='{0}'.format(species)) plt.title('Example Hybrid Switching Model') plt.legend(loc='best') ``` -------------------------------- ### Define a GillesPy2 model Source: https://gillespy2.readthedocs.io/en/latest/getting_started/basic_usage/basic_usage.html Creates a model instance with parameters, species, reactions, and a timespan. ```python import gillespy2 # Define the model. def AutomaticSwitchExample(parameter_values=None): # First call the gillespy2.Model initializer. model = gillespy2.Model(name="Automatic Switch Example") # Define parameters. k1 = gillespy2.Parameter(name='k1', expression=3e-4) k2 = gillespy2.Parameter(name='k2', expression=0.5e-2) k3 = gillespy2.Parameter(name='k3', expression=2e-1) model.add_parameter([k1,k2,k3]) # Define species. A = gillespy2.Species(name='A', initial_value=400) B = gillespy2.Species(name='B', initial_value=10000) C = gillespy2.Species(name='C', initial_value=10000) model.add_species([A, B, C]) # Define reactions. r1 = gillespy2.Reaction(name="r1", rate=k1, reactants={A:1,B:1}, products={B:1,C:1}) r2 = gillespy2.Reaction(name="r2", rate=k2, reactants={B:1}, products={}) r3 = gillespy2.Reaction(name="r3", rate=k3, reactants={C:1}, products={A:1}) model.add_reaction([r1,r2,r3]) # Set the timespan for the simulation. tspan = gillespy2.TimeSpan.linspace(t=600, num_points=601) model.timespan(tspan) return model ``` -------------------------------- ### gillespy2.sbml.SBMLimport Source: https://gillespy2.readthedocs.io/en/latest/_sources/classes/gillespy2.sbml.rst.txt Module for importing SBML files into gillespy2 models. ```APIDOC ## SBMLimport Module ### Description Provides functionality to parse and import SBML files into gillespy2 model structures. ### Module Path gillespy2.sbml.SBMLimport ``` -------------------------------- ### Plot Deterministic Simulation Results Source: https://gillespy2.readthedocs.io/en/latest/tutorials/tut_toggle_switch/tut_toggle_switch.html Visualize the results from the deterministic ODE simulation using the plot() method, providing a title for the plot. ```python d_results.plot(title="Deterministic Switch") ``` -------------------------------- ### gillespy2.sbml.SBMLexport Source: https://gillespy2.readthedocs.io/en/latest/_sources/classes/gillespy2.sbml.rst.txt Module for exporting gillespy2 models to SBML format. ```APIDOC ## SBMLexport Module ### Description Provides functionality to export gillespy2 model objects into SBML (Systems Biology Markup Language) files. ### Module Path gillespy2.sbml.SBMLexport ``` -------------------------------- ### Define a Dimerization Model Source: https://gillespy2.readthedocs.io/en/latest/getting_started/basic_usage/basic_usage.html Creates a model object representing a reversible dimerization process with specified parameters, species, and reactions. ```python import gillespy2 def Dimerization(parameter_values=None): # First call the gillespy2.Model initializer. model = gillespy2.Model() # Define parameters for the rates of creation and dissociation. k_c = gillespy2.Parameter(name='k_c', expression=0.005) k_d = gillespy2.Parameter(name='k_d', expression=0.08) model.add_parameter([k_c, k_d]) # Define variables for the molecular species representing M & D. m = gillespy2.Species(name='monomer', initial_value=30) d = gillespy2.Species(name='dimer', initial_value=0) model.add_species([m, d]) # The list of reactants and products for a Reaction object are # each a Python dictionary in which the dictionary keys are # Species objects and the values are stoichiometries of the # species in the reaction. r_c = gillespy2.Reaction(name="r_creation", rate=k_c, reactants={m:2}, products={d:1}) r_d = gillespy2.Reaction(name="r_dissociation", rate=k_d, reactants={d:1}, products={m:2}) model.add_reaction([r_c, r_d]) # Set the timespan for the simulation. tspan = gillespy2.TimeSpan.linspace(t=100, num_points=101) model.timespan(tspan) return model ``` -------------------------------- ### Plot Stochastic Simulation Results Source: https://gillespy2.readthedocs.io/en/latest/tutorials/tut_toggle_switch/tut_toggle_switch.html Visualize the results obtained from the stochastic simulation using the plot() method on the results object, with a specified title. ```python s_results.plot(title="Stochastic Switch") ``` -------------------------------- ### SortableObject Class Definition Source: https://gillespy2.readthedocs.io/en/latest/_modules/gillespy2/core/sortableobject.html This class defines comparison methods for objects, enabling sorting based on their string representation. It includes implementations for equality, inequality, greater than, greater than or equal to, less than, and less than or equal to operators. The hash method is also provided for use in hash-based collections. ```python # GillesPy2 is a modeling toolkit for biochemical simulation. # Copyright (C) 2019-2024 GillesPy2 developers. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . [docs] class SortableObject(object): """Base class for GillesPy2 objects that are sortable.""" def __eq__(self, other): return str(self) == str(other) def __ne__(self, other): return not self.__eq__(other) def __gt__(self, other): return not self.__le__(other) def __ge__(self, other): return not self.__lt__(other) def __lt__(self, other): return str(self) < str(other) def __le__(self, other): return str(self) <= str(other) def __cmp__(self, other): return cmp(str(self), str(other)) def __hash__(self): if hasattr(self, '_hash'): return self._hash if hasattr(self, 'id'): self._hash = hash(self.id) elif hasattr(self, 'name'): self._hash = hash(self.name) else: self._hash = hash(self) return self._hash ``` -------------------------------- ### SortableObject Class Source: https://gillespy2.readthedocs.io/en/latest/_modules/gillespy2/core/sortableobject.html The SortableObject class is the base class for GillesPy2 objects that support sorting and comparison operations. ```APIDOC ## Class: SortableObject ### Description Base class for GillesPy2 objects that are sortable. Provides comparison methods based on string representation or object ID/name. ### Methods - `__eq__(self, other)`: Checks if two objects are equal based on their string representation. - `__ne__(self, other)`: Checks if two objects are not equal. - `__gt__(self, other)`: Checks if the object is greater than another. - `__ge__(self, other)`: Checks if the object is greater than or equal to another. - `__lt__(self, other)`: Checks if the object is less than another. - `__le__(self, other)`: Checks if the object is less than or equal to another. - `__cmp__(self, other)`: Compares the object with another based on their string representation. - `__hash__(self)`: Computes the hash value for the object, prioritizing 'id', then 'name', then the object itself. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.