Skip to content

Commit 552cab2

Browse files
Andrew FreiburgerAndrew Freiburger
Andrew Freiburger
authored and
Andrew Freiburger
committed
docs, examples, and tests updates
1 parent 0b46953 commit 552cab2

File tree

92 files changed

+276743
-2604
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

92 files changed

+276743
-2604
lines changed

docs/requirements.txt

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
anyio
2+
appdirs
3+
certifi
4+
charset-normalizer
5+
chemicals
6+
ChemW
7+
cobra
8+
commonmark
9+
cycler
10+
depinfo
11+
diskcache
12+
et-xmlfile
13+
fluids
14+
fonttools
15+
future
16+
h11
17+
httpcore
18+
httpx
19+
idna
20+
importlib-resources
21+
joblib
22+
kiwisolver
23+
matplotlib
24+
mpmath
25+
networkx
26+
numpy
27+
openpyxl
28+
optlang
29+
packaging
30+
pandas
31+
Pillow
32+
PubChemPy
33+
PuLP
34+
pydantic
35+
pyDEA
36+
Pygments
37+
pyparsing
38+
python-dateutil
39+
python-libsbml
40+
pytz
41+
requests
42+
rfc3986
43+
rich
44+
ruamel.yaml
45+
ruamel.yaml.clib
46+
scikit-learn
47+
scipy
48+
sigfig
49+
six
50+
sniffio
51+
sortedcontainers
52+
swiglpk
53+
sympy
54+
threadpoolctl
55+
typing_extensions
56+
urllib3
57+
xlrd
58+
xlwt-future
59+
zipp

docs/source/api.rst

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
ModelSEEDpy API
2+
________________________________________________________________________
3+
4+
The detailed documentation of all user-operable classes and functions in the ModelSEEDpy library are provided.
5+
6+
.. toctree::
7+
8+
contents
9+
core/core_index
10+
community/community_index
11+
fbapkg/fbapkg_index
12+
ml/ml_index

docs/source/build.rst

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Building a Model
2+
________________________________________________________________________
3+
4+
Models are constructed through the following sequence.
5+
6+
1)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
CommKinetic
2+
-------------------
3+
4+
+++++++++++++++++++++
5+
CommKineticPkg()
6+
+++++++++++++++++++++
7+
8+
This class applies kinetic constraints to the individual growth rates of community members:
9+
10+
.. code-block:: python
11+
12+
from modelseedpy.community import CommKineticPkg
13+
commkin = CommKineticPkg(model)
14+
15+
- *model* ``cobra.core.model.Model``: the CobraKBase model that will be constrained. The conversion from `standard COBRA models <https://cobrapy.readthedocs.io/en/latest/autoapi/cobra/core/model/index.html>`_ to CobraKBase models is facilitated by the `cobrakbase` package.
16+
17+
----------------------
18+
build_package()
19+
----------------------
20+
21+
The constraints are applied to the model:
22+
23+
.. code-block:: python
24+
25+
commkin.build_package(kinetic_coef, community_model = None)
26+
27+
- *kinetic_coef* ``float``: the kinetic coefficient that will constrain the cross-feeding interactions amongst the community species.
28+
- *community_model* ``float``: the ``MSCommunity`` model object that will be constrained, where ``None`` specifies the model from the initiation of this package.
29+
30+
----------------------
31+
Accessible content
32+
----------------------
33+
34+
The ``CommKineticPkg`` class contains a couple of accessible content that may be useful for subsequent post-processing or troubleshooting:
35+
36+
- *model* ``cobra.core.model.Model``: The cobrakbase model, with the corresponding constraints, that is constrained.
37+
- *variables* & *parameters* ``dict``: Dictionaries of the linear programming variables and the simulation parameters, respectively.
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
community
2+
________________________________________________________________________
3+
4+
|PyPI version| |License| |Downloads|
5+
6+
.. |PyPI version| image:: https://img.shields.io/pypi/v/modelseedpy.svg?logo=PyPI&logoColor=brightgreen
7+
:target: https://pypi.org/project/modelseedpy/
8+
:alt: PyPI version
9+
10+
.. |Actions Status| image:: https://github.com/freiburgermsu/modelseedpy/workflows/Test%20modelseedpy/badge.svg
11+
:target: https://github.com/freiburgermsu/modelseedpy/actions
12+
:alt: Actions Status
13+
14+
.. |License| image:: https://img.shields.io/badge/License-MIT-blue.svg
15+
:target: https://opensource.org/licenses/MIT
16+
:alt: License
17+
18+
.. |Downloads| image:: https://pepy.tech/badge/modelseedpy
19+
:target: https://pepy.tech/project/modelseedpy
20+
:alt: Downloads
21+
22+
The ModelSEEDpy packages that compatibilize the transport reactions of individual models and simulate cross-feeding amongst community members are organized in the ``community`` directory of the ModelSEEDpy library. These packages are imported via::
23+
24+
from modelseedpy.community import *
25+
26+
and include the following:
27+
28+
.. toctree::
29+
30+
commkineticpkg_api
31+
dfbapkg_api
32+
mscommunity_api
33+
mscompatibility_api

