Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Generate consensus sequences and manage reference files using samtools. Use when creating consensus from alignments, indexing references, or creating sequence dictionaries.
.claude/skills/bio-reference-operations/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 46% | 0% |
| case-11 | ✗→✓ | ▲ Improved | 235% | 0% |
| case-10 | ✓→✓ | = Same ✓ | 214% | 0% |
| case-16 | ✓→✓ | = Same ✓ | 134% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 37% | 0% |
<!--
#
#
-->
Generate consensus sequences and manage reference files using samtools.
Create index for random access to reference sequences.
bashsamtools faidx reference.fa # Creates reference.fa.fai
bashsamtools faidx reference.fa chr1:1000-2000
bashsamtools faidx reference.fa chr1:1000-2000 chr2:3000-4000
bashsamtools faidx reference.fa chr1
bashsamtools faidx reference.fa chr1:1000-2000 > region.fa
bashsamtools faidx -i reference.fa chr1:1000-2000
chr1 248956422 6 60 61
chr2 242193529 253404903 60 61Columns: name, length, offset, line bases, line width
Create SAM header dictionary for reference (used by GATK, Picard).
bashsamtools dict reference.fa -o reference.dict
bashsamtools dict -a GRCh38 -s "Homo sapiens" reference.fa -o reference.dict
@HD VN:1.6 SO:unsorted
@SQ SN:chr1 LN:248956422 M5:6aef897c3d6ff0c78aff06ac189178dd UR:file:reference.fa
@SQ SN:chr2 LN:242193529 M5:f98db672eb0993dcfdabafe2a882905c UR:file:reference.faCreate consensus sequence from alignments.
bashsamtools consensus input.bam -o consensus.fa
bashsamtools consensus -r chr1:1000-2000 input.bam -o region_consensus.fa
bash# FASTA (default) samtools consensus -f fasta input.bam -o consensus.fa # FASTQ (includes quality) samtools consensus -f fastq input.bam -o consensus.fq
bash# Minimum depth to call base samtools consensus -d 5 input.bam -o consensus.fa # Call all positions (including low coverage) samtools consensus -a input.bam -o consensus.fa
bash# Use IUPAC codes for heterozygous positions samtools consensus --show-ins no --show-del no input.bam -o consensus.fa
pythonimport pysam with pysam.FastaFile('reference.fa') as ref: seq = ref.fetch('chr1', 999, 2000) # 0-based print(seq)
pythonwith pysam.FastaFile('reference.fa') as ref: for name in ref.references: length = ref.get_reference_length(name) print(f'{name}: {length:,} bp')
pythonwith pysam.FastaFile('reference.fa') as ref: for chrom in ref.references: seq = ref.fetch(chrom) print(f'>{chrom}') print(seq[:100] + '...')
pythonimport pysam from collections import Counter def consensus_at_position(bam, chrom, pos): bases = Counter() for pileup in bam.pileup(chrom, pos, pos + 1, truncate=True): if pileup.pos == pos: for read in pileup.pileups: if not read.is_del and not read.is_refskip: bases[read.alignment.query_sequence[read.query_position]] += 1 if bases: return bases.most_common(1)[0][0] return 'N' with pysam.AlignmentFile('input.bam', 'rb') as bam: consensus = consensus_at_position(bam, 'chr1', 1000000) print(f'Consensus at chr1:1000000 = {consensus}')
pythonimport pysam from collections import Counter def build_consensus(bam_path, chrom, start, end, min_depth=3): consensus = [] with pysam.AlignmentFile(bam_path, 'rb') as bam: for pileup in bam.pileup(chrom, start, end, truncate=True): bases = Counter() for read in pileup.pileups: if not read.is_del and not read.is_refskip: base = read.alignment.query_sequence[read.query_position] bases[base] += 1 if sum(bases.values()) >= min_depth: consensus.append(bases.most_common(1)[0][0]) else: consensus.append('N') return ''.join(consensus) seq = build_consensus('input.bam', 'chr1', 1000, 2000, min_depth=5) print(f'>{chrom}:{start}-{end}') print(seq)
pythonimport pysam def create_dict_header(fasta_path): header = {'HD': {'VN': '1.6', 'SO': 'unsorted'}, 'SQ': []} with pysam.FastaFile(fasta_path) as ref: for name in ref.references: length = ref.get_reference_length(name) header['SQ'].append({'SN': name, 'LN': length}) return header header = create_dict_header('reference.fa') for sq in header['SQ'][:5]: print(f'{sq["SN"]}: {sq["LN"]:,} bp')
bash# 1. Index FASTA for samtools/pysam samtools faidx reference.fa # 2. Create sequence dictionary for GATK/Picard samtools dict reference.fa -o reference.dict # 3. Index for BWA bwa index reference.fa # 4. Index for Bowtie2 bowtie2-build reference.fa reference
bash# Verify FAI exists ls -la reference.fa.fai # Verify dict exists head reference.dict # Test fetch samtools faidx reference.fa chr1:1-100
bashsamtools faidx reference.fa chr1 > chr1.fa samtools faidx chr1.fa # Index the subset
bashcut -f1,2 reference.fa.fai > chrom.sizes
bashsamtools faidx reference.fa chr1 chr2 chr3 > subset.fa samtools faidx subset.fa
bash# Generate consensus samtools consensus input.bam -o consensus.fa # Align consensus back to reference minimap2 -a reference.fa consensus.fa > comparison.sam
| Task | Command | |------|---------| | Index FASTA | samtools faidx ref.fa | | Fetch region | samtools faidx ref.fa chr1:1-1000 | | Create dict | samtools dict ref.fa -o ref.dict | | Build consensus | samtools consensus in.bam -o out.fa | | Chrom sizes | cut -f1,2 ref.fa.fai |
<!-- 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 | 9,413 | 5,096 | -46% | 1 | 1 | 0% | 2,069 | 3,031 | +46% | 0 | 0 | — |
case-10 | pass→pass | 4,233 | 2,438 | -42% | 1 | 1 | 0% | 851 | 2,669 | +214% | 0 | 0 | — |
case-16 | pass→pass | 6,161 | 2,720 | -56% | 1 | 1 | 0% | 1,173 | 2,743 | +134% | 0 | 0 | — |
case-02 | pass→pass | 9,738 | 2,337 | -76% | 1 | 1 | 0% | 1,853 | 2,547 | +37% | 0 | 0 | — |
case-03 | pass→pass | 8,269 | 5,595 | -32% | 1 | 1 | 0% | 1,566 | 3,265 | +108% | 0 | 0 | — |
case-04 | pass→pass | 13,864 | 3,659 | -74% | 1 | 1 | 0% | 2,238 | 2,523 | +13% | 0 | 0 | — |
case-05 | pass→pass | 13,567 | 9,278 | -32% | 1 | 1 | 0% | 3,004 | 4,044 | +35% | 0 | 0 | — |
case-11 | fail→pass | 3,886 | 2,876 | -26% | 1 | 1 | 0% | 838 | 2,805 | +235% | 0 | 0 | — |
case-06 | pass→pass | 13,182 | 7,803 | -41% | 1 | 1 | 0% | 2,664 | 3,806 | +43% | 0 | 0 | — |
case-07 | pass→pass | 16,861 | 7,108 | -58% | 1 | 1 | 0% | 2,073 | 3,545 | +71% | 0 | 0 | — |
case-08 | pass→pass | 3,798 | 2,769 | -27% | 1 | 1 | 0% | 785 | 2,744 | +250% | 0 | 0 | — |
case-09 | pass→pass | 5,253 | 4,205 | -20% | 1 | 1 | 0% | 1,000 | 2,951 | +195% | 0 | 0 | — |
case-12 | pass→pass | 10,378 | 3,526 | -66% | 1 | 1 | 0% | 1,998 | 2,918 | +46% | 0 | 0 | — |
case-13 | pass→pass | 3,848 | 3,754 | -2% | 1 | 1 | 0% | 820 | 2,946 | +259% | 0 | 0 | — |
case-14 | pass→pass | 9,105 | 5,354 | -41% | 1 | 1 | 0% | 1,659 | 3,250 | +96% | 0 | 0 | — |
case-15 | pass→pass | 5,256 | 2,032 | -61% | 1 | 1 | 0% | 955 | 2,511 | +163% | 0 | 0 | — |
case-17 | pass→pass | 6,454 | 2,956 | -54% | 1 | 1 | 0% | 1,256 | 2,768 | +120% | 0 | 0 | — |
case-18 | pass→pass | 2,501 | 2,412 | -4% | 1 | 1 | 0% | 457 | 2,626 | +475% | 0 | 0 | — |
case-19 | pass→pass | 3,762 | 2,614 | -31% | 1 | 1 | 0% | 593 | 2,705 | +356% | 0 | 0 | — |
case-20 | pass→pass | 6,569 | 5,562 | -15% | 1 | 1 | 0% | 1,260 | 3,283 | +161% | 0 | 0 | — |
case-21 | pass→pass | 4,317 | 3,444 | -20% | 1 | 1 | 0% | 855 | 2,815 | +229% | 0 | 0 | — |
case-22 | pass→pass | 10,950 | 6,882 | -37% | 1 | 1 | 0% | 2,321 | 3,564 | +54% | 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. 22 cases were attempted. The headline lift of +9 percentage points is the difference between those two pass rates over the 22 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/24/2026 | +9% |
Other measured skills in the registry, with their headline benchmark lift.