Hi- I'm filtering a VCF file with bcftools view
according the a FORMAT field with two items. How can I access the n-th item in the m-th sample?
For example, given this vcf file:
##fileformat=VCFv4.0
...
##FORMAT=<ID=AD,Number=2,Type=Integer,Description="Allele depth">
#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT normal tumour
chr1 14397 . CTGT C . PASS SVTYPE=DEL GT:AD 0/0:9,1 0/0:29,4
The AD tag has two elements which in the first sample are "9,1". I want to filter records where the second item in the first sample is greater than something (say 3). I thought this should work and it should exclude the record above because 1 < 3, but it doesn't:
bcftools view -i 'AD[0][1] > 3' recs.vcf # Access AD in first sample, second element
Is this possible at all with bcftools?
Thanks
Hi Kevin, thanks for replying (+1).
Actually, I would argue the opposite. I try to avoid parsing VCF records as raw strings as they are quite complex and it's easy to overlook some details. Since bcftools seems well tried and tested I'd use that instead.