Skip to content

Commit

Permalink
feat: improved XML namespace processing
Browse files Browse the repository at this point in the history
  • Loading branch information
jonrkarr committed Sep 18, 2021
1 parent c70ddce commit 2e8d9b3
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Base OS
FROM python:3.9-slim-buster

ARG VERSION="0.0.7"
ARG VERSION="0.0.8"
ARG SIMULATOR_VERSION=3.0.0b

# metadata
Expand Down
2 changes: 1 addition & 1 deletion biosimulators_ginsim/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.0.7'
__version__ = '0.0.8'
7 changes: 4 additions & 3 deletions biosimulators_ginsim/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from kisao.utils import get_preferred_substitute_algorithm_by_ids
from ginsim.gateway import japi as ginsim_japi
import biolqm # noqa: F401
import biosimulators_utils.model_lang.sbml.utils
import biosimulators_utils.sedml.validation
import biosimulators_utils.xml.utils
import lxml.etree # noqa: F401
Expand Down Expand Up @@ -111,14 +112,14 @@ def get_variable_target_xpath_ids(variables, model_etree):
corresponding qualitative species
"""
namespaces = biosimulators_utils.xml.utils.get_namespaces_for_xml_doc(model_etree)

sbml_qual_prefix, sbml_qual_uri = biosimulators_utils.model_lang.sbml.utils.get_package_namespace('qual', namespaces)
return biosimulators_utils.sedml.validation.validate_target_xpaths(
variables,
model_etree,
attr={
'namespace': {
'prefix': 'qual',
'uri': namespaces['qual'],
'prefix': sbml_qual_prefix,
'uri': sbml_qual_uri,
},
'name': 'id',
}
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[logging,sbml] >= 0.1.120
biosimulators_utils[logging,sbml] >= 0.1.122
ginsim >= 0.4.4
kisao >= 2.28
lxml
Expand Down
5 changes: 3 additions & 2 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ def test_validate_simulation(self):
def test_get_variable_target_xpath_ids(self):
with mock.patch('lxml.etree.parse', return_value=None):
with mock.patch('biosimulators_utils.xml.utils.get_namespaces_for_xml_doc', return_value={'qual': None}):
with mock.patch('biosimulators_utils.sedml.validation.validate_target_xpaths', return_value={'x': 'X'}):
self.assertEqual(get_variable_target_xpath_ids([Variable(target='x')], None), {'x': 'X'})
with mock.patch('biosimulators_utils.model_lang.sbml.utils.get_package_namespace', return_value=('qual', None)):
with mock.patch('biosimulators_utils.sedml.validation.validate_target_xpaths', return_value={'x': 'X'}):
self.assertEqual(get_variable_target_xpath_ids([Variable(target='x')], None), {'x': 'X'})

def test_read_model(self):
filename = os.path.join(os.path.dirname(__file__), 'fixtures', 'SuppMat_Model_Master_Model.zginml')
Expand Down

0 comments on commit 2e8d9b3

Please sign in to comment.