Testing & Validation Suite
This guide explains how to execute tests and validate changes in the pipeline codebase. It covers dry-runs, script unit tests, and full integration tests on mock data subsets.0. The Local Gate
Everything CI runs, you can run in one line. Install the tooling once:pre-commit install wires the lint and the config contracts into git commit.
Every hook is check-only; none of them rewrites a file. That rule exists because
a formatter would renormalise line endings and bury the real change in a
whole-file diff, which is also why .gitattributes pins * -text.
1. Dry-Run DAG Validation
Before committing any modification to rules (rules/*.smk) or configurations, verify that Snakemake can compile the Directed Acyclic Graph for every pathogen profile, not just the one you are working on. This is the loop CI runs:
Building DAG of jobs. A MissingInputException after that point is expected on a fresh clone, because no raw sequence data is committed; it means the rules are sound and only the cohort is absent. Anything else — WildcardError, RuleException, KeyError, an ambiguous rule — is a real defect.
One thing a dry-run cannot tell you: Snakefile declares configfile: "config/config.yaml", and Snakemake deep-merges any --configfile on top of that rather than replacing it. A per-pathogen config that omits a key therefore does not fail; it silently inherits the influenza-A-MP value. Section 2 is what catches those.
2. Unit Testing Python Scripts
Automated pytest suite
Thepytest suite in tests/ covers the correctness-critical scientific functions and, in tests/contracts/, the agreement between files. Run it before every commit:
The config contract
tests/contracts/config_contract.yaml is the single declaration of what a
pathogen config must contain: required keys with their types and bounds,
thresholds that are pipeline-wide policy and must be identical everywhere, and
keys that are read by nothing and must not appear. Each file is loaded on its
own, without the Snakemake merge, which is the only way the holes are visible.
Violations that exist today are recorded under known_gaps rather than hidden.
The tests assert the violation set matches those lists exactly, so a new
violation still fails, and repairing a recorded one also fails until its entry
is deleted. The lists can only shrink.
Continuous integration
.github/workflows/ci.yml runs three jobs on every push and pull request that
touches scripts/, rules/, tests/, config/, envs/, docs/,
requirements/ or the Snakefile:
Both workflows are gated on
github.repository, so they stay dormant on the
upstream lab repository, whose Actions quota they would otherwise spend.
The contract job selects tests by path, never by -m contract. Marker
deselection happens after collection, and collecting tests/ imports pipeline
scripts that need pandas, Biopython and primer3 — one of them calls sys.exit(1)
on ImportError, which crashes collection outright. Path selection is what keeps
that job down to two dependencies.
Running scripts directly
The scripts inscripts/ perform data sanitisation, filtering, scoring, and output generation. They are designed as standard modular Python files that can be run independently of Snakemake.
Setting up a Test Environment
Activate the environment containing the dependencies of the script you want to test (e.g.,hyphy_macse for Bridge scripts, primerlab for design verification).
Running Test Scripts
We provide mock input files indata/test_subset/ to allow developers to verify script logic quickly:
3. Integration Testing with Mock Datasets
This section is a recipe, not a description of the repository. Neitherconfig/config_test_mock.yaml nor data/test_subset/ is shipped, and data/
is gitignored, so a mock run has to be assembled locally before it can be used.
CI does not run one: a real pipeline pass takes hours and needs conda
environments, HyPhy, IQ-TREE and a multi-gigabyte BLAST database.
We recommend maintaining a small “mock dataset” (e.g., 50 sequences) to run full end-to-end integration tests in a fraction of the time required for complete surveillance datasets.
Creating a Mock Run Profile
Create a configuration profile specifically for integration testing:config/config_test_mock.yaml.
Executing the Integration Test
Run the full Snakemake workflow using the mock profile:- All outputs are successfully written to
results/test-mock-run/. - No Snakemake rules exited with non-zero status.
- Inspect
results/test-mock-run/m10/coverage_summary.tsvto ensure the final diagnostic candidates were validated and received non-zero coverage scores.
