diff tools/protein_analysis/wolf_psort.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/wolf_psort.py	Thu Sep 21 11:35:20 2017 -0400
+++ b/tools/protein_analysis/wolf_psort.py	Thu Jun 17 08:21:06 2021 +0000
@@ -69,7 +69,10 @@
     sys.exit("WoLF-PSORT wrapper version 0.0.11")
 
 if len(sys.argv) != 5:
-    sys.exit("Require four arguments, organism, threads, input protein FASTA file & output tabular file")
+    sys.exit(
+        "Require four arguments, organism, threads, input protein FASTA file, "
+        "and output tabular file"
+    )
 
 organism = sys.argv[1]
 if organism not in ["animal", "plant", "fungi"]:
@@ -88,15 +91,16 @@
         name, data = line.rstrip("\r\n").split(None, 1)
         for rank, comp_data in enumerate(data.split(",")):
             comp, score = comp_data.split()
-            out_handle.write("%s\t%s\t%s\t%i\n"
-                             % (name, comp, score, rank + 1))
+            out_handle.write("%s\t%s\t%s\t%i\n" % (name, comp, score, rank + 1))
 
 
 fasta_files = split_fasta(fasta_file, tabular_file, n=FASTA_CHUNK)
 temp_files = [f + ".out" for f in fasta_files]
 assert len(fasta_files) == len(temp_files)
-jobs = ["%s %s < %s > %s" % (exe, organism, fasta, temp)
-        for (fasta, temp) in zip(fasta_files, temp_files)]
+jobs = [
+    "%s %s < %s > %s" % (exe, organism, fasta, temp)
+    for (fasta, temp) in zip(fasta_files, temp_files)
+]
 assert len(fasta_files) == len(temp_files) == len(jobs)
 
 
@@ -120,8 +124,11 @@
     if error_level or output.lower().startswith("error running"):
         clean_up(fasta_files)
         clean_up(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
 
 out_handle = open(tabular_file, "w")