4363: Accept manifest_text in a non-UTF-8 encoding that is equal to its UTF-8 encoding.
[arvados.git] / crunch_scripts / split-fastq.py
index be37f043f3859c715f1cfa668173bb2246b7da10..17aabf2930393a48d3539483d5198cab5af35631 100755 (executable)
@@ -94,7 +94,7 @@ prog = re.compile(r'(.*?)(_[12])?\.fastq(\.gz)?$')
 for s in inp.all_streams():
     for f in s.all_files():
         name_pieces = prog.match(f.name())
-        if name_pieces != None:
+        if name_pieces is not None:
             if s.name() != ".":
                 # The downstream tool (run-command) only iterates over the top
                 # level of directories so if there are fastq files in
@@ -105,7 +105,7 @@ for s in inp.all_streams():
                 sys.exit(1)
 
             p = None
-            if name_pieces.group(2) != None:
+            if name_pieces.group(2) is not None:
                 if name_pieces.group(2) == "_1":
                     p = [{}, {}]
                     p[0]["reader"] = s.files()[name_pieces.group(0)]
@@ -114,15 +114,16 @@ for s in inp.all_streams():
                 p = [{}]
                 p[0]["reader"] = s.files()[name_pieces.group(0)]
 
-            if p != None:
+            if p is not None:
                 if chunking:
                     splitfastq(p)
                 else:
                     for i in xrange(0, len(p)):
-                        m = p[i]["reader"].as_manifest()[1:]
-                        manifest_list.append(["./_" + str(piece), m[:-1]])
+                        m = p[i]["reader"].as_manifest().split()
+                        m[0] = "./_" + str(piece)
+                        manifest_list.append(m)
                     piece += 1
 
-manifest_text = "\n".join(" ".join(m) for m in manifest_list)
+manifest_text = "\n".join(" ".join(m) for m in manifest_list) + "\n"
 
 arvados.current_task().set_output(manifest_text)