1
$\begingroup$

I am trying to use GATK IndexFeatureFile to create ".vcf.gz.tbi" file. But I have 480 files.

For the pilot study I used:

!./gatk IndexFeatureFile -I HG00096.chrom22.bam.10061.vcf.gz -O HG00096.chrom22.bam.10061.vcf.gz.tbi

Doing this procedure for 480 files is not seem very practical. Is there any way to use all file as an input and it takes all files and gives ".tbi" files as an output?

I thought

!./gatk IndexFeatureFile -I *.vcf.gz -O *.vcf.gz.tbi

or maybe not using output argument (just input). I did not worked for me.

$\endgroup$

1 Answer 1

2
$\begingroup$

You could run loop over the files in your shell, running a separate command for each file. For example, in Bash (or another Bourne shell):

for file in *.vcf.gz; do ./gatk IndexFeatureFile -I ${file} -O ${file}.tbi; done
$\endgroup$
2
  • $\begingroup$ Is this approach also valid for merging vcf files? Because, normally I am using bcftools for merging. For example for 3 vcf files I use this: bcftools merge HG00096.chrom22.bam.10061.vcf.gz HG00097.chrom22.bam.10062.vcf.gz HG00101.chrom22.bam.10065.vcf.gz -o merged.vcf $\endgroup$ Commented Mar 22, 2021 at 19:22
  • $\begingroup$ In the case of bcftools merge, I guess looping shouldn't be necessary since you can merge them with one command: bcftools merge -O z -o merged.vcf.gz HG*.vcf.gz $\endgroup$ Commented Mar 22, 2021 at 20:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.