Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Generate pileup data for variant calling using samtools mpileup and pysam. Use when preparing data for variant calling, analyzing per-position read data, or calculating allele frequencies.
.claude/skills/bio-pileup-generation/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 141% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 298% | 0% |
| case-03 | ✓→✓ | = Same ✓ | 244% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 104% | 0% |
| case-05 | ✓→✓ | = Same ✓ | 152% | 0% |
<!--
#
#
-->
Generate pileup data for variant calling and position-level analysis.
Pileup shows all reads covering each position in the reference, used for:
bashsamtools mpileup -f reference.fa input.bam > pileup.txt
bashsamtools mpileup -f reference.fa -g input.bam -o output.bcf
bashsamtools mpileup -f reference.fa -r chr1:1000000-2000000 input.bam
bashsamtools mpileup -f reference.fa -l targets.bed input.bam
bashsamtools mpileup -f reference.fa sample1.bam sample2.bam sample3.bam > pileup.txt
Text pileup format (6 columns per sample):
chr1 1000 A 15 ............... FFFFFFFFFFF
chr1 1001 T 12 ............ FFFFFFFFFFFF| Column | Description | |--------|-------------| | 1 | Chromosome | | 2 | Position (1-based) | | 3 | Reference base | | 4 | Read depth | | 5 | Read bases | | 6 | Base qualities |
| Symbol | Meaning | |--------|---------| | . | Match on forward strand | | , | Match on reverse strand | | ACGT | Mismatch (uppercase = forward) | | acgt | Mismatch (lowercase = reverse) | | ^Q | Start of read (Q = MAPQ as ASCII) | | $ | End of read | | +NNN | Insertion of N bases | | -NNN | Deletion of N bases | | * | Deleted base | | > / < | Reference skip (intron) |
bashsamtools mpileup -f reference.fa -q 20 input.bam
bashsamtools mpileup -f reference.fa -Q 20 input.bam
bashsamtools mpileup -f reference.fa -q 20 -Q 20 input.bam
bash# Prevent memory issues with high coverage samtools mpileup -f reference.fa -d 1000 input.bam
bashsamtools mpileup -f reference.fa input.bam | bcftools call -mv -o variants.vcf
bashsamtools mpileup -f reference.fa -g -o output.bcf input.bam bcftools call -mv output.bcf -o variants.vcf
bashsamtools mpileup -f reference.fa -q 20 -Q 20 input.bam | \ bcftools call -mv -Oz -o variants.vcf.gz bcftools index variants.vcf.gz
pythonimport pysam with pysam.AlignmentFile('input.bam', 'rb') as bam: for pileup_column in bam.pileup('chr1', 1000000, 1001000): print(f'{pileup_column.reference_name}:{pileup_column.pos} depth={pileup_column.n}')
pythonimport pysam with pysam.AlignmentFile('input.bam', 'rb') as bam: for pileup_column in bam.pileup('chr1', 1000000, 1000001, truncate=True): print(f'Position: {pileup_column.pos}') print(f'Depth: {pileup_column.n}') for pileup_read in pileup_column.pileups: if pileup_read.is_del: print(' Deletion') elif pileup_read.is_refskip: print(' Reference skip') else: qpos = pileup_read.query_position base = pileup_read.alignment.query_sequence[qpos] qual = pileup_read.alignment.query_qualities[qpos] print(f' {base} (Q{qual})')
pythonimport pysam from collections import Counter def allele_counts(bam_path, chrom, pos): counts = Counter() with pysam.AlignmentFile(bam_path, 'rb') as bam: for pileup_column in bam.pileup(chrom, pos, pos + 1, truncate=True): if pileup_column.pos != pos: continue for pileup_read in pileup_column.pileups: if pileup_read.is_del: counts['DEL'] += 1 elif pileup_read.is_refskip: continue else: qpos = pileup_read.query_position base = pileup_read.alignment.query_sequence[qpos] counts[base.upper()] += 1 return dict(counts) counts = allele_counts('input.bam', 'chr1', 1000000) print(counts) # {'A': 45, 'G': 5}
pythonimport pysam from collections import Counter def allele_frequency(bam_path, chrom, pos, min_qual=20): counts = Counter() with pysam.AlignmentFile(bam_path, 'rb') as bam: for pileup_column in bam.pileup(chrom, pos, pos + 1, truncate=True, min_base_quality=min_qual): if pileup_column.pos != pos: continue for pileup_read in pileup_column.pileups: if pileup_read.is_del or pileup_read.is_refskip: continue qpos = pileup_read.query_position base = pileup_read.alignment.query_sequence[qpos] counts[base.upper()] += 1 total = sum(counts.values()) if total == 0: return {} return {base: count / total for base, count in counts.items()} freq = allele_frequency('input.bam', 'chr1', 1000000) for base, f in sorted(freq.items(), key=lambda x: -x[1]): print(f'{base}: {f:.1%}')
pythonimport pysam with pysam.AlignmentFile('input.bam', 'rb') as bam: for pileup_column in bam.pileup('chr1', 1000000, 1001000, truncate=True, min_mapping_quality=20, min_base_quality=20): print(f'{pileup_column.pos}: {pileup_column.n}')
pythonimport pysam def pileup_text(bam_path, ref_path, chrom, start, end): with pysam.AlignmentFile(bam_path, 'rb') as bam: with pysam.FastaFile(ref_path) as ref: for pileup_column in bam.pileup(chrom, start, end, truncate=True): pos = pileup_column.pos ref_base = ref.fetch(chrom, pos, pos + 1) depth = pileup_column.n bases = [] for pileup_read in pileup_column.pileups: if pileup_read.is_del: bases.append('*') elif pileup_read.is_refskip: bases.append('>') else: qpos = pileup_read.query_position base = pileup_read.alignment.query_sequence[qpos] if base.upper() == ref_base.upper(): bases.append('.' if not pileup_read.alignment.is_reverse else ',') else: bases.append(base.upper() if not pileup_read.alignment.is_reverse else base.lower()) print(f'{chrom}\t{pos+1}\t{ref_base}\t{depth}\t{"".join(bases)}') pileup_text('input.bam', 'reference.fa', 'chr1', 1000000, 1000100)
| Option | Description | |--------|-------------| | -f FILE | Reference FASTA (required) | | -r REGION | Restrict to region | | -l FILE | BED file of regions | | -q INT | Min mapping quality | | -Q INT | Min base quality | | -d INT | Max depth (default 8000) | | -g | Output BCF format | | -u | Uncompressed BCF output |
| Task | Command | |------|---------| | Basic pileup | samtools mpileup -f ref.fa in.bam | | Quality filter | samtools mpileup -f ref.fa -q 20 -Q 20 in.bam | | Region | samtools mpileup -f ref.fa -r chr1:1-1000 in.bam | | BCF output | samtools mpileup -f ref.fa -g in.bam -o out.bcf | | To bcftools | samtools mpileup -f ref.fa in.bam \| bcftools call -mv |
| Error | Cause | Solution | |-------|-------|----------| | No FASTA reference | Missing -f option | Add -f reference.fa | | Reference mismatch | Wrong reference | Use same reference as alignment | | Out of memory | High coverage region | Use -d to cap depth |
<!-- AUTHOR_SIGNATURE: 9a7f3c2e-MD-BABU-MIA-2026-MSSM-SECURE -->
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 8,607 | 8,000 | -7% | 1 | 1 | 0% | 1,817 | 4,384 | +141% | 0 | 0 | — |
case-02 | pass→pass | 4,115 | 2,930 | -29% | 1 | 1 | 0% | 825 | 3,282 | +298% | 0 | 0 | — |
case-03 | pass→pass | 4,600 | 2,835 | -38% | 1 | 1 | 0% | 940 | 3,231 | +244% | 0 | 0 | — |
case-04 | pass→pass | 9,032 | 4,881 | -46% | 1 | 1 | 0% | 1,789 | 3,646 | +104% | 0 | 0 | — |
case-05 | pass→pass | 6,317 | 2,609 | -59% | 1 | 1 | 0% | 1,285 | 3,242 | +152% | 0 | 0 | — |
case-06 | pass→pass | 3,191 | 2,339 | -27% | 1 | 1 | 0% | 585 | 3,141 | +437% | 0 | 0 | — |
case-07 | pass→pass | 4,244 | 1,782 | -58% | 1 | 1 | 0% | 847 | 3,016 | +256% | 0 | 0 | — |
case-08 | pass→pass | 6,554 | 2,556 | -61% | 1 | 1 | 0% | 910 | 3,158 | +247% | 0 | 0 | — |
case-09 | pass→pass | 4,869 | 2,415 | -50% | 1 | 1 | 0% | 828 | 3,099 | +274% | 0 | 0 | — |
case-10 | pass→pass | 10,867 | 7,322 | -33% | 1 | 1 | 0% | 1,895 | 4,048 | +114% | 0 | 0 | — |
case-11 | pass→pass | 6,787 | 4,865 | -28% | 1 | 1 | 0% | 1,440 | 3,771 | +162% | 0 | 0 | — |
case-12 | pass→pass | 3,380 | 2,839 | -16% | 1 | 1 | 0% | 626 | 3,298 | +427% | 0 | 0 | — |
case-13 | pass→pass | 4,861 | 3,340 | -31% | 1 | 1 | 0% | 938 | 3,367 | +259% | 0 | 0 | — |
case-14 | pass→pass | 10,226 | 8,117 | -21% | 1 | 1 | 0% | 2,115 | 4,491 | +112% | 0 | 0 | — |
case-15 | pass→pass | 8,983 | 5,094 | -43% | 1 | 1 | 0% | 1,889 | 3,759 | +99% | 0 | 0 | — |
case-16 | pass→pass | 4,502 | 2,345 | -48% | 1 | 1 | 0% | 745 | 3,138 | +321% | 0 | 0 | — |
case-17 | pass→pass | 4,377 | 2,194 | -50% | 1 | 1 | 0% | 777 | 3,090 | +298% | 0 | 0 | — |
case-18 | fail→fail | 7,144 | 6,188 | -13% | 1 | 1 | 0% | 1,583 | 4,069 | +157% | 0 | 0 | — |
case-19 | pass→pass | 4,283 | 2,484 | -42% | 1 | 1 | 0% | 779 | 3,172 | +307% | 0 | 0 | — |
case-20 | pass→pass | 11,521 | 3,872 | -66% | 1 | 1 | 0% | 2,296 | 3,545 | +54% | 0 | 0 | — |
case-21 | pass→pass | 5,309 | 4,564 | -14% | 1 | 1 | 0% | 1,127 | 3,513 | +212% | 0 | 0 | — |
case-22 | pass→pass | 10,792 | 4,340 | -60% | 1 | 1 | 0% | 2,039 | 3,462 | +70% | 0 | 0 | — |
case-23 | pass→pass | 8,654 | 6,465 | -25% | 1 | 1 | 0% | 1,759 | 4,104 | +133% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted. The headline lift of +4 percentage points is the difference between those two pass rates over the 23 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
| Model | Method | Date | Lift |
|---|---|---|---|
| gemini-3.6-flash | verified | 7/26/2026 | +18% |
Other measured skills in the registry, with their headline benchmark lift.