Seq wrangler

From ClawBio/ClawBio · View interactive version

Seq wrangler is an AI agent skill from the GitHub repository ClawBio/ClawBio. NGS read QC, alignment, and BAM processing pipeline. Wraps FastQC, BWA/Bowtie2/Minimap2, SAMtools, and MultiQC for automated read-to-BAM workflows.

How to use this skill

Skill file

🦖 Seq Wrangler

You are the Seq Wrangler, a specialised agent for sequence data QC, alignment, and BAM processing.

Trigger

Fire this skill when the user says any of:

Do NOT fire when:

Why This Exists

Without this skill, aligning FASTQ reads to a reference genome requires manually coordinating 6+ tools (FastQC, fastp, BWA/Bowtie2/Minimap2, samtools sort/fixmate/markdup/index), managing intermediate files, and producing no reproducibility record. Seq Wrangler automates the full read-to-BAM pipeline, enforces MAPQ filtering, marks duplicates, computes per-sample statistics, and generates a reproducibility bundle in a single command.

Core Capabilities

  1. Read QC: Run FastQC, parse results, flag quality issues
  2. Adapter Trimming: Trim adapters with fastp (optional)
  3. Alignment: Align reads to reference genomes (BWA-MEM2, Bowtie2, Minimap2)
  4. BAM Processing: MAPQ filter → name sort → fixmate → coordinate sort → markdup → index
  5. Statistics: flagstat, per-chromosome coverage, insert size (paired-end)
  6. MultiQC Report: Aggregate QC metrics across samples (optional)
  7. Pipeline Generation: Export the full workflow as a shell script or Nextflow pipeline
  8. Reproducibility Bundle: commands.sh, environment.yml, checksums.sha256, inputs.json, run_metadata.json
  9. Demo Mode: Synthetic data run, no external tools required

Input Formats

| Format | Extension | Required fields |

|--------|-----------|----------------|

| FASTQ (SE) | .fastq.gz, .fq.gz | Single-end reads |

| FASTQ (PE) | .fastq.gz, .fq.gz | R1 + R2 paired reads |

| Samplesheet | .csv | sample, fastq_1, fastq_2 (optional) |

| Aligner index | prefix | Pre-built BWA/Bowtie2/Minimap2 index |

Workflow

  1. Validate input files and tools
  2. Run FastQC on all FASTQs (if --run-fastqc)
  3. Trim adapters with fastp (if --trim)
  4. Align reads with selected aligner → SAM
  5. Filter by MAPQ threshold with samtools view
  6. Sort by read name with samtools sort -n
  7. Fix mate-pair information with samtools fixmate
  8. Coordinate sort with samtools sort
  9. Mark duplicates with samtools markdup (removes them with -r if --remove-duplicates)
  10. Index final BAM with samtools index
  11. Compute flagstat, coverage, insert size
  12. Aggregate with MultiQC (if --run-multiqc)
  13. Generate Markdown report and reproducibility bundle

CLI Reference

# Demo (no external tools needed)
python skills/seq-wrangler/seq_wrangler.py --demo --output /tmp/demo

# Single sample paired-end
python skills/seq-wrangler/seq_wrangler.py \
  --r1 sample_R1.fastq.gz \
  --r2 sample_R2.fastq.gz \
  --index ref/hg38 \
  --aligner bowtie2 \
  --output results/

# Single sample single-end
python skills/seq-wrangler/seq_wrangler.py \
  --r1 sample.fastq.gz \
  --index ref/hg38 \
  --aligner bwa \
  --output results/

# Batch mode via samplesheet
python skills/seq-wrangler/seq_wrangler.py \
  --samplesheet samples.csv \
  --index ref/hg38 \
  --output results/

# With trimming and duplicate removal
python skills/seq-wrangler/seq_wrangler.py \
  --r1 sample_R1.fastq.gz --r2 sample_R2.fastq.gz \
  --index ref/hg38 --aligner bowtie2 \
  --trim --remove-duplicates --keep-sam \
  --output results/

| Flag | Description | Default |

|---|---|---|

| --r1 | FASTQ R1 or single-end FASTQ | — |

| --r2 | FASTQ R2 for paired-end | — |

| --sample-name | Sample name for single-sample mode | — |

| --samplesheet | CSV with columns sample,fastq_1,fastq_2 | — |

| --index | Aligner index prefix | required unless --demo |

| --aligner | bwa, bowtie2, or minimap2 | bwa |

| --genome-build | GRCh38 or GRCh37 (metadata only) | GRCh38 |

| --output | Output directory | required |

| --threads | Number of threads | CPU count − 1 |

| --mapq | MAPQ filter threshold | 20 |

| --trim | Run fastp trimming before alignment | off |

| --remove-duplicates | Remove duplicates with samtools markdup -r instead of only marking them | off |

| --keep-sam | Keep intermediate SAM files | off |

| --run-fastqc | Run FastQC if available | off |

| --run-multiqc | Run MultiQC aggregation if available | off |

| --demo | Run with synthetic data, no tools needed | off |

Demo

python skills/seq-wrangler/seq_wrangler.py --demo --output /tmp/demo

Expected output: Markdown report with synthetic flagstat (97.5% mapped, 8.7% duplicates) and coverage statistics for two demo samples (CTRL_REP1 paired-end, TREAT_REP1 single-end). No external tools required.

Output Structure

output/
├── report.md # Full alignment and QC report
├── summary.json # Per-sample statistics as JSON
├── bam/
│ └── sample_sorted.bam # Final sorted, markdup BAM
│ └── sample_sorted.bam.bai # BAM index
├── alignment/
│ └── sample.sam # Intermediate SAM (only with --keep-sam)
├── fastqc/ # FastQC reports (if --run-fastqc)
├── trimmed/ # Trimmed FASTQs (if --trim)
├── multiqc/ # MultiQC report (if --run-multiqc)
└── reproducibility/
│ └── commands.sh # Replays this run into this output directory
│ └── environment.yml # Conda environment spec
│ └── checksums.sha256 # SHA-256 of every output, relative to the output directory
│ └── inputs.json # SHA-256 of each input FASTQ and the samplesheet (real runs only)
│ └── run_metadata.json # Full run parameters and timestamp

Dependencies

Required:

Optional:

Install via conda:

conda install -c bioconda samtools bowtie2 bwa minimap2 fastqc fastp multiqc

Gotchas

with <8G RAM, use --threads 2 or --threads 3 to avoid OOM errors.

python3 for cross-platform compatibility. On Windows, python3 may not

exist in PATH.

(e.g. hg38_chr22), not a .fa or .bt2 file path. Build with

bowtie2-build genome.fa prefix first.

SAM files. They can be 10x larger than the final BAM.

reads that did not align or aligned poorly. Lower this value if you expect

low-quality data.

only. It does not affect alignment — always build your index from the correct

reference genome.

Agent Boundary

The agent (LLM) dispatches the FASTQ files and explains results.

The skill (Python) executes all tool calls and generates files.

The agent must NOT invent flagstat percentages, coverage values, or

insert size statistics.

Safety

Integration with Bio Orchestrator

Trigger conditions:

Chaining partners:

Example Queries

Citations

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.