This source did not publish a separate summary. Review SKILL.md before using the skill.
SKILL.md
Version Compatibility
Reference examples tested with: bcftools 1.19+
Before using code patterns, verify installed versions match. If versions differ:
Python: pip show <package> then help(module.function) to check signatures
CLI: <tool> --version then <tool> --help to confirm flags
If code throws ImportError, AttributeError, or TypeError, introspect the installed
package and adapt the example to match the actual API rather than retrying.
Variant Annotation
Tool Comparison
Tool
Best For
Speed
Output
bcftools csq
Simple consequence prediction
Fast
VCF
VEP
Comprehensive with plugins
Moderate
VCF/TXT
SnpEff
Fast batch annotation
Fast
VCF
ANNOVAR
Flexible databases
Moderate
TXT
bcftools annotate
Goal: Add or remove INFO/ID annotations from external databases using bcftools.
Approach: Match variants by position and allele against annotation VCF/BED/TAB files, copying specified columns.
"Add rsIDs to my VCF from dbSNP" → Match variant positions against a database and copy identifiers or annotation fields into the VCF.
Add Annotations from Database
bcftools annotate -a dbsnp.vcf.gz -c ID input.vcf.gz -Oz -o annotated.vcf.gz
Annotation Columns (-c)
Option
Description
ID
Copy ID column
INFO
Copy all INFO fields
INFO/TAG
Copy specific INFO field
+INFO/TAG
Add to existing values
Add rsIDs from dbSNP
bcftools annotate -a dbsnp.vcf.gz -c ID input.vcf.gz -Oz -o with_rsids.vcf.gz
Add Multiple Annotations
bcftools annotate -a database.vcf.gz -c ID,INFO/AF,INFO/CAF input.vcf.gz -Oz -o annotated.vcf.gz
Add from BED/TAB Files
# BED with 4th column as annotation
bcftools annotate -a regions.bed.gz -c CHROM,FROM,TO,INFO/REGION \
-h <(echo '##INFO=<ID=REGION,Number=1,Type=String,Description="Region name">') \
input.vcf.gz -Oz -o annotated.vcf.gz
# Tab file: CHROM POS VALUE
bcftools annotate -a annotations.tab.gz -c CHROM,POS,INFO/SCORE \
-h <(echo '##INFO=<ID=SCORE,Number=1,Type=Float,Description="Custom score">') \
input.vcf.gz -Oz -o annotated.vcf.gz
Remove Annotations
bcftools annotate -x INFO/DP,INFO/MQ input.vcf.gz -Oz -o clean.vcf.gz
bcftools annotate -x INFO input.vcf.gz -Oz -o minimal.vcf.gz # Remove all INFO
Goal: Annotate variants comprehensively with consequence, impact, pathogenicity scores, and population frequencies.
Approach: Run VEP with offline cache, enabling SIFT, PolyPhen, HGVS, frequency, and plugin-based predictions.
"Annotate my variants with functional consequences" → Predict coding effects, impact severity, and pathogenicity using Ensembl's Variant Effect Predictor.
Goal: Extract and interpret annotation fields from VEP CSQ or SnpEff ANN strings in Python.
Approach: Parse pipe-delimited annotation strings against the header-defined field order, then filter by impact or consequence.
Parse VEP CSQ
from cyvcf2 import VCF
def parse_vep_csq(csq_string, csq_header):
fields = csq_header.split('|')
values = csq_string.split('|')
return dict(zip(fields, values))
vcf = VCF('vep_output.vcf')
csq_header = None
for h in vcf.header_iter():
if h['HeaderType'] == 'INFO' and h['ID'] == 'CSQ':
csq_header = h['Description'].split('Format: ')[1].rstrip('"')
break
for variant in vcf:
csq = variant.INFO.get('CSQ')
if csq:
for transcript in csq.split(','):
parsed = parse_vep_csq(transcript, csq_header)
if parsed.get('IMPACT') in ('HIGH', 'MODERATE'):
print(f"{variant.CHROM}:{variant.POS} {parsed['SYMBOL']} {parsed['Consequence']}")
Parse SnpEff ANN
from cyvcf2 import VCF
def parse_snpeff_ann(ann_string):
fields = ['Allele', 'Annotation', 'Impact', 'Gene_Name', 'Gene_ID',
'Feature_Type', 'Feature_ID', 'Transcript_BioType', 'Rank',
'HGVS_c', 'HGVS_p', 'cDNA_pos', 'CDS_pos', 'Protein_pos', 'Distance']
values = ann_string.split('|')
return dict(zip(fields, values[:len(fields)]))
for variant in VCF('snpeff_output.vcf'):
ann = variant.INFO.get('ANN')
if ann:
for transcript in ann.split(','):
parsed = parse_snpeff_ann(transcript)
if parsed['Impact'] == 'HIGH':
print(f"{variant.CHROM}:{variant.POS} {parsed['Gene_Name']} {parsed['Annotation']}")
Complete Annotation Pipeline
Goal: Run a full annotation workflow from normalization through VEP annotation to impact filtering.
Approach: Normalize variants, annotate with VEP (--everything --pick), then filter for HIGH/MODERATE impact.