From 92f1ceaedb804b3643042d6130c2c9284a2fc2d6 Mon Sep 17 00:00:00 2001 From: Lucian Smith Date: Wed, 9 Oct 2024 14:52:21 -0700 Subject: [PATCH 01/12] Allow the return of combined IDs for multi-id xpaths. This is so that an xpath for an SBML local parameter like /sbml:sbml/sbml:model/sbml:listOfReactions/sbml:reaction[@id='J0']/sbml:kineticLaw/sbml:listOfParameters/sbml:parameter[@id='n'] can return J0.n or J0_n instead of just 'n'. Backwards-compatible, so that existing code doesn't break. --- biosimulators_utils/sedml/validation.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/biosimulators_utils/sedml/validation.py b/biosimulators_utils/sedml/validation.py index fdb4a5ce..11a0619b 100644 --- a/biosimulators_utils/sedml/validation.py +++ b/biosimulators_utils/sedml/validation.py @@ -1715,7 +1715,7 @@ def validate_target(target, namespaces, context, language, model_id, model_etree return errors, warnings -def validate_target_xpaths(targets, model_etree, attr='id'): +def validate_target_xpaths(targets, model_etree, attr='id', separator=None): """ Validate that the target of each model change or variable matches one object in an XML-encoded model and, optionally, return the value of one of its attributes @@ -1736,6 +1736,17 @@ def validate_target_xpaths(targets, model_etree, attr='id'): x_path, _, _ = x_path.rpartition('/@') x_path_attrs[target.target] = validate_xpaths_ref_to_unique_objects( model_etree, [x_path], target.target_namespaces, attr=attr)[x_path] + if separator is None: + return x_path_attrs + for xpath in x_path_attrs: + xpath_list = xpath.split("@" + attr + "=") + if len(xpath_list) < 3: + continue + combined_id = "" + for i in range(1, len(xpath_list)-1): + combined_id = combined_id + xpath_list[i].split(']')[0][1:-1] + separator + x_path_attrs[xpath] = combined_id + x_path_attrs[xpath] + return x_path_attrs From ecf76e3e0964deffb826f43fa7ba808f8b4bc429 Mon Sep 17 00:00:00 2001 From: Lucian Smith Date: Wed, 9 Oct 2024 14:56:39 -0700 Subject: [PATCH 02/12] Fix lint. --- biosimulators_utils/sedml/validation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/biosimulators_utils/sedml/validation.py b/biosimulators_utils/sedml/validation.py index 11a0619b..376b706e 100644 --- a/biosimulators_utils/sedml/validation.py +++ b/biosimulators_utils/sedml/validation.py @@ -1746,7 +1746,7 @@ def validate_target_xpaths(targets, model_etree, attr='id', separator=None): for i in range(1, len(xpath_list)-1): combined_id = combined_id + xpath_list[i].split(']')[0][1:-1] + separator x_path_attrs[xpath] = combined_id + x_path_attrs[xpath] - + return x_path_attrs From 5036dfe6ae0c837a16570a34b4edf8aa813728aa Mon Sep 17 00:00:00 2001 From: Lucian Smith Date: Wed, 9 Oct 2024 15:58:01 -0700 Subject: [PATCH 03/12] Add test. --- tests/fixtures/BIOMD0000000010_url.xml | 704 +++++++++++++++++++++++++ tests/sedml/test_sedml_validation.py | 23 + 2 files changed, 727 insertions(+) create mode 100644 tests/fixtures/BIOMD0000000010_url.xml diff --git a/tests/fixtures/BIOMD0000000010_url.xml b/tests/fixtures/BIOMD0000000010_url.xml new file mode 100644 index 00000000..ad4e4c2a --- /dev/null +++ b/tests/fixtures/BIOMD0000000010_url.xml @@ -0,0 +1,704 @@ + + + + + +
Kholodenko2000 - Ultrasensitivity and negative feedback bring oscillations in MAPK cascade
+
+

The combination of ultrasensitivity and negative feedback bring sustained oscillations in the mitogen-activated protein kinase cascades.

+
+
+

This model is described in the article:

+ +
Kholodenko BN
+
Eur. J. Biochem. 2000; 267(6):1583-8
+

Abstract:

+
+

