changeset 8:ee50d9ef9d69 draft

v0.0.11 Python 3 compatible print; capture script version
author peterjc
date Thu, 11 May 2017 06:21:20 -0400
parents ba31415fedc5
children 5c5a9ce6c46d
files tools/venn_list/README.rst tools/venn_list/venn_list.py tools/venn_list/venn_list.xml
diffstat 3 files changed, 31 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/tools/venn_list/README.rst	Thu Feb 02 11:45:35 2017 -0500
+++ b/tools/venn_list/README.rst	Thu May 11 06:21:20 2017 -0400
@@ -75,6 +75,10 @@
 v0.0.10 - Updated to point at Biopython 1.67 (latest version in Tool Shed).
         - Explicit dependency on ``galaxy_sequence_utils``.
         - Python style updates (internal change only).
+v0.0.11 - Use ``<command detect_errors="aggressive">`` (internal change only).
+        - Single quote command line arguments (internal change only)
+        - Python 3 compatible print function.
+        - Capture python script version when run from Galaxy.
 ======= ======================================================================
 
 
@@ -91,17 +95,17 @@
 Planemo commands (which requires you have set your Tool Shed access details in
 ``~/.planemo.yml`` and that you have access rights on the Tool Shed)::
 
-    $ planemo shed_update -t testtoolshed --check_diff ~/repositories/pico_galaxy/tools/venn_list/
+    $ planemo shed_update -t testtoolshed --check_diff tools/venn_list/
     ...
 
 or::
 
-    $ planemo shed_update -t toolshed --check_diff ~/repositories/pico_galaxy/tools/venn_list/
+    $ planemo shed_update -t toolshed --check_diff tools/venn_list/
     ...
 
 To just build and check the tar ball, use::
 
-    $ planemo shed_upload --tar_only  ~/repositories/pico_galaxy/tools/venn_list/
+    $ planemo shed_upload --tar_only tools/venn_list/
     ...
     $ tar -tzf shed_upload.tar.gz 
     tools/venn_list/README.rst
--- a/tools/venn_list/venn_list.py	Thu Feb 02 11:45:35 2017 -0500
+++ b/tools/venn_list/venn_list.py	Thu May 11 06:21:20 2017 -0400
@@ -1,16 +1,20 @@
 #!/usr/bin/env python
 """Plot up to 3-way Venn Diagram using R limma vennDiagram (via rpy)
 
-This script is copyright 2010 by Peter Cock, The James Hutton Institute
+This script is copyright 2010-2017 by Peter Cock, The James Hutton Institute
 (formerly SCRI), UK. All rights reserved.
-See accompanying text file for licence details (MIT/BSD style).
 
-This is version 0.0.8 of the script.
+See accompanying text file for licence details (MIT License).
 """
 
+from __futute__ import print_function
 
 import sys
 
+if "-v" in sys.argv or "--version" in sys.argv:
+    print("v0.0.11")
+    sys.exit(0)
+
 try:
     import rpy
 except ImportError:
@@ -37,7 +41,7 @@
     set_data.append(tuple(sys.argv[10:13]))
 pdf_file = sys.argv[-1]
 n = len(set_data)
-print "Doing %i-way Venn Diagram" % n
+print("Doing %i-way Venn Diagram" % n)
 
 
 def load_ids(filename, filetype):
@@ -77,6 +81,7 @@
         else:
             sys.exit("Unexpected ID %s in %s file %s" % (name, filetype, filename))
 
+
 if all_file in ["", "-", '""', '"-"']:
     # Load without white list
     sets = [set(load_ids(f, t)) for (f, t, c) in set_data]
@@ -84,14 +89,14 @@
     all_ids = set()
     for s in sets:
         all_ids.update(s)
-    print "Inferred total of %i IDs" % len(all_ids)
+    print("Inferred total of %i IDs" % len(all_ids))
 else:
     all_ids = set(load_ids(all_file, all_type))
-    print "Total of %i IDs" % len(all_ids)
+    print("Total of %i IDs" % len(all_ids))
     sets = [set(load_ids_whitelist(f, t, all_ids)) for (f, t, c) in set_data]
 
 for s, (f, t, c) in zip(sets, set_data):
-    print "%i in %s" % (len(s), c)
+    print("%i in %s" % (len(s), c))
 
 # Now call R library to draw simple Venn diagram
 try:
@@ -102,7 +107,7 @@
     rpy.r('vc <- vennCounts(groups)')
     # Populate the 2^n classes with real counts
     # Don't make any assumptions about the class order
-    # print rpy.r('vc')
+    # print(rpy.r('vc'))
     for index, row in enumerate(rpy.r('vc[,%s]' % cols)):
         if isinstance(row, int) or isinstance(row, float):
             # Hack for rpy being too clever for single element row
@@ -114,7 +119,7 @@
             else:
                 names = names.difference(s)
         rpy.r('vc[%i,"Counts"] <- %i' % (index + 1, len(names)))
-    # print rpy.r('vc')
+    # print(rpy.r('vc'))
     if n == 1:
         # Single circle, don't need to add (Total XXX) line
         names = [c for (t, f, c) in set_data]
@@ -131,4 +136,4 @@
 except Exception, exc:
     sys.exit("%s" % str(exc))
 rpy.r.quit(save="no")
-print "Done"
+print("Done")
--- a/tools/venn_list/venn_list.xml	Thu Feb 02 11:45:35 2017 -0500
+++ b/tools/venn_list/venn_list.xml	Thu May 11 06:21:20 2017 -0400
@@ -1,28 +1,24 @@
-<tool id="venn_list" name="Venn Diagram" version="0.0.10">
+<tool id="venn_list" name="Venn Diagram" version="0.0.11">
     <description>from lists</description>
     <requirements>
         <requirement type="package" version="1.0.1">galaxy_sequence_utils</requirement>
-        <requirement type="python-module">rpy</requirement>
-        <requirement type="python-module">Bio</requirement>
         <requirement type="package" version="1.0.3">rpy</requirement>
         <requirement type="package" version="3.25.3">limma</requirement>
         <requirement type="package" version="1.67">biopython</requirement>
     </requirements>
-    <stdio>
-        <!-- Anything other than zero is an error -->
-        <exit_code range="1:" />
-        <exit_code range=":-1" />
-    </stdio>
-    <command interpreter="python">
-venn_list.py
+    <version_command>
+python $__tool_directory__/venn_list.py --version
+    </version_comman>
+    <command detect_errors="aggressive">
+python $__tool_directory__/venn_list.py
 #if $universe.type_select=="implicit":
   - -
 #else:
-  "$main" $main.ext
+  '$main' $main.ext
 #end if
-"$main_lab"
+'$main_lab'
 #for $s in $sets:
-  "$s.set" $s.set.ext "$s.lab"
+  '$s.set' $s.set.ext '$s.lab'
 #end for
 $PDF
     </command>