Hello,
I am in need to convert vcf to fasta. Previous topics did not seem to resolve this type of problem

I have this code, but when trying to do bgzip and tabix commands, i afterwards get error like "the input file is not BGZF" and "Broken VCF header, no column names?"
Any help will be appreciated

#!bin/bash
module load bio/vcftools/0.1.17
module load bio/samtools/1.10

export inpath=/dir

export outpath=/dir
mkdir -p $outpath
chmod u+rwx $outpath
export reference=/ref
$reference
for file in $inpath/* ;
do
bname=$(basename $file)
echo "base name is $bname"
bfile=$outpath/$bname".bgz"
tabfile=$outpath/$bname".tabix"
outfile=$outpath/$bname".fasta"
bgzip $file $bfile
cd $outpath
tabix -f $bfile > $tabfile
cat $reference | vcf-consensus $tabfile > $outfile
done



Source link