diff tools/protein_analysis/tmhmm2.py @ 21:238eae32483c draft

"Check this is up to date with all 2020 changes (black etc)"
author peterjc
date Thu, 17 Jun 2021 08:21:06 +0000
parents a19b3ded8f33
children e1996f0f4e85
line wrap: on
line diff
--- a/tools/protein_analysis/tmhmm2.py	Thu Sep 21 11:35:20 2017 -0400
+++ b/tools/protein_analysis/tmhmm2.py	Thu Jun 17 08:21:06 2021 +0000
@@ -39,7 +39,7 @@
 Also tmhmm2 can fail without returning an error code, for example if run on a
 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.
-"""
+"""  # noqa: E501
 
 from __future__ import print_function
 
@@ -55,7 +55,10 @@
     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")
+    sys.exit(
+        "Require three arguments, number of threads (int), input protein "
+        "FASTA file & output tabular file"
+    )
 
 num_threads = thread_count(sys.argv[1], default=4)
 fasta_file = sys.argv[2]
@@ -87,8 +90,10 @@
         predhel = predhel[8:]
         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))
+        out_handle.write(
+            "%s\t%s\t%s\t%s\t%s\t%s\n"
+            % (identifier, length, exp_aa, first60, predhel, topology)
+        )
         count += 1
     return count
 
@@ -97,8 +102,10 @@
 # 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)
 temp_files = [f + ".out" for f in fasta_files]
-jobs = ["tmhmm -short %s > %s" % (fasta, temp)
-        for fasta, temp in zip(fasta_files, temp_files)]
+jobs = [
+    "tmhmm -short %s > %s" % (fasta, temp)
+    for fasta, temp in zip(fasta_files, temp_files)
+]
 
 
 def clean_up(file_list):
@@ -124,8 +131,11 @@
         except IOError:
             output = ""
         clean_up(fasta_files + temp_files)
-        sys.exit("One or more tasks failed, e.g. %i from %r gave:\n%s" % (error_level, cmd, output),
-                 error_level)
+        sys.exit(
+            "One or more tasks failed, e.g. %i from %r gave:\n%s"
+            % (error_level, cmd, output),
+            error_level,
+        )
 del results
 del jobs