diff --git a/release-notes/0.9.0.md b/release-notes/0.9.0.md index ed7bd5f9..edb546df 100644 --- a/release-notes/0.9.0.md +++ b/release-notes/0.9.0.md @@ -6,9 +6,11 @@ following changes: # Features - bump `pymetadata>=0.4.0` to switch to OLS4 -- python 3.12 support -- dropping python 3.9 +- python 3.12 support (dropping python 3.9) - pydantic fixes - bugfixes +- updated sbml4humans +- libsbml-4.20.4 +- improved ODE generation Your sbmlutils team diff --git a/src/sbmlutils/__init__.py b/src/sbmlutils/__init__.py index ede484d9..242e4afb 100644 --- a/src/sbmlutils/__init__.py +++ b/src/sbmlutils/__init__.py @@ -1,4 +1,5 @@ """sbmlutils - Python utilities for SBML.""" + from pathlib import Path __author__ = "Matthias König" diff --git a/src/sbmlutils/biomodels.py b/src/sbmlutils/biomodels.py index 1b1b4462..36d04e1c 100644 --- a/src/sbmlutils/biomodels.py +++ b/src/sbmlutils/biomodels.py @@ -1,4 +1,5 @@ """Utilities for downloading biomodel models.""" + import shutil import tempfile from pathlib import Path diff --git a/src/sbmlutils/comp/__init__.py b/src/sbmlutils/comp/__init__.py index 331ca695..d5279bf2 100644 --- a/src/sbmlutils/comp/__init__.py +++ b/src/sbmlutils/comp/__init__.py @@ -1,4 +1,5 @@ """Package for SBML comp.""" + from .comp import ( # Port, create_ExternalModelDefinition, diff --git a/src/sbmlutils/comp/flatten.py b/src/sbmlutils/comp/flatten.py index db1a7f80..b5f21dcb 100644 --- a/src/sbmlutils/comp/flatten.py +++ b/src/sbmlutils/comp/flatten.py @@ -1,4 +1,5 @@ """Helpers for model flattening.""" + import os import time from pathlib import Path diff --git a/src/sbmlutils/console.py b/src/sbmlutils/console.py index 3a03c22a..6f7da271 100644 --- a/src/sbmlutils/console.py +++ b/src/sbmlutils/console.py @@ -1,4 +1,5 @@ """Rich console for logging.""" + from rich import pretty from rich.console import Console from rich.theme import Theme diff --git a/src/sbmlutils/converters/copasi.py b/src/sbmlutils/converters/copasi.py index 803ad699..29e3dfc0 100644 --- a/src/sbmlutils/converters/copasi.py +++ b/src/sbmlutils/converters/copasi.py @@ -1,4 +1,5 @@ """Helpers to work with COPASI files.""" + from pathlib import Path import libsbml diff --git a/src/sbmlutils/converters/mathml.py b/src/sbmlutils/converters/mathml.py index addcec09..c41ce97f 100644 --- a/src/sbmlutils/converters/mathml.py +++ b/src/sbmlutils/converters/mathml.py @@ -6,6 +6,7 @@ *, /, +, - and, or, not """ + from math import * from typing import Any, Dict, Optional, Tuple diff --git a/src/sbmlutils/converters/odefac_example/odefac_example.py b/src/sbmlutils/converters/odefac_example/odefac_example.py index 5ad92c19..de7aab47 100644 --- a/src/sbmlutils/converters/odefac_example/odefac_example.py +++ b/src/sbmlutils/converters/odefac_example/odefac_example.py @@ -1,4 +1,5 @@ """Example of creating markdown and python code.""" + from pathlib import Path from sbmlutils.console import console diff --git a/src/sbmlutils/converters/xpp_examples.py b/src/sbmlutils/converters/xpp_examples.py index 82ee21af..0906aeb4 100644 --- a/src/sbmlutils/converters/xpp_examples.py +++ b/src/sbmlutils/converters/xpp_examples.py @@ -5,6 +5,7 @@ pip install libroadrunner ``` """ + from pathlib import Path import roadrunner diff --git a/src/sbmlutils/cytoscape.py b/src/sbmlutils/cytoscape.py index 30cf9995..b026ae3f 100644 --- a/src/sbmlutils/cytoscape.py +++ b/src/sbmlutils/cytoscape.py @@ -1,17 +1,20 @@ """Module for visualiation in Cytoscape.""" + import os import tempfile + + os.environ["PY4CYTOSCAPE_DETAIL_LOGGER_DIR"] = str(tempfile.gettempdir()) -from pathlib import Path -from typing import Any, Union +from pathlib import Path # noqa: E402 +from typing import Any, Union # noqa: E402 -import py4cytoscape as p4c -from requests.exceptions import RequestException +import py4cytoscape as p4c # type: ignore # noqa: E402 +from requests.exceptions import RequestException # noqa: E402 -from sbmlutils import log -from sbmlutils.console import console -from sbmlutils.parser import antimony_to_sbml +from sbmlutils import log # noqa: E402 +from sbmlutils.console import console # noqa: E402 +from sbmlutils.parser import antimony_to_sbml # noqa: E402 logger = log.get_logger(__name__) diff --git a/src/sbmlutils/data/interpolation.py b/src/sbmlutils/data/interpolation.py index 82aa0c2e..383bb59e 100644 --- a/src/sbmlutils/data/interpolation.py +++ b/src/sbmlutils/data/interpolation.py @@ -8,6 +8,7 @@ The functionality is very useful, but only if this can be applied to existing models in a simple manner. """ + from __future__ import annotations from pathlib import Path diff --git a/src/sbmlutils/data/interpolation_example.py b/src/sbmlutils/data/interpolation_example.py index 37a7bacd..21379de7 100644 --- a/src/sbmlutils/data/interpolation_example.py +++ b/src/sbmlutils/data/interpolation_example.py @@ -1,4 +1,5 @@ """Example demonstrating the interpolation of data.""" + import tempfile from pathlib import Path diff --git a/src/sbmlutils/data/interpolation_pancreas.py b/src/sbmlutils/data/interpolation_pancreas.py index f7226887..f1356158 100644 --- a/src/sbmlutils/data/interpolation_pancreas.py +++ b/src/sbmlutils/data/interpolation_pancreas.py @@ -1,4 +1,5 @@ """Example demonstrating the interpolation of data.""" + import tempfile from pathlib import Path from typing import Optional diff --git a/src/sbmlutils/distrib/distrib_examples.py b/src/sbmlutils/distrib/distrib_examples.py index 6a17dd4d..816cfab5 100644 --- a/src/sbmlutils/distrib/distrib_examples.py +++ b/src/sbmlutils/distrib/distrib_examples.py @@ -1,4 +1,5 @@ """Code for working with the libsbml distrib package.""" + import tempfile import libsbml diff --git a/src/sbmlutils/distrib/distrib_packages.py b/src/sbmlutils/distrib/distrib_packages.py index d120bd8e..fc18bfed 100644 --- a/src/sbmlutils/distrib/distrib_packages.py +++ b/src/sbmlutils/distrib/distrib_packages.py @@ -1,4 +1,5 @@ """Example testing uncertainty with libsbml packages.""" + import tempfile from pathlib import Path diff --git a/src/sbmlutils/examples/__init__.py b/src/sbmlutils/examples/__init__.py index 2669e1b4..bde95d8a 100644 --- a/src/sbmlutils/examples/__init__.py +++ b/src/sbmlutils/examples/__init__.py @@ -1,4 +1,5 @@ """Examples for model creation.""" + from pathlib import Path from sbmlutils.examples.dallaman import dallaman from sbmlutils.examples.demo import demo diff --git a/src/sbmlutils/examples/algebraic_rule.py b/src/sbmlutils/examples/algebraic_rule.py index 5ea70e57..e33c6806 100644 --- a/src/sbmlutils/examples/algebraic_rule.py +++ b/src/sbmlutils/examples/algebraic_rule.py @@ -1,4 +1,5 @@ """AlgebraicRule example.""" + from sbmlutils.examples import templates from sbmlutils.factory import * from sbmlutils.resources import EXAMPLES_DIR diff --git a/src/sbmlutils/examples/annotation.py b/src/sbmlutils/examples/annotation.py index b96217ed..cfa8687a 100644 --- a/src/sbmlutils/examples/annotation.py +++ b/src/sbmlutils/examples/annotation.py @@ -3,6 +3,7 @@ Model demonstrates how to annotate model objects with SBOTerms and Terms from other ontologies. Annotations use the functionality from `pymetadata`. """ + from sbmlutils.examples import templates from sbmlutils.factory import * from sbmlutils.metadata import * diff --git a/src/sbmlutils/examples/assignment.py b/src/sbmlutils/examples/assignment.py index 5c1b7c24..d1b141fa 100644 --- a/src/sbmlutils/examples/assignment.py +++ b/src/sbmlutils/examples/assignment.py @@ -1,4 +1,5 @@ """AssignmentRule and InitialAssignment example.""" + from sbmlutils.console import console from sbmlutils.converters import odefac from sbmlutils.examples import templates diff --git a/src/sbmlutils/examples/combine_archive/omex_models.py b/src/sbmlutils/examples/combine_archive/omex_models.py index 9948f00b..d6f14b92 100644 --- a/src/sbmlutils/examples/combine_archive/omex_models.py +++ b/src/sbmlutils/examples/combine_archive/omex_models.py @@ -2,6 +2,7 @@ This demonstrates just the very core SBML functionality. """ + from pathlib import Path from typing import Optional @@ -69,7 +70,7 @@ for k in range(n_cells - 1): _m.reactions.append( # type: ignore Reaction( - sid=f"J{k}", equation=f"S{k} <-> S{k+1}", formula=f"D * (S{k}-S{k+1})" + sid=f"J{k}", equation=f"S{k} <-> S{k + 1}", formula=f"D * (S{k} - S{k + 1})" ), ) diff --git a/src/sbmlutils/examples/compartment_species_reaction.py b/src/sbmlutils/examples/compartment_species_reaction.py index 50aa2626..c2f17132 100644 --- a/src/sbmlutils/examples/compartment_species_reaction.py +++ b/src/sbmlutils/examples/compartment_species_reaction.py @@ -1,4 +1,5 @@ """Compartment, Species, Reaction example.""" + from sbmlutils.examples import templates from sbmlutils.factory import * from sbmlutils.metadata.sbo import * diff --git a/src/sbmlutils/examples/dallaman/__init__.py b/src/sbmlutils/examples/dallaman/__init__.py new file mode 100644 index 00000000..6dce3e99 --- /dev/null +++ b/src/sbmlutils/examples/dallaman/__init__.py @@ -0,0 +1 @@ +"""Module for DallaMan Meal model.""" diff --git a/src/sbmlutils/examples/demo/demo.py b/src/sbmlutils/examples/demo/demo.py index fd347d39..fa32ce9b 100644 --- a/src/sbmlutils/examples/demo/demo.py +++ b/src/sbmlutils/examples/demo/demo.py @@ -1,4 +1,5 @@ """Demo kinetic network.""" + from pathlib import Path from sbmlutils.examples import templates diff --git a/src/sbmlutils/examples/distrib/distrib_comp.py b/src/sbmlutils/examples/distrib/distrib_comp.py index 1ac86509..02a1d8f0 100644 --- a/src/sbmlutils/examples/distrib/distrib_comp.py +++ b/src/sbmlutils/examples/distrib/distrib_comp.py @@ -1,4 +1,5 @@ """Distrib and comp example to check flattening.""" + import shutil from pathlib import Path diff --git a/src/sbmlutils/examples/distrib/distrib_distributions.py b/src/sbmlutils/examples/distrib/distrib_distributions.py index 610200fe..c358f731 100644 --- a/src/sbmlutils/examples/distrib/distrib_distributions.py +++ b/src/sbmlutils/examples/distrib/distrib_distributions.py @@ -1,4 +1,5 @@ """Distrib example demonstrating distributions.""" + from sbmlutils.examples import templates from sbmlutils.factory import * from sbmlutils.validation import ValidationOptions diff --git a/src/sbmlutils/examples/distrib/distrib_uncertainties.py b/src/sbmlutils/examples/distrib/distrib_uncertainties.py index 62ca34d8..356e3a97 100644 --- a/src/sbmlutils/examples/distrib/distrib_uncertainties.py +++ b/src/sbmlutils/examples/distrib/distrib_uncertainties.py @@ -1,4 +1,5 @@ """Uncertainty example.""" + import libsbml from sbmlutils.examples import templates diff --git a/src/sbmlutils/examples/fbc/fbc_key_value_pair.py b/src/sbmlutils/examples/fbc/fbc_key_value_pair.py index e3e07c09..71482d4b 100644 --- a/src/sbmlutils/examples/fbc/fbc_key_value_pair.py +++ b/src/sbmlutils/examples/fbc/fbc_key_value_pair.py @@ -1,4 +1,5 @@ """FBC example for KeyValuePairs.""" + from sbmlutils.examples import templates from sbmlutils.factory import * from sbmlutils.metadata.sbo import * diff --git a/src/sbmlutils/examples/fbc/fbc_mass_charge.py b/src/sbmlutils/examples/fbc/fbc_mass_charge.py index 6c1c0c9e..05056de1 100644 --- a/src/sbmlutils/examples/fbc/fbc_mass_charge.py +++ b/src/sbmlutils/examples/fbc/fbc_mass_charge.py @@ -1,4 +1,5 @@ """FBC mass and charge example.""" + from sbmlutils.examples import templates from sbmlutils.factory import * from sbmlutils.metadata import * diff --git a/src/sbmlutils/examples/fbc/fbc_userdefinedconstraints.py b/src/sbmlutils/examples/fbc/fbc_userdefinedconstraints.py index 70686d33..647639e9 100644 --- a/src/sbmlutils/examples/fbc/fbc_userdefinedconstraints.py +++ b/src/sbmlutils/examples/fbc/fbc_userdefinedconstraints.py @@ -1,4 +1,5 @@ """FBA example with UserDefinedConstraints.""" + import numpy as np from sbmlutils.examples import templates diff --git a/src/sbmlutils/examples/fbc/fbc_v2.py b/src/sbmlutils/examples/fbc/fbc_v2.py index 09e8493f..de7f94ce 100644 --- a/src/sbmlutils/examples/fbc/fbc_v2.py +++ b/src/sbmlutils/examples/fbc/fbc_v2.py @@ -1,4 +1,5 @@ """FBA example with exchange reactions.""" + from sbmlutils.examples import templates from sbmlutils.factory import * from sbmlutils.metadata import * diff --git a/src/sbmlutils/examples/fbc/fbc_v3.py b/src/sbmlutils/examples/fbc/fbc_v3.py index 5403f20e..7df9416b 100644 --- a/src/sbmlutils/examples/fbc/fbc_v3.py +++ b/src/sbmlutils/examples/fbc/fbc_v3.py @@ -1,4 +1,5 @@ """FBA example with exchange reactions.""" + from sbmlutils.examples import templates from sbmlutils.factory import * from sbmlutils.metadata.sbo import * diff --git a/src/sbmlutils/examples/fbc/fbc_version3.py b/src/sbmlutils/examples/fbc/fbc_version3.py index 5ade1ae8..ae0ed085 100644 --- a/src/sbmlutils/examples/fbc/fbc_version3.py +++ b/src/sbmlutils/examples/fbc/fbc_version3.py @@ -3,6 +3,7 @@ For latest SBML fbc v3 specification see https://github.com/bgoli/sbml-fbc-spec/blob/main/sf_svn/spec/main.pdf """ + from logging import getLogger from pathlib import Path diff --git a/src/sbmlutils/examples/icg/__init__.py b/src/sbmlutils/examples/icg/__init__.py index 83b60dab..ca6005d2 100644 --- a/src/sbmlutils/examples/icg/__init__.py +++ b/src/sbmlutils/examples/icg/__init__.py @@ -1,4 +1,5 @@ """ICG examples.""" + from pathlib import Path ICG_PATH = Path(__file__).parent diff --git a/src/sbmlutils/examples/icg/factory.py b/src/sbmlutils/examples/icg/factory.py index 0e78512f..3e1f4f7e 100644 --- a/src/sbmlutils/examples/icg/factory.py +++ b/src/sbmlutils/examples/icg/factory.py @@ -1,4 +1,5 @@ """ICG model factory.""" + from pathlib import Path from typing import Any, Dict diff --git a/src/sbmlutils/examples/icg/model_body.py b/src/sbmlutils/examples/icg/model_body.py index 7b031014..fa0aa0a7 100644 --- a/src/sbmlutils/examples/icg/model_body.py +++ b/src/sbmlutils/examples/icg/model_body.py @@ -1,4 +1,5 @@ """PKPD model for whole-body icg metabolism.""" + import os import numpy as np diff --git a/src/sbmlutils/examples/icg/model_liver.py b/src/sbmlutils/examples/icg/model_liver.py index 61ac1515..e8b08ce1 100644 --- a/src/sbmlutils/examples/icg/model_liver.py +++ b/src/sbmlutils/examples/icg/model_liver.py @@ -1,4 +1,5 @@ """ICG liver model.""" + from pathlib import Path from sbmlutils.cytoscape import visualize_sbml diff --git a/src/sbmlutils/examples/model.py b/src/sbmlutils/examples/model.py index f6ffe840..c581cb2e 100644 --- a/src/sbmlutils/examples/model.py +++ b/src/sbmlutils/examples/model.py @@ -2,6 +2,7 @@ This demonstrates just the very core SBML functionality. """ + from pathlib import Path import libsbml diff --git a/src/sbmlutils/examples/model_definitions.py b/src/sbmlutils/examples/model_definitions.py index e73b70e6..1a56276b 100644 --- a/src/sbmlutils/examples/model_definitions.py +++ b/src/sbmlutils/examples/model_definitions.py @@ -1,4 +1,5 @@ """Multiple model definitions.""" + from sbmlutils.examples import templates from sbmlutils.factory import * diff --git a/src/sbmlutils/examples/multiple_substance_units.py b/src/sbmlutils/examples/multiple_substance_units.py index b45c8742..fef54ed5 100644 --- a/src/sbmlutils/examples/multiple_substance_units.py +++ b/src/sbmlutils/examples/multiple_substance_units.py @@ -1,4 +1,5 @@ """Example for substance units.""" + from sbmlutils.examples import templates from sbmlutils.factory import * from sbmlutils.metadata.sbo import * diff --git a/src/sbmlutils/examples/notes.py b/src/sbmlutils/examples/notes.py index 8a46ccbe..88c4ff70 100644 --- a/src/sbmlutils/examples/notes.py +++ b/src/sbmlutils/examples/notes.py @@ -1,4 +1,5 @@ """Example model with notes.""" + from sbmlutils.examples import templates from sbmlutils.factory import * diff --git a/src/sbmlutils/examples/parameter.py b/src/sbmlutils/examples/parameter.py index 475413ee..859d406a 100644 --- a/src/sbmlutils/examples/parameter.py +++ b/src/sbmlutils/examples/parameter.py @@ -1,4 +1,5 @@ """Parameter example.""" + from sbmlutils.examples import templates from sbmlutils.factory import * from sbmlutils.metadata import * diff --git a/src/sbmlutils/examples/reaction.py b/src/sbmlutils/examples/reaction.py index 98b44ede..bbbae1d4 100644 --- a/src/sbmlutils/examples/reaction.py +++ b/src/sbmlutils/examples/reaction.py @@ -1,4 +1,5 @@ """Create reaction example.""" + import numpy as np from sbmlutils.examples import templates diff --git a/src/sbmlutils/examples/templates.py b/src/sbmlutils/examples/templates.py index 73a58632..e2fccebe 100644 --- a/src/sbmlutils/examples/templates.py +++ b/src/sbmlutils/examples/templates.py @@ -1,4 +1,5 @@ """Template information for the model creation.""" + from datetime import datetime from sbmlutils.factory import Creator diff --git a/src/sbmlutils/examples/tiny/simulation.py b/src/sbmlutils/examples/tiny/simulation.py index 6349c371..afbc5114 100644 --- a/src/sbmlutils/examples/tiny/simulation.py +++ b/src/sbmlutils/examples/tiny/simulation.py @@ -10,6 +10,7 @@ ``` """ + from pathlib import Path import pandas as pd diff --git a/src/sbmlutils/examples/tiny/tiny.py b/src/sbmlutils/examples/tiny/tiny.py index 97900ce9..b4c7a123 100644 --- a/src/sbmlutils/examples/tiny/tiny.py +++ b/src/sbmlutils/examples/tiny/tiny.py @@ -1,4 +1,5 @@ """Tiny model example.""" + from math import inf from pathlib import Path diff --git a/src/sbmlutils/examples/tutorial/linear_chain.py b/src/sbmlutils/examples/tutorial/linear_chain.py index 9815be47..c26e68d5 100644 --- a/src/sbmlutils/examples/tutorial/linear_chain.py +++ b/src/sbmlutils/examples/tutorial/linear_chain.py @@ -4,6 +4,7 @@ `sbmlutils` allows to generate patterns of objects by combining loops in combination with string patterns. In this example we create a kinetic model of a linear chain. """ + from sbmlutils.converters import odefac from sbmlutils.cytoscape import visualize_sbml from sbmlutils.examples import templates @@ -34,15 +35,17 @@ sid=f"S{k + 2}", initialConcentration=0.0, compartment="cell", - name=f"Species {k +2}", + name=f"Species {k + 2}", ), ) model.parameters.append( - Parameter(sid=f"k{k+1}", value=0.1, name=f"rate constant {k+1}"), + Parameter(sid=f"k{k + 1}", value=0.1, name=f"rate constant {k + 1}"), ) model.reactions.append( Reaction( - sid=f"J{k+1}", equation=f"S{k+1} -> S{k+2}", formula=f"k{k+1} * S{k+1}" + sid=f"J{k + 1}", + equation=f"S{k + 1} -> S{k + 2}", + formula=f"k{k + 1} * S{k + 1}", ), ) diff --git a/src/sbmlutils/examples/tutorial/minimal_model.py b/src/sbmlutils/examples/tutorial/minimal_model.py index 98f6be8d..285f7eb9 100644 --- a/src/sbmlutils/examples/tutorial/minimal_model.py +++ b/src/sbmlutils/examples/tutorial/minimal_model.py @@ -2,6 +2,7 @@ This demonstrates just the very core SBML functionality. """ + from sbmlutils.cytoscape import visualize_sbml from sbmlutils.factory import * from sbmlutils.metadata import * diff --git a/src/sbmlutils/examples/tutorial/minimal_model_annotations.py b/src/sbmlutils/examples/tutorial/minimal_model_annotations.py index cac31226..9b61532e 100644 --- a/src/sbmlutils/examples/tutorial/minimal_model_annotations.py +++ b/src/sbmlutils/examples/tutorial/minimal_model_annotations.py @@ -1,4 +1,5 @@ """Annotate an existing model.""" + from pathlib import Path from sbmlutils.cytoscape import visualize_sbml diff --git a/src/sbmlutils/examples/tutorial/minimal_model_comp.py b/src/sbmlutils/examples/tutorial/minimal_model_comp.py index bb9b1076..090fa25c 100644 --- a/src/sbmlutils/examples/tutorial/minimal_model_comp.py +++ b/src/sbmlutils/examples/tutorial/minimal_model_comp.py @@ -1,4 +1,5 @@ """Example creating composite model.""" + from pathlib import Path from sbmlutils.comp import flatten_sbml @@ -40,7 +41,7 @@ for k in range(n_cells - 1): model.reactions.append( Reaction( - sid=f"J{k}", equation=f"S{k} <-> S{k+1}", formula=f"D * (S{k}-S{k+1})" + sid=f"J{k}", equation=f"S{k} <-> S{k + 1}", formula=f"D * (S{k} - S{k + 1})" ), ) diff --git a/src/sbmlutils/examples/tutorial/model_composition.py b/src/sbmlutils/examples/tutorial/model_composition.py index 7171b198..5896ab8f 100644 --- a/src/sbmlutils/examples/tutorial/model_composition.py +++ b/src/sbmlutils/examples/tutorial/model_composition.py @@ -1,4 +1,5 @@ """Example for model composition via multiple models.""" + from pathlib import Path from sbmlutils.cytoscape import visualize_sbml diff --git a/src/sbmlutils/examples/tutorial/random_network.py b/src/sbmlutils/examples/tutorial/random_network.py index 7e6f5431..d13a1133 100644 --- a/src/sbmlutils/examples/tutorial/random_network.py +++ b/src/sbmlutils/examples/tutorial/random_network.py @@ -1,4 +1,5 @@ """Example creating random network.""" + import random from sbmlutils.cytoscape import visualize_sbml @@ -34,7 +35,7 @@ model.reactions.append( Reaction( - sid=f"J{k+1}", + sid=f"J{k + 1}", equation=f"S{k_source} -> S{k_target}", formula=f"k * S{k_source}", ), diff --git a/src/sbmlutils/examples/unit_definitions.py b/src/sbmlutils/examples/unit_definitions.py index 5b812f00..16d7c161 100644 --- a/src/sbmlutils/examples/unit_definitions.py +++ b/src/sbmlutils/examples/unit_definitions.py @@ -1,4 +1,5 @@ """Example model with UnitDefinitions.""" + from sbmlutils.examples import templates from sbmlutils.factory import * from sbmlutils.metadata import * diff --git a/src/sbmlutils/examples/units_namespace.py b/src/sbmlutils/examples/units_namespace.py index 64fc176f..528c8da9 100644 --- a/src/sbmlutils/examples/units_namespace.py +++ b/src/sbmlutils/examples/units_namespace.py @@ -2,6 +2,7 @@ Model used for testing units namespacing. """ + from pathlib import Path from sbmlutils.examples import templates diff --git a/src/sbmlutils/factory.py b/src/sbmlutils/factory.py index f4dfb9a7..45659e16 100644 --- a/src/sbmlutils/factory.py +++ b/src/sbmlutils/factory.py @@ -15,6 +15,7 @@ To create complete models one should use the modelcreator functionality, which takes care of the order of object creation. """ + from __future__ import annotations import datetime diff --git a/src/sbmlutils/fbc/cobra.py b/src/sbmlutils/fbc/cobra.py index 44cb60e1..c4a40eeb 100644 --- a/src/sbmlutils/fbc/cobra.py +++ b/src/sbmlutils/fbc/cobra.py @@ -1,4 +1,5 @@ """cobrapy based helper methods.""" + from pathlib import Path from typing import Dict diff --git a/src/sbmlutils/fbc/fbc.py b/src/sbmlutils/fbc/fbc.py index 8e2e44aa..56e52eab 100644 --- a/src/sbmlutils/fbc/fbc.py +++ b/src/sbmlutils/fbc/fbc.py @@ -1,4 +1,5 @@ """Helper functions for working with FBC and cobrapy models.""" + import warnings import libsbml diff --git a/src/sbmlutils/io/__init__.py b/src/sbmlutils/io/__init__.py index 199bbc7c..50cde2fe 100644 --- a/src/sbmlutils/io/__init__.py +++ b/src/sbmlutils/io/__init__.py @@ -1,2 +1,3 @@ """Helper functions for input/output (IO).""" + from .sbml import read_sbml, validate_sbml, write_sbml diff --git a/src/sbmlutils/io/sbml.py b/src/sbmlutils/io/sbml.py index deed204f..931dc748 100644 --- a/src/sbmlutils/io/sbml.py +++ b/src/sbmlutils/io/sbml.py @@ -1,4 +1,5 @@ """Utility functions for reading, writing and validating SBML.""" + from pathlib import Path from typing import Optional, Union diff --git a/src/sbmlutils/layout/__init__.py b/src/sbmlutils/layout/__init__.py index f5fa8f63..f4fa6264 100644 --- a/src/sbmlutils/layout/__init__.py +++ b/src/sbmlutils/layout/__init__.py @@ -1,2 +1,3 @@ """Package for SBML layout.""" + from .layout import * diff --git a/src/sbmlutils/layout/layout.py b/src/sbmlutils/layout/layout.py index 43e305d9..468bfb67 100644 --- a/src/sbmlutils/layout/layout.py +++ b/src/sbmlutils/layout/layout.py @@ -1,4 +1,5 @@ """Utilities for the creation and work with layout models.""" + from typing import Dict, List, Optional import libsbml diff --git a/src/sbmlutils/log.py b/src/sbmlutils/log.py index e675d8d5..7b266ad0 100644 --- a/src/sbmlutils/log.py +++ b/src/sbmlutils/log.py @@ -2,6 +2,7 @@ Using rich for output formating. """ + import logging from typing import List diff --git a/src/sbmlutils/manipulation/merge.py b/src/sbmlutils/manipulation/merge.py index 9a77c2f7..b4584479 100644 --- a/src/sbmlutils/manipulation/merge.py +++ b/src/sbmlutils/manipulation/merge.py @@ -3,6 +3,7 @@ The following is a helper function for merging multiple SBML models into a single model. """ + import os from pathlib import Path from typing import Dict, Optional diff --git a/src/sbmlutils/metadata/__init__.py b/src/sbmlutils/metadata/__init__.py index 035ed887..34cd1232 100644 --- a/src/sbmlutils/metadata/__init__.py +++ b/src/sbmlutils/metadata/__init__.py @@ -2,5 +2,6 @@ Most metadata functionality is part pf `pymetadata`. """ + from .miriam import * from .sbo import * diff --git a/src/sbmlutils/metadata/annotator.py b/src/sbmlutils/metadata/annotator.py index 4d4ed09a..d4712b46 100644 --- a/src/sbmlutils/metadata/annotator.py +++ b/src/sbmlutils/metadata/annotator.py @@ -10,6 +10,7 @@ A standard workflow is looking up the components for instance in things like OLS ontology lookup service. """ + import os import re from pathlib import Path diff --git a/src/sbmlutils/notes.py b/src/sbmlutils/notes.py index f5690ad2..e157c703 100644 --- a/src/sbmlutils/notes.py +++ b/src/sbmlutils/notes.py @@ -4,6 +4,7 @@ Markdown -> HTML conversion is performed using `markdown-it-py` for the conversion. No styles for the display are inserted here. """ + import textwrap from enum import Enum diff --git a/src/sbmlutils/parser.py b/src/sbmlutils/parser.py index 023cb334..81c3a126 100644 --- a/src/sbmlutils/parser.py +++ b/src/sbmlutils/parser.py @@ -4,6 +4,7 @@ FIXME: no support for modelHistory """ + from pathlib import Path from typing import Any, Dict, List, Optional, Union @@ -168,9 +169,9 @@ def parse_sbase_kwargs(sbase: libsbml.SBase) -> Dict[str, Any]: Compartment( value=c.getSize() if c.isSetSize() else NaN, constant=c.getConstant() if c.isSetConstant() else True, - spatialDimensions=c.getSpatialDimensions() - if c.isSetSpatialDimensions() - else None, + spatialDimensions=( + c.getSpatialDimensions() if c.isSetSpatialDimensions() else None + ), # unit=p.getUnits(), **parse_sbase_kwargs(c), ) @@ -182,16 +183,20 @@ def parse_sbase_kwargs(sbase: libsbml.SBase) -> Dict[str, Any]: Species( compartment=s.getCompartment() if s.isSetCompartment() else None, initialAmount=s.getInitialAmount() if s.isSetInitialAmount() else None, - initialConcentration=s.getInitialConcentration() - if s.isSetInitialConcentration() - else None, + initialConcentration=( + s.getInitialConcentration() + if s.isSetInitialConcentration() + else None + ), constant=s.getConstant() if s.isSetConstant() else None, - hasOnlySubstanceUnits=s.getHasOnlySubstanceUnits() - if s.isSetHasOnlySubstanceUnits() - else None, - boundaryCondition=s.getBoundaryCondition() - if s.isSetBoundaryCondition() - else None, + hasOnlySubstanceUnits=( + s.getHasOnlySubstanceUnits() + if s.isSetHasOnlySubstanceUnits() + else None + ), + boundaryCondition=( + s.getBoundaryCondition() if s.isSetBoundaryCondition() else None + ), # unit=p.getUnits(), **parse_sbase_kwargs(s), ) @@ -212,12 +217,14 @@ def parse_sbase_kwargs(sbase: libsbml.SBase) -> Dict[str, Any]: equation.reactants.append( EquationPart( species=reactant.getSpecies() if reactant.isSetSpecies() else None, - stoichiometry=reactant.getStoichiometry() - if reactant.isSetStoichiometry() - else None, - constant=reactant.getConstant() - if reactant.isSetConstant() - else True, + stoichiometry=( + reactant.getStoichiometry() + if reactant.isSetStoichiometry() + else None + ), + constant=( + reactant.getConstant() if reactant.isSetConstant() else True + ), **parse_sbase_kwargs(reactant), ) ) @@ -226,9 +233,11 @@ def parse_sbase_kwargs(sbase: libsbml.SBase) -> Dict[str, Any]: equation.products.append( EquationPart( species=product.getSpecies() if product.isSetSpecies() else None, - stoichiometry=product.getStoichiometry() - if product.isSetStoichiometry() - else None, + stoichiometry=( + product.getStoichiometry() + if product.isSetStoichiometry() + else None + ), constant=product.getConstant() if product.isSetConstant() else True, **parse_sbase_kwargs(product), ) diff --git a/src/sbmlutils/reaction_equation.py b/src/sbmlutils/reaction_equation.py index 0a65c7e3..5095927d 100644 --- a/src/sbmlutils/reaction_equation.py +++ b/src/sbmlutils/reaction_equation.py @@ -39,6 +39,7 @@ 'f * acoa =>', """ + from __future__ import annotations import re diff --git a/src/sbmlutils/report/api.py b/src/sbmlutils/report/api.py index 4209be21..b65fd2cb 100644 --- a/src/sbmlutils/report/api.py +++ b/src/sbmlutils/report/api.py @@ -3,6 +3,7 @@ This provides basic functionality of parsing the model and returning the JSON representation based on fastAPI. """ + import tempfile import time import traceback diff --git a/src/sbmlutils/report/api_examples.py b/src/sbmlutils/report/api_examples.py index 5a4d8bbb..484c1df8 100644 --- a/src/sbmlutils/report/api_examples.py +++ b/src/sbmlutils/report/api_examples.py @@ -1,4 +1,5 @@ """Example models for the sbml4humans API.""" + from pathlib import Path from typing import List, Optional diff --git a/src/sbmlutils/report/mathml.py b/src/sbmlutils/report/mathml.py index 3d63b2fc..9743c74c 100644 --- a/src/sbmlutils/report/mathml.py +++ b/src/sbmlutils/report/mathml.py @@ -167,7 +167,7 @@ def _fix_mathit_symbols(tex_str: str) -> str: # replace greek symbols for symbol in greek_symbols: tex_str = tex_str.replace( - r"\mathit{" + symbol + "}", r"\mathit{" + f"\{symbol}" + "}" # noqa: W605 + r"\mathit{" + symbol + "}", r"\mathit{" + f"\\{symbol}" + "}" # noqa: W605 ) return tex_str diff --git a/src/sbmlutils/report/sbmlinfo.py b/src/sbmlutils/report/sbmlinfo.py index 5202de5c..24a09c72 100644 --- a/src/sbmlutils/report/sbmlinfo.py +++ b/src/sbmlutils/report/sbmlinfo.py @@ -3,6 +3,7 @@ The model dictionary can be used for rendering the HTML report. The information can be serialized to JSON for later rendering in web app. """ + from __future__ import annotations import hashlib @@ -386,12 +387,16 @@ def sbase_dict(cls, sbase: libsbml.SBase) -> Dict[str, Any]: "value": upar.getValue() if upar.isSetValue() else None, "units": upar.getUnits() if upar.isSetUnits() else None, "type": upar.getTypeAsString() if upar.isSetType() else None, - "definitionURL": upar.getDefinitionURL() - if upar.isSetDefinitionURL() - else None, - "math": astnode_to_latex(upar.getMath()) - if upar.isSetMath() - else None, + "definitionURL": ( + upar.getDefinitionURL() + if upar.isSetDefinitionURL() + else None + ), + "math": ( + astnode_to_latex(upar.getMath()) + if upar.isSetMath() + else None + ), } u_dict["uncertaintyParameters"].append(param_dict) @@ -486,9 +491,9 @@ def model_history(cls, sbase: libsbml.SBase) -> Optional[Dict]: { "givenName": c.getGivenName() if c.isSetGivenName() else None, "familyName": c.getFamilyName() if c.isSetFamilyName() else None, - "organization": c.getOrganization() - if c.isSetOrganization() - else None, + "organization": ( + c.getOrganization() if c.isSetOrganization() else None + ), "email": c.getEmail() if c.isSetEmail() else None, } ) @@ -691,12 +696,16 @@ def species( sfbc = s.getPlugin("fbc") d["fbc"] = ( { - "formula": sfbc.getChemicalFormula() - if sfbc.isSetChemicalFormula() - else None, - "charge": sfbc.getCharge() - if (sfbc.isSetCharge() and sfbc.getCharge() != 0) - else None, + "formula": ( + sfbc.getChemicalFormula() + if sfbc.isSetChemicalFormula() + else None + ), + "charge": ( + sfbc.getCharge() + if (sfbc.isSetCharge() and sfbc.getCharge() != 0) + else None + ), } if sfbc else None @@ -901,9 +910,9 @@ def _species_reference(species: libsbml.SpeciesReference) -> Dict[str, Any]: """Resolve species reference.""" return { "species": species.getSpecies() if species.isSetSpecies() else None, - "stoichiometry": species.getStoichiometry() - if species.isSetStoichiometry() - else 1.0, + "stoichiometry": ( + species.getStoichiometry() if species.isSetStoichiometry() else 1.0 + ), "constant": species.getConstant() if species.isSetConstant() else None, } @@ -1065,9 +1074,11 @@ def events(self, model: libsbml.Model) -> List[Dict[str, Any]]: ) if trigger: d["trigger"] = { - "math": astnode_to_latex(trigger.getMath()) - if trigger.isSetMath() - else None, + "math": ( + astnode_to_latex(trigger.getMath()) + if trigger.isSetMath() + else None + ), "initialValue": trigger.initial_value, "persistent": trigger.persistent, } @@ -1095,9 +1106,9 @@ def events(self, model: libsbml.Model) -> List[Dict[str, Any]]: assignments.append( { "variable": eva.getVariable() if eva.isSetVariable() else None, - "math": astnode_to_latex(eva.getMath()) - if eva.isSetMath() - else None, + "math": ( + astnode_to_latex(eva.getMath()) if eva.isSetMath() else None + ), } ) d["listOfEventAssignments"] = assignments @@ -1235,9 +1246,9 @@ def objectives(self, model: libsbml.Model) -> List[Dict[str, Any]]: part = { "sign": sign, "coefficient": abs(coefficient), - "reaction": f_obj.getReaction() - if f_obj.isSetReaction() - else None, + "reaction": ( + f_obj.getReaction() if f_obj.isSetReaction() else None + ), } flux_objectives.append(part) d["fluxObjectives"] = flux_objectives diff --git a/src/sbmlutils/report/units.py b/src/sbmlutils/report/units.py index d3a3db2e..3cf8db19 100644 --- a/src/sbmlutils/report/units.py +++ b/src/sbmlutils/report/units.py @@ -1,4 +1,5 @@ """Helper functions for formating and rendering units.""" + from typing import Optional, Union import libsbml diff --git a/src/sbmlutils/resources/__init__.py b/src/sbmlutils/resources/__init__.py index d161bec0..ab90ca6f 100644 --- a/src/sbmlutils/resources/__init__.py +++ b/src/sbmlutils/resources/__init__.py @@ -1,4 +1,5 @@ """Resources for testing.""" + from pathlib import Path from typing import List @@ -162,7 +163,6 @@ def all_distrib_paths() -> List[Path]: COMP_SPT_KIDNEY, COMP_SPT_BODY_FLAT, COMP_SPT_BODY, - DISTRIB_DISTRIBUTIONS_SBML, DISTRIB_UNCERTAINTIES_SBML, FBC_ECOLI_CORE_SBML, diff --git a/src/sbmlutils/resources/converters/odefac_template.pytemp b/src/sbmlutils/resources/converters/odefac_template.pytemp index 99978245..4d8d2e5a 100644 --- a/src/sbmlutils/resources/converters/odefac_template.pytemp +++ b/src/sbmlutils/resources/converters/odefac_template.pytemp @@ -10,11 +10,12 @@ volume: [{{model_units["volume"]}}] area: [{{model_units["area"]}}] length: [{{model_units["length"]}}] """ +from typing import Any import numpy as np import pandas as pd -def piecewise(*kwargs): +def piecewise(*kwargs: Any) -> Any: """Piecewise function. piecewise | x1, y1, [x2, y2,] [...] [z] | A piecewise function: if (y1), x1. Otherwise, if (y2), x2, etc. Otherwise, z. @@ -90,7 +91,7 @@ def f_y(x: np.ndarray, t: float, p: np.ndarray) -> np.ndarray: return y -def f_z(X, T, p): +def f_z(X: np.ndarray, T: np.ndarray, p: np.ndarray) -> np.ndarray: """ DataFrame of full timecourse of solution. """ (Nt, Nx) = X.shape Ny = len(yids) diff --git a/src/sbmlutils/resources/examples/linear_chain.py b/src/sbmlutils/resources/examples/linear_chain.py index c7b37e94..db1462ad 100644 --- a/src/sbmlutils/resources/examples/linear_chain.py +++ b/src/sbmlutils/resources/examples/linear_chain.py @@ -10,17 +10,20 @@ area: [-] length: [-] """ + +from typing import Any + import numpy as np import pandas as pd -def piecewise(*kwargs): +def piecewise(*kwargs: Any) -> Any: """Piecewise function. piecewise | x1, y1, [x2, y2,] [...] [z] | A piecewise function: if (y1), x1. Otherwise, if (y2), x2, etc. Otherwise, z. """ - for k in np.floor(len(kwargs)/2.0): - if kwargs[k+1]: + for k in np.floor(len(kwargs) / 2.0): + if kwargs[k + 1]: return kwargs[k] if len(kwargs) % 2 == 1: return kwargs[-1] @@ -29,112 +32,183 @@ def piecewise(*kwargs): # ------------------- # ids # ------------------- -xids = ["S1", "S10", "S11", "S12", "S13", "S14", "S15", "S16", "S17", "S18", "S19", "S2", "S20", "S21", "S3", "S4", "S5", "S6", "S7", "S8", "S9", ] -pids = ["cell", "k1", "k10", "k11", "k12", "k13", "k14", "k15", "k16", "k17", "k18", "k19", "k2", "k20", "k3", "k4", "k5", "k6", "k7", "k8", "k9", ] -yids = ["J1", "J10", "J11", "J12", "J13", "J14", "J15", "J16", "J17", "J18", "J19", "J2", "J20", "J3", "J4", "J5", "J6", "J7", "J8", "J9", ] +xids = [ + "S1", + "S10", + "S11", + "S12", + "S13", + "S14", + "S15", + "S16", + "S17", + "S18", + "S19", + "S2", + "S20", + "S21", + "S3", + "S4", + "S5", + "S6", + "S7", + "S8", + "S9", +] +pids = [ + "cell", + "k1", + "k10", + "k11", + "k12", + "k13", + "k14", + "k15", + "k16", + "k17", + "k18", + "k19", + "k2", + "k20", + "k3", + "k4", + "k5", + "k6", + "k7", + "k8", + "k9", +] +yids = [ + "J1", + "J10", + "J11", + "J12", + "J13", + "J14", + "J15", + "J16", + "J17", + "J18", + "J19", + "J2", + "J20", + "J3", + "J4", + "J5", + "J6", + "J7", + "J8", + "J9", +] # ------------------- # initial conditions # ------------------- -x0 = np.array([ - 10.0, # [0] S1 [-/-] in cell - 0.0, # [1] S10 [-/-] Species 10 in cell - 0.0, # [2] S11 [-/-] Species 11 in cell - 0.0, # [3] S12 [-/-] Species 12 in cell - 0.0, # [4] S13 [-/-] Species 13 in cell - 0.0, # [5] S14 [-/-] Species 14 in cell - 0.0, # [6] S15 [-/-] Species 15 in cell - 0.0, # [7] S16 [-/-] Species 16 in cell - 0.0, # [8] S17 [-/-] Species 17 in cell - 0.0, # [9] S18 [-/-] Species 18 in cell - 0.0, # [10] S19 [-/-] Species 19 in cell - 0.0, # [11] S2 [-/-] Species 2 in cell - 0.0, # [12] S20 [-/-] Species 20 in cell - 0.0, # [13] S21 [-/-] Species 21 in cell - 0.0, # [14] S3 [-/-] Species 3 in cell - 0.0, # [15] S4 [-/-] Species 4 in cell - 0.0, # [16] S5 [-/-] Species 5 in cell - 0.0, # [17] S6 [-/-] Species 6 in cell - 0.0, # [18] S7 [-/-] Species 7 in cell - 0.0, # [19] S8 [-/-] Species 8 in cell - 0.0, # [20] S9 [-/-] Species 9 in cell -]) +x0 = np.array( + [ + 10.0, # [0] S1 [-/-] in cell + 0.0, # [1] S10 [-/-] Species 10 in cell + 0.0, # [2] S11 [-/-] Species 11 in cell + 0.0, # [3] S12 [-/-] Species 12 in cell + 0.0, # [4] S13 [-/-] Species 13 in cell + 0.0, # [5] S14 [-/-] Species 14 in cell + 0.0, # [6] S15 [-/-] Species 15 in cell + 0.0, # [7] S16 [-/-] Species 16 in cell + 0.0, # [8] S17 [-/-] Species 17 in cell + 0.0, # [9] S18 [-/-] Species 18 in cell + 0.0, # [10] S19 [-/-] Species 19 in cell + 0.0, # [11] S2 [-/-] Species 2 in cell + 0.0, # [12] S20 [-/-] Species 20 in cell + 0.0, # [13] S21 [-/-] Species 21 in cell + 0.0, # [14] S3 [-/-] Species 3 in cell + 0.0, # [15] S4 [-/-] Species 4 in cell + 0.0, # [16] S5 [-/-] Species 5 in cell + 0.0, # [17] S6 [-/-] Species 6 in cell + 0.0, # [18] S7 [-/-] Species 7 in cell + 0.0, # [19] S8 [-/-] Species 8 in cell + 0.0, # [20] S9 [-/-] Species 9 in cell + ] +) # ------------------- # parameters # ------------------- -p = np.array([ - 1.0, # [0] cell [-] - 0.1, # [1] k1 [-] rate constant 1 - 0.1, # [2] k10 [-] rate constant 10 - 0.1, # [3] k11 [-] rate constant 11 - 0.1, # [4] k12 [-] rate constant 12 - 0.1, # [5] k13 [-] rate constant 13 - 0.1, # [6] k14 [-] rate constant 14 - 0.1, # [7] k15 [-] rate constant 15 - 0.1, # [8] k16 [-] rate constant 16 - 0.1, # [9] k17 [-] rate constant 17 - 0.1, # [10] k18 [-] rate constant 18 - 0.1, # [11] k19 [-] rate constant 19 - 0.1, # [12] k2 [-] rate constant 2 - 0.1, # [13] k20 [-] rate constant 20 - 0.1, # [14] k3 [-] rate constant 3 - 0.1, # [15] k4 [-] rate constant 4 - 0.1, # [16] k5 [-] rate constant 5 - 0.1, # [17] k6 [-] rate constant 6 - 0.1, # [18] k7 [-] rate constant 7 - 0.1, # [19] k8 [-] rate constant 8 - 0.1, # [20] k9 [-] rate constant 9 -]) +p = np.array( + [ + 1.0, # [0] cell [-] + 0.1, # [1] k1 [-] rate constant 1 + 0.1, # [2] k10 [-] rate constant 10 + 0.1, # [3] k11 [-] rate constant 11 + 0.1, # [4] k12 [-] rate constant 12 + 0.1, # [5] k13 [-] rate constant 13 + 0.1, # [6] k14 [-] rate constant 14 + 0.1, # [7] k15 [-] rate constant 15 + 0.1, # [8] k16 [-] rate constant 16 + 0.1, # [9] k17 [-] rate constant 17 + 0.1, # [10] k18 [-] rate constant 18 + 0.1, # [11] k19 [-] rate constant 19 + 0.1, # [12] k2 [-] rate constant 2 + 0.1, # [13] k20 [-] rate constant 20 + 0.1, # [14] k3 [-] rate constant 3 + 0.1, # [15] k4 [-] rate constant 4 + 0.1, # [16] k5 [-] rate constant 5 + 0.1, # [17] k6 [-] rate constant 6 + 0.1, # [18] k7 [-] rate constant 7 + 0.1, # [19] k8 [-] rate constant 8 + 0.1, # [20] k9 [-] rate constant 9 + ] +) def f_dxdt(x: np.ndarray, t: float, p: np.ndarray) -> np.ndarray: """ODE system.""" - J1 = p[1] * x[0] # [0] J1 [-/-] - J10 = p[2] * x[1] # [1] J10 [-/-] - J11 = p[3] * x[2] # [2] J11 [-/-] - J12 = p[4] * x[3] # [3] J12 [-/-] - J13 = p[5] * x[4] # [4] J13 [-/-] - J14 = p[6] * x[5] # [5] J14 [-/-] - J15 = p[7] * x[6] # [6] J15 [-/-] - J16 = p[8] * x[7] # [7] J16 [-/-] - J17 = p[9] * x[8] # [8] J17 [-/-] - J18 = p[10] * x[9] # [9] J18 [-/-] - J19 = p[11] * x[10] # [10] J19 [-/-] - J2 = p[12] * x[11] # [11] J2 [-/-] - J20 = p[13] * x[12] # [12] J20 [-/-] - J3 = p[14] * x[14] # [13] J3 [-/-] - J4 = p[15] * x[15] # [14] J4 [-/-] - J5 = p[16] * x[16] # [15] J5 [-/-] - J6 = p[17] * x[17] # [16] J6 [-/-] - J7 = p[18] * x[18] # [17] J7 [-/-] - J8 = p[19] * x[19] # [18] J8 [-/-] - J9 = p[20] * x[20] # [19] J9 [-/-] + J1 = p[1] * x[0] # [0] J1 [-/-] + J10 = p[2] * x[1] # [1] J10 [-/-] + J11 = p[3] * x[2] # [2] J11 [-/-] + J12 = p[4] * x[3] # [3] J12 [-/-] + J13 = p[5] * x[4] # [4] J13 [-/-] + J14 = p[6] * x[5] # [5] J14 [-/-] + J15 = p[7] * x[6] # [6] J15 [-/-] + J16 = p[8] * x[7] # [7] J16 [-/-] + J17 = p[9] * x[8] # [8] J17 [-/-] + J18 = p[10] * x[9] # [9] J18 [-/-] + J19 = p[11] * x[10] # [10] J19 [-/-] + J2 = p[12] * x[11] # [11] J2 [-/-] + J20 = p[13] * x[12] # [12] J20 [-/-] + J3 = p[14] * x[14] # [13] J3 [-/-] + J4 = p[15] * x[15] # [14] J4 [-/-] + J5 = p[16] * x[16] # [15] J5 [-/-] + J6 = p[17] * x[17] # [16] J6 [-/-] + J7 = p[18] * x[18] # [17] J7 [-/-] + J8 = p[19] * x[19] # [18] J8 [-/-] + J9 = p[20] * x[20] # [19] J9 [-/-] # ode - return np.ndarray([ - -J1 / p[0], # [0] S1 [-/-] - J9 / p[0] - J10 / p[0], # [1] S10 [-/-] Species 10 - J10 / p[0] - J11 / p[0], # [2] S11 [-/-] Species 11 - J11 / p[0] - J12 / p[0], # [3] S12 [-/-] Species 12 - J12 / p[0] - J13 / p[0], # [4] S13 [-/-] Species 13 - J13 / p[0] - J14 / p[0], # [5] S14 [-/-] Species 14 - J14 / p[0] - J15 / p[0], # [6] S15 [-/-] Species 15 - J15 / p[0] - J16 / p[0], # [7] S16 [-/-] Species 16 - J16 / p[0] - J17 / p[0], # [8] S17 [-/-] Species 17 - J17 / p[0] - J18 / p[0], # [9] S18 [-/-] Species 18 - J18 / p[0] - J19 / p[0], # [10] S19 [-/-] Species 19 - J1 / p[0] - J2 / p[0], # [11] S2 [-/-] Species 2 - J19 / p[0] - J20 / p[0], # [12] S20 [-/-] Species 20 - J20 / p[0], # [13] S21 [-/-] Species 21 - J2 / p[0] - J3 / p[0], # [14] S3 [-/-] Species 3 - J3 / p[0] - J4 / p[0], # [15] S4 [-/-] Species 4 - J4 / p[0] - J5 / p[0], # [16] S5 [-/-] Species 5 - J5 / p[0] - J6 / p[0], # [17] S6 [-/-] Species 6 - J6 / p[0] - J7 / p[0], # [18] S7 [-/-] Species 7 - J7 / p[0] - J8 / p[0], # [19] S8 [-/-] Species 8 - J8 / p[0] - J9 / p[0], # [20] S9 [-/-] Species 9 - ]) + return np.ndarray( + [ + -J1 / p[0], # [0] S1 [-/-] + J9 / p[0] - J10 / p[0], # [1] S10 [-/-] Species 10 + J10 / p[0] - J11 / p[0], # [2] S11 [-/-] Species 11 + J11 / p[0] - J12 / p[0], # [3] S12 [-/-] Species 12 + J12 / p[0] - J13 / p[0], # [4] S13 [-/-] Species 13 + J13 / p[0] - J14 / p[0], # [5] S14 [-/-] Species 14 + J14 / p[0] - J15 / p[0], # [6] S15 [-/-] Species 15 + J15 / p[0] - J16 / p[0], # [7] S16 [-/-] Species 16 + J16 / p[0] - J17 / p[0], # [8] S17 [-/-] Species 17 + J17 / p[0] - J18 / p[0], # [9] S18 [-/-] Species 18 + J18 / p[0] - J19 / p[0], # [10] S19 [-/-] Species 19 + J1 / p[0] - J2 / p[0], # [11] S2 [-/-] Species 2 + J19 / p[0] - J20 / p[0], # [12] S20 [-/-] Species 20 + J20 / p[0], # [13] S21 [-/-] Species 21 + J2 / p[0] - J3 / p[0], # [14] S3 [-/-] Species 3 + J3 / p[0] - J4 / p[0], # [15] S4 [-/-] Species 4 + J4 / p[0] - J5 / p[0], # [16] S5 [-/-] Species 5 + J5 / p[0] - J6 / p[0], # [17] S6 [-/-] Species 6 + J6 / p[0] - J7 / p[0], # [18] S7 [-/-] Species 7 + J7 / p[0] - J8 / p[0], # [19] S8 [-/-] Species 8 + J8 / p[0] - J9 / p[0], # [20] S9 [-/-] Species 9 + ] + ) def f_y(x: np.ndarray, t: float, p: np.ndarray) -> np.ndarray: @@ -146,66 +220,66 @@ def f_y(x: np.ndarray, t: float, p: np.ndarray) -> np.ndarray: :return: """ - J1 = p[1] * x[0] # [0] J1 [-/-] - J10 = p[2] * x[1] # [1] J10 [-/-] - J11 = p[3] * x[2] # [2] J11 [-/-] - J12 = p[4] * x[3] # [3] J12 [-/-] - J13 = p[5] * x[4] # [4] J13 [-/-] - J14 = p[6] * x[5] # [5] J14 [-/-] - J15 = p[7] * x[6] # [6] J15 [-/-] - J16 = p[8] * x[7] # [7] J16 [-/-] - J17 = p[9] * x[8] # [8] J17 [-/-] - J18 = p[10] * x[9] # [9] J18 [-/-] - J19 = p[11] * x[10] # [10] J19 [-/-] - J2 = p[12] * x[11] # [11] J2 [-/-] - J20 = p[13] * x[12] # [12] J20 [-/-] - J3 = p[14] * x[14] # [13] J3 [-/-] - J4 = p[15] * x[15] # [14] J4 [-/-] - J5 = p[16] * x[16] # [15] J5 [-/-] - J6 = p[17] * x[17] # [16] J6 [-/-] - J7 = p[18] * x[18] # [17] J7 [-/-] - J8 = p[19] * x[19] # [18] J8 [-/-] - J9 = p[20] * x[20] # [19] J9 [-/-] + J1 = p[1] * x[0] # [0] J1 [-/-] + J10 = p[2] * x[1] # [1] J10 [-/-] + J11 = p[3] * x[2] # [2] J11 [-/-] + J12 = p[4] * x[3] # [3] J12 [-/-] + J13 = p[5] * x[4] # [4] J13 [-/-] + J14 = p[6] * x[5] # [5] J14 [-/-] + J15 = p[7] * x[6] # [6] J15 [-/-] + J16 = p[8] * x[7] # [7] J16 [-/-] + J17 = p[9] * x[8] # [8] J17 [-/-] + J18 = p[10] * x[9] # [9] J18 [-/-] + J19 = p[11] * x[10] # [10] J19 [-/-] + J2 = p[12] * x[11] # [11] J2 [-/-] + J20 = p[13] * x[12] # [12] J20 [-/-] + J3 = p[14] * x[14] # [13] J3 [-/-] + J4 = p[15] * x[15] # [14] J4 [-/-] + J5 = p[16] * x[16] # [15] J5 [-/-] + J6 = p[17] * x[17] # [16] J6 [-/-] + J7 = p[18] * x[18] # [17] J7 [-/-] + J8 = p[19] * x[19] # [18] J8 [-/-] + J9 = p[20] * x[20] # [19] J9 [-/-] # -------------------------------------- y = np.empty(shape=(20)) - y[0] = J1 # [0] J1 [-/-] - y[1] = J10 # [1] J10 [-/-] - y[2] = J11 # [2] J11 [-/-] - y[3] = J12 # [3] J12 [-/-] - y[4] = J13 # [4] J13 [-/-] - y[5] = J14 # [5] J14 [-/-] - y[6] = J15 # [6] J15 [-/-] - y[7] = J16 # [7] J16 [-/-] - y[8] = J17 # [8] J17 [-/-] - y[9] = J18 # [9] J18 [-/-] - y[10] = J19 # [10] J19 [-/-] - y[11] = J2 # [11] J2 [-/-] - y[12] = J20 # [12] J20 [-/-] - y[13] = J3 # [13] J3 [-/-] - y[14] = J4 # [14] J4 [-/-] - y[15] = J5 # [15] J5 [-/-] - y[16] = J6 # [16] J6 [-/-] - y[17] = J7 # [17] J7 [-/-] - y[18] = J8 # [18] J8 [-/-] - y[19] = J9 # [19] J9 [-/-] + y[0] = J1 # [0] J1 [-/-] + y[1] = J10 # [1] J10 [-/-] + y[2] = J11 # [2] J11 [-/-] + y[3] = J12 # [3] J12 [-/-] + y[4] = J13 # [4] J13 [-/-] + y[5] = J14 # [5] J14 [-/-] + y[6] = J15 # [6] J15 [-/-] + y[7] = J16 # [7] J16 [-/-] + y[8] = J17 # [8] J17 [-/-] + y[9] = J18 # [9] J18 [-/-] + y[10] = J19 # [10] J19 [-/-] + y[11] = J2 # [11] J2 [-/-] + y[12] = J20 # [12] J20 [-/-] + y[13] = J3 # [13] J3 [-/-] + y[14] = J4 # [14] J4 [-/-] + y[15] = J5 # [15] J5 [-/-] + y[16] = J6 # [16] J6 [-/-] + y[17] = J7 # [17] J7 [-/-] + y[18] = J8 # [18] J8 [-/-] + y[19] = J9 # [19] J9 [-/-] return y -def f_z(X, T, p): - """ DataFrame of full timecourse of solution. """ +def f_z(X: np.ndarray, T: np.ndarray, p: np.ndarray) -> np.ndarray: + """DataFrame of full timecourse of solution.""" (Nt, Nx) = X.shape Ny = len(yids) Nz = 1 + Nx + Ny columns = ["time"] + xids + yids Z = np.empty(shape=(Nt, Nz)) Z[:, 0] = T - Z[:, 1:(Nx+1)] = X + Z[:, 1 : (Nx + 1)] = X for kt in range(Nt): y = f_y(x=X[kt, :], t=T[kt], p=p) - Z[kt, (Nx+1):] = y + Z[kt, (Nx + 1) :] = y Z = pd.DataFrame(Z, columns=columns) - return Z \ No newline at end of file + return Z diff --git a/src/sbmlutils/utils.py b/src/sbmlutils/utils.py index d8f37766..49407e78 100644 --- a/src/sbmlutils/utils.py +++ b/src/sbmlutils/utils.py @@ -1,4 +1,5 @@ """Utility functions.""" + import functools import hashlib import time diff --git a/src/sbmlutils/validation.py b/src/sbmlutils/validation.py index 92d41bee..ed742448 100644 --- a/src/sbmlutils/validation.py +++ b/src/sbmlutils/validation.py @@ -1,4 +1,5 @@ """Helpers for validation and checking of SBML and libsbml operations.""" + import time from dataclasses import dataclass from typing import Iterable, List, Optional diff --git a/tests/converters/test_copasi.py b/tests/converters/test_copasi.py index 82b5ca90..3e3be026 100644 --- a/tests/converters/test_copasi.py +++ b/tests/converters/test_copasi.py @@ -1,4 +1,5 @@ """Testing COPASI functionality.""" + from pathlib import Path from sbmlutils.converters import copasi diff --git a/tests/converters/test_odefac.py b/tests/converters/test_odefac.py index 90d1ba67..d6683c80 100644 --- a/tests/converters/test_odefac.py +++ b/tests/converters/test_odefac.py @@ -1,4 +1,5 @@ """Testing ODE factory.""" + from pathlib import Path import libsbml diff --git a/tests/converters/test_xpp.py b/tests/converters/test_xpp.py index d90bb27f..7ca3988d 100644 --- a/tests/converters/test_xpp.py +++ b/tests/converters/test_xpp.py @@ -1,4 +1,5 @@ """Test XPP generation.""" + from pathlib import Path from sbmlutils.converters import xpp diff --git a/tests/examples/test_examples.py b/tests/examples/test_examples.py index 1a7ebeb7..9c07ae80 100644 --- a/tests/examples/test_examples.py +++ b/tests/examples/test_examples.py @@ -1,4 +1,5 @@ """Example model creation.""" + from pathlib import Path from typing import Any diff --git a/tests/examples/test_galactose.py b/tests/examples/test_galactose.py index 0a7eb772..b6b67fa4 100644 --- a/tests/examples/test_galactose.py +++ b/tests/examples/test_galactose.py @@ -1,4 +1,5 @@ """Test the galactose model.""" + from sbmlutils.io.sbml import validate_sbml from sbmlutils.resources import GALACTOSE_SINGLECELL_SBML diff --git a/tests/fbc/test_cobra.py b/tests/fbc/test_cobra.py index 651dcba0..d9a9482f 100644 --- a/tests/fbc/test_cobra.py +++ b/tests/fbc/test_cobra.py @@ -1,4 +1,5 @@ """Testing cobra and fbc functionality.""" + from pathlib import Path import pytest diff --git a/tests/interpolation/test_interpolation.py b/tests/interpolation/test_interpolation.py index 5806e608..f02d593c 100644 --- a/tests/interpolation/test_interpolation.py +++ b/tests/interpolation/test_interpolation.py @@ -1,4 +1,5 @@ """Test interpolation.""" + from pathlib import Path import pandas as pd diff --git a/tests/io/test_sbml.py b/tests/io/test_sbml.py index cd40b4a1..24358f6b 100644 --- a/tests/io/test_sbml.py +++ b/tests/io/test_sbml.py @@ -1,4 +1,5 @@ """Test SBML reading and writing.""" + from pathlib import Path import libsbml diff --git a/tests/manipulation/test_merge.py b/tests/manipulation/test_merge.py index c61c0b6d..7e478538 100644 --- a/tests/manipulation/test_merge.py +++ b/tests/manipulation/test_merge.py @@ -1,4 +1,5 @@ """Test model merging functionality.""" + from pathlib import Path from sbmlutils import comp, validation diff --git a/tests/metadata/test_annotator.py b/tests/metadata/test_annotator.py index 49ae0e39..9eb3b69f 100644 --- a/tests/metadata/test_annotator.py +++ b/tests/metadata/test_annotator.py @@ -1,4 +1,5 @@ """Test annotation functions and annotating of SBML models.""" + import re from pathlib import Path from typing import Iterable diff --git a/tests/report/test_api.py b/tests/report/test_api.py index 77ba749c..4c5f7c5e 100644 --- a/tests/report/test_api.py +++ b/tests/report/test_api.py @@ -1,4 +1,5 @@ """Test SBML report.""" + from pathlib import Path import pytest diff --git a/tests/report/test_mathml.py b/tests/report/test_mathml.py index 285f7c08..5b3133da 100644 --- a/tests/report/test_mathml.py +++ b/tests/report/test_mathml.py @@ -1,4 +1,5 @@ """Test MathML functionality.""" + import libsbml import pytest diff --git a/tests/test_biomodels.py b/tests/test_biomodels.py index 31916bca..614ad6e8 100644 --- a/tests/test_biomodels.py +++ b/tests/test_biomodels.py @@ -1,4 +1,5 @@ """Testing the biomodels module.""" + from pathlib import Path import pytest diff --git a/tests/test_comp.py b/tests/test_comp.py index cc7d4157..bc9f43cd 100644 --- a/tests/test_comp.py +++ b/tests/test_comp.py @@ -1,4 +1,5 @@ """Tests for the comp package.""" + import libsbml from sbmlutils import comp diff --git a/tests/test_distrib.py b/tests/test_distrib.py index a35073d4..b2a0ffaf 100644 --- a/tests/test_distrib.py +++ b/tests/test_distrib.py @@ -1,4 +1,5 @@ """Test distrib functionality.""" + import libsbml from sbmlutils.distrib import distrib_examples, distrib_packages diff --git a/tests/test_factory.py b/tests/test_factory.py index 1553058d..92adbf1a 100644 --- a/tests/test_factory.py +++ b/tests/test_factory.py @@ -1,4 +1,5 @@ """Testing the factory methods.""" + from pathlib import Path from typing import Any, Dict diff --git a/tests/test_history.py b/tests/test_history.py index 1a639a54..177f14c5 100644 --- a/tests/test_history.py +++ b/tests/test_history.py @@ -1,4 +1,5 @@ """Test history on SBML models.""" + import libsbml from sbmlutils.factory import Creator, date_now, set_model_history diff --git a/tests/test_model.py b/tests/test_model.py index 75c98b24..fc5cd974 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -1,4 +1,5 @@ """Test model functionality.""" + import pytest from sbmlutils.factory import * diff --git a/tests/test_model_creator.py b/tests/test_model_creator.py index 008327d1..bb0b8ec0 100644 --- a/tests/test_model_creator.py +++ b/tests/test_model_creator.py @@ -1,4 +1,5 @@ """Test the creator module.""" + from pathlib import Path import pytest diff --git a/tests/test_notes.py b/tests/test_notes.py index 594b0b44..33105ec4 100644 --- a/tests/test_notes.py +++ b/tests/test_notes.py @@ -1,4 +1,5 @@ """Testing notes.""" + import re import libsbml diff --git a/tests/test_parser.py b/tests/test_parser.py index bb730d4c..3ebf6744 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -1,4 +1,5 @@ """Test parsing of SBML.""" + from pathlib import Path from typing import List diff --git a/tests/test_reaction_equation.py b/tests/test_reaction_equation.py index 9f97e11d..136a1441 100644 --- a/tests/test_reaction_equation.py +++ b/tests/test_reaction_equation.py @@ -1,4 +1,5 @@ """Test equations.""" + import pytest from sbmlutils.reaction_equation import ( diff --git a/tests/test_sbml_testsuite.py b/tests/test_sbml_testsuite.py index 93e3706a..1aa19d0d 100644 --- a/tests/test_sbml_testsuite.py +++ b/tests/test_sbml_testsuite.py @@ -1,4 +1,5 @@ """Testing the biomodels module.""" + from pathlib import Path import pytest diff --git a/tests/test_udef_to_str.py b/tests/test_udef_to_str.py index 0e7b1d1d..ea70c25e 100644 --- a/tests/test_udef_to_str.py +++ b/tests/test_udef_to_str.py @@ -1,4 +1,5 @@ """Test UnitDefinition to string functions.""" + import libsbml import pytest @@ -38,7 +39,7 @@ def test_unit_definition_str(uid: str, definition: str, expected: str) -> None: ("m3", "meter^3", "m^3"), ("m3", "meter^3/second", "\\frac{m^3}{s}"), ("mM", "mmole/liter", "\\frac{mmol}{l}"), - ("ml_per_s_kg", "ml/s/kg", "\\frac{ml}{s \cdot kg}"), # noqa: W605 + ("ml_per_s_kg", "ml/s/kg", "\\frac{ml}{s \\cdot kg}"), # noqa: W605 ("dimensionless", "dimensionless", "-"), ("item", "item", "item"), ] diff --git a/tests/test_validation.py b/tests/test_validation.py index c017bc86..d67733f5 100644 --- a/tests/test_validation.py +++ b/tests/test_validation.py @@ -1,4 +1,5 @@ """Test SBML validation.""" + from pathlib import Path import pytest diff --git a/tox.ini b/tox.ini index 3fa450ce..ed01f3fd 100644 --- a/tox.ini +++ b/tox.ini @@ -136,10 +136,6 @@ follow_imports = silent disallow_untyped_defs = True disallow_incomplete_defs = True - -[py2cytoscape.data.cyrest_client] -ignore_missing_imports = True - [mypy-libsbml.*] ignore_missing_imports = True