Skip to content

Commit

Permalink
fix: fixed working directories of temporary files
Browse files Browse the repository at this point in the history
  • Loading branch information
jonrkarr committed Jan 3, 2022
1 parent 296ffcf commit 326ffaa
Show file tree
Hide file tree
Showing 12 changed files with 1,078 additions and 2 deletions.
3 changes: 2 additions & 1 deletion biosimulators_opencor/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,15 @@ def exec_sed_task(task, variables, preprocessed_task=None, log=None, config=None
error_summary='Changes for model `{}` are not supported.'.format(task.model.id))

model_etree = preprocessed_task['model_etree']
working_dir = os.path.dirname(task.model.source)

model = copy.deepcopy(task.model)
for change in model.changes:
change.new_value = str(change.new_value)

apply_changes_to_xml_model(model, model_etree, sed_doc=None, working_dir=None)

model_file, model_filename = tempfile.mkstemp(suffix='.xml')
model_file, model_filename = tempfile.mkstemp(suffix='.xml', dir=working_dir)
os.close(model_file)

model_etree.write(model_filename,
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
biosimulators_utils[cellml,logging] >= 0.1.151
biosimulators_utils[cellml,logging] >= 0.1.155
kisao >= 2.28
lxml
numpy
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<?xml version='1.0'?>
<!-- This CellML file was generated from:
Weinstein, Alan M. "A mathematical model of the outer medullary collecting duct of the rat." American Journal of Physiology-Renal Physiology 279.1 (2000): F24-F45.
The results are compared with Figure 6 in:
Chang, Hangil, and Toshiro Fujita. "A numerical model of acid-base transport in rat distal tubule." American Journal of Physiology-Renal Physiology 281.2 (2001): F222-F243.-->
<model cmeta:id="Weinstein_2000_HATPase" name="Weinstein_2000_HATPase" xmlns="http://www.cellml.org/cellml/1.1#" xmlns:cellml="http://www.cellml.org/cellml/1.1#" xmlns:cmeta="http://www.cellml.org/metadata/1.0#" xmlns:xlink="http://www.w3.org/1999/xlink">
<import xlink:href="Units/Units.cellml">
<units name="mM" units_ref="mM"/>
<units name="per_s" units_ref="per_s"/>
<units name="mV" units_ref="mV"/>
<units name="umol_per_s_per_cm2" units_ref="umol_per_s_per_cm2"/>
</import>
<import xlink:href="subdir/subdir/Weinstein_2000_HATPase.cellml">
<component component_ref="H_ATPase" name="H_ATPase"/>
</import>
<component name="environment">
<variable name="time" public_interface="out" units="second"/>
</component>
<component name="concentrations">
<variable name="time" public_interface="in" units="second"/>
<variable name="H_int" public_interface="out" units="mM"/>
<variable name="H_ext" public_interface="out" units="mM"/>
<variable initial_value="-30.0" name="psi_int" units="mV"/>
<variable initial_value="0.0" name="psi_ext" units="mV"/>
<variable name="psi" public_interface="out" units="mV"/>
<variable initial_value="7.5" name="pH_int" units="dimensionless"/>
<variable initial_value="4.0" name="pH_ext" units="dimensionless"/>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply>
<eq/>
<ci>psi</ci>
<apply>
<minus/>
<ci>psi_ext</ci>
<ci>psi_int</ci>
</apply>
</apply>
<apply>
<eq/>
<ci>H_int</ci>
<apply>
<times/>
<cn cellml:units="mM" type="e-notation">1<sep/>3</cn>
<apply>
<power/>
<cn cellml:units="dimensionless">10</cn>
<apply>
<minus/>
<ci>pH_int</ci>
</apply>
</apply>
</apply>
</apply>
<apply>
<eq/>
<ci>H_ext</ci>
<apply>
<times/>
<cn cellml:units="mM" type="e-notation">1<sep/>3</cn>
<apply>
<power/>
<cn cellml:units="dimensionless">10</cn>
<apply>
<minus/>
<ci>pH_ext</ci>
</apply>
</apply>
</apply>
</apply>
<apply>
<eq/>
<apply>
<diff/>
<bvar>
<ci>time</ci>
</bvar>
<ci>pH_int</ci>
</apply>
<cn cellml:units="per_s">0.0</cn>
</apply>
<apply>
<eq/>
<apply>
<diff/>
<bvar>
<ci>time</ci>
</bvar>
<ci>pH_ext</ci>
</apply>
<cn cellml:units="per_s">0.1</cn>
</apply>
</math>
</component>
<component name="fluxes">
<variable name="J_Vtype_H_Max" public_interface="in" units="umol_per_s_per_cm2"/>
<variable name="J_Vtype_H" public_interface="in" units="umol_per_s_per_cm2"/>
<variable name="plot" units="dimensionless"/>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply>
<eq/>
<ci>plot</ci>
<apply>
<divide/>
<ci>J_Vtype_H</ci>
<ci>J_Vtype_H_Max</ci>
</apply>
</apply>
</math>
</component>
<connection>
<map_components component_1="concentrations" component_2="H_ATPase"/>
<map_variables variable_1="H_int" variable_2="H_int"/>
<map_variables variable_1="H_ext" variable_2="H_ext"/>
<map_variables variable_1="psi" variable_2="psi"/>
</connection>
<connection>
<map_components component_1="fluxes" component_2="H_ATPase"/>
<map_variables variable_1="J_Vtype_H" variable_2="J_Vtype_H"/>
<map_variables variable_1="J_Vtype_H_Max" variable_2="J_Vtype_H_Max"/>
</connection>
<connection>
<map_components component_1="concentrations" component_2="environment"/>
<map_variables variable_1="time" variable_2="time"/>
</connection>
</model>
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?xml version='1.0'?>
<model name="Units" xmlns="http://www.cellml.org/cellml/1.0#" xmlns:cellml="http://www.cellml.org/cellml/1.0#">
<units name="cm">
<unit prefix="centi" units="metre"/>
</units>
<units name="cm2">
<unit exponent="2" prefix="centi" units="metre"/>
</units>
<units name="cm3">
<unit exponent="3" prefix="centi" units="metre"/>
</units>
<units name="mmol">
<unit prefix="milli" units="mole"/>
</units>
<units name="umol">
<unit prefix="micro" units="mole"/>
</units>
<units name="M">
<unit units="mole"/>
<unit exponent="-1" units="litre"/>
</units>
<units name="mM">
<unit prefix="milli" units="mole"/>
<unit exponent="-1" units="litre"/>
</units>
<units name="mM_per_s">
<unit units="mM"/>
<unit exponent="-1" units="second"/>
</units>
<units name="per_s">
<unit exponent="-1" units="second"/>
</units>
<units name="umol_per_s_per_cm2">
<unit units="umol"/>
<unit exponent="-1" units="second"/>
<unit exponent="-1" units="cm2"/>
</units>
<units name="mmol_per_cm2">
<unit prefix="milli" units="mole"/>
<unit exponent="-1" units="cm2"/>
</units>
<units name="mmHg">
<unit multiplier="133.32" units="pascal"/>
</units>
<units name="mM_per_mmHg">
<unit units="mM"/>
<unit exponent="-1" units="mmHg"/>
</units>
<units name="cm_per_s">
<unit prefix="centi" units="metre"/>
<unit exponent="-1" units="second"/>
</units>
<units name="mV">
<unit prefix="milli" units="volt"/>
</units>
<units name="mV_per_s">
<unit prefix="milli" units="volt"/>
<unit exponent="-1" units="second"/>
</units>
<units name="mJ_per_mol_per_kelvin">
<unit prefix="milli" units="joule"/>
<unit exponent="-1" units="mole"/>
<unit exponent="-1" units="kelvin"/>
</units>
<units name="C_per_mol">
<unit units="coulomb"/>
<unit exponent="-1" units="mole"/>
</units>
<units name="mS_per_cm2">
<unit prefix="milli" units="siemens"/>
<unit exponent="-2" prefix="centi" units="metre"/>
</units>
<units name="mA_per_cm2">
<unit prefix="milli" units="ampere"/>
<unit exponent="-1" units="cm2"/>
</units>
<units name="mJ_per_mol">
<unit units="joule"/>
<unit exponent="-1" prefix="milli" units="mole"/>
</units>
<units name="mol_per_mJ">
<unit prefix="milli" units="mole"/>
<unit exponent="-1" units="joule"/>
</units>
</model>
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<?xml version='1.0'?>
<!-- This CellML file was generated from:
Weinstein, Alan M. "A mathematical model of the outer medullary collecting duct of the rat." American Journal of Physiology-Renal Physiology 279.1 (2000): F24-F45.
The results are compared with Figure 6 in:
Chang, Hangil, and Toshiro Fujita. "A numerical model of acid-base transport in rat distal tubule." American Journal of Physiology-Renal Physiology 281.2 (2001): F222-F243.
If J_Vtype_H>0 then the flux direction is from intracellular space to extracellular space. (always [C_int]-J and [C_ext]+J)-->
<model cmeta:id="Weinstein_2000_HATPase" name="Weinstein_2000_HATPase" xmlns="http://www.cellml.org/cellml/1.1#" xmlns:cellml="http://www.cellml.org/cellml/1.1#" xmlns:cmeta="http://www.cellml.org/metadata/1.0#" xmlns:xlink="http://www.w3.org/1999/xlink">
<import xlink:href="../../Units/Units.cellml">
<units name="mJ_per_mol" units_ref="mJ_per_mol"/>
<units name="mol_per_mJ" units_ref="mol_per_mJ"/>
<units name="mV" units_ref="mV"/>
<units name="mM" units_ref="mM"/>
<units name="C_per_mol" units_ref="C_per_mol"/>
<units name="mJ_per_mol_per_kelvin" units_ref="mJ_per_mol_per_kelvin"/>
<units name="umol_per_s_per_cm2" units_ref="umol_per_s_per_cm2"/>
</import>
<component name="H_ATPase">
<variable name="psi" public_interface="in" units="mV"/>
<variable name="H_int" public_interface="in" units="mM"/>
<variable name="H_ext" public_interface="in" units="mM"/>
<variable name="mu_H" units="mJ_per_mol"/>
<variable initial_value="2.1e-6" name="mu_0" units="mJ_per_mol"/>
<variable initial_value="0.4e-6" name="xi" units="mol_per_mJ"/>
<variable initial_value="96485" name="F" units="C_per_mol"/>
<variable initial_value="8314.41" name="R" units="mJ_per_mol_per_kelvin"/>
<variable initial_value="300" name="T" units="kelvin"/>
<variable initial_value="-1.57" name="z" units="dimensionless"/>
<variable initial_value="0.0018" name="J_Vtype_H_Max" public_interface="out" units="umol_per_s_per_cm2"/>
<variable name="J_Vtype_H" public_interface="out" units="umol_per_s_per_cm2"/>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply id="electrochemical_potential_difference_calculation">
<eq/>
<ci>mu_H</ci>
<apply>
<plus/>
<apply>
<times/>
<ci>R</ci>
<ci>T</ci>
<apply>
<ln/>
<apply>
<divide/>
<ci>H_ext</ci>
<ci>H_int</ci>
</apply>
</apply>
</apply>
<apply>
<times/>
<ci>z</ci>
<ci>F</ci>
<ci>psi</ci>
</apply>
</apply>
</apply>
<apply id="H_flux">
<eq/>
<ci>J_Vtype_H</ci>
<apply>
<divide/>
<ci>J_Vtype_H_Max</ci>
<apply>
<plus/>
<cn cellml:units="dimensionless">1</cn>
<apply>
<exp/>
<apply>
<times/>
<ci>xi</ci>
<apply>
<minus/>
<ci>mu_H</ci>
<ci>mu_0</ci>
</apply>
</apply>
</apply>
</apply>
</apply>
</apply>
</math>
</component>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rdf:about="">
<dc:title xmlns:dc="http://purl.org/dc/elements/1.1/">A kinetic model of V-type H+-ATPase (proton pump)</dc:title>
</rdf:Description>
<rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rdf:about="#Weinstein_2000_HATPase">
<bqs:reference xmlns:bqs="http://www.cellml.org/bqs/1.0#" rdf:parseType="Resource" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<dc:subject xmlns:dc="http://purl.org/dc/elements/1.1/" rdf:parseType="Resource" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<bqs:subject_type xmlns:bqs="http://www.cellml.org/bqs/1.0#">keyword</bqs:subject_type>
<rdf:value xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Bag xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:li xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">protein module</rdf:li>
</rdf:Bag>
</rdf:value>
</dc:subject>
</bqs:reference>
</rdf:Description>
</rdf:RDF>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rdf:about="">
<dc:title xmlns:dc="http://purl.org/dc/elements/1.1/">A kinetic model of V-type H+-ATPase (proton pump)</dc:title>
</rdf:Description>
<rdf:Description xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" rdf:about="#Weinstein_2000_HATPase">
<bqs:reference xmlns:bqs="http://www.cellml.org/bqs/1.0#" rdf:parseType="Resource" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<dc:subject xmlns:dc="http://purl.org/dc/elements/1.1/" rdf:parseType="Resource" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<bqs:subject_type xmlns:bqs="http://www.cellml.org/bqs/1.0#">keyword</bqs:subject_type>
<rdf:value xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Bag xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:li xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">protein module</rdf:li>
</rdf:Bag>
</rdf:value>
</dc:subject>
</bqs:reference>
</rdf:Description>
</rdf:RDF>
</model>
Loading

0 comments on commit 326ffaa

Please sign in to comment.