Skip to content

Rc5.1.0 - #280

Open
karlnyr wants to merge 53 commits into
masterfrom
rc5.1.0
Open

karlnyr wants to merge 53 commits into
masterfrom
rc5.1.0

Conversation

@karlnyr

@karlnyr karlnyr commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Description

Closes #272
Closes #273

This pull request introduces significant improvements to the microSALT pipeline, focusing on robust validation and support for QC-only (quality control only) workflows. The changes enhance the CLI experience, enforce strict input and reference validation before job submission, and add new error handling mechanisms. Additionally, the reporting and job creation logic have been updated to support these new features.

Key changes include:

QC-only Workflow Support

  • Added --qc-only/--qc_only flags to the analyse and utils finish CLI commands, enabling users to perform read/alignment QC without assembly, typing, or resistance analysis. The documentation in README.md has been updated with detailed instructions and explanations of the QC-only workflow. [1] [2] [3] [4]
  • Modified the finalization logic so that utils finish --qc-only generates only QC-related reports and deliverables, omitting assembly, QUAST, and typing outputs. [1] [2]

ExPEC virulence references

  • ExPEC (ExpAC) virulence reference sequences are no longer bundled with microSALT. Existing deployments must supply the reference FASTA files separately and set the required folders.expec configuration key to the directory containing the .fsa files, rather than to an individual file. This follows the same directory layout as folders.resistances.
  • Full E. coli analyses use the configured directory for ExPEC searching and scraping. microSALT builds BLAST indexes alongside the FASTA files, so the directory must be writable when indexes are built or refreshed. QC-only runs skip ExPEC analysis.

Input and Reference Validation

  • Introduced comprehensive validation before SLURM job submission: sample metadata, FASTQ filenames, reference genome files, and required resources are all checked. Errors are collected and reported together, and no jobs are submitted if any setup error occurs. [1] [2]
  • Added whitespace normalization for sample-info reference values and improved handling of reference genome downloads and validation, including stricter checks for valid FASTA files and proper error reporting for corrupt or missing resources.

Error Handling and Exceptions

  • Introduced new custom exceptions (AnalysisSetupError, ReferenceSetupError, MLSTUnavailableError) to clearly distinguish setup failures and allow for more informative error messages. These are now used throughout the CLI and job creation logic. [1] [2]
  • CLI commands now raise click.ClickException with detailed error information if setup or job creation fails, ensuring users are immediately informed of all issues. [1] [2]

Reporting and Job Creation

  • Modified the report fingerprinting logic in DB_Manipulator.set_report to use a structured JSON fingerprint based on sample metadata, improving report versioning and reproducibility.
  • Updated job creation logic to integrate the new validation routines and error handling, and to support the new QC-only workflow.

Web Interface and Report Data

  • Enhanced gen_reportdata and related web view functions to allow filtering by sample IDs, supporting more flexible report generation and visualization. [1] [2] [3]

These changes collectively make the pipeline more robust, user-friendly, and maintainable, particularly for large-scale or QC-focused sequencing projects.

Primary function of PR

  • Hot-fix
  • Patch
  • Minor functionality improvement
  • New type of analysis
  • Backward-breaking functionality improvement
  • This change requires internal documents to be updated
  • This change requires another repository to be updated

Testing

  • bash /home/proj/production/servers/resources/hasta.scilifelab.se/install-microsalt-stage.sh BRANCHNAME
  • us
  • conda activate S_microSALT
  • microSALT analyse --input /path/to/fastq/ SAMPLEINFO_FILE

Test results

These are the results of the tests, and necessary conclusions, that prove the stability of the PR.

Sign-offs

  • Approved to run at Clinical-Genomics by @karlnyr or @Clinical-Genomics/micro

