This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to pass multiple "argument value" pair using variable in GATK command?

Hii,

I have to call genotype for multiple samples using joint genotyping methedology of GATK best practices, So I made a shell script which take list of samples in a text file as an input, and script through all commands on each sample one by one up to GVCF step. After generating GVCF for each sample, I want to call joint genotype using following command:

java -jar GenomeAnalysisTK.jar -T GenotypeGVCFs -R hg19.fa -V sample1.g.vcf -V sample2.g.vcf [.. -V sampleN.g.vcf] -o rawVariants.vcf

So I pass "-V sample1.g.vcf -V sample2.g.vcf -V sampleN.g.vcf" as a variable like below:

V="-V sample1.g.vcf -V sample2.g.vcf .. -V sampleN.g.vcf"

java -jar GenomeAnalysisTK.jar -T GenotypeGVCFs -R hg19.fa `echo $V` -o rawVariants.vcf

OR

java -jar GenomeAnalysisTK.jar -T GenotypeGVCFs -R hg19.fa $V -o rawVariants.vcf

I got "ERROR MESSAGE: Invalid argument value '-V sample1.g.vcf -V sample2.g.vcf .. -V sampleN.g.vcf'. As the command is considering $V variable as a single argument.

Please provide me some way to pass '-V sample1.g.vcf -V sample2.g.vcf .. -V sampleN.g.vcf' to the GATK command in shell script.

Thanks in advance!

software error snp next-gen variant calling gatk

1 answer

Use a list with the '.list' suffix

echo "sample1.g.vcf" > my.list
echo "sample2.g.vcf" >> my.list
echo "sample3.g.vcf" >> my.list
echo "sampleN.g.vcf" >> my.list

and then

java -jar GenomeAnalysisTK.jar -T GenotypeGVCFs -R hg19.fa -V my.list -o rawVariants.vcf

Thank you so much Pierre Lindenbaum, It works! You saved my lots of time.

I am using list as well, but this is not workin for me... /usr/bin/bash: -c: line 0: syntax error near unexpected token `newline'

Log in to answer this question.