Mercurial > repos > peterjc > mira_assembler
diff tools/sr_assembly/mira.py @ 4:117cce3296af
Uploaded wrapper v0.0.3, which is for MIRA v3.4.x which includes support for Ion Torrent.
The Galaxy wrapper will no longer work with MIRA v3.2.x - if you are still using the old version of MIRA, please continue to use v0.0.2 of the wrapper.
author | peterjc |
---|---|
date | Wed, 21 Dec 2011 11:33:19 -0500 |
parents | 298f5c1d9521 |
children | 3e7eca1f5d04 |
line wrap: on
line diff
--- a/tools/sr_assembly/mira.py Tue Jun 21 09:50:32 2011 -0400 +++ b/tools/sr_assembly/mira.py Wed Dec 21 11:33:19 2011 -0500 @@ -11,24 +11,6 @@ sys.stderr.write(msg+"\n") sys.exit(err) -def tcs_to_tabular(old, new): - in_handle = open(old, "rU") - out_handle = open(new, "w") - assert in_handle.readline() == "#TCS V1.0\n" - assert in_handle.readline() == "#\n" - assert in_handle.readline() == "# contig name padPos upadPos | B Q | tcov covA covC covG covT cov* | qA qC qG qT q* | S | Tags\n" - assert in_handle.readline() == "#\n" - out_handle.write("#%s\n" % "\t".join(["contig", "pasPos", "upadPos", "B", "Q", - "tcov", "covA", "covC", "covG", "covT", "cov*", - "qA", "qC", "qG", "qT", "q*", "S", "Tags"])) - for line in in_handle: - parts = line.rstrip("\n").split(None,22) - assert parts[3] == parts[6] == parts[13] == parts[19] == parts[21] == "|" - wanted = parts[:3] + parts[4:6]+parts[7:13]+parts[14:19]+parts[20:21]+parts[22:] - out_handle.write("%s\n" % "\t".join(wanted)) - out_handle.close() - in_handle.close() - def collect_output(temp, name): n3 = (temp, name, name, name) f = "%s/%s_assembly/%s_d_results" % (temp, name, name) @@ -36,16 +18,18 @@ stop_err("Missing output folder") if not os.listdir(f): stop_err("Empty output folder") + missing = [] for old, new in [("%s/%s_out.unpadded.fasta" % (f, name), out_fasta), ("%s/%s_out.unpadded.fasta.qual" % (f, name), out_qual), ("%s/%s_out.wig" % (f, name), out_wig), ("%s/%s_out.caf" % (f, name), out_caf), ("%s/%s_out.ace" % (f, name), out_ace)]: if not os.path.isfile(old): - stop_err("Missing %s output file" % os.path.splitext(old)[-1]) + missing.append(os.path.splitext(old)[-1]) else: shutil.move(old, new) - tcs_to_tabular("%s/%s_assembly/%s_d_results/%s_out.tcs" % n3, out_tcs) + if missing: + stop_err("Missing output files: %s" % ", ".join(missing)) def clean_up(temp, name): folder = "%s/%s_assembly" % (temp, name) @@ -56,14 +40,15 @@ #Currently Galaxy puts us somewhere safe like: #/opt/galaxy-dist/database/job_working_directory/846/ temp = "." -name, out_fasta, out_qual, out_tcs, out_ace, out_caf, out_wig, out_log = sys.argv[1:9] +name, out_fasta, out_qual, out_ace, out_caf, out_wig, out_log = sys.argv[1:8] start_time = time.time() -cmd = " ".join(sys.argv[9:]) +cmd_list =sys.argv[8:] +cmd = " ".join(cmd_list) assert os.path.isdir(temp) d = "%s_assembly" % name -assert not os.path.isdir(d) +assert not os.path.isdir(d), "Path %s already exists" % d try: #Check path access os.mkdir(d) @@ -77,7 +62,7 @@ handle = open(out_log, "w") try: #Run MIRA - child = subprocess.Popen(sys.argv[9:], + child = subprocess.Popen(cmd_list, stdout=handle, stderr=subprocess.STDOUT) except Exception, err: @@ -102,6 +87,10 @@ return_code) handle.close() +#print "Collecting output..." collect_output(temp, name) + +#print "Cleaning up..." clean_up(temp, name) + print "Done"