0

Here is the code that gets the VCF file from a specific region using tabix and then filters it for specific (european) population using 'keep' option from vcftools.

####select specific population
if [ "$POP_FILE" != "" ]; then
    vcftools --vcf temp.vcf --keep $POP_FILE --recode --recode-INFO-all > temp2.vcf 2> /dev/null
else
    cp -f temp.vcf temp2.vcf    
fi

PROBLEM: it creates the recode.vcf file but then the redirection is not happening as the temp2 file is empty

Timur Shtatland
  • 12,024
  • 2
  • 30
  • 47
MrMsarguru
  • 125
  • 1
  • 1
  • 10

1 Answers1

1

I would avoid vcftools and use bcftools (https://github.com/samtools/bcftools) instead:

if [ "$POP_FILE" != "" ]; then
  bcftools view temp.vcf -S $POP_FILE -o temp2.vcf
else
  cp -f temp.vcf temp2.vcf
fi

To install bcftools:

git clone --branch=develop git://github.com/samtools/bcftools.git
git clone --branch=develop git://github.com/samtools/htslib.git
cd htslib && make && cd ..
cd bcftools && make && cd ..
sudo cp bcftools/bcftools /usr/local/bin/
Giulio Genovese
  • 2,761
  • 1
  • 15
  • 12