AndersenLab / VCF-kit

VCF-kit: Assorted utilities for the variant call format
http://www.andersenlab.org
MIT License
122 stars 25 forks source link

got an KeyError with the tajima.py #33

Closed JieGao-XTBG closed 3 years ago

JieGao-XTBG commented 3 years ago

Hi, I got an KeyError report with the tajima.py like this: Traceback (most recent call last): File "/lustre/home/gaojie/miniconda3/envs/vcf-kit/lib/python3.7/site-packages/vcfkit/tajima.py", line 148, in main() File "/lustre/home/gaojie/miniconda3/envs/vcf-kit/lib/python3.7/site-packages/vcfkit/tajima.py", line 144, in main for i in tajima(args[""]).calc_tajima(wz, sz, args["--sliding"], extra=args["--extra"]): File "/lustre/home/gaojie/miniconda3/envs/vcf-kit/lib/python3.7/site-packages/vcfkit/tajima.py", line 82, in calc_tajima AC = variant.INFO["AC"] File "cyvcf2/cyvcf2.pyx", line 2133, in cyvcf2.cyvcf2.INFO.getitem KeyError: b'AC'

Could you please tell me how to fix this. Thank you very much!

danielecook commented 3 years ago

Hi @JieGao-XTBG

VCFs normally have an AC INFO tag. I believe your VCF is missing this.

##INFO=<ID=AC,Number=A,Type=Integer,Description="Total number of alternate alleles in called genotypes">

You can calculate the AC by using the +fill-tags plugin from VCF-tools:

bcftools +fill-tags <your VCF> > out.vcf
# Then run vcf-kit