Functional organization of signal transduction into protein phosphorylation cascades, such as the mitogen-activated protein kinase (MAPK) cascades, greatly enhances the sensitivity of cellular targets to external stimuli. The sensitivity increases multiplicatively with the number of cascade levels, so that a tiny change in a stimulus results in a large change in the response, the phenomenon referred to as ultrasensitivity. In a variety of cell types, the MAPK cascades are imbedded in long feedback loops, positive or negative, depending on whether the terminal kinase stimulates or inhibits the activation of the initial level. Here we demonstrate that a negative feedback loop combined with intrinsic ultrasensitivity of the MAPK cascade can bring about sustained oscillations in MAPK phosphorylation. Based on recent kinetic data on the MAPK cascades, we predict that the period of oscillations can range from minutes to hours. The phosphorylation level can vary between the base level and almost 100% of the total protein. The oscillations of the phosphorylation cascades and slow protein diffusion in the cytoplasm can lead to intracellular waves of phospho-proteins.

+
+
+
+

This model is hosted on BioModels Database + and identified by: BIOMD0000000010 + .

+

To cite BioModels Database, please use: BioModels Database: An enhanced, curated and annotated resource for published quantitative kinetic models + .

+
+
+

To the extent possible under law, all copyright and related or neighbouring rights to this encoded model have been dedicated to the public domain worldwide. Please refer to CC0 Public Domain Dedication + for more information.

