diff --git a/test/integration/test_intrahost.py b/test/integration/test_intrahost.py index 481cac256..c98d36ba9 100644 --- a/test/integration/test_intrahost.py +++ b/test/integration/test_intrahost.py @@ -100,7 +100,7 @@ class TestSnpEff(TestCaseWithTmp): def capsys(self, capsys): self.capsys = capsys - @unittest.skipIf(True, "test is marked to be skipped") + #@unittest.skipIf(True, "test is marked to be skipped") def test_snpeff(self): temp_dir = tempfile.gettempdir() input_dir = util.file.get_test_input_path(self) diff --git a/tools/snpeff.py b/tools/snpeff.py index 186f297ff..da14dff65 100644 --- a/tools/snpeff.py +++ b/tools/snpeff.py @@ -43,7 +43,7 @@ def __init__(self, install_methods=None, extra_genomes=None): def version(self): return "4.1" - def execute(self, command, args, JVMmemory=None, stdin=None, stdout=None): # pylint: disable=W0221 + def execute(self, command, args, JVMmemory=None, stdin=None, stdout=None, stderr=None): # pylint: disable=W0221 if not JVMmemory: JVMmemory = self.jvmMemDefault @@ -59,7 +59,7 @@ def execute(self, command, args, JVMmemory=None, stdin=None, stdout=None): # ] + args _log.debug(' '.join(tool_cmd)) - return util.misc.run_and_print(tool_cmd, stdin=stdin, buffered=True, silent=("databases" in command), check=True) + return util.misc.run_and_print(tool_cmd, stdin=stdin, stderr=stderr, buffered=True, silent=("databases" in command), check=True) def has_genome(self, genome): if not self.known_dbs: @@ -109,7 +109,9 @@ def create_db(self, accessions, emailAddress=None, JVMmemory=None): self.execute('build', args, JVMmemory=JVMmemory) def available_databases(self): - command_ps = self.execute("databases", args=[]) + # do not capture stderr, since snpEff writes 'Picked up _JAVA_OPTIONS' + # which is not helpful for reading the stdout of the databases command + command_ps = self.execute("databases", args=[], stderr=subprocess.DEVNULL) split_points = [] keys = ['Genome', 'Organism', 'Status', 'Bundle', 'Database'] diff --git a/util/misc.py b/util/misc.py index 0716879af..eb20a6813 100644 --- a/util/misc.py +++ b/util/misc.py @@ -229,6 +229,9 @@ def run_and_print(args, stdout=None, stderr=None, This is useful for nose, which has difficulty capturing stdout of subprocess invocations. ''' + + stderr = stderr or subprocess.STDOUT + if loglevel: silent = False if not buffered: @@ -238,7 +241,7 @@ def run_and_print(args, stdout=None, stderr=None, args, stdin=stdin, stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, + stderr=stderr, env=env, cwd=cwd, timeout=timeout, @@ -268,7 +271,7 @@ def run_and_print(args, stdout=None, stderr=None, raise(e) else: result = run(args, stdin=stdin, stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, env=env, cwd=cwd, + stderr=stderr, env=env, cwd=cwd, timeout=timeout, check=check) if not silent and not loglevel: print(result.stdout.decode('utf-8')) @@ -281,7 +284,7 @@ def run_and_print(args, stdout=None, stderr=None, 'CompletedProcess', ['args', 'returncode', 'stdout', 'stderr']) process = subprocess.Popen(args, stdin=stdin, stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, env=env, + stderr=stderr, env=env, cwd=cwd) output = [] while process.poll() is None: