How alexandrovlab/dupcaller works
Project Type and Purpose
• DupCaller is a Python-based CLI pipeline for somatic mutation calling and burden estimation on ecNGS data.
• It wraps several “subcommands” (index, trim, call, learn, summarize, aggregateProfile, estimate) and orchestrates external tools (BWA, GATK, samtools).
Main Architectural Components
a. CLI Dispatcher
– src/DupCaller.py: Entry point (console script) that parses top-level arguments and delegates to subcommands.
b. Subcommand Modules
– src/subcommands/{Index, Trim, Caller, Learn, Summarize, AggregateProfile, Estimate}.py
– Each implements one pipeline stage, imports reusable routines from funcs.
c. Core Function Libraries
– src/subcommands/funcs/*.py (call.py, depth.py, indels.py, learn.py, misc.py, prob.py)
– Encapsulate statistical models, file I/O, context indexing logic.
d. External Tools
– BWA-MEM (alignment)
– GATK MarkDuplicates (deduplication with optical vs. PCR UMI tags)
– Samtools (sorting, indexing)
e. Data Artifacts
– Input: FASTQ, BAM, reference.fa, germline.vcf, noise mask bed files
– Intermediate: ref.h5, tn.h5, hp.h5 (indexed references), trimmed fastqs, sorted/marked BAMs
– Output: VCFs (snv.vcf, indel.vcf), burden reports
Relationships & Data Flow
• CLI Dispatcher → Subcommand Module → Core Funcs → (optionally) invoke External Tool → write output
• Data flows in sequence:
1) index: reference.fa → {ref.h5, tn.h5, hp.h5}
2) trim: FASTQ → trimmed FASTQ + annotated read names
3) align: trimmed FASTQ → BAM → sorted/indexed BAM (external BWA/samtools)
4) Dup: BAM → mkdped.bam + metrics (external GATK)
5) call: mkdped.bam → snv.vcf + indel.vcf (internal routines, multi‐thread across regions)
6) summarize/aggregateProfile/learn: VCFs + error profiles → trained models + profiles
7) estimate: VCFs → mutational burden report
Architectural Patterns & Principles
• Command Pattern: each “subcommand” is a pluggable command class.
• Layered Design: CLI layer → command layer → library layer → external‐tool layer → storage.
• Single Responsibility: each module handles one stage or one aspect of error modeling.
• Extensibility: add new subcommands by dropping a new script under src/subcommands.