This is a test version of Biostars. For the public version, visit https://www.biostars.org.
bcftools subset by ids stored in a unix variable

I have been trying to subset a vcf by ids stored in a variable, is this even possible

IFS=
ids=$(bcftools query -f '%ID\n' my.vcf)
bcftools view -i "ID=@${ids}" my_other_vcf

error I get: -bash: /usr/local/bin/bcftools: Argument list too long`

what am I missing here? I realize this is probably more of a bash question sorry

bcftools

1 answer

I think you want:

bcftools query -f '%ID\n' my.vcf > ids.txt
bcftools view -i "ID=@ids.txt" my_other_vcf

Thanks I knew that would work I was just wondering if there is a way to store the values in a variable and avoid the temporary file

Log in to answer this question.