changeset 4:8a9f61d08201 draft

planemo upload for repository https://github.com/jvolkening/galaxy-tools/tree/master/tools/albacore commit 9a7fa5134243f712595bef72121b8006be8a318b
author jdv
date Fri, 13 Oct 2017 16:13:22 -0400
parents d561e3f9ccbb
children 4d72adba794f
files albacore_1D.py
diffstat 1 files changed, 18 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/albacore_1D.py	Tue Oct 03 20:12:09 2017 -0400
+++ b/albacore_1D.py	Fri Oct 13 16:13:22 2017 -0400
@@ -31,12 +31,16 @@
         "--reads_per_fastq_batch", "999999999" ] +
         ["--barcoding"] * demux )
 
+    out_path = "out_dir/workspace"
+    pass_path = os.path.join( out_path, "pass" )
+    if os.path.exists( pass_path ):
+        out_path = pass_path
     if demux:
         #check for demuxed albacore output and copy to Galaxy output
         final_dir = "final"
         if not os.path.exists(final_dir):
             os.makedirs(final_dir)
-        dirs = glob.glob("out_dir/workspace/*")
+        dirs = glob.glob( os.path.join(out_path, "*") )
         for d in dirs:
 
             if out_fmt == 'fastq':
@@ -51,11 +55,16 @@
                 shutil.copy(found_file, out)
 
             elif out_fmt == 'fast5':
-                bc = os.path.basename( os.path.normpath( d ) ) + ".fast5.tar.gz"
-                print(d)
-                print(bc)
+                if (os.path.isfile(d)):
+                    if (d.endswith('.fast5')):
+                        bc = os.path.basename( os.path.normpath(d) ) + ".tar.gz"
+                        files = [d]
+                    else:
+                        continue
+                else:
+                    bc = os.path.basename( os.path.normpath( d ) ) + ".fast5.tar.gz"
+                    files = glob.glob( os.path.join( d, "**", "*.fast5"), recursive=True)
                 out = os.path.join( final_dir, bc )
-                files = glob.glob( os.path.join( d, "**", "*.fast5"), recursive=True)
                 if len(files) < 1:
                     raise ValueError('No FAST5 output files found')
                 tar = tarfile.open(out, 'w:gz')
@@ -68,18 +77,18 @@
     else:
         if out_fmt == 'fastq':
             #check for single albacore output and copy to Galaxy output
-            files = glob.glob("out_dir/workspace/*.fastq")
+            files = glob.glob( os.path.join(out_path, "*.fastq") )
             if len(files) != 1:
                 raise ValueError('No or multiple FASTQ output files found')
             found_file = files[0]
             shutil.copy(found_file, out_file)
         elif out_fmt == 'fast5':
             #check for single albacore output and copy to Galaxy output
-            files = glob.glob("out_dir/workspace/**/*.fast5", recursive=True)
+            files = glob.glob( os.path.join(out_path,"**","*.fast5"), recursive=True )
             if len(files) < 1:
                 raise ValueError('No FAST5 output files found')
             tar = tarfile.open(out_file, 'w:gz')
-            tar.add("out_dir/workspace")
+            tar.add(out_path)
             tar.close()
         else:
             raise ValueError('Bad output format specified')
@@ -97,6 +106,7 @@
         # default, so it's easier/safer here just to call the system tar
         subprocess.call([
             "tar",
+            "--warning=no-unknown-keyword",
             "-xf",
             fn,
             "-C",