Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ See also our [versioning policy](https://amici.readthedocs.io/en/latest/versioni
modules.
* The `force_compile` argument to `import_petab_problem` has been removed.
See the `compile_` argument.
* Removals without deprecation:
* `amici.sbml_import.species_to_parameters` has been removed.


**Features**

Expand Down
67 changes: 0 additions & 67 deletions python/sdist/amici/importers/petab/v1/sbml_import.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging
import math
import os
import re
from _collections import OrderedDict
Expand Down Expand Up @@ -433,72 +432,6 @@ def show_model_info(sbml_model: "libsbml.Model"):
logger.info(f"Reactions: {len(sbml_model.getListOfReactions())}")


# TODO - remove?!
def species_to_parameters(
species_ids: list[str], sbml_model: "libsbml.Model"
) -> list[str]:
"""
Turn a SBML species into parameters and replace species references
inside the model instance.

:param species_ids:
list of SBML species ID to convert to parameters with the same ID as
the replaced species.

:param sbml_model:
SBML model to modify

:return:
list of IDs of species which have been converted to parameters
"""
transformables = []

for species_id in species_ids:
species = sbml_model.getSpecies(species_id)

if species.getHasOnlySubstanceUnits():
logger.warning(
f"Ignoring {species.getId()} which has only substance units."
" Conversion not yet implemented."
)
continue

if math.isnan(species.getInitialConcentration()):
logger.warning(
f"Ignoring {species.getId()} which has no initial "
"concentration. Amount conversion not yet implemented."
)
continue

transformables.append(species_id)

# Must not remove species while iterating over getListOfSpecies()
for species_id in transformables:
species = sbml_model.removeSpecies(species_id)
par = sbml_model.createParameter()
par.setId(species.getId())
par.setName(species.getName())
par.setConstant(True)
par.setValue(species.getInitialConcentration())
par.setUnits(species.getUnits())

# Remove from reactants and products
for reaction in sbml_model.getListOfReactions():
for species_id in transformables:
# loop, since removeX only removes one instance
while reaction.removeReactant(species_id):
# remove from reactants
pass
while reaction.removeProduct(species_id):
# remove from products
pass
while reaction.removeModifier(species_id):
# remove from modifiers
pass

return transformables


def _add_global_parameter(
sbml_model: libsbml.Model,
parameter_id: str,
Expand Down
Loading