Test-drive the GATK tools and Best Practices pipelines on Terra


Check out this blog post to learn how you can get started with GATK and try out the pipelines in preconfigured workspaces (with a user-friendly interface!) without having to install anything.

Re:Automating SelectVariants in a script using bash parameter sustitution

SivajuSivaju AmesMember
edited December 2016 in Ask the GATK team

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?

Tagged:

Comments

  • Geraldine_VdAuweraGeraldine_VdAuwera Cambridge, MAMember, Administrator, Broadie admin
    This sounds like a matter of finding the right bash syntax, but unfortunately my bash-fu is too superficial to answer that.
  • SivajuSivaju AmesMember
    edited December 2016

    I did modify my bash syntaxes as well, in fact if I echo I get the exact command I would use if I were running it on an individual file. However when I run the program I always get a variation of the JEXL error. So i think it is a case of finding the right JEXL syntax to make it recognize the bash variables we are passing to it.

  • Geraldine_VdAuweraGeraldine_VdAuwera Cambridge, MAMember, Administrator, Broadie admin
    Fair enough; if you find a way to do it please share with the community, as we cannot provide guidance to do that. Good luck!
Sign In or Register to comment.