Module M01: Data Acquisition & Standardisation
M01 is the pipeline entry point. It ingests raw viral genomic data from two selectable pathways (NCBI API or local files), executes Nextclade for quality-controlled clade classification, and outputs a standardised metadata TSV and cleaned FASTA that all downstream modules depend upon.Input Requirements
Supported Local Metadata Formats
The NCBI Datasets API pathway (
database: ncbi) is marked experimental in the rule code. For reproducible production runs, use database: local with files manually downloaded from NCBI Virus or GISAID.Processing Stages
Stage 1A — NCBI Pathway (when database: ncbi)
Rule: download_ncbi_data
Calls the ncbi-datasets-cli to download a ZIP archive of genomic sequences matching the taxon and location query.
extract_ncbi_data
Unpacks the ZIP, extracts genomic.fna, and converts the JSONL data report to a raw TSV metadata table using the dataformat utility:
convert_metadata_tsv (Python in-process)
Remaps raw NCBI column names to the Nextstrain standard schema using a hardcoded FIELD_MAP dict. Parses country by splitting Geographic Location on ":".
Stage 1B — Local Pathway (when database: local)
Rule: copy_local_sequences — Simple file copy from local_input.sequences path.
Rule: convert_local_metadata — Dispatches to the appropriate parser based on local_input.format. For ncbi_virus_csv, applies a full COLUMN_MAP conversion including country/region extraction from Geo_Location. For all TSV/GISAID formats, copies as-is.
Stage 2 — Metadata Sanitisation (both pathways)
Rule:sanitize_metadata → Script: scripts/sanitize_metadata.py
Normalises column names across heterogeneous sources. Handles:
- GISAID EpiFlu XLS (direct Excel reading via
openpyxl) - Divergent date formats (ISO 8601, GISAID partial dates
YYYY-XX-XX→YYYY) - Strain name deduplication and whitespace stripping
- Country/region extraction from compound location strings
Stage 3 — Nextclade Classification (optional, nextclade.enabled: true)
Rule: nextclade_dataset — Downloads the Nextclade reference dataset:
run_nextclade — Assigns clade and lineage labels to all sequences in the input FASTA:
enrich_metadata → Script: scripts/enrich_metadata.py
Left-joins the Nextclade output TSV onto the sanitised metadata on the strain column. Appends clade, lineage, aaSubstitutions, qcOverallStatus fields to produce the final metadata_enriched.tsv.
Outputs
Enriched Metadata Schema (Key Columns)
Conda Environment
augur, nextclade, ncbi-datasets-cli, dataformat, pandas, openpyxl
Debugging & Manual Invocation
Run Nextclade independently on a FASTA subset to verify clade assignment before launching the full pipeline:Known Limitations & Edge Cases
- Partial dates: GISAID sequences with collection dates like
2024-XX-XXare coerced to2024. This intentional loss of precision may introduce small biases inaugur refineclock fitting. Sequences withdate: unknownare excluded. - NCBI API throttling: The NCBI API enforces rate limits. Set the
NCBI_API_KEYenvironment variable to raise the limit from 3 to 10 requests/second. - Nextclade dataset versioning: Nextclade datasets evolve. Pin
nextclade.dataset_nameto a versioned identifier in long-term surveillance studies to ensure reproducible clade calls across runs. - Subtype underrepresentation: If a subtype has fewer than
global_params.min_subtype_countsequences in the input, all sequences of that subtype are excluded byqc_prefilterin M02 to prevent tree artifacts from low-count groups.
