Mercurial > repos > peterjc > mira4_assembler
diff 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 |
line wrap: on
line diff
--- a/tools/mira4/mira4.py Mon Oct 21 12:01:47 2013 -0400 +++ b/tools/mira4/mira4.py Fri Oct 25 07:18:38 2013 -0400 @@ -31,8 +31,14 @@ return ver.split("\n", 1)[0] -os.environ["PATH"] = "/mnt/galaxy/downloads/mira_4.0rc4_linux-gnu_x86_64_static/bin/:%s" % os.environ["PATH"] -mira_binary = "mira" +try: + mira_path = os.environ["MIRA4"] +except ImportError: + stop_err("Environment variable $MIRA4 not set") +mira_binary = os.path.join(mira_path, "mira") +if not os.path.isfile(mira_binary): + stop_err("Missing mira under $MIRA4, %r" % mira_binary) + mira_ver = get_version(mira_binary) if not mira_ver.strip().startswith("4.0"): stop_err("This wrapper is for MIRA V4.0, not:\n%s" % mira_ver) @@ -40,6 +46,27 @@ print "%s, MIRA wrapper version %s" % (mira_ver, WRAPPER_VER) sys.exit(0) +def fix_threads(manifest): + """Tweak the manifest to alter the number of threads.""" + try: + threads = int(os.environ.get("GALAXY_SLOTS", "1")) + except ValueError: + threads = 1 + assert 1 <= threads + if threads == 1: + #Nothing to do... + return + + handle = open(manifest) + text = handle.read() + handle.close() + + text = text.replace(" -GE:not=1 ", " -GE:not=%i " % threads) + + handle = open(manifest, "w") + handle.write(text) + handle.flush() + handle.close() def log_manifest(manifest): """Write the manifest file to stderr.""" @@ -102,6 +129,8 @@ name = "MIRA" manifest, out_maf, out_fasta, out_log = sys.argv[1:5] +fix_threads(manifest) + start_time = time.time() #cmd_list =sys.argv[8:] cmd_list = [mira_binary, manifest]