Mercurial > repos > peterjc > mira4_assembler
comparison tools/mira4/mira4.py @ 7:902f01c1084b draft
Uploaded v0.0.1 preview 7, with mirabait wrapper
author | peterjc |
---|---|
date | Fri, 25 Oct 2013 07:18:38 -0400 |
parents | ffefb87bd414 |
children | 302d13490b23 |
comparison
equal
deleted
inserted
replaced
6:626d5cfd01aa | 7:902f01c1084b |
---|---|
29 ver, tmp = child.communicate() | 29 ver, tmp = child.communicate() |
30 del child | 30 del child |
31 return ver.split("\n", 1)[0] | 31 return ver.split("\n", 1)[0] |
32 | 32 |
33 | 33 |
34 os.environ["PATH"] = "/mnt/galaxy/downloads/mira_4.0rc4_linux-gnu_x86_64_static/bin/:%s" % os.environ["PATH"] | 34 try: |
35 mira_binary = "mira" | 35 mira_path = os.environ["MIRA4"] |
36 except ImportError: | |
37 stop_err("Environment variable $MIRA4 not set") | |
38 mira_binary = os.path.join(mira_path, "mira") | |
39 if not os.path.isfile(mira_binary): | |
40 stop_err("Missing mira under $MIRA4, %r" % mira_binary) | |
41 | |
36 mira_ver = get_version(mira_binary) | 42 mira_ver = get_version(mira_binary) |
37 if not mira_ver.strip().startswith("4.0"): | 43 if not mira_ver.strip().startswith("4.0"): |
38 stop_err("This wrapper is for MIRA V4.0, not:\n%s" % mira_ver) | 44 stop_err("This wrapper is for MIRA V4.0, not:\n%s" % mira_ver) |
39 if "-v" in sys.argv or "--version" in sys.argv: | 45 if "-v" in sys.argv or "--version" in sys.argv: |
40 print "%s, MIRA wrapper version %s" % (mira_ver, WRAPPER_VER) | 46 print "%s, MIRA wrapper version %s" % (mira_ver, WRAPPER_VER) |
41 sys.exit(0) | 47 sys.exit(0) |
42 | 48 |
49 def fix_threads(manifest): | |
50 """Tweak the manifest to alter the number of threads.""" | |
51 try: | |
52 threads = int(os.environ.get("GALAXY_SLOTS", "1")) | |
53 except ValueError: | |
54 threads = 1 | |
55 assert 1 <= threads | |
56 if threads == 1: | |
57 #Nothing to do... | |
58 return | |
59 | |
60 handle = open(manifest) | |
61 text = handle.read() | |
62 handle.close() | |
63 | |
64 text = text.replace(" -GE:not=1 ", " -GE:not=%i " % threads) | |
65 | |
66 handle = open(manifest, "w") | |
67 handle.write(text) | |
68 handle.flush() | |
69 handle.close() | |
43 | 70 |
44 def log_manifest(manifest): | 71 def log_manifest(manifest): |
45 """Write the manifest file to stderr.""" | 72 """Write the manifest file to stderr.""" |
46 sys.stderr.write("\n%s\nManifest file\n%s\n" % ("="*60, "="*60)) | 73 sys.stderr.write("\n%s\nManifest file\n%s\n" % ("="*60, "="*60)) |
47 with open(manifest) as h: | 74 with open(manifest) as h: |
99 #/opt/galaxy-dist/database/job_working_directory/846/ | 126 #/opt/galaxy-dist/database/job_working_directory/846/ |
100 temp = "." | 127 temp = "." |
101 #name, out_fasta, out_qual, out_ace, out_caf, out_wig, out_log = sys.argv[1:8] | 128 #name, out_fasta, out_qual, out_ace, out_caf, out_wig, out_log = sys.argv[1:8] |
102 name = "MIRA" | 129 name = "MIRA" |
103 manifest, out_maf, out_fasta, out_log = sys.argv[1:5] | 130 manifest, out_maf, out_fasta, out_log = sys.argv[1:5] |
131 | |
132 fix_threads(manifest) | |
104 | 133 |
105 start_time = time.time() | 134 start_time = time.time() |
106 #cmd_list =sys.argv[8:] | 135 #cmd_list =sys.argv[8:] |
107 cmd_list = [mira_binary, manifest] | 136 cmd_list = [mira_binary, manifest] |
108 cmd = " ".join(cmd_list) | 137 cmd = " ".join(cmd_list) |