jaechang-hits/sciagent-skills/bwa-mem2-dna-aligner
Claude Code and agent skill by jaechang-hits/sciagent-skills
- community
Checking that the SKILL.md file is still in the repository.
Fast short-read DNA aligner for WGS/WES/ChIP-seq. 2× faster BWA-MEM successor; outputs SAM/BAM with read group headers for GATK. Primary plus supplementary records for chimeric reads. Use STAR for RNA-seq splice-aware alignment; Bowtie2 is a comparable alternative.
Install
npx vskill@latest install jaechang-hits/sciagent-skills/bwa-mem2-dna-alignerSKILL.md
The same SKILL.md was published earlier as jaechang-hits/sciagent-skills/bwa-mem2-dna-aligner.
BWA-MEM2 — DNA Short-Read Aligner
Overview
BWA-MEM2 aligns short DNA reads (Illumina, 50–250 bp) to a reference genome using the BWT-FM index. It is the standard aligner for whole-genome sequencing (WGS), whole-exome sequencing (WES), ChIP-seq, and ATAC-seq DNA alignment. BWA-MEM2 is 2× faster than the original BWA-MEM while producing identical results. It outputs SAM format with proper read group (@RG) headers required by GATK HaplotypeCaller and Picard tools. For paired-end reads, it marks proper pairs and resolves chimeric/split reads into supplementary alignments.
When to Use
- Aligning WGS or WES Illumina reads to a reference genome for variant calling (SNP, indel, SV)
- ChIP-seq or ATAC-seq DNA alignment to produce BAM files for peak calling with MACS3
- Producing GATK-compatible BAM files with
@RGread group tags - Aligning reads ≥ 50 bp; for shorter reads (< 50 bp), BWA-backtrack may be more appropriate
- Re-aligning legacy FASTQ files to an updated reference genome assembly
- Use STAR instead for RNA-seq reads that span splice junctions
- Use Bowtie2 as an alternative for local alignment or when index size must be minimized
Prerequisites
- Software: bwa-mem2 (conda or pre-compiled binary), samtools
- Reference: genome FASTA (e.g., GRCh38, hg19, mm10)
- RAM: ~28 GB for human genome index; 6–8 GB for mouse
Check before installing: The tool may already be available in the current environment (e.g., inside apixi/condaenv). Runcommand -v bwa-mem2first and skip the install commands below if it returns a path. When running inside a pixi project, invoke the tool viapixi run bwa-mem2rather than barebwa-mem2.
Pre-flight Interview
Settle these with the user before writing any analysis code.
D2 is not cosmetic. The sample name in the read group is what joint genotyping groups by; an omitted or duplicated one silently merges or splits samples downstream, long after the alignment itself looks fine.
Quick Start
Workflow
Step 1: Download Reference Genome
Obtain the reference genome FASTA file matching the target assembly.
Step 2: Build BWA-MEM2 Index
Index the reference genome — required once per genome, takes ~25-35 min for human.
Step 3: Align Paired-End Reads
Align FASTQ reads with a read group header required for GATK compatibility.
Step 4: Mark PCR Duplicates
Remove or mark optical and PCR duplicates before variant calling.
Step 5: Assess Alignment Quality
Generate alignment statistics and check key quality metrics.
Step 6: Complete WGS/WES Pipeline → Variant Calling
Pipe BWA-MEM2 output directly into GATK HaplotypeCaller.
Key Parameters
| Parameter | Default | Range/Options | Effect | |
|---|---|---|---|---|
-t | 1 | 1–64 | CPU threads; use 8–16 for production runs | |
-R | — | @RG\tID:...\tSM:... | Read group string; required for GATK compatibility | |
-k | 19 | 10–28 | Minimum seed length; lower = more sensitive for shorter reads | |
-w | 100 | 50–500 | Band width for Smith-Waterman alignment | |
-M | off | flag | Mark split/supplementary reads as secondary (BWA-MEM style); needed for Picard compatibility | |
-a | off | flag | Output all alignments for single-end reads (for seeding; increases file size) | |
-p | off | flag | Treat input as interleaved paired-end FASTQ | |
-c | 500 | 100–10000 | Skip alignment for MEM count > threshold (reduces multi-mapper noise) | |
-T | 30 | 20–60 | Minimum alignment score threshold; lower = report more low-quality alignments | |
-Y | off | flag | Use soft clipping for supplementary alignments (recommended for GATK) |
Common Recipes
Recipe 1: Batch Align Multiple Samples
Recipe 2: Parse Alignment Metrics with Python
Expected Outputs
| Output | Format | Description | |
|---|---|---|---|
*.sorted.bam | BAM | Coordinate-sorted aligned reads; index with samtools index | |
*.sorted.bam.bai | BAI | BAM index; required for random access by GATK and IGV | |
*.flagstat.txt | Text | Alignment summary: total/mapped/paired/duplicate counts and percentages | |
*.markdup.bam | BAM | Duplicate-marked BAM; use as input to GATK HaplotypeCaller | |
*.dupmetrics.txt | Text | Picard duplication metrics with estimated library size |
Troubleshooting
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/genomics-bioinformatics/alignment/bwa-mem2-dna-aligner/SKILL.md
Popularity
- 7-day trend score
- 5
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/jaechang-hits/sciagent-skills/bwa-mem2-dna-aligner)