Developer Guide
This guide is for bioinformaticians and software engineers who want to extend, modify, or contribute to the pipeline codebase.Repository Structure
Key Design Principle: Configuration-Driven, Zero Hardcoding
The pipeline follows a strict zero-hardcoding principle:- Gene names are parsed dynamically from the GFF3 annotation at workflow load time via
_parse_cds_genes_from_gff()inm02_m06_augur_core.smk. TARGET_GENESin the Snakefile is populated from the active config + GFF3 parse result.- Adding support for a new virus means adding a GFF3 annotation file — not modifying any rule or script code.
- All BLAST database taxonomy IDs and host genomes are specified in config, not hardcoded in build scripts.
Conda Environment Management
Environment Files
Creating a New Environment
If a new module requires packages not in any existing environment:- Create
envs/new_env.yamlfollowing this template:
- Pin specific versions for all critical tools (never use unpinned
latest). - Test the environment:
conda env create -f envs/new_env.yaml && conda activate new_env - Reference the environment from your rule:
conda: "../envs/new_env.yaml"
Do not add packages to
nextstrain.yaml unless they are required by a nextstrain/augur tool. The nextstrain environment is the largest and most fragile — unnecessary additions risk breaking conda’s dependency solver.Adding a New Snakemake Rule
Rule Template
All rules must follow this structure:set -euo pipefailin all shell blocks — causes immediate exit on any error, undefined variable, or pipe failure.mkdir -pthe output directory at the top of every shell block.- Log file must capture both stdout and stderr:
2>&1 | tee {log}. - All parameters must come from
config— never hardcode values inside a rule. - Add the rule file import to
Snakefileif creating a new.smkfile.
Adding to an Existing .smk File
When extending an existing rule file (e.g., adding a new QC step to m02_m06_augur_core.smk), follow the file’s existing conventions for variable naming and config access patterns.
Writing a New Python Script
All scripts called by Snakemake rules must follow these conventions:Script Template
- Use
argparsefor CLI — never usesys.argvdirectly. - Log to
stderrwithlogging— Snakemake captures stderr to the log file. - Use
pathlib.Pathfor file operations, not raw string concatenation. - Exit with non-zero status on any unrecoverable error — Snakemake treats non-zero exit as rule failure.
- Include docstring with: purpose, calling rule, inputs, outputs.
Snakemake script: Directive
For scripts that need access to Snakemake’s input, output, params, log, and config objects directly (without argparse), use the script: directive instead of shell::
Dry-Run Testing Protocol
Before pushing any rule or script change, always verify with a dry-run across all supported config profiles:Error, Exception, or Missing messages.
PrimerLab Integration Development Notes
The pipeline integrates with the PrimerLab Genomic framework as an external dependency. For local development of PrimerLab itself alongside this pipeline:- Override the production git repo URL with your absolute local development path:
- M08’s
m08_install_primerlabrule installs PrimerLab in editable mode (pip install -e) when a local directory path is detected. - Changes to the local PrimerLab repository are reflected immediately on the next M08 run without re-installation.
E:/Project/...). When running inside WSL2, the rule converts Windows paths to WSL mount paths (/mnt/e/Project/...) automatically.
Documentation Conventions
All documentation lives indocs/ and is rendered by Mintlify. Conventions:
- Page frontmatter requires
titleanddescriptionfields. - Use Mintlify callout tags (
<Note>,<Warning>,<Info>,<Tip>) for callout blocks. - Code blocks must include a language identifier (
```bash,```yaml,```python,```json). - All file paths in docs should be relative to the project root.
- Navigation is managed in
docs/docs.json— add any new page to the appropriate group.
