8 api = arvados.api('v1')
13 # Look for paired reads
15 inp = arvados.CollectionReader(arvados.getjobparam('reads'))
19 def nextline(reader, start):
22 r = reader.readfrom(start, 128)
25 n = string.find(r, "\n")
32 prog = re.compile(r'(.*?)(_[12])?\.fastq(\.gz)?$')
34 # Look for fastq files
35 for s in inp.all_streams():
36 for f in s.all_files():
37 name_pieces = prog.match(f.name())
38 if name_pieces is not None:
40 # The downstream tool (run-command) only iterates over the top
41 # level of directories so if there are fastq files in
42 # directories in the input, the choice is either to forget
43 # there are directories (which might lead to name conflicts) or
45 print >>sys.stderr, "fastq must be at the root of the collection"
49 if name_pieces.group(2) is not None:
50 if name_pieces.group(2) == "_1":
52 p[0]["reader"] = s.files()[name_pieces.group(0)]
53 p[1]["reader"] = s.files()[name_pieces.group(1) + "_2.fastq" + (name_pieces.group(3) if name_pieces.group(3) else '')]
56 p[0]["reader"] = s.files()[name_pieces.group(0)]
59 for i in xrange(0, len(p)):
60 m = p[i]["reader"].as_manifest().split()
61 m[0] = "./_" + str(piece)
62 manifest_list.append(m)
65 manifest_text = "\n".join(" ".join(m) for m in manifest_list) + "\n"
67 arvados.current_task().set_output(manifest_text)