How epi2me-labs/wf-flu works
Project Type and Purpose
• This is a bioinformatics data‐processing workflow built with Nextflow.
• Its goal is to take Nanopore FASTQ reads from Influenza A/B amplification, run them through a modular pipeline of filtering, alignment, variant calling, consensus building, typing and reporting, and produce per-sample and aggregated outputs.
• It is intended to run either on a local machine or HPC/cluster via Nextflow, using Docker or Singularity containers for reproducibility.
Key Architectural Components
a. Orchestrator
• Nextflow Engine (main.nf + lib/*.nf + Groovy helper classes in lib/*.groovy + nextflow.config).
• Profiles for Docker/Singularity, resource settings, parameter definitions.
b. Workflow Definition
• main.nf: core pipeline steps defined in Nextflow DSL.
• lib/common.nf, lib/ingress.nf: shared DSL modules.
• lib/WorkflowMain.groovy, lib/ArgumentParser.groovy, etc.: Groovy classes to parse parameters and bootstrap.
c. Glue & Utility Scripts
• bin/workflow_glue/*.py: Python scripts for database creation, parsing, report scaffolding, INSaFLU abricate helper, etc.
• bin/workflow_glue/wfg_helpers/*.py: small utilities for checking inputs, reheadering, depth calculations.
d. Reference Data & Resources
• data/primer_schemes: primer definitions and blastdb files.
• data/nextclade.csv: clade assignment reference.
• output_definition.json & nextflow_schema.json: JSON schemas for validation and output manifest.
e. External Command-Line Tools (invoked within pipeline)
• minimap2, samtools, medaka, bcftools, abricate (INSaFLU DB), nextclade.
f. Input & Test Data
• User-provided FASTQ files (single, directory or multiplexed with barcodes + sample_sheet).
• test_data/: sample FASTQs and sample sheets for automated tests.
g. Reporting & Output
• HTML report (wf-flu-report.html), CSV results (wf-flu-results.csv), per-sample BAMs, VCFs, FASTAs, depth metrics.
h. CI & Quality
• .gitlab-ci.yml, pre-commit config, tests in bin/workflow_glue/tests.
Relationships and Data Flow
• User invokes nextflow run main.nf with parameters → Nextflow Engine reads nextflow.config → bootstrap DSL modules (lib/) → ingest input FASTQs and sample_sheet.
• Nextflow schedules processes as a DAG:
1. concatenate_and_filter_reads (filters reads <200 bases)
2. align_reads (minimap2 → SAM/BAM)
3. calculate_coverage (samtools depth)
4. variant_calling (medaka)
5. build_consensus (bcftools)
6. typing_insaflu (abricate + INSaFLU DB)
7. nextclade_assignment
8. assemble_report (Python scripts gather outputs and generate HTML/CSV)
• Each process runs inside a container (Docker/Singularity) as defined in the profile.
Architectural Patterns & Principles
• Pipeline (DAG) pattern: clearly separated stages with defined inputs/outputs.
• Modularization: Nextflow DSL modules + external helper scripts keep logic decoupled.
• Containerization: ensures reproducible environments.
• Schema-driven I/O: JSON schemas validate outputs, sample sheets map barcodes → aliases.