changeset 4:17caf7a7c2c5 draft

Bump Biopython dependency
author peterjc
date Thu, 30 Nov 2023 09:49:28 +0000
parents fcdf11fb34de
children ea3c01e08251
files tools/seq_length/README.rst tools/seq_length/seq_length.py tools/seq_length/seq_length.xml tools/seq_length/tool_dependencies.xml
diffstat 4 files changed, 60 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/tools/seq_length/README.rst	Thu May 17 08:13:25 2018 -0400
+++ b/tools/seq_length/README.rst	Thu Nov 30 09:49:28 2023 +0000
@@ -1,7 +1,7 @@
 Galaxy tool to rename FASTA, QUAL, FASTQ or SFF sequences
 =========================================================
 
-This tool is copyright 2011-2017 by Peter Cock, The James Hutton Institute
+This tool is copyright 2011-2023 by Peter Cock, The James Hutton Institute
 (formerly SCRI, Scottish Crop Research Institute), UK. All rights reserved.
 See the licence text below.
 
@@ -67,6 +67,7 @@
         - Fix requesting SFF format.
 v0.0.4  - Report mean, minimum and maximum sequence lengths (via stdout).
         - Option to compute median and N50 as well.
+v0.0.5  - Bump dependency to current Biopython for Python 3 fixes.
 ======= ======================================================================
 
 
--- a/tools/seq_length/seq_length.py	Thu May 17 08:13:25 2018 -0400
+++ b/tools/seq_length/seq_length.py	Thu Nov 30 09:49:28 2023 +0000
@@ -10,7 +10,7 @@
 
 Cock et al 2009. Biopython: freely available Python tools for computational
 molecular biology and bioinformatics. Bioinformatics 25(11) 1422-3.
-http://dx.doi.org/10.1093/bioinformatics/btp163 pmid:19304878.
+https://doi.org/10.1093/bioinformatics/btp163 pmid:19304878.
 
 This script is copyright 2018 by Peter Cock, The James Hutton Institute UK.
 All rights reserved. See accompanying text file for licence details (MIT
@@ -29,20 +29,45 @@
 """
 
 parser = OptionParser(usage=usage)
-parser.add_option('-i', '--input', dest='input',
-                  default=None, help='Input sequence filename (FASTA, FASTQ, etc)',
-                  metavar="FILE")
-parser.add_option('-f', '--format', dest='format',
-                  default=None, help='Input sequence format (FASTA, QUAL, FASTQ, SFF)')
-parser.add_option('-o', '--output', dest='output',
-                  default=None, help='Output filename (tabular)',
-                  metavar="FILE")
-parser.add_option("-s", "--stats", dest="stats",
-                  default=False, action="store_true",
-                  help="Compute statistics (median, N50 - will require much more RAM).")
-parser.add_option("-v", "--version", dest="version",
-                  default=False, action="store_true",
-                  help="Show version and quit")
+parser.add_option(
+    "-i",
+    "--input",
+    dest="input",
+    default=None,
+    help="Input sequence filename (FASTA, FASTQ, etc)",
+    metavar="FILE",
+)
+parser.add_option(
+    "-f",
+    "--format",
+    dest="format",
+    default=None,
+    help="Input sequence format (FASTA, QUAL, FASTQ, SFF)",
+)
+parser.add_option(
+    "-o",
+    "--output",
+    dest="output",
+    default=None,
+    help="Output filename (tabular)",
+    metavar="FILE",
+)
+parser.add_option(
+    "-s",
+    "--stats",
+    dest="stats",
+    default=False,
+    action="store_true",
+    help="Compute statistics (median, N50 - will require much more RAM).",
+)
+parser.add_option(
+    "-v",
+    "--version",
+    dest="version",
+    default=False,
+    action="store_true",
+    help="Show version and quit",
+)
 options, args = parser.parse_args()
 
 if options.version:
@@ -125,11 +150,14 @@
 
 if sys.version_info[0] >= 3:
     from statistics import median
-    for test in [{1: 4, 2: 3},
-                 {1: 4, 3: 6},
-                 {1: 4, 5: 4},
-                 {0: 5, 1: 1, 2: 1, 3: 5},
-                 {0: 5, 1: 1, 2: 1, 3: 1, 4: 5}]:
+
+    for test in [
+        {1: 4, 2: 3},
+        {1: 4, 3: 6},
+        {1: 4, 5: 4},
+        {0: 5, 1: 1, 2: 1, 3: 5},
+        {0: 5, 1: 1, 2: 1, 3: 1, 4: 5},
+    ]:
         test_list = []
         for v, c in test.items():
             test_list.extend([v] * c)
@@ -158,7 +186,7 @@
     """
     # Continuing the above example, input L would be {2:3, 3:2, 4:1, 8:2}
     # and L' becomes {2:6, 3:6, 4:4, 8:16}} as tally tables.
-    l_prime = dict((v, v * c) for v, c in counts_dict.items())
+    l_prime = {v: v * c for v, c in counts_dict.items()}
     return median_from_counts_dict(l_prime)
 
 
@@ -208,7 +236,9 @@
             else:
                 length_min = min(length_min, length)
                 length_max = max(length_max, length)
-print("%i sequences, total length %i, mean %0.1f" % (count, total, float(total) / count))
+print(
+    "%i sequences, total length %i, mean %0.1f" % (count, total, float(total) / count)
+)
 if not count:
     pass
 elif not stats:
--- a/tools/seq_length/seq_length.xml	Thu May 17 08:13:25 2018 -0400
+++ b/tools/seq_length/seq_length.xml	Thu Nov 30 09:49:28 2023 +0000
@@ -1,8 +1,7 @@
-<tool id="seq_length" name="Sequence lengths" version="0.0.4">
+<tool id="seq_length" name="Sequence lengths" version="0.0.5">
     <description>from FASTA, QUAL, FASTQ, or SFF file</description>
     <requirements>
-        <!-- This is the currently the last release of Biopython which is available via Galaxy's legacy XML packaging system -->
-        <requirement type="package" version="1.67">biopython</requirement>
+        <requirement type="package" version="1.81">biopython</requirement>
     </requirements>
     <version_command>
 python $__tool_directory__/seq_length.py --version
@@ -75,7 +74,7 @@
 
 Cock et al (2009). Biopython: freely available Python tools for computational
 molecular biology and bioinformatics. Bioinformatics 25(11) 1422-3.
-http://dx.doi.org/10.1093/bioinformatics/btp163 pmid:19304878.
+https://doi.org/10.1093/bioinformatics/btp163 pmid:19304878.
 
 This tool is available to install into other Galaxy Instances via the Galaxy
 Tool Shed at http://toolshed.g2.bx.psu.edu/view/peterjc/seq_length
--- a/tools/seq_length/tool_dependencies.xml	Thu May 17 08:13:25 2018 -0400
+++ b/tools/seq_length/tool_dependencies.xml	Thu Nov 30 09:49:28 2023 +0000
@@ -1,6 +1,6 @@
-<?xml version="1.0"?>
+<?xml version="1.0" ?>
 <tool_dependency>
     <package name="biopython" version="1.67">
-        <repository changeset_revision="a12f73c3b116" name="package_biopython_1_67" owner="biopython" toolshed="https://toolshed.g2.bx.psu.edu" />
+        <repository name="package_biopython_1_67" owner="biopython" toolshed="https://toolshed.g2.bx.psu.edu" changeset_revision="a12f73c3b116"/>
     </package>
-</tool_dependency>
+</tool_dependency>
\ No newline at end of file