diff tools/blast2go/massage_xml_for_blast2go.py @ 25:242cf17c3bf9 draft default tip

"planemo upload for repository https://github.com/peterjc/galaxy_blast/tree/master/tools/blast2go commit 0c82b9ef284c686cbffd30582d2586e4fb52881e"
author peterjc
date Wed, 09 Sep 2020 15:01:39 +0000
parents 05eef6b222af
children
line wrap: on
line diff
--- a/tools/blast2go/massage_xml_for_blast2go.py	Fri May 15 06:01:16 2015 -0400
+++ b/tools/blast2go/massage_xml_for_blast2go.py	Wed Sep 09 15:01:39 2020 +0000
@@ -14,18 +14,15 @@
 
 This script is called from my Galaxy wrapper for Blast2GO for pipelines,
 available from the Galaxy Tool Shed here:
-http://toolshed.g2.bx.psu.edu/view/peterjc/blast2go 
+http://toolshed.g2.bx.psu.edu/view/peterjc/blast2go
 
 This script is under version control here:
 https://github.com/peterjc/galaxy_blast/tree/master/blast2go
 """
-import sys
-import os
 
-def stop_err(msg, error_level=1):
-    """Print error message to stdout and quit with given error level."""
-    sys.stderr.write("%s\n" % msg)
-    sys.exit(error_level)
+import os
+import sys
+
 
 def prepare_xml(original_xml, mangled_xml):
     """Reformat BLAST XML to suit Blast2GO.
@@ -44,8 +41,8 @@
     while True:
         line = in_handle.readline()
         if not line:
-            #No hits?
-            stop_err("Problem with XML file?")
+            # No hits?
+            sys.exit("Problem with XML file?")
         if line.strip() == "<Iteration>":
             break
         header += line
@@ -56,7 +53,7 @@
         print("BLASTP output identified")
     else:
         in_handle.close()
-        stop_err("Expect BLASTP or BLASTX output")
+        sys.exit("Expect BLASTP or BLASTX output")
 
     out_handle = open(mangled_xml, "w")
     out_handle.write(header)
@@ -67,10 +64,10 @@
         if not line:
             break
         elif line.strip() == "<Iteration>":
-           #Insert footer/header
-           out_handle.write(footer)
-           out_handle.write(header)
-           count += 1
+            # Insert footer/header
+            out_handle.write(footer)
+            out_handle.write(header)
+            count += 1
         out_handle.write(line)
 
     out_handle.close()
@@ -81,11 +78,11 @@
 if __name__ == "__main__":
     # Run the conversion...
     if len(sys.argv) != 3:
-        stop_err("Require two arguments: XML input filename, XML output filename")
+        sys.exit("Require two arguments: XML input filename, XML output filename")
 
     xml_file, out_xml_file = sys.argv[1:]
 
     if not os.path.isfile(xml_file):
-        stop_err("Input BLAST XML file not found: %s" % xml_file)
+        sys.exit("Input BLAST XML file not found: %s" % xml_file)
 
     prepare_xml(xml_file, out_xml_file)