-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed model generator incompatible to Python 3.7 (#39)
- Loading branch information
Showing
5 changed files
with
248 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
from pyenzyme.enzymeml.models.kineticmodel import KineticModel | ||
from pyenzyme.enzymeml.models.kineticmodel import KineticParameter | ||
from pyenzyme.enzymeml.core.ontology import SBOTerm | ||
|
||
|
||
class TestKineticModel: | ||
def test_content(self): | ||
"""Tests consistency of content""" | ||
|
||
# Set up kinetic parameter | ||
param = KineticParameter( | ||
name="kcat", | ||
value=10.0, | ||
unit="1 / s", | ||
initial_value=20.0, | ||
upper=30.0, | ||
lower=0, | ||
is_global=False, | ||
stdev=1.0, | ||
) | ||
|
||
assert param.name == "kcat" | ||
assert param.value == 10.0 | ||
assert param.unit == "1 / s" | ||
assert param.initial_value == 20.0 | ||
assert param.upper == 30.0 | ||
assert param.lower == 0.0 | ||
assert param.stdev == 1.0 | ||
assert not param.is_global | ||
|
||
# Set up kinetic model | ||
km = KineticModel( | ||
name="Michaelis Menten Model", | ||
equation="p0*kcat*s0 / (km * s0)", | ||
parameters=[param], | ||
ontology=SBOTerm.MICHAELIS_MENTEN, | ||
) | ||
|
||
assert km.name == "Michaelis Menten Model" | ||
assert km.equation == "p0*kcat*s0 / (km * s0)" | ||
assert km.ontology == SBOTerm.MICHAELIS_MENTEN | ||
|
||
# Add another paramete | ||
km.addParameter( | ||
name="km", | ||
value=10.0, | ||
unit="mmole / l", | ||
initial_value=20.0, | ||
upper=30.0, | ||
lower=0, | ||
is_global=False, | ||
stdev=1.0, | ||
) | ||
|
||
# Check addition has worked | ||
assert km.getParameter("km").name == "km" | ||
assert km.getParameter("km").value == 10.0 | ||
assert km.getParameter("km").unit == "mmole / l" | ||
assert km.getParameter("km").initial_value == 20.0 | ||
assert km.getParameter("km").upper == 30.0 | ||
assert km.getParameter("km").lower == 0.0 | ||
assert km.getParameter("km").stdev == 1.0 | ||
assert not km.getParameter("km").is_global | ||
|
||
def test_model_generator(self, enzmldoc): | ||
"""Tests consistency of the model generator""" | ||
|
||
# Set up a generator | ||
generator = KineticModel.createGenerator( | ||
name="Michaelis Menten Model", | ||
equation="protein*kcat*substrate / (km * substrate)", | ||
kcat={"unit": "1 / s", "value": 10.0}, | ||
km={"unit": "mmole / l", "value": 10.0}, | ||
) | ||
|
||
# Generate kinetic model | ||
km = generator(protein="p0", substrate="s0") | ||
|
||
assert km.name == "Michaelis Menten Model" | ||
assert km.equation == "'p0'*kcat*'s0' / (km * 's0')" | ||
|
||
# Add model to reaction | ||
enzmldoc.reaction_dict["r0"].setModel(km, enzmldoc) | ||
|
||
assert km.name == "Michaelis Menten Model" | ||
assert km.equation == "p0*kcat*s0 / (km * s0)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<sbml xmlns="http://www.sbml.org/sbml/level3/version2/core" level="3" version="2"> | ||
<model id="Test" name="Test"> | ||
<annotation> | ||
<enzymeml:references xmlns:enzymeml="http://sbml.org/enzymeml/version2"> | ||
<enzymeml:doi>DOI</enzymeml:doi> | ||
<enzymeml:pubmedID>https://identifiers.org/pubmed:PubMedID</enzymeml:pubmedID> | ||
<enzymeml:url>URL</enzymeml:url> | ||
</enzymeml:references> | ||
</annotation> | ||
<listOfUnitDefinitions> | ||
<unitDefinition metaid="METAID_U0" id="u0" name="ml"> | ||
<listOfUnits> | ||
<unit kind="litre" exponent="1" scale="-3" multiplier="1"/> | ||
</listOfUnits> | ||
</unitDefinition> | ||
<unitDefinition metaid="METAID_U1" id="u1" name="mmole / l"> | ||
<listOfUnits> | ||
<unit kind="litre" exponent="-1" scale="1" multiplier="1"/> | ||
<unit kind="mole" exponent="1" scale="-3" multiplier="1"/> | ||
</listOfUnits> | ||
</unitDefinition> | ||
<unitDefinition metaid="METAID_U2" id="u2" name="K"> | ||
<listOfUnits> | ||
<unit kind="kelvin" exponent="1" scale="1" multiplier="1"/> | ||
</listOfUnits> | ||
</unitDefinition> | ||
<unitDefinition metaid="METAID_U3" id="u3" name="1 / s"> | ||
<listOfUnits> | ||
<unit kind="second" exponent="-1" scale="1" multiplier="1"/> | ||
</listOfUnits> | ||
</unitDefinition> | ||
<unitDefinition metaid="METAID_U4" id="u4" name="s"> | ||
<listOfUnits> | ||
<unit kind="second" exponent="1" scale="1" multiplier="1"/> | ||
</listOfUnits> | ||
</unitDefinition> | ||
</listOfUnitDefinitions> | ||
<listOfCompartments> | ||
<compartment id="v0" name="Vessel" spatialDimensions="3" size="10" units="u0" constant="true"/> | ||
</listOfCompartments> | ||
<listOfSpecies> | ||
<species metaid="METAID_P0" sboTerm="SBO:0000252" id="p0" name="Protein" compartment="v0" initialConcentration="10" substanceUnits="u1" hasOnlySubstanceUnits="false" boundaryCondition="false" constant="true"> | ||
<annotation> | ||
<enzymeml:protein xmlns:enzymeml="http://sbml.org/enzymeml/version2"> | ||
<enzymeml:sequence>HLPMV</enzymeml:sequence> | ||
<enzymeml:ECnumber>1.1.1.1</enzymeml:ECnumber> | ||
<enzymeml:uniprotID>P02357</enzymeml:uniprotID> | ||
<enzymeml:organism>E.coli</enzymeml:organism> | ||
<enzymeml:organismTaxID>27367</enzymeml:organismTaxID> | ||
</enzymeml:protein> | ||
</annotation> | ||
</species> | ||
<species metaid="METAID_C0" sboTerm="SBO:0000296" id="c0" name="Complex" compartment="v0" initialConcentration="10" substanceUnits="u1" hasOnlySubstanceUnits="false" boundaryCondition="false" constant="false"> | ||
<annotation> | ||
<enzymeml:complex xmlns:enzymeml="http://sbml.org/enzymeml/version2"> | ||
<enzymeml:participant>s0</enzymeml:participant> | ||
<enzymeml:participant>p0</enzymeml:participant> | ||
</enzymeml:complex> | ||
</annotation> | ||
</species> | ||
<species metaid="METAID_S0" sboTerm="SBO:0000247" id="s0" name="Reactant" compartment="v0" initialConcentration="10" substanceUnits="u1" hasOnlySubstanceUnits="false" boundaryCondition="false" constant="false"> | ||
<annotation> | ||
<enzymeml:reactant xmlns:enzymeml="http://sbml.org/enzymeml/version2"> | ||
<enzymeml:inchi>InChI:HJJH</enzymeml:inchi> | ||
<enzymeml:smiles>[H]O[H]</enzymeml:smiles> | ||
<enzymeml:chebiID>CHEBI:09823</enzymeml:chebiID> | ||
</enzymeml:reactant> | ||
</annotation> | ||
</species> | ||
<species metaid="METAID_S1" sboTerm="SBO:0000247" id="s1" name="Reactant2" compartment="v0" initialConcentration="10" substanceUnits="u1" hasOnlySubstanceUnits="false" boundaryCondition="false" constant="false"> | ||
<annotation> | ||
<enzymeml:reactant xmlns:enzymeml="http://sbml.org/enzymeml/version2"> | ||
<enzymeml:inchi>InChI:HJJH</enzymeml:inchi> | ||
<enzymeml:smiles>[H]O[H]</enzymeml:smiles> | ||
<enzymeml:chebiID>CHEBI:09823</enzymeml:chebiID> | ||
</enzymeml:reactant> | ||
</annotation> | ||
</species> | ||
</listOfSpecies> | ||
<listOfReactions> | ||
<annotation> | ||
<enzymeml:data xmlns:enzymeml="http://sbml.org/enzymeml/version2"> | ||
<enzymeml:formats> | ||
<enzymeml:format id="format0"> | ||
<enzymeml:column type="time" unit="u4" index="0"/> | ||
<enzymeml:column replica="repl_p0_0" species="p0" type="conc" unit="u1" index="1" isCalculated="False"/> | ||
<enzymeml:column replica="repl_s0_0" species="s0" type="conc" unit="u1" index="2" isCalculated="False"/> | ||
</enzymeml:format> | ||
</enzymeml:formats> | ||
<enzymeml:listOfMeasurements> | ||
<enzymeml:measurement file="file0" id="m0" name="SomeMeasurement" temperature_unit="u2" temperature_value="4.0" ph="7.0"> | ||
<enzymeml:initConc protein="p0" value="10.0" unit="u1"/> | ||
<enzymeml:initConc reactant="s0" value="10.0" unit="u1"/> | ||
</enzymeml:measurement> | ||
</enzymeml:listOfMeasurements> | ||
<enzymeml:files> | ||
<enzymeml:file file="./data/m0.csv" format="format0" id="file0"/> | ||
</enzymeml:files> | ||
</enzymeml:data> | ||
</annotation> | ||
<reaction metaid="METAID_R0" sboTerm="SBO:0000176" id="r0" name="string" reversible="true"> | ||
<annotation> | ||
<enzymeml:reaction xmlns:enzymeml="http://sbml.org/enzymeml/version2"> | ||
<enzymeml:conditions> | ||
<enzymeml:temperature value="200.0" unit="u2"/> | ||
<enzymeml:ph value="7.0"/> | ||
</enzymeml:conditions> | ||
</enzymeml:reaction> | ||
</annotation> | ||
<listOfReactants> | ||
<speciesReference sboTerm="SBO:0000015" species="s0" stoichiometry="1" constant="false"/> | ||
</listOfReactants> | ||
<listOfProducts> | ||
<speciesReference sboTerm="SBO:0000011" species="s1" stoichiometry="1" constant="false"/> | ||
</listOfProducts> | ||
<listOfModifiers> | ||
<modifierSpeciesReference sboTerm="SBO:0000013" species="p0"/> | ||
</listOfModifiers> | ||
<kineticLaw name="Menten"> | ||
<math xmlns="http://www.w3.org/1998/Math/MathML"> | ||
<apply> | ||
<times/> | ||
<ci> s0 </ci> | ||
<ci> x </ci> | ||
</apply> | ||
</math> | ||
<listOfLocalParameters> | ||
<localParameter id="x" value="10" units="u3"> | ||
<annotation> | ||
<enzymeml:parameter xmlns:enzymeml="http://sbml.org/enzymeml/version2"> | ||
<enzymeml:initialValue>10.0</enzymeml:initialValue> | ||
<enzymeml:stdev>0.1</enzymeml:stdev> | ||
</enzymeml:parameter> | ||
</annotation> | ||
</localParameter> | ||
</listOfLocalParameters> | ||
</kineticLaw> | ||
</reaction> | ||
</listOfReactions> | ||
</model> | ||
</sbml> |