diff tools/protein_analysis/promoter2.py @ 18:eb6ac44d4b8e draft

Suite v0.2.8, record Promoter 2 verion + misc internal updates
author peterjc
date Tue, 01 Sep 2015 09:56:36 -0400
parents e52220a9ddad
children f3ecd80850e2
line wrap: on
line diff
--- a/tools/protein_analysis/promoter2.py	Fri Nov 21 08:19:09 2014 -0500
+++ b/tools/protein_analysis/promoter2.py	Tue Sep 01 09:56:36 2015 -0400
@@ -30,12 +30,15 @@
 import os
 import commands
 import tempfile
-from seq_analysis_utils import stop_err, split_fasta, run_jobs, thread_count
+from seq_analysis_utils import sys_exit, split_fasta, run_jobs, thread_count
 
 FASTA_CHUNK = 500
 
+if "-v" in sys.argv or "--version" in sys.argv:
+    sys.exit(os.system("promoter -V"))
+
 if len(sys.argv) != 4:
-    stop_err("Require three arguments, number of threads (int), input DNA FASTA file & output tabular file. "
+    sys_exit("Require three arguments, number of threads (int), input DNA FASTA file & output tabular file. "
              "Got %i arguments." % (len(sys.argv)-1))
 
 num_threads = thread_count(sys.argv[3],default=4)
@@ -48,7 +51,7 @@
     platform = commands.getoutput("uname") #e.g. Linux
     shell_script = commands.getoutput("which promoter")
     if not os.path.isfile(shell_script):
-        stop_err("ERROR: Missing promoter executable shell script")
+        sys_exit("ERROR: Missing promoter executable shell script")
     path = None
     for line in open(shell_script):
         if line.startswith("setenv"): #could then be tab or space!
@@ -56,12 +59,12 @@
             if parts[0] == "setenv" and parts[1] == "PROM":
                 path = parts[2]
     if not path:
-        stop_err("ERROR: Could not find promoter path (PROM) in %r" % shell_script)
+        sys_exit("ERROR: Could not find promoter path (PROM) in %r" % shell_script)
     if not os.path.isdir(path):
-        stop_error("ERROR: %r is not a directory" % path)
+        sys_exit("ERROR: %r is not a directory" % path)
     bin = "%s/bin/promoter_%s" % (path, platform)
     if not os.path.isfile(bin):
-        stop_err("ERROR: Missing promoter binary %r" % bin)
+        sys_exit("ERROR: Missing promoter binary %r" % bin)
     return path, bin
 
 def make_tabular(raw_handle, out_handle):
@@ -86,19 +89,19 @@
             except ValueError:
                 print "WARNING: Problem with line: %r" % line
                 continue
-                #stop_err("ERROR: Problem with line: %r" % line)
+                #sys_exit("ERROR: Problem with line: %r" % line)
             if likelihood not in ["ignored",
                                   "Marginal prediction",
                                   "Medium likely prediction",
                                   "Highly likely prediction"]:
-                stop_err("ERROR: Problem with line: %r" % line)
+                sys_exit("ERROR: Problem with line: %r" % line)
             out_handle.write("%s\t%s\t%s\t%s\n" % (identifier, position, score, likelihood))
     return queries
     
 working_dir, bin = get_path_and_binary()
 
 if not os.path.isfile(fasta_file):
-   stop_err("ERROR: Missing input FASTA file %r" % fasta_file)
+   sys_exit("ERROR: Missing input FASTA file %r" % fasta_file)
 
 #Note that if the input FASTA file contains no sequences,
 #split_fasta returns an empty list (i.e. zero temp files).
@@ -133,7 +136,7 @@
         except IOError:
             output = ""
         clean_up(fasta_files + temp_files)
-        stop_err("One or more tasks failed, e.g. %i from %r gave:\n%s" % (error_level, cmd, output),
+        sys_exit("One or more tasks failed, e.g. %i from %r gave:\n%s" % (error_level, cmd, output),
                  error_level)
 
 del results
@@ -148,7 +151,7 @@
     data_handle.close()
     if not count:
         clean_up(fasta_files + temp_files)
-        stop_err("No output from promoter2")
+        sys_exit("No output from promoter2")
     queries += count
 out_handle.close()