dependabot Bot and others added 26 commits August 21, 2026 08:38
Bumps [sh](https://github.com/amoffat/sh) from 1.14.3 to 2.2.4.
- [Release notes](https://github.com/amoffat/sh/releases)
- [Changelog](https://github.com/amoffat/sh/blob/develop/CHANGELOG.md)
- [Commits](amoffat/sh@1.14.3...2.2.4)

---
updated-dependencies:
- dependency-name: sh
  dependency-version: 2.2.4
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [urllib3](https://github.com/urllib3/urllib3) from 2.7.0 to 2.8.0.
- [Release notes](https://github.com/urllib3/urllib3/releases)
- [Changelog](https://github.com/urllib3/urllib3/blob/main/CHANGES.rst)
- [Commits](urllib3/urllib3@2.7.0...2.8.0)

---
updated-dependencies:
- dependency-name: urllib3
  dependency-version: 2.8.0
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [werkzeug](https://github.com/pallets/werkzeug) from 3.1.6 to 3.1.9.
- [Release notes](https://github.com/pallets/werkzeug/releases)
- [Changelog](https://github.com/pallets/werkzeug/blob/main/CHANGES.rst)
- [Commits](pallets/werkzeug@3.1.6...3.1.9)

---
updated-dependencies:
- dependency-name: werkzeug
  dependency-version: 3.1.9
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [certifi](https://github.com/certifi/python-certifi) from 2026.1.4 to 2026.10.19.
- [Commits](certifi/python-certifi@2026.01.04...2026.10.19)

---
updated-dependencies:
- dependency-name: certifi
  dependency-version: 2026.10.19
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [black](https://github.com/psf/black) from 26.3.1 to 26.10.1.
- [Release notes](https://github.com/psf/black/releases)
- [Changelog](https://github.com/psf/black/blob/main/CHANGES.md)
- [Commits](psf/black@26.3.1...26.10.1)

---
updated-dependencies:
- dependency-name: black
  dependency-version: 26.10.1
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [mako](https://github.com/sqlalchemy/mako) from 1.3.12 to 1.4.2.
- [Release notes](https://github.com/sqlalchemy/mako/releases)
- [Changelog](https://github.com/sqlalchemy/mako/blob/main/CHANGES)
- [Commits](https://github.com/sqlalchemy/mako/commits)

---
updated-dependencies:
- dependency-name: mako
  dependency-version: 1.4.2
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [pylint](https://github.com/pylint-dev/pylint) from 4.0.5 to 4.0.9.
- [Release notes](https://github.com/pylint-dev/pylint/releases)
- [Commits](pylint-dev/pylint@v4.0.5...v4.0.9)

---
updated-dependencies:
- dependency-name: pylint
  dependency-version: 4.0.9
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [oauthlib](https://github.com/oauthlib/oauthlib) from 3.3.1 to 4.0.1.
- [Release notes](https://github.com/oauthlib/oauthlib/releases)
- [Changelog](https://github.com/oauthlib/oauthlib/blob/v4.0.1/CHANGELOG.rst)
- [Commits](oauthlib/oauthlib@v3.3.1...v4.0.1)

---
updated-dependencies:
- dependency-name: oauthlib
  dependency-version: 4.0.1
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [soupsieve](https://github.com/facelessuser/soupsieve) from 2.8.4 to 4.0.
- [Release notes](https://github.com/facelessuser/soupsieve/releases)
- [Commits](facelessuser/soupsieve@2.8.4...4.0)

---
updated-dependencies:
- dependency-name: soupsieve
  dependency-version: '4.0'
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Add qc_only flag that skips the typing when using the finish command
Pass the QC-only setting through analysis jobs and select the QC track
when finishing, avoiding typing scraping for QC-only runs.

Refs #271
Enable QC-only runs from the analyse command
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
…-validation

Validate analysis setup before submission and support assembly references
Implement QC-only report generation and filtering in reporter
@karlnyr
karlnyr requested a balanced review from Copilot November 16, 2026 15:31
@karlnyr
karlnyr requested a review from a team as a code owner November 16, 2026 15:31

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

MLST setup can submit typing jobs against empty profile tables, while QC-only runs can retain stale metadata and full-report versioning can miss changes to included samples.

3 open issues
What changed in this PR

This PR adds QC-only workflows to microSALT and strengthens validation before SLURM submission, with supporting changes to reference preparation, reporting and error handling.

Changes:

  • Add QC-only analysis and finalization, excluding typing and assembly outputs from reports and deliverables.
  • Validate sample metadata, FASTQ paths and reference resources, collecting setup errors before job submission.
  • Update report fingerprints and sample filtering, with expanded regression coverage.
File Description
tests/​utils/​test_validation.py Tests metadata, identifiers, FASTQ pairing and file access.
tests/​utils/​test_scraper.py Tests QC-only scraping and preservation of typing results.
tests/​utils/​test_reporter.py Tests QC-only output filtering and report versioning calls.
tests/​utils/​test_referencer.py Tests genome downloads, indexing and MLST availability handling.
tests/​utils/​test_reference_preparation.py Tests resource preparation and collected failures.
tests/​utils/​test_jobcreator.py Tests preparation-before-submission and QC-only job behavior.
tests/​utils/​conftest.py Adds an isolated reference-management fixture.
tests/​test_cli.py Tests QC flags, validation errors and job integration.
tests/​store/​test_database.py Tests roster and metadata changes in report fingerprints.
tests/​server/​test_jinja2_rendering.py Tests sample filtering in QC HTML.
README.md Documents QC-only workflows, validation and failure behavior.
microSALT/​utils/​validation.py Adds reusable input and metadata validation.
microSALT/​utils/​scraper.py Adds QC-only scraping and missing-MLST handling.
microSALT/​utils/​reporter.py Filters QC-only outputs and passes report roster metadata.
microSALT/​utils/​referencer.py Adds resource validation and safer genome download preparation.
microSALT/​utils/​job_creator.py Prepares jobs before submission and propagates submission failures.
microSALT/​store/​db_manipulator.py Uses structured JSON fingerprints for report versions.
microSALT/​server/​views.py Supports sample-ID filtering for report data and QC pages.
microSALT/​exc/​exceptions.py Defines setup-failure and unavailable-MLST exceptions.
microSALT/​cli.py Exposes QC-only flags and coordinates pre-submission validation.

Review effort: Balanced

Comment thread microSALT/utils/referencer.py Resolved
Comment thread microSALT/utils/reporter.py Resolved
Comment thread microSALT/utils/scraper.py Resolved

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.

Comment thread microSALT/cli.py
"trimmed": not untrimmed,
"pool": pool,
"qc_only": qc_only,
"pool": [sample["CG_ID_sample"] for sample in sampleinfo] if len(sampleinfo) > 1 else [],
Comment on lines +524 to +525
self.session.add(self.add_report(CG_ID_project=name, date=datetime.now(), version=version))
self.commit_session()
Comment on lines +147 to +148
if new is None:
continue
Comment on lines +153 to +155
checks = list(self.state.checks(f"{self.name}/").values())
if not checks:
return "-"

def snapshot_project(self, project: str) -> dict:
"""Per-sample typing, metadata and QC values plus typing row counts."""
self.session.expire_all()
state: State
runner: MicrosaltRunner
fixtures: FixtureHelper
_db: Database | None = field(default=None, repr=False)
Comment thread .github/pull_request_template.md Resolved
raise
except Exception as e:
self.logger.error(f"Unable to create job for sample {self.name}\nSource: {e!s}")
shutil.rmtree(self.finishdir, ignore_errors=True)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Won't removing that make the output directory too bulky?

Comment thread DEPLOYMENT.md
the release includes one), `-d` reinstall all dependencies.
1. Deploy master to production:
1. Log in to appropriate server `ssh <server.scilifelab.se>`
1. `sudo -iu hiseq.clinical`, then `up`

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

same, no username

Comment thread configExample.json
"references": "/tmp/MLST/references/ST_loci",
"_comment": "Resistances. Commonly from resFinder",
"resistances": "/tmp/MLST/references/resistances",
"_comment": "ExPEC virulence genes (.fsa files) for Escherichia coli. Not bundled; must be provided",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ExPEC seems to be deleted?

Comment thread .github/pull_request_template.md Resolved
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.

Finish command crash when organism is not in ST_loci/ directory References genome fetching error is not handled

4 participants