This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Grep VCF position awk

Hi all, I need to grep positions from vcf files to make another vcf file so I used this command

less output.VCF|awk '{OFS="\t"; if ($2 >= 1166 && $2 <= 80082 ){ print }}' |grep -w "^scaffold329" > scaffold329_116-80082.vcf

But it is taking a long time to grep. Is there any way to speed up this task ?

awk vcf grep

Please use dedicated tools such as tabix to handle defined formats.

1 answer

Following-up on the advise of cpad0112

bgzip output.VCF
tabix -p vcf output.VCF.gz
tabix -h output.VCF.gz scaffold329:1166-80082 > scaffold329_116-80082.vcf

Log in to answer this question.