Skip to content

Commit

Permalink
added simple examples to test-ghactions.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
robertvi committed Nov 13, 2023
1 parent d30e57d commit c358b2f
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 2 deletions.
42 changes: 42 additions & 0 deletions examples/test_data/valid_doc.sbml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<sbml xmlns="http://www.sbml.org/sbml/level3/version1/core" level="3" version="1">
<model substanceUnits="mole" timeUnits="second" extentUnits="mole">
<listOfUnitDefinitions>
<unitDefinition id="per_second">
<listOfUnits>
<unit kind="second" exponent="-1" scale="0" multiplier="1"/>
</listOfUnits>
</unitDefinition>
</listOfUnitDefinitions>
<listOfCompartments>
<compartment id="c1" spatialDimensions="3" size="1" units="litre" constant="true"/>
</listOfCompartments>
<listOfSpecies>
<species id="S1" compartment="c1" initialAmount="5" substanceUnits="mole" hasOnlySubstanceUnits="false" boundaryCondition="false" constant="false"/>
<species id="S2" compartment="c1" initialAmount="0" substanceUnits="mole" hasOnlySubstanceUnits="false" boundaryCondition="false" constant="false"/>
</listOfSpecies>
<listOfParameters>
<parameter id="k" value="1" units="per_second" constant="true"/>
</listOfParameters>
<listOfReactions>
<reaction id="r1" reversible="false" fast="false">
<listOfReactants>
<speciesReference species="S1" constant="true"/>
</listOfReactants>
<listOfProducts>
<speciesReference species="S2" constant="true"/>
</listOfProducts>
<kineticLaw>
<math xmlns="http://www.w3.org/1998/Math/MathML">
<apply>
<times/>
<ci> k </ci>
<ci> S1 </ci>
<ci> c1 </ci>
</apply>
</math>
</kineticLaw>
</reaction>
</listOfReactions>
</model>
</sbml>
2 changes: 1 addition & 1 deletion pyneuroml/pynml.py
Original file line number Diff line number Diff line change
Expand Up @@ -2143,7 +2143,7 @@ def evaluate_arguments(args):
try:
result = validate_sbml_files(args.input_files, strict_units)
except Exception as e:
logger.critical(f"validate_sbml_files failed with {e.message}")
logger.critical(f"validate_sbml_files failed with {str(e)}")
sys.exit(UNKNOWN_ERR)

if result:
Expand Down
3 changes: 2 additions & 1 deletion pyneuroml/sbml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""

import os
import errno
import libsbml
from libsbml import SBMLReader
from typing import List
Expand All @@ -25,7 +26,7 @@ def validate_sbml_files(input_files: List[str], strict_units: bool = False) -> b
# These checks are already implemented by SBMLReader
# But could just be logged along with the other error types rather than causing exceptions
if not os.path.isfile(file_name):
raise FileNotFoundError(f"Could not find SBML file {file_name}")
raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), file_name)

if not os.access(file_name, os.R_OK):
raise IOError(f"Could not read SBML file {file_name}")
Expand Down
7 changes: 7 additions & 0 deletions test-ghactions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ pynml LEMS_NML2_Ex9_FN.xml -spineml
pynml LEMS_NML2_Ex9_FN.xml -sbml


echo
echo "################################################"
echo "## Simple SBML validation example"

pynml -validate-sbml test_data/valid_doc.sbml
pynml -validate-sbml-units test_data/valid_doc.sbml


echo
echo "################################################"
Expand Down

0 comments on commit c358b2f

Please sign in to comment.