Skip to content

Validate analysis setup before submission and support assembly references - #276

Merged
karlnyr merged 5 commits into
rc5.1.0from
fix/analysis-preflight-validation
Nov 16, 2026
Merged

karlnyr merged 5 commits into
rc5.1.0from
fix/analysis-preflight-validation

Conversation

@karlnyr

@karlnyr karlnyr commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Description

Closes #272.

Validate analysis inputs and references before submitting any SLURM jobs, collect setup errors across samples, and support NCBI Assembly accessions as reference genomes.

Stack

Depends on #274, which depends on #271. This PR targets fix/analyse-qc-only to keep its diff focused; retarget to master once the preceding PRs merge.

Changes

  • Normalize whitespace in reference IDs before lookup and job generation. Preserve the source sample-info file and save normalized values for finish.
  • Validate sample metadata, paired gzip FASTQ inputs, cached/downloaded nucleotide FASTA files, and required indexes.
  • Resolve GCF_... and GCA_... accessions through NCBI Assembly and download the complete genomic FASTA from the matching RefSeq/GenBank directory over HTTPS. Do not silently substitute another assembly version or the paired assembly.
  • Stage downloads and indexing before publishing reference files; reject HTTP-200 error bodies, corrupt gzip files, empty/malformed FASTA and indexing failures.
  • Collect independent setup failures, deduplicating shared reference failures while listing affected samples.
  • Prepare all sample scripts and reporting inputs before the first SLURM submission. Any setup error exits nonzero without submitting sample/reporting jobs.
  • Report already accepted analysis job IDs if a later SLURM submission fails.
  • Preserve existing results when sample preparation fails rather than deleting the output directory.
  • Keep QC-only runs independent of typing resources. --skip_update disables downloading/indexing but still validates required cached resources.

Primary function of PR

  • Bug fix
  • Minor functionality improvement

Testing

  • .venv/bin/python -m pytest: 180 passed.
  • Syntax/undefined-name and unused-import lint checks: passed.
  • Black formatting checks (100-character line length): passed.
  • git diff --check: passed.
  • Live NCBI lookup and download of GCF_000262545.1: gzip decoded successfully, containing three FASTA records.
  • Live resolution of paired GenBank accession GCA_000262545.1: matching GenBank download URL confirmed.
  • No live indexing or SLURM run performed.

@karlnyr
karlnyr requested a review from a team as a code owner November 12, 2026 13:01
karlnyr added a commit that referenced this pull request Nov 12, 2026
Treat absent MLST schemes and version dates separately from resource
failures. Skip unavailable MLST, retain other analyses, and clear stale
sequence types. Keep genuine setup failures fatal.

Rename preflight to validation and split its checks into focused,
independently tested helpers.

Refs #276
karlnyr added a commit that referenced this pull request Nov 12, 2026
Keep setup checks limited to filenames, mate pairs and file access.
Leave FASTQ record and gzip integrity checks to compute-node analysis
tools instead of decompressing inputs during validation.

Refs #276
karlnyr added a commit that referenced this pull request Nov 12, 2026
Reduce preparation complexity while preserving collected errors,
optional MLST handling and independent ExPEC checks. Add direct tests
for each helper and the top-level orchestration.

Refs #276
@karlnyr
karlnyr added this pull request to stack #275 November 13, 2026 12:57
@karlnyr
karlnyr removed this pull request from stack #275 November 13, 2026 13:05
@karlnyr
karlnyr added this pull request to stack #278 November 13, 2026 13:05
@karlnyr
karlnyr requested a balanced review from Copilot November 14, 2026 09:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Preflight accepts an incomplete MLST cache, allowing jobs to run with missing required loci and produce incomplete typing results instead of blocking submission.

1 open issue
What changed in this PR

This PR addresses #272 by validating analysis setup before SLURM submission and adding NCBI Assembly reference support, while preserving QC-only behavior.

Changes:

  • Validate metadata, paired FASTQ paths, reference FASTA files and indexes; collect setup failures across samples.
  • Resolve matching RefSeq/GenBank assemblies and stage genome downloads and indexing before publication.
  • Prepare sample and reporting scripts before submission, preserve existing results on preparation failure, and report accepted job IDs after submission failures.
File Description
tests/​utils/​test_validation.py Tests metadata, reference normalization and paired-input checks.
tests/​utils/​test_scraper.py Tests continued analysis without an MLST scheme.
tests/​utils/​test_referencer.py Tests assembly downloads, reference validation and indexing failures.
tests/​utils/​test_reference_preparation.py Tests resource preparation and error collection.
tests/​utils/​test_jobcreator.py Tests preparation ordering, submission failures and result preservation.
tests/​utils/​conftest.py Adds an isolated reference-manager fixture.
tests/​test_cli.py Tests preflight failures, normalized metadata and QC submission.
README.md Documents validation, assembly references and failure behavior.
microSALT/​utils/​validation.py Adds shared metadata and FASTQ-path validation.
microSALT/​utils/​scraper.py Skips unavailable MLST scraping while retaining other analyses.
microSALT/​utils/​referencer.py Adds resource preflight and staged assembly downloads.
microSALT/​utils/​job_creator.py Separates job preparation from submission and reports failures.
microSALT/​exc/​exceptions.py Defines reference and analysis setup exceptions.
microSALT/​cli.py Runs preflight validation before creating analysis jobs.

Review effort: Balanced

Comment thread microSALT/utils/referencer.py Resolved
Comment thread microSALT/cli.py Resolved
karlnyr added a commit that referenced this pull request Nov 16, 2026
Treat absent MLST schemes and version dates separately from resource
failures. Skip unavailable MLST, retain other analyses, and clear stale
sequence types. Keep genuine setup failures fatal.

Rename preflight to validation and split its checks into focused,
independently tested helpers.

Refs #276
@karlnyr
karlnyr force-pushed the fix/analysis-preflight-validation branch from 8caabb0 to 4dc8828 Compare November 16, 2026 11:07
karlnyr added a commit that referenced this pull request Nov 16, 2026
Keep setup checks limited to filenames, mate pairs and file access.
Leave FASTQ record and gzip integrity checks to compute-node analysis
tools instead of decompressing inputs during validation.

Refs #276
karlnyr added a commit that referenced this pull request Nov 16, 2026
Reduce preparation complexity while preserving collected errors,
optional MLST handling and independent ExPEC checks. Add direct tests
for each helper and the top-level orchestration.

Refs #276
Base automatically changed from fix/analyse-qc-only to rc5.1.0 November 16, 2026 11:07
Collect setup failures before submitting any analysis jobs. Validate
reference FASTA and indexes, normalize reference IDs, and resolve NCBI
assembly accessions through the Assembly database.

Closes #272
Refs #274
Treat absent MLST schemes and version dates separately from resource
failures. Skip unavailable MLST, retain other analyses, and clear stale
sequence types. Keep genuine setup failures fatal.

Rename preflight to validation and split its checks into focused,
independently tested helpers.

Refs #276
Keep setup checks limited to filenames, mate pairs and file access.
Leave FASTQ record and gzip integrity checks to compute-node analysis
tools instead of decompressing inputs during validation.

Refs #276
Reduce preparation complexity while preserving collected errors,
optional MLST handling and independent ExPEC checks. Add direct tests
for each helper and the top-level orchestration.

Refs #276
@karlnyr
karlnyr force-pushed the fix/analysis-preflight-validation branch from 4dc8828 to 177627d Compare November 16, 2026 11:07
@karlnyr
karlnyr merged commit 2966421 into rc5.1.0 Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants