comparison nanonet_1D.py @ 0:decd5688d719 draft

planemo upload for repository https://github.com/jvolkening/galaxy-tools/tree/master/tools/nanonet commit bf5788ad5a3293446a50a3246b44ba09174c9b71
author jdv
date Wed, 30 Aug 2017 02:53:02 -0400
parents
children 3f35881c2e25
comparison
equal deleted inserted replaced
-1:000000000000 0:decd5688d719
1 #!/usr/bin/env python3
2
3 import sys, os
4 import glob
5 import tarfile
6 import subprocess
7 import shutil
8 import h5py
9 import numpy as np
10
11 def main():
12 tar_file = sys.argv[1]
13 out_file = sys.argv[2]
14 threads = sys.argv[3]
15
16 extract_fast5(tar_file)
17
18 subprocess.call(["nanonetcall",
19 "--jobs", threads,
20 "--fastq",
21 "--output", out_file,
22 "in_dir" ])
23
24 def extract_fast5(fn):
25
26 try:
27 in_dir = "in_dir"
28 if not os.path.exists(in_dir):
29 os.makedirs(in_dir)
30
31 tar = tarfile.open(fn, mode='r')
32 tar.extractall(path=in_dir)
33
34 files = glob.glob(
35 os.path.join(in_dir, "**", "*.fast5"),
36 recursive=True
37 )
38 if len(files) < 1:
39 raise ValueError('No FAST5 files found')
40 for f in files:
41 shutil.copy(f, in_dir)
42
43 except OSError as e:
44 print("Unexpected error:", e.strerror)
45 raise
46
47 except:
48 print("Unexpected error:", sys.exc_info()[0])
49 raise
50
51 if __name__ == "__main__" :
52 main()