Skip to content

Commit

Permalink
More models to antimony (#78)
Browse files Browse the repository at this point in the history
And remove some superfluous files. More to follow later.

No relevant changes to the models, just converting them to antimony and creating SBML models on the fly.
  • Loading branch information
dweindl authored Jul 2, 2024
1 parent a09a120 commit bd0ff4d
Show file tree
Hide file tree
Showing 23 changed files with 275 additions and 1,025 deletions.
24 changes: 22 additions & 2 deletions petabtests/cases/v1.0.0/sbml/0005/0005.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import pandas as pd
from petab.v1.C import *

from petabtests import PetabTestCase, analytical_a
from petabtests import PetabTestCase, analytical_a, antimony_to_sbml_str

DESCRIPTION = cleandoc("""
## Objective
Expand All @@ -23,6 +23,26 @@
""")

# problem --------------------------------------------------------------------
ant_model = """
model *petab_test_0011()
compartment compartment_ = 1;
species A in compartment_, B in compartment_;
fwd: A => B; compartment_ * k1 * A;
rev: B => A; compartment_ * k2 * B;
A = a0;
B = b0;
B = 1;
a0 = 1;
b0 = 1;
k1 = 0;
k2 = 0;
offset_A = 0;
end
"""
model_file = Path(__file__).parent / "_model.xml"
model_file.write_text(antimony_to_sbml_str(ant_model))

condition_df = pd.DataFrame(
data={
Expand Down Expand Up @@ -73,7 +93,7 @@
brief="Simulation. Condition-specific parameters only defined in "
"parameter table.",
description=DESCRIPTION,
model=Path("conversion_modified.xml"),
model=model_file,
condition_dfs=[condition_df],
observable_dfs=[observable_df],
measurement_dfs=[measurement_df],
Expand Down
69 changes: 19 additions & 50 deletions petabtests/cases/v1.0.0/sbml/0005/_model.xml
Original file line number Diff line number Diff line change
@@ -1,96 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<sbml xmlns="http://www.sbml.org/sbml/level2/version4" level="2" version="4">
<model id="conversion_reaction_0" name="Conversion Reaction 0">

<listOfUnitDefinitions>
<unitDefinition id="volume" name="volume">
<listOfUnits>
<unit kind="litre" exponent="1" scale="-3" multiplier="1"/>
</listOfUnits>
</unitDefinition>
<unitDefinition id="substance" name="substance">
<listOfUnits>
<unit kind="mole" exponent="1" scale="-3" multiplier="1"/>
</listOfUnits>
</unitDefinition>
</listOfUnitDefinitions>

<!-- Created by libAntimony version v2.14.0 with libSBML version 5.20.2. -->
<sbml xmlns="http://www.sbml.org/sbml/level3/version2/core" level="3" version="2">
<model metaid="petab_test_0011" id="petab_test_0011">
<listOfCompartments>
<compartment id="compartment" name="compartment" spatialDimensions="3" size="1" constant="true">
</compartment>
<compartment id="compartment_" spatialDimensions="3" size="1" constant="true"/>
</listOfCompartments>

<listOfSpecies>
<species id="A" name="A" compartment="compartment" initialConcentration="1" boundaryCondition="false" constant="false">
</species>
<species id="B" name="B" compartment="compartment" initialConcentration="1" boundaryCondition="false" constant="false">
</species>
<species id="A" compartment="compartment_" hasOnlySubstanceUnits="false" boundaryCondition="false" constant="false"/>
<species id="B" compartment="compartment_" initialConcentration="1" hasOnlySubstanceUnits="false" boundaryCondition="false" constant="false"/>
</listOfSpecies>

<listOfParameters>
<parameter id="a0" name="a0" value="1" constant="true">
</parameter>
<parameter id="b0" name="b0" value="1" constant="true">
</parameter>
<parameter id="k1" name="k1" value="0" constant="true">
</parameter>
<parameter id="k2" name="k2" value="0" constant="true">
</parameter>
<parameter id="offset_A" name="offset_A" value="0" constant="true">
</parameter>
<parameter id="k1" value="0" constant="true"/>
<parameter id="k2" value="0" constant="true"/>
<parameter id="a0" value="1" constant="true"/>
<parameter id="b0" value="1" constant="true"/>
<parameter id="offset_A" value="0" constant="true"/>
</listOfParameters>

<listOfInitialAssignments>
<initialAssignment symbol="A">
<math xmlns="http://www.w3.org/1998/Math/MathML">
<ci> a0 </ci>
</math>
</initialAssignment>
<initialAssignment symbol="B">
<math xmlns="http://www.w3.org/1998/Math/MathML">
<ci> b0 </ci>
</math>
</initialAssignment>
</listOfInitialAssignments>

<listOfReactions>
<reaction id="fwd" name="fwd" reversible="false">
<reaction id="fwd" reversible="false">
<listOfReactants>
<speciesReference species="A" stoichiometry="1"/>
<speciesReference species="A" stoichiometry="1" constant="true"/>
</listOfReactants>
<listOfProducts>
<speciesReference species="B" stoichiometry="1"/>
<speciesReference species="B" stoichiometry="1" constant="true"/>
</listOfProducts>
<kineticLaw>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply>
<times/>
<ci> compartment </ci>
<ci> compartment_ </ci>
<ci> k1 </ci>
<ci> A </ci>
</apply>
</math>
</kineticLaw>
</reaction>
<reaction id="rev" name="rev" reversible="false">
<reaction id="rev" reversible="false">
<listOfReactants>
<speciesReference species="B" stoichiometry="1"/>
<speciesReference species="B" stoichiometry="1" constant="true"/>
</listOfReactants>
<listOfProducts>
<speciesReference species="A" stoichiometry="1"/>
<speciesReference species="A" stoichiometry="1" constant="true"/>
</listOfProducts>
<kineticLaw>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply>
<times/>
<ci> compartment </ci>
<ci> compartment_ </ci>
<ci> k2 </ci>
<ci> B </ci>
</apply>
</math>
</kineticLaw>
</reaction>
</listOfReactions>

</model>
</sbml>
87 changes: 0 additions & 87 deletions petabtests/cases/v1.0.0/sbml/0010/conversion_modified.xml

This file was deleted.

24 changes: 21 additions & 3 deletions petabtests/cases/v1.0.0/sbml/0011/0011.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import pandas as pd
from petab.v1.C import *

from petabtests import PetabTestCase, analytical_a
from pathlib import Path
from petabtests import PetabTestCase, analytical_a, antimony_to_sbml_str

DESCRIPTION = cleandoc("""
## Objective
Expand All @@ -20,6 +20,24 @@

# problem --------------------------------------------------------------------

ant_model = """
model *petab_test_0011()
compartment compartment_ = 1;
species A in compartment_, B in compartment_;
fwd: A => B; compartment_ * k1 * A;
rev: B => A; compartment_ * k2 * B;
A = a0;
B = 1;
a0 = 1;
k1 = 0;
k2 = 0;
end
"""
model_file = Path(__file__).parent / "_model.xml"
model_file.write_text(antimony_to_sbml_str(ant_model))

condition_df = pd.DataFrame(data={CONDITION_ID: ["c0"], "B": [2]}).set_index(
[CONDITION_ID]
)
Expand Down Expand Up @@ -65,7 +83,7 @@
id=11,
brief="Simulation. InitialAssignment to species overridden.",
description=DESCRIPTION,
model="conversion_modified.xml",
model=model_file,
condition_dfs=[condition_df],
observable_dfs=[observable_df],
measurement_dfs=[measurement_df],
Expand Down
58 changes: 17 additions & 41 deletions petabtests/cases/v1.0.0/sbml/0011/_model.xml
Original file line number Diff line number Diff line change
@@ -1,87 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<sbml xmlns="http://www.sbml.org/sbml/level2/version4" level="2" version="4">
<model id="conversion_reaction_0" name="Conversion Reaction 0">

<listOfUnitDefinitions>
<unitDefinition id="volume" name="volume">
<listOfUnits>
<unit kind="litre" exponent="1" scale="-3" multiplier="1"/>
</listOfUnits>
</unitDefinition>
<unitDefinition id="substance" name="substance">
<listOfUnits>
<unit kind="mole" exponent="1" scale="-3" multiplier="1"/>
</listOfUnits>
</unitDefinition>
</listOfUnitDefinitions>

<!-- Created by libAntimony version v2.14.0 with libSBML version 5.20.2. -->
<sbml xmlns="http://www.sbml.org/sbml/level3/version2/core" level="3" version="2">
<model metaid="petab_test_0011" id="petab_test_0011">
<listOfCompartments>
<compartment id="compartment" name="compartment" spatialDimensions="3" size="1" constant="true">
</compartment>
<compartment id="compartment_" spatialDimensions="3" size="1" constant="true"/>
</listOfCompartments>

<listOfSpecies>
<species id="A" name="A" compartment="compartment" initialConcentration="1" boundaryCondition="false" constant="false">
</species>
<species id="B" name="B" compartment="compartment" initialConcentration="1" boundaryCondition="false" constant="false">
</species>
<species id="A" compartment="compartment_" hasOnlySubstanceUnits="false" boundaryCondition="false" constant="false"/>
<species id="B" compartment="compartment_" initialConcentration="1" hasOnlySubstanceUnits="false" boundaryCondition="false" constant="false"/>
</listOfSpecies>

<listOfParameters>
<parameter id="a0" name="a0" value="1" constant="true">
</parameter>
<parameter id="k1" name="k1" value="0" constant="true">
</parameter>
<parameter id="k2" name="k2" value="0" constant="true">
</parameter>
<parameter id="k1" value="0" constant="true"/>
<parameter id="k2" value="0" constant="true"/>
<parameter id="a0" value="1" constant="true"/>
</listOfParameters>

<listOfInitialAssignments>
<initialAssignment symbol="A">
<math xmlns="http://www.w3.org/1998/Math/MathML">
<ci> a0 </ci>
</math>
</initialAssignment>
</listOfInitialAssignments>

<listOfReactions>
<reaction id="fwd" name="fwd" reversible="false">
<reaction id="fwd" reversible="false">
<listOfReactants>
<speciesReference species="A" stoichiometry="1"/>
<speciesReference species="A" stoichiometry="1" constant="true"/>
</listOfReactants>
<listOfProducts>
<speciesReference species="B" stoichiometry="1"/>
<speciesReference species="B" stoichiometry="1" constant="true"/>
</listOfProducts>
<kineticLaw>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply>
<times/>
<ci> compartment </ci>
<ci> compartment_ </ci>
<ci> k1 </ci>
<ci> A </ci>
</apply>
</math>
</kineticLaw>
</reaction>
<reaction id="rev" name="rev" reversible="false">
<reaction id="rev" reversible="false">
<listOfReactants>
<speciesReference species="B" stoichiometry="1"/>
<speciesReference species="B" stoichiometry="1" constant="true"/>
</listOfReactants>
<listOfProducts>
<speciesReference species="A" stoichiometry="1"/>
<speciesReference species="A" stoichiometry="1" constant="true"/>
</listOfProducts>
<kineticLaw>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply>
<times/>
<ci> compartment </ci>
<ci> compartment_ </ci>
<ci> k2 </ci>
<ci> B </ci>
</apply>
</math>
</kineticLaw>
</reaction>
</listOfReactions>

</model>
</sbml>
Loading

0 comments on commit bd0ff4d

Please sign in to comment.