To loop over FORMAT fields, you need the square brackets, so:

bcftools query -f '%CHROM\t%POS\t%REF\t%ALT[\t%DPR\t%DP4]\n' results.vcf 

Shane


On 29 Oct 2014, at 19:28, Thomas W. Blackwell wrote:

> 
> The manpage for bcftools annotate -c suggests trying something like:
> 
> bcftools query -f'%CHROM\t%POS\t%REF\t%ALT\t%FORMAT/DPR\t%FORMAT/DP4\n' 
> results.vcf | head
> 
> Don't know where else in the manpage this appears.
> 
>                                               -  tom blackwell  -
> 
> On Wed, 29 Oct 2014, jbr950 wrote:
> 
>> Hello,
>>   I'd like to avoid writing my own parser, using stock 'bcftools query'
>> for its intended purpose instead.
>> 
>> I need to extract the DP4 field, and the command I'm issuing is not
>> including it:
>> 
>> First I check that DP4 is actually present in my vcf:
>> 
>> grep "<X" results.vcf | head -2
>> 1 10397540  . T <X>     0  .
>> DP=15;I16=11,4,0,0,535,19161,0,0,300,6000,0,0,238,4626,0,0;QS=1,0;MQSB=1;MQ0F=0;DPR=15,0
>>      PL:DP4:DPR      0,45,146:11,4,0,0:15,0
>> 1 10397541  . G <X>     0  .
>> DP=15;I16=11,4,0,0,514,17700,0,0,300,6000,0,0,235,4541,0,0;QS=1,0;MQSB=1;MQ0F=0;DPR=15,0
>>      PL:DP4:DPR      0,45,146:11,4,0,0:15,0
>> 
>> 
>> 
>> Then I try bcftools query:
>> $bcftools_htslib_path/bcftools query
>> -f'%CHROM\t%POS\t%REF\t%ALT\t%DPR\t%DP4\n' results.vcf | head
>> 1 10397540  T <X>       15,0    .
>> 1 10397541  G <X>       15,0    .
>> 1 10397542  C <X>       15,0    .
>> 1 10397543  A <X>       15,0    .
>> 1 10397544  G <X>       15,0    .
>> 1 10397545  G <X>       15,0    .
>> 1 10397546  C <X>       15,0    .
>> 1 10397547  C <X>       16,0    .
>> 1 10397548  A <X>       17,0    .
>> 1 10397549  G <X>       17,0    .
>> 
>> 
>> Is there a way to adjust my command, or is this a bug?
>> 
>> Best,
>> Jonathan
>> 
> 
> ------------------------------------------------------------------------------
> _______________________________________________
> Samtools-help mailing list
> Samtools-help@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/samtools-help



-- 
 The Wellcome Trust Sanger Institute is operated by Genome Research 
 Limited, a charity registered in England with number 1021457 and a 
 company registered in England with number 2742969, whose registered 
 office is 215 Euston Road, London, NW1 2BE. 

------------------------------------------------------------------------------
_______________________________________________
Samtools-help mailing list
Samtools-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/samtools-help

Reply via email to