Skip to content

Commit fb5fce0

Browse files
authored
Merge pull request #60 from SystemsBioinformatics/dev
CBMPy 0.8.7 dev merge
2 parents 2280d11 + 727a0f9 commit fb5fce0

Some content is hidden

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

63 files changed

+51409
-615
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.svn
2+
build
23
cbmpy.egg-info
34
__pycache__
45
wing-cbmpy.wpr

CONTRIBUTORS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Contributors
22

3+
## Release 0.8.7
4+
Many thanks to Steven Wijnen for his debugging, testing and help with the QP, constraints and FBCV3 implementation. This release supports his dcFBA/endPointFBA https://github.com/SystemsBioinformatics/dynamic-community-fba package.
5+
36
## Release 0.8.4
47
Many thanks go to @willigot for their suggestions and code contributions.
58

README.md

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# CBMPy
2-
PySCeS Constraint Based Modelling (http://cbmpy.sourceforge.net)
3-
Copyright (C) 2010-2023 Brett G. Olivier, Vrije Universiteit Amsterdam, Amsterdam, The Netherlands
2+
PySCeS Constraint Based Modelling (https://systemsbioinformatics.github.io/cbmpy/)
3+
Copyright (C) 2010-2024 Brett G. Olivier, Vrije Universiteit Amsterdam, Amsterdam, The Netherlands
44

55
This program is free software: you can redistribute it and/or modify
66
it under the terms of the GNU General Public License as published by
@@ -18,38 +18,40 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
1818
Author: Brett G. Olivier (@bgoli)
1919

2020
## About
21-
PySCeS CBMPy (http://cbmpy.sourceforge.net) is a new platform for constraint
21+
CBMPy (https://systemsbioinformatics.github.io/cbmpy/) is a new platform for constraint
2222
based modelling and analysis. It has been designed using principles developed
2323
in the PySCeS simulation software project: usability, flexibility and accessibility.
2424
Its architecture is both extensible and flexible using data structures that are intuitive
2525
to the biologist (metabolites, reactions, compartments) while transparently translating
2626
these into the underlying mathematical structures used in advanced analysis (LP's, MILP's).
2727

28-
PySCeS CBMPy implements popular analyses such as FBA, FVA, element/charge
28+
CBMPy fully supports all the SBML Flux Balance Constraints (FBC) interoperability standards.
29+
30+
CBMPy implements popular analyses such as FBA, FVA, element/charge
2931
balancing, network analysis and model editing as well as advanced methods
3032
developed specifically for the ecosystem modelling: minimal distance methods,
3133
flux minimization and input selection. To cater for a diverse range of modelling
32-
needs PySCeS CBMPy supports user interaction via:
34+
needs CBMPy supports user interaction via:
3335

3436
- interactive console, scripting for advanced use or as a library for software development
3537
- GUI, for quick access to a visual representation of the model, analysis methods and annotation tools
3638
- SOAP based web services: using the Mariner framework much high level functionality is exposed for integration into web tools
3739

38-
For more information on the development and use of CBMPy (https://github.com/SystemsBioinformatics/cbmpy)
40+
For more information on the development and use of CBMPy (https://systemsbioinformatics.github.io/cbmpy/)
3941

40-
CBMPy has been tested on Windows 7 and 8.1, 10, Mac OSX and Ubuntu Linux 12.04, 14.04, 16.04, 20.04.
41-
CBMPy is currently developed on Python 3.7 and Python 3.6 or newer is highly recommended
42+
CBMPy has been tested on Windows 7 and 8.1, 10, 11, Mac OSX and Ubuntu Linux 12.04, 14.04, 16.04, 20.04, 22.04
43+
CBMPy is currently developed on Python 3.10 and Python 3.8 or newer is highly recommended
4244

4345
## Install
44-
The best way to get the basic CBMPy running is to install from **PyPI** or create an Anaconda environment. CBMPy is developed on GitHub (https://github.com/SystemsBioinformatics/cbmpy)
46+
The best way to get the basic CBMPy running is to install from **PyPI** or create an Anaconda environment. CBMPy is developed on GitHub (https://systemsbioinformatics.github.io/cbmpy/)
4547

4648
### Install with pip using requirements.txt
47-
From a terrminal or command prompt try:
49+
From a terrminal or command prompt try to install the required packages
4850

4951
`pip install -r requirements.txt`
5052

51-
### New experimental PyPI install method.
52-
`pip install cbmpy[sbml]`
53+
### Then install CBMPy
54+
`pip install cbmpy`
5355

5456
### Install by creating an Anaconda environment using environment.yml
5557
From a terminal or command prompt try:
@@ -75,4 +77,4 @@ Once you have installed CBMPy it can be easily upgraded.
7577
### Anaconda update
7678
`conda update cbmpy`
7779

78-
(c) Brett G. Olivier, Amsterdam, 2014-2023
80+
(c) Brett G. Olivier, Amsterdam, 2014-2024

RELEASES.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
# Release history
22

3-
## Release 0.8.4 (2023)
4-
Primarily a Python 9.x compatability release
3+
## Release 0.8.7 (2023)
4+
Intermediatery release that includes bug fixes, code cleanup and new features to support endPoint FBA. Has alpha support for Flux Balance Constraints V3 features including quadratic objectives, non-storichiometric user constraints and KeyValue pairs. Try the latest format with cbmpy.writeSBML3FBCV3.
55

6+
## Release 0.8.4 (2022)
7+
Primarily a Python 3.x compatability release
68

79
## Release 0.8.2 (2021)
810
## Release 0.8.1 (2021-07-23)
9-
1011
Primarily a bugfix release to fix the SymPy compatability issues as well as improved requirements handling.
1112

1213

1314

1415

1516

16-
(c) Brett G. Olivier, Amsterdam, 2021
17+
(c) Brett G. Olivier, Amsterdam, 2023
18+
cbmpy.writeSBML3FBCV2(

cbmpy-anaconda-py10.yml

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
name: cbmpy
2+
channels:
3+
- conda-forge
4+
- defaults
5+
dependencies:
6+
- aiofiles=22.1.0=py310haa95532_0
7+
- aiosqlite=0.18.0=py310haa95532_0
8+
- anyio=3.5.0=py310haa95532_0
9+
- appdirs=1.4.4=pyhd3eb1b0_0
10+
- argon2-cffi=21.3.0=pyhd3eb1b0_0
11+
- argon2-cffi-bindings=21.2.0=py310h2bbff1b_0
12+
- asttokens=2.0.5=pyhd3eb1b0_0
13+
- attrs=22.1.0=py310haa95532_0
14+
- babel=2.11.0=py310haa95532_0
15+
- backcall=0.2.0=pyhd3eb1b0_0
16+
- beautifulsoup4=4.12.2=py310haa95532_0
17+
- biopython=1.78=py310h2bbff1b_0
18+
- blas=1.0=mkl
19+
- bleach=4.1.0=pyhd3eb1b0_0
20+
- brotli=1.0.9=h2bbff1b_7
21+
- brotli-bin=1.0.9=h2bbff1b_7
22+
- brotlipy=0.7.0=py310h2bbff1b_1002
23+
- bzip2=1.0.8=he774522_0
24+
- ca-certificates=2023.05.30=haa95532_0
25+
- certifi=2023.7.22=py310haa95532_0
26+
- cffi=1.15.1=py310h2bbff1b_3
27+
- charset-normalizer=2.0.4=pyhd3eb1b0_0
28+
- colorama=0.4.6=py310haa95532_0
29+
- comm=0.1.2=py310haa95532_0
30+
- contourpy=1.0.5=py310h59b6b97_0
31+
- cryptography=41.0.2=py310h31511bf_0
32+
- cycler=0.11.0=pyhd3eb1b0_0
33+
- debugpy=1.6.7=py310hd77b12b_0
34+
- decorator=5.1.1=pyhd3eb1b0_0
35+
- defusedxml=0.7.1=pyhd3eb1b0_0
36+
- entrypoints=0.4=py310haa95532_0
37+
- executing=0.8.3=pyhd3eb1b0_0
38+
- fonttools=4.25.0=pyhd3eb1b0_0
39+
- freetype=2.12.1=ha860e81_0
40+
- giflib=5.2.1=h8cc25b3_3
41+
- glib=2.69.1=h5dc1a3c_2
42+
- gst-plugins-base=1.18.5=h9e645db_0
43+
- gstreamer=1.18.5=hd78058f_0
44+
- icc_rt=2022.1.0=h6049295_2
45+
- icu=58.2=ha925a31_3
46+
- idna=3.4=py310haa95532_0
47+
- intel-openmp=2023.1.0=h59b6b97_46319
48+
- ipykernel=6.25.0=py310h9909e9c_0
49+
- ipython=8.12.0=py310haa95532_0
50+
- ipython_genutils=0.2.0=pyhd3eb1b0_1
51+
- ipywidgets=8.0.4=py310haa95532_0
52+
- jedi=0.18.1=py310haa95532_1
53+
- jinja2=3.1.2=py310haa95532_0
54+
- jpeg=9e=h2bbff1b_1
55+
- json5=0.9.6=pyhd3eb1b0_0
56+
- jsonschema=4.17.3=py310haa95532_0
57+
- jupyter=1.0.0=py310haa95532_8
58+
- jupyter_client=7.4.9=py310haa95532_0
59+
- jupyter_console=6.6.3=py310haa95532_0
60+
- jupyter_core=5.3.0=py310haa95532_0
61+
- jupyter_events=0.6.3=py310haa95532_0
62+
- jupyter_server=1.23.4=py310haa95532_0
63+
- jupyter_server_fileid=0.9.0=py310haa95532_0
64+
- jupyter_server_ydoc=0.8.0=py310haa95532_1
65+
- jupyter_ydoc=0.2.4=py310haa95532_0
66+
- jupyterlab=3.6.3=py310haa95532_0
67+
- jupyterlab_pygments=0.1.2=py_0
68+
- jupyterlab_server=2.22.0=py310haa95532_0
69+
- jupyterlab_widgets=3.0.5=py310haa95532_0
70+
- kiwisolver=1.4.4=py310hd77b12b_0
71+
- krb5=1.19.4=h5b6d351_0
72+
- lerc=3.0=hd77b12b_0
73+
- libbrotlicommon=1.0.9=h2bbff1b_7
74+
- libbrotlidec=1.0.9=h2bbff1b_7
75+
- libbrotlienc=1.0.9=h2bbff1b_7
76+
- libclang=14.0.6=default_hb5a9fac_1
77+
- libclang13=14.0.6=default_h8e68704_1
78+
- libdeflate=1.17=h2bbff1b_0
79+
- libffi=3.4.4=hd77b12b_0
80+
- libiconv=1.16=h2bbff1b_2
81+
- libogg=1.3.5=h2bbff1b_1
82+
- libpng=1.6.39=h8cc25b3_0
83+
- libsodium=1.0.18=h62dcd97_0
84+
- libtiff=4.5.0=h6c2663c_2
85+
- libvorbis=1.3.7=he774522_0
86+
- libwebp=1.2.4=hbc33d0d_1
87+
- libwebp-base=1.2.4=h2bbff1b_1
88+
- libxml2=2.10.3=h0ad7f3c_0
89+
- libxslt=1.1.37=h2bbff1b_0
90+
- lxml=4.9.2=py310h2bbff1b_0
91+
- lz4-c=1.9.4=h2bbff1b_0
92+
- markupsafe=2.1.1=py310h2bbff1b_0
93+
- matplotlib=3.7.1=py310haa95532_1
94+
- matplotlib-base=3.7.1=py310h4ed8f06_1
95+
- matplotlib-inline=0.1.6=py310haa95532_0
96+
- mistune=0.8.4=py310h2bbff1b_1000
97+
- mkl=2023.1.0=h8bd8f75_46356
98+
- mkl-service=2.4.0=py310h2bbff1b_1
99+
- mkl_fft=1.3.6=py310h4ed8f06_1
100+
- mkl_random=1.2.2=py310h4ed8f06_1
101+
- mpmath=1.3.0=py310haa95532_0
102+
- munkres=1.1.4=py_0
103+
- nbclassic=0.5.5=py310haa95532_0
104+
- nbclient=0.5.13=py310haa95532_0
105+
- nbconvert=6.5.4=py310haa95532_0
106+
- nbformat=5.7.0=py310haa95532_0
107+
- nest-asyncio=1.5.6=py310haa95532_0
108+
- notebook=6.5.4=py310haa95532_1
109+
- notebook-shim=0.2.2=py310haa95532_0
110+
- numpy=1.25.0=py310h055cbcc_0
111+
- numpy-base=1.25.0=py310h65a83cf_0
112+
- openssl=1.1.1v=h2bbff1b_0
113+
- packaging=23.0=py310haa95532_0
114+
- pandocfilters=1.5.0=pyhd3eb1b0_0
115+
- parso=0.8.3=pyhd3eb1b0_0
116+
- pcre=8.45=hd77b12b_0
117+
- pickleshare=0.7.5=pyhd3eb1b0_1003
118+
- pillow=9.4.0=py310hd77b12b_0
119+
- pip=23.2.1=py310haa95532_0
120+
- platformdirs=2.5.2=py310haa95532_0
121+
- ply=3.11=py310haa95532_0
122+
- pooch=1.4.0=pyhd3eb1b0_0
123+
- prometheus_client=0.14.1=py310haa95532_0
124+
- prompt-toolkit=3.0.36=py310haa95532_0
125+
- prompt_toolkit=3.0.36=hd3eb1b0_0
126+
- psutil=5.9.0=py310h2bbff1b_0
127+
- pure_eval=0.2.2=pyhd3eb1b0_0
128+
- pycparser=2.21=pyhd3eb1b0_0
129+
- pygments=2.15.1=py310haa95532_1
130+
- pyopenssl=23.2.0=py310haa95532_0
131+
- pyparsing=3.0.9=py310haa95532_0
132+
- pyqt=5.15.7=py310hd77b12b_0
133+
- pyqt5-sip=12.11.0=py310hd77b12b_0
134+
- pyrsistent=0.18.0=py310h2bbff1b_0
135+
- pysocks=1.7.1=py310haa95532_0
136+
- python=3.10.12=h966fe2a_0
137+
- python-dateutil=2.8.2=pyhd3eb1b0_0
138+
- python-fastjsonschema=2.16.2=py310haa95532_0
139+
- python-json-logger=2.0.7=py310haa95532_0
140+
- python-libsbml=5.20.1=py310h00ffb61_0
141+
- python_abi=3.10=2_cp310
142+
- pytz=2022.7=py310haa95532_0
143+
- pywin32=305=py310h2bbff1b_0
144+
- pywinpty=2.0.10=py310h5da7b33_0
145+
- pyyaml=6.0=py310h2bbff1b_1
146+
- pyzmq=23.2.0=py310hd77b12b_0
147+
- qt-main=5.15.2=he8e5bd7_8
148+
- qt-webengine=5.15.9=hb9a9bb5_5
149+
- qtconsole=5.4.2=py310haa95532_0
150+
- qtpy=2.2.0=py310haa95532_0
151+
- qtwebkit=5.212=h2bbfb41_5
152+
- requests=2.31.0=py310haa95532_0
153+
- rfc3339-validator=0.1.4=py310haa95532_0
154+
- rfc3986-validator=0.1.1=py310haa95532_0
155+
- scipy=1.10.1=py310h309d312_1
156+
- send2trash=1.8.0=pyhd3eb1b0_1
157+
- setuptools=68.0.0=py310haa95532_0
158+
- sip=6.6.2=py310hd77b12b_0
159+
- six=1.16.0=pyhd3eb1b0_1
160+
- sniffio=1.2.0=py310haa95532_1
161+
- soupsieve=2.4=py310haa95532_0
162+
- sqlite=3.41.2=h2bbff1b_0
163+
- stack_data=0.2.0=pyhd3eb1b0_0
164+
- sympy=1.11.1=py310haa95532_0
165+
- tbb=2021.8.0=h59b6b97_0
166+
- terminado=0.17.1=py310haa95532_0
167+
- tinycss2=1.2.1=py310haa95532_0
168+
- tk=8.6.12=h2bbff1b_0
169+
- toml=0.10.2=pyhd3eb1b0_0
170+
- tomli=2.0.1=py310haa95532_0
171+
- tornado=6.3.2=py310h2bbff1b_0
172+
- traitlets=5.7.1=py310haa95532_0
173+
- typing-extensions=4.7.1=py310haa95532_0
174+
- typing_extensions=4.7.1=py310haa95532_0
175+
- tzdata=2023c=h04d1e81_0
176+
- ucrt=10.0.22621.0=h57928b3_0
177+
- urllib3=1.26.16=py310haa95532_0
178+
- vc=14.2=h21ff451_1
179+
- vc14_runtime=14.36.32532=hfdfe4a8_17
180+
- vs2015_runtime=14.36.32532=h05e6639_17
181+
- wcwidth=0.2.5=pyhd3eb1b0_0
182+
- webencodings=0.5.1=py310haa95532_1
183+
- websocket-client=0.58.0=py310haa95532_4
184+
- wheel=0.38.4=py310haa95532_0
185+
- widgetsnbextension=4.0.5=py310haa95532_0
186+
- win_inet_pton=1.1.0=py310haa95532_0
187+
- winpty=0.4.3=4
188+
- xlrd=2.0.1=pyhd3eb1b0_1
189+
- xlsxwriter=3.1.1=py310haa95532_0
190+
- xlwt=1.3.0=py310haa95532_0
191+
- xz=5.4.2=h8cc25b3_0
192+
- y-py=0.5.9=py310hb6bf4ef_0
193+
- yaml=0.2.5=he774522_0
194+
- ypy-websocket=0.8.2=py310haa95532_0
195+
- zeromq=4.3.4=hd77b12b_0
196+
- zlib=1.2.13=h8cc25b3_0
197+
- zstd=1.5.5=hd43e919_0
198+
- pip:
199+
- nose-py3
200+
prefix: C:\Anaconda3\envs\cbmpy

cbmpy/CBCPLEX.py

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
CBMPy: CBCPLEX module
33
=====================
44
PySCeS Constraint Based Modelling (http://cbmpy.sourceforge.net)
5-
Copyright (C) 2009-2022 Brett G. Olivier, VU University Amsterdam, Amsterdam, The Netherlands
5+
Copyright (C) 2009-2024 Brett G. Olivier, VU University Amsterdam, Amsterdam, The Netherlands
66
77
This program is free software: you can redistribute it and/or modify
88
it under the terms of the GNU General Public License as published by
@@ -17,8 +17,8 @@
1717
You should have received a copy of the GNU General Public License
1818
along with this program. If not, see <http://www.gnu.org/licenses/>
1919
20-
Author: Brett G. Olivier
21-
Contact email: [email protected]
20+
Author: Brett G. Olivier PhD
21+
Contact developers: https://github.com/SystemsBioinformatics/cbmpy/issues
2222
Last edit: $Author: bgoli $ ($Id: CBCPLEX.py 710 2020-04-27 14:22:34Z bgoli $)
2323
2424
"""
@@ -212,6 +212,7 @@ def cplx_constructLPfromFBA(fba, fname=None):
212212
# print(lp.parameters.simplex.get_changed())
213213
lp.set_problem_name('%s' % (fba.getId()))
214214
lp.variables.add(names=fba.N.col)
215+
215216
try:
216217
# define objective
217218
osense = fba.getActiveObjective().operation.lower()
@@ -222,12 +223,42 @@ def cplx_constructLPfromFBA(fba, fname=None):
222223
else:
223224
raise RuntimeError('\n%s - is not a valid objective operation' % osense)
224225
lp.objective.set_name(fba.getActiveObjective().getId())
225-
lp.objective.set_linear(
226-
[
227-
(fo.reaction, fo.coefficient)
228-
for fo in fba.getActiveObjective().fluxObjectives
229-
]
230-
)
226+
227+
if fba.__FBC_VERSION__ < 3:
228+
lp.objective.set_linear(
229+
[
230+
(fo.reaction, fo.coefficient)
231+
for fo in fba.getActiveObjective().flux_objectives
232+
]
233+
)
234+
else:
235+
# TODO bgoli this needs to be cleaned up
236+
if len(fba.getActiveObjective().getLinearFluxObjectives()) > 0:
237+
print('Linear term(s) detected and added to objective function.')
238+
# print(fba.getActiveObjective().getLinearFluxObjectives())
239+
# print([
240+
# (fo.reaction, fo.coefficient)
241+
# for fo in fba.getActiveObjective().getLinearFluxObjectives()
242+
# ])
243+
lp.objective.set_linear(
244+
[
245+
(fo.reaction, fo.coefficient)
246+
for fo in fba.getActiveObjective().getLinearFluxObjectives()
247+
]
248+
)
249+
if len(fba.getActiveObjective().getQuadraticFluxObjectives()) > 0:
250+
print('Quadratric terms detected and added to objective function.')
251+
# print(fba.getActiveObjective().getQuadraticFluxObjectives())
252+
# print([
253+
# (fo.reaction, fo.reaction2, float(fo.coefficient))
254+
# for fo in fba.getActiveObjective().getQuadraticFluxObjectives()
255+
# ])
256+
lp.objective.set_quadratic_coefficients(
257+
[
258+
(fo.reaction, fo.reaction2, float(fo.coefficient))
259+
for fo in fba.getActiveObjective().getQuadraticFluxObjectives()
260+
])
261+
231262
except AttributeError:
232263
print('\nWARNING(CPLEX create LP): no objective function defined')
233264

@@ -390,8 +421,10 @@ def cplx_analyzeModel(
390421
if build_n:
391422
f.buildStoichMatrix()
392423

424+
# I've moved the check gene activity function to the evaluation
393425
if f.__check_gene_activity__:
394426
f.updateNetwork(lower=0.0, upper=0.0)
427+
f.__check_gene_activity__ = False
395428

396429
fid = f.id
397430

0 commit comments

Comments
 (0)