Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SBML import: conservation laws for non-constant species #1669

Merged
merged 234 commits into from
Feb 17, 2022

Conversation

dweindl
Copy link
Member

@dweindl dweindl commented Feb 10, 2022

Extends identification conservation laws during SBML import to non-constant species based on the algorithm proposed in [1].

Parameterized stoichiometric coefficients are not supported. Neither are models with events/Heaviside/piecewise or RateRules. Conservation laws for non-constant species are completely ignored in this case.

Experimental feature: Enable by setting environment variable AMICI_EXPERIMENTAL_SBML_NONCONST_CLS to any value.

[1] De Martino A, De Martino D, Mulet R, Pagnani A (2014) Identifying All Moiety Conservation Laws in Genome-Scale Metabolic Networks. PLoS ONE 9(7): e100750. https://doi.org/10.1371/journal.pone.0100750

Also: Modified the run-python-tests script to work also outside of
Python virtual environments (venvs) by installing pip packages to the
user's home directory.
Also, debugging null_space(...) call for stoichiometric matrix.
@dweindl dweindl marked this pull request as ready for review February 16, 2022 11:06
@@ -347,7 +347,8 @@ def sbml2amici(self,
sbml.L3P_PARSE_LOG_AS_LN
)
self._process_sbml(constant_parameters)
if self.symbols.get(SymbolId.EVENT, False):
if self.symbols.get(SymbolId.EVENT, False) \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the issue with heavisides in the flux vector, shouldn't break any conservation laws should it?

Copy link
Member Author

@dweindl dweindl Feb 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. That "fix" was too specific for an SBML test case and misses the point.

The actual problem are conservation-law/x_rdata-dependent root functions:

'root':
_FunctionInfo(
'realtype *root, const realtype t, const realtype *x, '
'const realtype *p, const realtype *k, const realtype *h'
),

Should be addressed accordingly.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me do that in a separate PR shortly.

python/amici/sbml_import.py Outdated Show resolved Hide resolved
assert len(state_idxs) == len(coefficients)

# choose a state that is not already subject to removal
# TODO is this necessary or can we just take the first one?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with toposort + hierarchical expressions, I don't think this is necessary and we can just pick the first

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Among the states involved in that CL, we still need to choose a state that has not been eliminated yet. Confused myself.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, true, that makes sense.

interactions of metabolites and reactions, and matrix of interaction
"""
dim = len(matched)
MIN = 1e-9
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my feeling is that MIN/MAX should be consistent across the different functions?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tend to agree.

T1 = initial_temperature
e = math.exp(-1 / T1)
while True:
en = int(random.uniform(0, 1) * dim)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be great if the determination of conservation laws was deterministic. Use a fixed random seed here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I guess that makes sense.

@sonarcloud
Copy link

sonarcloud bot commented Feb 17, 2022

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 15 Code Smells

56.7% 56.7% Coverage
7.0% 7.0% Duplication

@dweindl dweindl merged commit 9212bbd into develop Feb 17, 2022
@dweindl dweindl deleted the conserved_moieties branch February 17, 2022 09:08
@dweindl dweindl linked an issue Feb 17, 2022 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable computation of conservation laws in SBML
3 participants