comparison albacore_1D.py @ 7:ce1fa05ffb6c draft

planemo upload for repository https://github.com/jvolkening/galaxy-tools/tree/master/tools/albacore commit 00096785a6bc71027828388a53a61b9d22fdaadf
author jdv
date Sat, 10 Mar 2018 15:43:07 -0500
parents 3870c546db18
children 3dfde840119e
comparison
equal deleted inserted replaced
6:3870c546db18 7:ce1fa05ffb6c
6 import subprocess 6 import subprocess
7 import shutil 7 import shutil
8 import h5py 8 import h5py
9 import numpy as np 9 import numpy as np
10 from distutils.util import strtobool 10 from distutils.util import strtobool
11 from tempfile import mkdtemp
11 12
12 def main(): 13 def main():
13 tar_file = sys.argv[1] 14 tar_file = sys.argv[1]
14 out_file = sys.argv[2] 15 out_file = sys.argv[2]
15 out_fmt = sys.argv[3] 16 out_fmt = sys.argv[3]
16 demux = strtobool( sys.argv[4] ) 17 demux = strtobool( sys.argv[4] )
17 threads = sys.argv[5] 18 threads = sys.argv[5]
18 19
19 (flowcell, kit) = parse_meta(tar_file) 20 tempdir = mkdtemp()
21
22 (flowcell, kit) = parse_meta(tar_file, tempdir)
20 23
21 subprocess.call( 24 subprocess.call(
22 ["read_fast5_basecaller.py", 25 ["read_fast5_basecaller.py",
23 "--input", "in_dir", 26 "--input", tempdir,
24 "--worker_threads", threads, 27 "--worker_threads", threads,
25 "--save_path", "out_dir", 28 "--save_path", "out_dir",
26 "--flowcell", flowcell, 29 "--flowcell", flowcell,
27 "--kit", kit, 30 "--kit", kit,
28 "--recursive", 31 "--recursive",
91 tar.add(out_path) 94 tar.add(out_path)
92 tar.close() 95 tar.close()
93 else: 96 else:
94 raise ValueError('Bad output format specified') 97 raise ValueError('Bad output format specified')
95 98
99 try:
100 shutil.rmtree(tempdir)
101 except:
102 print("Unable to remove temp directory:", sys.exc_info()[0])
103 raise
96 104
97 def parse_meta(fn): 105
106 def parse_meta(fn, in_dir):
98 107
99 try: 108 try:
100 in_dir = "in_dir"
101 if not os.path.exists(in_dir):
102 os.makedirs(in_dir)
103
104 # python's tarfile interface does not sanitize file paths within 109 # python's tarfile interface does not sanitize file paths within
105 # tarballs, which can be a big security risk. GNU tar does sanitize by 110 # tarballs, which can be a big security risk. GNU tar does sanitize by
106 # default, so it's easier/safer here just to call the system tar 111 # default, so it's easier/safer here just to call the system tar
107 subprocess.call([ 112 subprocess.call([
108 "tar", 113 "tar",