From d326ce1e7fac2c7d7e33246633c09afd3ffe941d Mon Sep 17 00:00:00 2001 From: Bert Droesbeke Date: Thu, 12 Nov 2026 18:12:08 +0100 Subject: [PATCH 1/5] fix new attribute names --- MARS | 2 +- scripts/isa_generator.py | 46 +++++++++++++++---- scripts/prepare_poc_submission.py | 2 +- .../isa_jsons/1_after_biosamples.json | 6 +-- tests/test_isa_json.py | 5 +- 5 files changed, 42 insertions(+), 19 deletions(-) diff --git a/MARS b/MARS index 8de3731..8a76c0e 160000 --- a/MARS +++ b/MARS @@ -1 +1 @@ -Subproject commit 8de373195cd3e60a2f26b4d04e9df809ec834a44 +Subproject commit 8a76c0e72facc42295b107432e8bd628bf1227b8 diff --git a/scripts/isa_generator.py b/scripts/isa_generator.py index d2ab6e2..9711581 100644 --- a/scripts/isa_generator.py +++ b/scripts/isa_generator.py @@ -8,6 +8,17 @@ import hashlib from typing import Any +# Data-file comments for the attributes of ENA's FILE element, named like those +# attributes (as the MARS ENA adapter reads them), with the spellings that older +# ISA-JSON used. The older spellings are removed when a comment is set, so a template +# that still uses them does not end up with two conflicting values. +DATA_FILE_COMMENT_LEGACY_NAMES = { + "filename": ("file name", "file_name"), + "filetype": ("file type", "file_type"), + "checksum": ("file checksum",), + "checksum_method": ("checksum type",), +} + def _timestamp_suffix() -> str: """Unique suffix for this run (used for data file names).""" @@ -84,6 +95,19 @@ def _ensure_comment(comments: list[dict[str, Any]], name: str, value: str) -> No comments.append({"name": name, "value": value}) +def _set_data_file_comment( + comments: list[dict[str, Any]], name: str, value: str +) -> None: + """Set a data-file comment, dropping any comment under an older spelling.""" + legacy_names = DATA_FILE_COMMENT_LEGACY_NAMES[name] + comments[:] = [ + c + for c in comments + if not (isinstance(c, dict) and c.get("name") in legacy_names) + ] + _ensure_comment(comments, name, value) + + def _update_datafiles_with_generated_files( assays: list[dict[str, Any]], data_dir: Path, @@ -103,12 +127,13 @@ def _update_datafiles_with_generated_files( - Update the dataFiles entry: * "name" = new file name - * in "comments": - - "file name" -> new file name - - "file type" -> the preserved extension - - "file checksum" -> MD5 of the generated file + * in "comments", named like the attributes of ENA's FILE element: + - "filename" -> new file name + - "filetype" -> "fastq", or the preserved extension + - "checksum" -> MD5 of the generated file - "checksum_method" -> "MD5" - (existing "accession", "submission date", etc. are kept as-is) + (older spellings such as "file checksum" are removed; existing + "accession", "submission date", etc. are kept as-is) """ generated_paths: list[Path] = [] suffix = _timestamp_suffix() @@ -147,15 +172,15 @@ def _update_datafiles_with_generated_files( comments = [] df_json["comments"] = comments - _ensure_comment(comments, "file name", new_name) file_type = ( "fastq" if new_name.lower().endswith((".fastq.gz", ".fq.gz")) else Path(new_name).suffix.lstrip(".") or "data" ) - _ensure_comment(comments, "file type", file_type) - _ensure_comment(comments, "file checksum", md5) - _ensure_comment(comments, "checksum_method", "MD5") + _set_data_file_comment(comments, "filename", new_name) + _set_data_file_comment(comments, "filetype", file_type) + _set_data_file_comment(comments, "checksum", md5) + _set_data_file_comment(comments, "checksum_method", "MD5") generated_paths.append(file_path) updated_count += 1 @@ -176,7 +201,8 @@ def generate_investigation_with_data( 3. For each data file (or the first n_files when limited), generate UNIQUE files with preserved extensions and update: - dataFiles[i]["name"] - - dataFiles[i]["comments"] entries for file name, type, checksum, method. + - dataFiles[i]["comments"] filename, filetype, checksum and + checksum_method. 4. Write the resulting ISA-JSON to work_dir / 'isa.json'. We DO NOT change other identifiers or comments (including 'target_repository'). diff --git a/scripts/prepare_poc_submission.py b/scripts/prepare_poc_submission.py index 7a3d710..25a56f1 100644 --- a/scripts/prepare_poc_submission.py +++ b/scripts/prepare_poc_submission.py @@ -6,7 +6,7 @@ - Generate an ISA-JSON from each configured template, where: * dataFiles entries are updated to point to UNIQUE generated files while preserving their original extensions - * 'file name', 'file type', 'file checksum', 'checksum_method' + * 'filename', 'filetype', 'checksum', 'checksum_method' comments are updated accordingly (MD5 over the .fastq.gz) - Create poc_work/credentials.json from environment variables diff --git a/tests/fixtures/isa_jsons/1_after_biosamples.json b/tests/fixtures/isa_jsons/1_after_biosamples.json index 0c87b44..f0ecd79 100644 --- a/tests/fixtures/isa_jsons/1_after_biosamples.json +++ b/tests/fixtures/isa_jsons/1_after_biosamples.json @@ -89,15 +89,15 @@ { "comments": [ { - "name": "file name", + "name": "filename", "value": "ENA_TEST2.R2.fastq.gz" }, { - "name": "file type", + "name": "filetype", "value": "fastq" }, { - "name": "file checksum", + "name": "checksum", "value": "69c903251902c1e0b75331f70e531012" }, { diff --git a/tests/test_isa_json.py b/tests/test_isa_json.py index f19b459..3f11c8c 100644 --- a/tests/test_isa_json.py +++ b/tests/test_isa_json.py @@ -40,10 +40,7 @@ HOLOFOOD_ISA = "MARS/test-data/HoloFoodinISA_v1.0.json" # Every sampling step is split over two linked processes: one with only the source as # input, and one with only the sample as output -PTX_ISA = ( - "MARS/test-data/ISA-PTX-TEST/isajson/" - "i_investigation_PTX_Pilot_Daphnia_magna_valid.json" -) +PTX_ISA = "MARS/test-data/i_investigation_PTX_Pilot_Daphnia_magna_valid.json" def _multi_repository_investigation(): From e216c912a7404605907d71fc8636781e2e13af90 Mon Sep 17 00:00:00 2001 From: Bert Droesbeke Date: Thu, 12 Nov 2026 18:14:11 +0100 Subject: [PATCH 2/5] add PTX to integration test --- .../multi-omics-submission-test.yaml | 13 ++++++++++ scripts/prepare_poc_submission.py | 25 +++++++++++++------ 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/.github/workflows/multi-omics-submission-test.yaml b/.github/workflows/multi-omics-submission-test.yaml index 8bd9cb1..c1b2df2 100644 --- a/.github/workflows/multi-omics-submission-test.yaml +++ b/.github/workflows/multi-omics-submission-test.yaml @@ -17,6 +17,7 @@ jobs: REPOSITORY_SERVICES_PATH: ${{ github.workspace }}/MARS/repository-services ISA_TEMPLATE_PATH: ${{ github.workspace }}/MARS/test-data/ena-complete.json HOLOFOOD_ISA_TEMPLATE_PATH: ${{ github.workspace }}/MARS/test-data/HoloFoodinISA_v1.0.json + PTX_ISA_TEMPLATE_PATH: ${{ github.workspace }}/MARS/test-data/i_investigation_PTX_Pilot_Daphnia_magna_valid.json # Credentials from GitHub secrets WEBIN_USERNAME: ${{ secrets.WEBIN_USERNAME }} @@ -100,6 +101,18 @@ jobs: --credentials-file ./poc_work/credentials.json \ poc_work/holofood/isa.json + - name: Submit PTX ISA JSON + run: | + set -euo pipefail + + mars-cli --development submit \ + --submit-to-metabolights False \ + --file-transfer ftp \ + --output "output_ptx_${{ github.run_id }}_${{ github.run_attempt }}" \ + --data-folder poc_work/ptx/data \ + --credentials-file ./poc_work/credentials.json \ + poc_work/ptx/isa.json + - name: Collect repository-service logs if: always() working-directory: ${{ env.REPOSITORY_SERVICES_PATH }} diff --git a/scripts/prepare_poc_submission.py b/scripts/prepare_poc_submission.py index 25a56f1..321fdac 100644 --- a/scripts/prepare_poc_submission.py +++ b/scripts/prepare_poc_submission.py @@ -10,8 +10,8 @@ comments are updated accordingly (MD5 over the .fastq.gz) - Create poc_work/credentials.json from environment variables -Set ``HOLOFOOD_ISA_TEMPLATE_PATH`` to prepare the additional HoloFood -submission alongside ``ISA_TEMPLATE_PATH``. +Set ``HOLOFOOD_ISA_TEMPLATE_PATH`` and/or ``PTX_ISA_TEMPLATE_PATH`` to prepare +the additional HoloFood and PTX submissions alongside ``ISA_TEMPLATE_PATH``. The GitHub Action (or you, locally) will then call mars-cli using: @@ -31,6 +31,13 @@ PROJECT_ROOT = Path(__file__).resolve().parents[1] +# Additional submissions, each prepared when its environment variable is set: +# submission name -> (label, environment variable with the ISA template path) +EXTRA_SUBMISSIONS = { + "holofood": ("HoloFood", "HOLOFOOD_ISA_TEMPLATE_PATH"), + "ptx": ("PTX", "PTX_ISA_TEMPLATE_PATH"), +} + def ensure_settings_ini() -> Path: parent_str = os.environ.get("MARS_SETTINGS_DIR") @@ -126,14 +133,16 @@ def main() -> None: work_dir.mkdir(parents=True, exist_ok=True) isa_templates = {"multi-omics": resolve_isa_template()} - holofood_template = os.environ.get("HOLOFOOD_ISA_TEMPLATE_PATH") - if holofood_template: - holofood_path = Path(holofood_template) - if not holofood_path.exists(): + for submission_name, (label, env_var) in EXTRA_SUBMISSIONS.items(): + template = os.environ.get(env_var) + if not template: + continue + template_path = Path(template) + if not template_path.exists(): raise FileNotFoundError( - f"HoloFood ISA template not found at {holofood_path}" + f"{label} ISA template not found at {template_path}" ) - isa_templates["holofood"] = holofood_path + isa_templates[submission_name] = template_path prepared_submissions = [] for submission_name, isa_template in isa_templates.items(): From da055fac7179dfebc5be52a4b9a2d67f06649150 Mon Sep 17 00:00:00 2001 From: Bert Droesbeke Date: Thu, 12 Nov 2026 18:31:21 +0100 Subject: [PATCH 3/5] use main --- MARS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MARS b/MARS index 8a76c0e..df23435 160000 --- a/MARS +++ b/MARS @@ -1 +1 @@ -Subproject commit 8a76c0e72facc42295b107432e8bd628bf1227b8 +Subproject commit df2343503b4cb70c1664a3025886198c12328047 From ac8c3850788bbc223202a885d0d25867f96daf50 Mon Sep 17 00:00:00 2001 From: Bert Droesbeke Date: Thu, 12 Nov 2026 19:45:21 +0100 Subject: [PATCH 4/5] update --- MARS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MARS b/MARS index df23435..2f887ba 160000 --- a/MARS +++ b/MARS @@ -1 +1 @@ -Subproject commit df2343503b4cb70c1664a3025886198c12328047 +Subproject commit 2f887baa62639780515049b105006298516830dc From dfb0db3b7db5447f8ac7e69982545ecd17111d58 Mon Sep 17 00:00:00 2001 From: Bert Droesbeke Date: Fri, 13 Nov 2026 09:28:49 +0100 Subject: [PATCH 5/5] update attributes --- MARS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MARS b/MARS index 2f887ba..1ecdd15 160000 --- a/MARS +++ b/MARS @@ -1 +1 @@ -Subproject commit 2f887baa62639780515049b105006298516830dc +Subproject commit 1ecdd15fe2a2fbd6fd2d8bd3555ccdb39829828c