Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More robust determination of GATK version #1004

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion pipes/WDL/workflows/tasks/tasks_assembly.wdl
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ task refine_2x_and_plot {
if [[ ${gatk_jar} == *.tar.bz2 ]]; then
tar -xjvof ${gatk_jar} -C gatk
# find the jar and move it one level up if it is buried in a subdir
find gatk -mindepth 1 -type f -iname '*.jar' | xargs -I__ mv -f "__" gatk/
find gatk -mindepth 2 -type f -iname '*.jar' | xargs -I__ mv -f "__" gatk/
else
ln -s ${gatk_jar} gatk/GenomeAnalysisTK.jar
fi
Expand Down
11 changes: 9 additions & 2 deletions tools/gatk.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import logging
import os
import os.path
import re
import subprocess
import tempfile

Expand Down Expand Up @@ -76,6 +77,11 @@ def version(self):
self._get_tool_version()
return self.tool_version

def version_tuple(self):
version_match = re.match(r'(\d+)\.(\d+)', self.version())
util.misc.chk(version_match, 'Cannot parse GATK version: {}'.format(self.version()))
return tuple(map(int, version_match.groups()))

def _get_tool_version(self):
if self.install_and_get_path().endswith(".jar"):
cmd = [
Expand All @@ -87,7 +93,8 @@ def _get_tool_version(self):
self.install_and_get_path(), '--version'
]

self.tool_version = util.misc.run_and_print(cmd, buffered=False, silent=True).stdout.decode("utf-8").strip()
self.tool_version = util.misc.run_and_print(cmd, buffered=False, silent=True,
stderr=subprocess.DEVNULL).stdout.decode("utf-8").strip()

def ug(self, inBam, refFasta, outVcf, options=None, JVMmemory=None, threads=None):
options = options or ["--min_base_quality_score", 15, "-ploidy", 4]
Expand All @@ -105,7 +112,7 @@ def ug(self, inBam, refFasta, outVcf, options=None, JVMmemory=None, threads=None
'--num_threads', threads,
'-A', 'AlleleBalance',
]
if TOOL_VERSION_TUPLE < (3, 7):
if self.version_tuple() < (3, 7):
opts += ['-stand_call_conf', 0, '-stand_emit_conf', 0] # deprecated in 3.7+

self.execute('UnifiedGenotyper', opts + options, JVMmemory=JVMmemory)
Expand Down