Mercurial > repos > jdv > nanopolish
comparison nanopolish_extract.py @ 0:2136c2725fc4 draft
planemo upload for repository https://github.com/jvolkening/galaxy-tools/tree/master/tools/nanopolish commit 0206b7bd377b39ad28592b0a02588f40575efd3e-dirty
author | jdv |
---|---|
date | Wed, 06 Sep 2017 12:15:45 -0400 |
parents | |
children | e4b6d4a53f2e |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:2136c2725fc4 |
---|---|
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] # currently unused | |
15 | |
16 extract_fast5(tar_file) | |
17 | |
18 subprocess.call(["nanopolish", | |
19 "extract", | |
20 "--recurse", | |
21 "--fastq", | |
22 "--output", out_file, | |
23 "in_dir" ]) | |
24 | |
25 def extract_fast5(fn): | |
26 | |
27 try: | |
28 in_dir = "in_dir" | |
29 if not os.path.exists(in_dir): | |
30 os.makedirs(in_dir) | |
31 | |
32 tar = tarfile.open(fn, mode='r') | |
33 tar.extractall(path=in_dir) | |
34 | |
35 files = glob.glob( | |
36 os.path.join(in_dir, "**", "*.fast5"), | |
37 recursive=True | |
38 ) | |
39 if len(files) < 1: | |
40 raise ValueError('No FAST5 files found') | |
41 | |
42 except OSError as e: | |
43 print("Unexpected error:", e.strerror) | |
44 raise | |
45 | |
46 except: | |
47 print("Unexpected error:", sys.exc_info()[0]) | |
48 raise | |
49 | |
50 if __name__ == "__main__" : | |
51 main() |