Collections are now automatically normalized on both read and write. Tests updated.
[arvados.git] / crunch_scripts / arvados_picard.py
1 import arvados
2 import re
3 import os
4 import sys
5 import fcntl
6 import subprocess
7
8 picard_install_path = None
9
10 def install_path():
11     global picard_install_path
12     if picard_install_path:
13         return picard_install_path
14     zipball = arvados.current_job()['script_parameters']['picard_zip']
15     extracted = arvados.util.zipball_extract(
16         zipball = zipball,
17         path = 'picard')
18     for f in os.listdir(extracted):
19         if (re.search(r'^picard-tools-[\d\.]+$', f) and
20             os.path.exists(os.path.join(extracted, f, '.'))):
21             picard_install_path = os.path.join(extracted, f)
22             break
23     if not picard_install_path:
24         raise Exception("picard-tools-{version} directory not found in %s" %
25                         zipball)
26     return picard_install_path
27
28 def run(module, **kwargs):
29     kwargs.setdefault('cwd', arvados.current_task().tmpdir)
30     execargs = ['java',
31                 '-Xmx1500m',
32                 '-Djava.io.tmpdir=' + arvados.current_task().tmpdir,
33                 '-jar', os.path.join(install_path(), module + '.jar')]
34     execargs += [str(arg) for arg in kwargs.pop('args', [])]
35     for key, value in kwargs.pop('params', {}).items():
36         execargs += [key.upper() + '=' + str(value)]
37     sys.stderr.write("%s.run: exec %s\n" % (__name__, str(execargs)))
38     return arvados.util.run_command(execargs, **kwargs)