docs/source/community/dfbapkg_api.rst

+178
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
dFBA Package
2+
--------------
3+
4+
++++++++++
5+
dFBAPkg()
6+
++++++++++
7+
8+
This class defines and executes dynamic FBA simulations of COBRA models:
9+
10+
.. code-block:: python
11+
12+
from modelseedpy.fbapkg import dFBAPkg
13+
dfba = dFBAPkg(model, modelseed_db_path, solver = 'glpk', warnings = True, verbose = False, printing = False, jupyter = False)
14+
15+
- *model* ``cobra.core.model.Model``: the CobraKBase model that will be simulated. The conversion from `standard COBRA models <https://cobrapy.readthedocs.io/en/latest/autoapi/cobra/core/model/index.html>`_ to CobraKBase models is facilitated by the `cobrakbase` package.
16+
- *modelseed_db_path* ``str``: specifies the path to a local version of the ModelSEED Database.
17+
- *solver* ``str``: specifies which linear programmating algorithm will be used to simulate the FBA model. The `glpk` solver is selected by default since it is free and universally accessible.
18+
- *warnings*, *verbose*, & *printing* ``bool``: specifies whether simulation warnings, details and calculations, or results will be printed, respectively. These options are valuable for troubleshooting.
19+
- *jupyter* ``bool``: specifies whether simulation is being conducted in a Jupyter notebook, in which case the printed DataFrames will be expressed with the ``display()`` function.
20+
21+
22+
----------------------
23+
simulate()
24+
----------------------
25+
26+
A cobrakbase model is simulated with the parameterized kinetics data over the defined time and conditions:
27+
28+
.. code-block:: python
29+
30+
dfba.simulate(kinetics_path = None, initial_concentrations_M: dict = {}, total_time = 200, timestep = 20, export_name = None,
31+
export_directory = None, kinetics_data = {}, temperature = 25, p_h = 7, cellular_dry_mass_fg = 222, cellular_fL = 1,
32+
figure_title = 'Metabolic perturbation', included_metabolites = [], labeled_plots = True, visualize = True, export = True)
33+
34+
- *kinetics_path* & *kinetics_data* ``str`` & ``dict``: either the path to a `JSON` file that can be imported or a dictionary argument that provide the kinetics data that will constrain the model in the simulation. The `JSON` structure in both means of providing the data, and possesses the following nesting: ``<reaction>`` -> ``<source>`` -> ``substituted_rate_law`` + ``initial_concentrations_M`` + optional keys (such as ``metadata``). The ``substituted_rate_law`` key must contain the mathematically valid rate law expression as a string that can be evaluated through the `eval() built-in function <https://pythongeeks.org/python-eval-function/>`_ of Python, where each metabolite in the rate law is represented by a **single letter variable** that is defined with a `ModelSEED Compound ID <https://modelseed.org/biochem/compounds>`_ in the ``met_id`` key. The concentrations of the ``initial_concentrations_M`` key must be provided in units of Molar and defined for the rate law variable letters.
35+
36+
.. code-block:: json
37+
38+
{
39+
"R_3OAS140": {
40+
"source_1": {
41+
"substituted_rate_law": "(68.0*A*B)/(50.0*0.34*C+360.0*B+0.34*A+A*B*C)",
42+
"initial_concentrations_M": {
43+
"A": 0.0200,
44+
"C": 0.022,
45+
"B": 0.0014
46+
},
47+
"met_id": {
48+
"A": "cpd11468",
49+
"B": "cpd00067",
50+
"C": "cpd11492"
51+
}
52+
}
53+
},
54+
"rxn2": {
55+
"source_1": {
56+
"substituted_rate_law": "(A*B)/(50.0*0.34*C+3*B+0.34*A+C)",
57+
"initial_concentrations_M": {
58+
"A": 0.0200,
59+
"C": 0.022,
60+
"B": 0.0012
61+
},
62+
"met_id": {
63+
"A": "cpd11468",
64+
"B": "cpd00011",
65+
"C": "cpd11492"
66+
}
67+
}
68+
}
69+
}
70+
71+
The additional keys can provide provenance of the datum source:
72+
73+
.. code-block:: json
74+
75+
{
76+
"2-Oxogluterate dehydrogenase": {
77+
"55199": {
78+
"RateLaw": "Vmax*S/(Km+S)",
79+
"initial_concentrations_M": {
80+
"S": 1.6e-08
81+
},
82+
"metadata": {
83+
"Buffer": "[50 mm Mops, 8 mm TCEP, 50 mm Mops, 8 mm TCEP]",
84+
"Enzyme Variant": "wildtype",
85+
"KineticMechanismType": "Michaelis-Menten",
86+
"Organism": "Pisum sativum",
87+
"Pathway": null,
88+
"Product": "NADH;H+;Oxidized N-alpha-(benzyloxycarbonyl)-N-omega-(D,L-1,2-dithiolane-3-pentanoyl)-L-lysine",
89+
"Publication": "Neuburger M, Polidori AM, Pi\u00e8tre E, Faure M, Jourdain A, Bourguignon J, Pucci B, Douce R: Interaction between the lipoamide-containing H-protein and the lipoamide dehydrogenase (L-protein) of the glycine decarboxylase multienzyme system. 1. Biochemical studies., Eur J Biochem 2000 (267) , 2882-9",
90+
"Temperature": "30.0",
91+
"annotations": {
92+
"ECNumber": "1.8.1.4",
93+
"KeggReactionID": null,
94+
"PubMedID": 10806385.0,
95+
"SabioReactionID": 13969
96+
},
97+
"pH": "7.5",
98+
"reaction_string": " <-> Nicotinamide adenine dinucleotide-reduced + H+"
99+
},
100+
"substituted_parameters": {
101+
"Km": {
102+
"comment": "-",
103+
"deviat.": "10",
104+
"end val.": "-",
105+
"species": "N-alpha-(benzyloxycarbonyl)-N-omega-(D,L-1,2-dithiolane-3-pentanoyl)-L-lysine",
106+
"start val.": "170.0",
107+
"type": "Km",
108+
"unit": "\u00b5M"
109+
},
110+
"Vmax": {
111+
"comment": "-",
112+
"deviat.": "7",
113+
"end val.": "-",
114+
"species": "-",
115+
"start val.": "90.0",
116+
"type": "Vmax",
117+
"unit": "nmol/min"
118+
}
119+
},
120+
"substituted_rate_law": "1.5000000000000002e-09*S/(0.00016999999999999999+S)",
121+
"variables_molar": {
122+
"Km": "0.00016999999999999999",
123+
"Vmax": "1.5000000000000002e-09"
124+
},
125+
"variables_name": {
126+
"Km": "N-alpha-(benzyloxycarbonyl)-N-omega-(D,L-1,2-dithiolane-3-pentanoyl)-L-lysine",
127+
"S": "N-alpha-(benzyloxycarbonyl)-N-omega-(D,L-1,2-dithiolane-3-pentanoyl)-L-lysine",
128+
"Vmax": "-"
129+
}
130+
}
131+
}
132+
}
133+
134+
- *initial_concentrations_M* ``dict``: specifies initial concentrations of the simulated metabolites that supplant values from the kinetics data. Every metabolite in this dictionary must be defined in the model, and the concentrations in units of molar must be assigned according to the metabolite's ModelSEED Compound ID:
135+
136+
.. code-block:: json
137+
138+
{
139+
"cpd00002":0.0200,
140+
"cpd00008":0.0014
141+
}
142+
143+
- *total_time* & *timestep* ``float``: specify the total time and the timstep of the simulation in minutes.
144+
- *export_name* & *export_directory* ``str``: specify the folder name and directory to which the simulation content will be exported, where `None` defaults to a unique folder name in the current working directory.
145+
- *temperature* & *p_h* ``float``: optionally specify the temperature and pH at which the simulation will occur, respective, which allows the most closely matched datum to be parameterized, where multiple datum exist for the same reaction.
146+
- *cellular_dry_mass_fg* & *cellular_fL* ``float``: The `dry mass <https://doi.org/10.1101/2021.12.30.474524>`_ and `volume <https://doi.org/10.1128/AEM.00117-14>`_ of the simulated cell, in base units of femto- grams and liters, respectively. These values can be sourced from literature, and the standard values may approximate prokaryotic cells.
147+
- *figure_title*, *included_metabolites*, & *labeled_plots* ``str``, ``list``, & ``bool``: specify the title of the simulation Figure, the metabolites that will be plotted in the simulation Figure, and where each plot will be labeled with text to clarify its identity.
148+
- *visualize* & *export* ``bool``: specifies whether the simulation results will be visually depicted or exported to a specified folder, respectively.
149+
150+
151+
152+
----------------------
153+
Accessible content
154+
----------------------
155+
156+
A multitude of values are stored within the ``dFBA`` object, and can be subsequently used in a workflow. The complete list of content within the ``dFBA`` object can be printed through the built-in ``dir()`` function in the following example sequence:
157+
158+
.. code-block:: python
159+
160+
# conduct a dFBA simulation
161+
from dfbapy import dFBA
162+
dfba = dFBA(model)
163+
dfba.simulate(reaction_kinetics, None, total_time, timestep)
164+
165+
# evaluate the dFBA simulation contents
166+
print(dir(dfba))
167+
168+
The following list highlights stored content in the ``dFBA`` object after a simulation:
169+
170+
- *model* ``cobra.core.model.Model``: The cobrakbase model that is simulated.
171+
- *concentrations* & *fluxes* ``pandas.core.frame.DataFrame``: `Pandas DataFrames <https://pandas.pydata.org/pandas-docs/stable/reference/frame.html>`_ that contain the ``mM`` concentrations (or changes thereof) for each metabolite and ``mmol/g_(dw)/hr`` fluxes for each reaction, respectively.
172+
- *kinetics_data* ``dict``: A dictionary of the kinetics data constrains the model.
173+
- *timestep_value* ``float``: The simulation timestep in minutes.
174+
- *compound_ids* ``dict``: A dictionary of all ModelSEED IDs with their names as values, which is loaded from the ModelSEED Database via the parameterized path.
175+
- *cell_dry_mass* & *cell_liters* ``float``: The mass and volume of the simulated cell.
176+
- *changed* & *unchanged* ``set``: The exclusive sets of metabolites whose concentrations either changed or did not change over the simulation, respectively.
177+
- *constrained* ``OrderedDict``: A dictionary with reaction names as the keys and their respective kinetic constraints as the values.
178+
- *solutions* ``list``: A list of the Cobra solutions from each timestep that constitute the columns of the `fluxes` DataFrame.

0 commit comments

Comments
 (0)