Skip to main content

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.
Rule: 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:
Rule: 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:
Rule: run_nextclade — Assigns clade and lineage labels to all sequences in the input FASTA:
Rule: 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

Key packages: 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:
Force-re-run only M01 rules without rebuilding the rest of the DAG:

Known Limitations & Edge Cases

  • Partial dates: GISAID sequences with collection dates like 2024-XX-XX are coerced to 2024. This intentional loss of precision may introduce small biases in augur refine clock fitting. Sequences with date: unknown are excluded.
  • NCBI API throttling: The NCBI API enforces rate limits. Set the NCBI_API_KEY environment variable to raise the limit from 3 to 10 requests/second.
  • Nextclade dataset versioning: Nextclade datasets evolve. Pin nextclade.dataset_name to 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_count sequences in the input, all sequences of that subtype are excluded by qc_prefilter in M02 to prevent tree artifacts from low-count groups.