I have found SelectVariants really useful to cull out homozygous calls from my vcf file, especially using the variant context JEXL expressions. However, since I have many VCF files, I like to automate using a bash script. The following is my bash script:
for file in .vcf; do\
java -jar <path_to_gatk/GenomeAnalysisTK.jar> -T SelectVariants -R < path_to_reference.fa> -V $file\
-select 'vc.getGenotype("${file%.f}").isHet()' -o ${file%.*}_out.vcf; done
It fails with the following error message:
ERROR MESSAGE: Invalid JEXL expression detected for select-0 with message ![30,37]: 'vc.getGenotype('${file%.f*}').isHet();' attempting to call method on null
I understand the error message, clearly the JEXL expression "vc.getGenotype()" is expecting a real sample ID and the bash parameter substitution isn't working. I have no problems passing sample IDs if I run SelectVariants on an individual VCF files and I have done that many times. However if I have to automate, do you have suggestions about how I can pass the appropriate sample IDs from within each VCF file during every cycle of the bash script? I think it amounts to passing a bash parameter substitution to a JEXL expression, Is this possible?