changeset 13:0b38302b09c7 draft

planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/tools/mummer commit 7cf7d2e3fc5480fbe1a463e8a876e54c5c858dbe-dirty
author peterjc
date Wed, 10 May 2017 11:52:52 -0400
parents caf5b859cf7b
children b4a88e27d274
files tools/mummer/README.rst tools/mummer/mummer.py
diffstat 2 files changed, 24 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/tools/mummer/README.rst	Fri Apr 21 12:03:10 2017 -0400
+++ b/tools/mummer/README.rst	Wed May 10 11:52:52 2017 -0400
@@ -69,6 +69,8 @@
         - Fixed display of input parameter help text.
 v0.0.7  - Use ``<command detect_errors="aggressive">`` (internal change only).
         - Single quote command line arguments (internal change only).
+        - Wrapper script catches missing output explicitly.
+        - Capture gnuplot version as well.
 ======= ======================================================================
 
 
--- a/tools/mummer/mummer.py	Fri Apr 21 12:03:10 2017 -0400
+++ b/tools/mummer/mummer.py	Wed May 10 11:52:52 2017 -0400
@@ -23,11 +23,13 @@
 
 
 if "-v" in sys.argv[1:]or "--version" in sys.argv[1:]:
-    print("MUMmer wrapper v0.0.3\n")
+    print("MUMmer wrapper v0.0.7\n")
     # TODO - How to get a version string from the mummer binary?
     os.system("nucmer --version")
     os.system("promer --version")
     os.system("mummerplot --version")
+    os.system("gnuplot --version")
+    # TODO - Should we include "gs --version" as a proxy for ps2pdf?
     sys.exit(0)
 
 # Parse Command Line
@@ -59,11 +61,17 @@
     cmd = '%s "%s" "%s"' % (algorithm, fasta_a, fasta_b)
 run(cmd)
 
+output_failed = False
+
 # PNG
 # ===
 cmd = 'mummerplot -R "%s" -Q "%s" --png --large --prefix=%s %s' % (fasta_a, fasta_b, prefix, coords)
 run(cmd)
-shutil.move(png_image, png_out)
+if os.path.isfile(png_image):
+    shutil.move(png_image, png_out)
+else:
+    sys.stderr.write("ERROR: PNG file not created.\n")
+    output_failed = True
 
 # PS --> PDF
 # ==========
@@ -75,9 +83,19 @@
 # Using "set size 1,1" works better - which is what --small gives:
 cmd = 'mummerplot -R "%s" -Q "%s" --postscript --small --prefix=%s %s' % (fasta_a, fasta_b, prefix, coords)
 run(cmd)
-cmd = 'ps2pdf -dEPSCrop "%s" "%s"' % (ps_image, pdf_out)
-run(cmd)
+if not os.path.isfile(ps_image):
+    sys.stderr.write("ERROR: PostScript file needed for PDF output was not created.\n")
+    output_failed = True
+else:
+    cmd = 'ps2pdf -dEPSCrop "%s" "%s"' % (ps_image, pdf_out)
+    run(cmd)
+    if not os.path.isfile(pdf_out):
+        sys.stderr.write("ERROR: PDF file not created.\n")
+        output_failed = True
 
 # Remove temp files...
 os.remove(coords)  # Might not be under the temp directory...
 shutil.rmtree(base_path)
+
+if output_failed:
+    sys.exit("ERROR: Failed to produce output file(s).")