Mercurial > repos > jdv > scrappie
comparison scrappie_raw.py @ 0:30c2b84b4117 draft
planemo upload for repository https://github.com/jvolkening/galaxy-tools/tree/master/tools/scrappie commit bf5788ad5a3293446a50a3246b44ba09174c9b71
| author | jdv |
|---|---|
| date | Wed, 30 Aug 2017 02:55:35 -0400 |
| parents | |
| children | 632c50fe83ba |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:30c2b84b4117 |
|---|---|
| 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 with open(out_file, "w") as outfile: | |
| 18 subprocess.call(["scrappie", | |
| 19 "raw", | |
| 20 "--threads", threads, | |
| 21 "--outformat", "fasta", | |
| 22 "in_dir" ], | |
| 23 stdout=outfile ) | |
| 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 for f in files: | |
| 42 shutil.copy(f, in_dir) | |
| 43 | |
| 44 except OSError as e: | |
| 45 print("Unexpected error:", e.strerror) | |
| 46 raise | |
| 47 | |
| 48 except: | |
| 49 print("Unexpected error:", sys.exc_info()[0]) | |
| 50 raise | |
| 51 | |
| 52 if __name__ == "__main__" : | |
| 53 main() |