+
+ +
+ + + + + + + + Sauro + Herbert + + Herbert_Sauro@kgi.edu + + Keck Graduate Institute + + + + + + 2005-02-12T00:18:12Z + + + 2015-06-02T12:04:33Z + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + uVol + V1 + MKKK + + + + + + 1 + + + + + MAPK_PP + Ki + + n + + + + + K1 + MKKK + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + uVol + V2 + MKKK_P + + + + KK2 + MKKK_P + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + uVol + k3 + MKKK_P + MKK + + + + KK3 + MKK + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + uVol + k4 + MKKK_P + MKK_P + + + + KK4 + MKK_P + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + uVol + V5 + MKK_PP + + + + KK5 + MKK_PP + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + uVol + V6 + MKK_P + + + + KK6 + MKK_P + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + uVol + k7 + MKK_PP + MAPK + + + + KK7 + MAPK + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + uVol + k8 + MKK_PP + MAPK_P + + + + KK8 + MAPK_P + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + uVol + V9 + MAPK_PP + + + + KK9 + MAPK_PP + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + uVol + V10 + MAPK_P + + + + KK10 + MAPK_P + + + + + + + + + + +
+
diff --git a/tests/sedml/test_sedml_validation.py b/tests/sedml/test_sedml_validation.py index 1eef9617..9a3b7892 100644 --- a/tests/sedml/test_sedml_validation.py +++ b/tests/sedml/test_sedml_validation.py @@ -1318,6 +1318,29 @@ def test_validate_target_xpaths(self): with self.assertRaises(ValueError): validation.validate_target_xpaths(variables, model_etree) + def test_validate_target_xpaths_separator(self): + namespaces = {'sbml': 'http://www.sbml.org/sbml/level2/version4'} + + model_source = os.path.join(os.path.dirname(__file__), '..', 'fixtures', 'BIOMD0000000010_url.xml') + model_etree = etree.parse(model_source) + + variables = [ + data_model.Variable(target_namespaces=namespaces, + target="/sbml:sbml/sbml:model/sbml:listOfReactions/sbml:reaction[@id='J0']"), + data_model.Variable(target_namespaces=namespaces, + target="/sbml:sbml/sbml:model/sbml:listOfReactions/sbml:reaction[@id='J0']/sbml:kineticLaw/sbml:listOfParameters/sbml:parameter[@id='n']"), + ] + + + idmap = validation.validate_target_xpaths(variables, model_etree, attr='id', separator="_") + idmap_expect = { + "/sbml:sbml/sbml:model/sbml:listOfReactions/sbml:reaction[@id='J0']": 'J0', + "/sbml:sbml/sbml:model/sbml:listOfReactions/sbml:reaction[@id='J0']/sbml:kineticLaw/sbml:listOfParameters/sbml:parameter[@id='n']": 'J0_n', + } + + self.assertEqual(idmap, idmap_expect) + + def test_validate_target(self): self.assertEqual(validation.validate_target('/sbml:sbml/sbml:model', {'sbml': 'sbml'}, From 87ef0e070978e336cc2bf2dab0d8d70be8cc0a32 Mon Sep 17 00:00:00 2001 From: Lucian Smith Date: Wed, 9 Oct 2024 16:12:38 -0700 Subject: [PATCH 04/12] Combine new test into old test. No good reason to do this; the problem was that we failed the 'sonarcloud' check because the namespace had http instead of https. Sigh. --- tests/sedml/test_sedml_validation.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/sedml/test_sedml_validation.py b/tests/sedml/test_sedml_validation.py index 9a3b7892..3ef4c4b1 100644 --- a/tests/sedml/test_sedml_validation.py +++ b/tests/sedml/test_sedml_validation.py @@ -1318,9 +1318,7 @@ def test_validate_target_xpaths(self): with self.assertRaises(ValueError): validation.validate_target_xpaths(variables, model_etree) - def test_validate_target_xpaths_separator(self): - namespaces = {'sbml': 'http://www.sbml.org/sbml/level2/version4'} - + #Test the 'separator' argument of validate_target_xpaths model_source = os.path.join(os.path.dirname(__file__), '..', 'fixtures', 'BIOMD0000000010_url.xml') model_etree = etree.parse(model_source) From 43e2b7f3a11794b5e325052ba38d182469536322 Mon Sep 17 00:00:00 2001 From: Lucian Smith Date: Wed, 9 Oct 2024 16:25:20 -0700 Subject: [PATCH 05/12] Document new argument. --- biosimulators_utils/sedml/validation.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/biosimulators_utils/sedml/validation.py b/biosimulators_utils/sedml/validation.py index 376b706e..f48ee8cc 100644 --- a/biosimulators_utils/sedml/validation.py +++ b/biosimulators_utils/sedml/validation.py @@ -1717,12 +1717,13 @@ def validate_target(target, namespaces, context, language, model_id, model_etree def validate_target_xpaths(targets, model_etree, attr='id', separator=None): """ Validate that the target of each model change or variable matches one object in - an XML-encoded model and, optionally, return the value of one of its attributes + an XML-encoded model and, optionally, return the value of one of its attributes. Args: targets (:obj:`list` of :obj:`TargetGroupMixin`): model changes or variables model_source (:obj:`lxml.etree._ElementTree`): element tree for the XML model document attr (:obj:`str`, optional): attribute to get values of + separator (:obj:`str`, optional): string to use when combining attributes into a single id (i.e. 'J0.n' from 'J0' and 'n'.) If None, don't combine and just use final id. Returns: :obj:`dict` of :obj:`str` to :obj:`str`: dictionary that maps each XPath to the From 63aac31d799188c4c83e4759caa5b182281f0174 Mon Sep 17 00:00:00 2001 From: Lucian Smith Date: Wed, 9 Oct 2024 16:29:45 -0700 Subject: [PATCH 06/12] Fix lint. --- biosimulators_utils/sedml/validation.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/biosimulators_utils/sedml/validation.py b/biosimulators_utils/sedml/validation.py index f48ee8cc..4c851677 100644 --- a/biosimulators_utils/sedml/validation.py +++ b/biosimulators_utils/sedml/validation.py @@ -1723,7 +1723,8 @@ def validate_target_xpaths(targets, model_etree, attr='id', separator=None): targets (:obj:`list` of :obj:`TargetGroupMixin`): model changes or variables model_source (:obj:`lxml.etree._ElementTree`): element tree for the XML model document attr (:obj:`str`, optional): attribute to get values of - separator (:obj:`str`, optional): string to use when combining attributes into a single id (i.e. 'J0.n' from 'J0' and 'n'.) If None, don't combine and just use final id. + separator (:obj:`str`, optional): string to use when combining attributes into a single id + (i.e. 'J0.n' from 'J0' and 'n'.) If None, don't combine and just use final id. Returns: :obj:`dict` of :obj:`str` to :obj:`str`: dictionary that maps each XPath to the From 2ce1fb571e2a49218e2974f674af1c91effef818 Mon Sep 17 00:00:00 2001 From: Lucian Smith Date: Wed, 9 Oct 2024 16:42:53 -0700 Subject: [PATCH 07/12] Fix lint. --- biosimulators_utils/sedml/validation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/biosimulators_utils/sedml/validation.py b/biosimulators_utils/sedml/validation.py index 4c851677..7f5b8ba8 100644 --- a/biosimulators_utils/sedml/validation.py +++ b/biosimulators_utils/sedml/validation.py @@ -1723,7 +1723,7 @@ def validate_target_xpaths(targets, model_etree, attr='id', separator=None): targets (:obj:`list` of :obj:`TargetGroupMixin`): model changes or variables model_source (:obj:`lxml.etree._ElementTree`): element tree for the XML model document attr (:obj:`str`, optional): attribute to get values of - separator (:obj:`str`, optional): string to use when combining attributes into a single id + separator (:obj:`str`, optional): string to use when combining attributes into a single id (i.e. 'J0.n' from 'J0' and 'n'.) If None, don't combine and just use final id. Returns: From c304a7a334a231939fb49e0f25b70b20f12dcaa1 Mon Sep 17 00:00:00 2001 From: Lucian Smith Date: Wed, 9 Oct 2024 16:59:09 -0700 Subject: [PATCH 08/12] Update workflow to newer actions. Old versions were being deprecated. --- .github/workflows/ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3441b97a..3280b765 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,7 +38,7 @@ jobs: fetch-depth: 1 - name: Install Java # for pyNeuroML - uses: actions/setup-java@v2 + uses: actions/setup-java@v4 with: distribution: 'adopt' java-version: '15' @@ -53,7 +53,7 @@ jobs: sudo apt-get install -y --no-install-recommends wget make gcc libx11-dev libc6-dev xppaut - name: Install Singularity # to validate that the Docker image can be converted into a Singularity image - uses: eWaterCycle/setup-singularity@v5 + uses: eWaterCycle/setup-singularity@v7 with: singularity-version: 3.7.1 @@ -67,7 +67,7 @@ jobs: run: poetry run python -m flake8 - name: Run the tests - uses: GabrielBB/xvfb-action@v1 + uses: coactions/setup-xvfb@v1 env: MPLBACKEND: PDF # BIOSIMULATORS_API_ENDPOINT: https://api.biosimulators.dev/ # uncomment to execute tests with the dev deployment @@ -75,7 +75,7 @@ jobs: run: poetry run python -m pytest tests/ --cov=./biosimulators_utils --cov-report=xml - name: Upload the coverage report to Codecov - uses: codecov/codecov-action@v2 + uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} flags: unittests From 8209f4b081753ce70fcc53bcbaaa5beb05e625b9 Mon Sep 17 00:00:00 2001 From: Lucian Smith Date: Thu, 10 Oct 2024 10:57:35 -0700 Subject: [PATCH 09/12] Update version number. --- biosimulators_utils/_version.py | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/biosimulators_utils/_version.py b/biosimulators_utils/_version.py index 020ed73d..d93b5b24 100644 --- a/biosimulators_utils/_version.py +++ b/biosimulators_utils/_version.py @@ -1 +1 @@ -__version__ = '0.2.2' +__version__ = '0.2.3' diff --git a/pyproject.toml b/pyproject.toml index 41856c18..30823271 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "biosimulators-utils" -version = "0.2.2" +version = "0.2.3" description = "description" license = "MIT" authors = ["Center for Reproducible Biomedical Modeling "] From a17b17734e093c0720f2475c867f4a617ea59548 Mon Sep 17 00:00:00 2001 From: Lucian Smith Date: Thu, 10 Oct 2024 11:10:43 -0700 Subject: [PATCH 10/12] Update java version? --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3280b765..2edb5117 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: uses: actions/setup-java@v4 with: distribution: 'adopt' - java-version: '15' + java-version: '16' - name: Install Perl # for BioNetGen run: | From 3a6702f513fe0f5c8cecddecf35bc4af89785cd0 Mon Sep 17 00:00:00 2001 From: Lucian Smith Date: Thu, 10 Oct 2024 11:12:03 -0700 Subject: [PATCH 11/12] Java -> v20? --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2edb5117..927b1a01 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,7 +41,7 @@ jobs: uses: actions/setup-java@v4 with: distribution: 'adopt' - java-version: '16' + java-version: '20' - name: Install Perl # for BioNetGen run: | From fb037c3afd7bf1d9501bea6da8939cabd8089efd Mon Sep 17 00:00:00 2001 From: Lucian Smith Date: Thu, 10 Oct 2024 11:14:37 -0700 Subject: [PATCH 12/12] Try a different source? --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 927b1a01..e149c7f7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,8 +40,8 @@ jobs: - name: Install Java # for pyNeuroML uses: actions/setup-java@v4 with: - distribution: 'adopt' - java-version: '20' + distribution: 'temurin' + java-version: '21' - name: Install Perl # for BioNetGen run: |