diff tools/protein_analysis/tmhmm2.py @ 20:a19b3ded8f33 draft

v0.2.11 Job splitting fast-fail; RXLR tools supports HMMER2 from BioConda; Capture more version information; misc internal changes
author peterjc
date Thu, 21 Sep 2017 11:35:20 -0400
parents f3ecd80850e2
children 238eae32483c
line wrap: on
line diff
--- a/tools/protein_analysis/tmhmm2.py	Wed Feb 01 09:46:42 2017 -0500
+++ b/tools/protein_analysis/tmhmm2.py	Thu Sep 21 11:35:20 2017 -0400
@@ -40,13 +40,20 @@
 64 bit machine with only the 32 bit binaries installed. This script will spot
 when there is no output from tmhmm2, and raise an error.
 """
-import sys
+
+from __future__ import print_function
+
 import os
+import sys
 import tempfile
-from seq_analysis_utils import split_fasta, run_jobs, thread_count
+
+from seq_analysis_utils import run_jobs, split_fasta, thread_count
 
 FASTA_CHUNK = 500
 
+if "-v" in sys.argv or "--version" in sys.argv:
+    sys.exit("TMHMM wrapper version 0.0.16")
+
 if len(sys.argv) != 4:
     sys.exit("Require three arguments, number of threads (int), input protein FASTA file & output tabular file")
 
@@ -81,10 +88,11 @@
         assert topology.startswith("Topology="), line
         topology = topology[9:]
         out_handle.write("%s\t%s\t%s\t%s\t%s\t%s\n"
-                   % (identifier, length, exp_aa, first60, predhel, topology))
+                         % (identifier, length, exp_aa, first60, predhel, topology))
         count += 1
     return count
 
+
 # Note that if the input FASTA file contains no sequences,
 # split_fasta returns an empty list (i.e. zero temp files).
 fasta_files = split_fasta(fasta_file, os.path.join(tmp_dir, "tmhmm"), FASTA_CHUNK)
@@ -103,9 +111,10 @@
     except Exception:
         pass
 
+
 if len(jobs) > 1 and num_threads > 1:
     # A small "info" message for Galaxy to show the user.
-    print "Using %i threads for %i tasks" % (min(num_threads, len(jobs)), len(jobs))
+    print("Using %i threads for %i tasks" % (min(num_threads, len(jobs)), len(jobs)))
 results = run_jobs(jobs, num_threads)
 for fasta, temp, cmd in zip(fasta_files, temp_files, jobs):
     error_level = results[cmd]