Skip to main content

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() in m02_m06_augur_core.smk.
  • TARGET_GENES in 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:
  1. Create envs/new_env.yaml following this template:
  1. Pin specific versions for all critical tools (never use unpinned latest).
  2. Test the environment: conda env create -f envs/new_env.yaml && conda activate new_env
  3. 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:
Mandatory conventions:
  • set -euo pipefail in all shell blocks — causes immediate exit on any error, undefined variable, or pipe failure.
  • mkdir -p the 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 Snakefile if creating a new .smk file.

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

Required conventions:
  • Use argparse for CLI — never use sys.argv directly.
  • Log to stderr with logging — Snakemake captures stderr to the log file.
  • Use pathlib.Path for 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:
A clean dry-run shows only job counts with no 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:
  1. Override the production git repo URL with your absolute local development path:
  2. M08’s m08_install_primerlab rule installs PrimerLab in editable mode (pip install -e) when a local directory path is detected.
  3. Changes to the local PrimerLab repository are reflected immediately on the next M08 run without re-installation.
Cross-platform path handling: The M08 install rule contains path-handling logic for Windows drive letters (e.g., E:/Project/...). When running inside WSL2, the rule converts Windows paths to WSL mount paths (/mnt/e/Project/...) automatically.

Documentation Conventions

All documentation lives in docs/ and is rendered by Mintlify. Conventions:
  • Page frontmatter requires title and description fields.
  • 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.
To preview documentation locally: