# HG changeset patch # User peterjc # Date 1494498080 14400 # Node ID ee50d9ef9d690f6df29e4b85b7cb46212a0fbedd # Parent ba31415fedc5ab6420d8549282fc01427243b367 v0.0.11 Python 3 compatible print; capture script version diff -r ba31415fedc5 -r ee50d9ef9d69 tools/venn_list/README.rst --- 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 ```` (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 diff -r ba31415fedc5 -r ee50d9ef9d69 tools/venn_list/venn_list.py --- 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") diff -r ba31415fedc5 -r ee50d9ef9d69 tools/venn_list/venn_list.xml --- 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 @@ - + from lists galaxy_sequence_utils - rpy - Bio rpy limma biopython - - - - - - -venn_list.py + +python $__tool_directory__/venn_list.py --version + + +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