[med-svn] [Git][med-team/stacks][master] 6 commits: Python3 port of two simple scripts using 2to3

Andreas Tille gitlab at salsa.debian.org
Fri Jul 12 19:48:12 BST 2019



Andreas Tille pushed to branch master at Debian Med / stacks


Commits:
0e129e52 by Andreas Tille at 2019-07-12T09:17:47Z
Python3 port of two simple scripts using 2to3

- - - - -
bd57cd29 by Andreas Tille at 2019-07-12T09:23:02Z
Use Python3

- - - - -
b87cb9bb by Andreas Tille at 2019-07-12T11:15:09Z
Another try to run the test suite which does not work yet.  Asked on google group for any hints.

- - - - -
810a8721 by Andreas Tille at 2019-07-12T11:36:11Z
Restore old directory layout

- - - - -
db5bbada by Andreas Tille at 2019-07-12T18:40:15Z
Fix code to fix perl interpreter

- - - - -
3cc99788 by Andreas Tille at 2019-07-12T18:44:49Z
Upload to unstable

- - - - -


6 changed files:

- debian/changelog
- debian/control
- + debian/patches/2to3.patch
- debian/patches/series
- debian/rules
- debian/stacks.install


Changes:

=====================================
debian/changelog
=====================================
@@ -1,4 +1,4 @@
-stacks (2.41+dfsg-1) UNRELEASED; urgency=medium
+stacks (2.41+dfsg-1) unstable; urgency=medium
 
   * New upstream version
   * debhelper 12
@@ -9,8 +9,9 @@ stacks (2.41+dfsg-1) UNRELEASED; urgency=medium
   * Removed stacks-web package since the code for the web service
     was removed from upstream source and the package has no active
     users according to popcon anyway
+  * Python3 port of two simple scripts using 2to3
 
- -- Andreas Tille <tille at debian.org>  Wed, 10 Jul 2019 21:58:30 +0200
+ -- Andreas Tille <tille at debian.org>  Fri, 12 Jul 2019 20:40:33 +0200
 
 stacks (2.2+dfsg-1) unstable; urgency=medium
 


=====================================
debian/control
=====================================
@@ -5,7 +5,6 @@ Uploaders: Tim Booth <tbooth at ceh.ac.uk>,
 Section: science
 Priority: optional
 Build-Depends: debhelper (>= 12~),
-               python,
                zlib1g-dev,
                libbam-dev,
                libsparsehash-dev,
@@ -20,10 +19,10 @@ Package: stacks
 Architecture: any
 Depends: ${shlibs:Depends},
          ${misc:Depends},
-         ${python:Depends},
          samtools,
          libdbi-perl
-Recommends: libspreadsheet-writeexcel-perl
+Recommends: libspreadsheet-writeexcel-perl,
+            python3
 Conflicts: stacks-web
 Provides: stacks-web
 Replaces: stacks-web


=====================================
debian/patches/2to3.patch
=====================================
@@ -0,0 +1,164 @@
+Author: Andreas Tille <tille at debian.org>
+Last-Update: Wed, 10 Jul 2019 21:58:30 +0200
+Description: Result of 2to3 port to Python3
+
+--- a/scripts/count_fixed_catalog_snps.py
++++ b/scripts/count_fixed_catalog_snps.py
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env python
++#!/usr/bin/python3
+ 
+ import optparse
+ import sys
+@@ -39,7 +39,7 @@ def parse_command_line():
+         batch_id = int(opts.batch_id)
+ 
+     if len(path) == 0 or os.path.exists(path) == False:
+-        print >> sys.stderr, "You must specify a valid path to Stacks input files."
++        print("You must specify a valid path to Stacks input files.", file=sys.stderr)
+         p.print_help()
+         sys.exit()
+ 
+@@ -62,10 +62,10 @@ def find_stacks_files(path, files):
+                 pos = entry.find(".matches.tsv")
+             if (pos != -1):
+                 files.append(entry[0:pos])
+-        print >> sys.stderr, "Found", len(files), "Stacks samples."
++        print("Found", len(files), "Stacks samples.", file=sys.stderr)
+ 
+     except:
+-        print >> sys.stderr, "Unable to read files from Stacks directory, '" + path + "'"
++        print("Unable to read files from Stacks directory, '" + path + "'", file=sys.stderr)
+ 
+ 
+ def parse_cigar(cigar, components):
+@@ -143,14 +143,14 @@ def count_sample_snps(path, file, sample
+             matches[sample_locus] = cat_locus
+         else:
+             if cat_locus != matches[sample_locus]:
+-                print >> sys.stderr, "Error: sample locus", sample_locus, "matches more than one catalog locus."
++                print("Error: sample locus", sample_locus, "matches more than one catalog locus.", file=sys.stderr)
+ 
+         if len(cigar) > 0:
+             if sample_locus not in cigars:
+                 cigars[sample_locus] = cigar
+             else:
+                 if cigar != cigars[sample_locus]:
+-                    print >> sys.stderr, "Error: sample locus", sample_locus, "has multiple cigar alignments."
++                    print("Error: sample locus", sample_locus, "has multiple cigar alignments.", file=sys.stderr)
+ 
+     fh.close()
+ 
+@@ -279,23 +279,23 @@ find_stacks_files(path, files)
+ #
+ i = 1
+ for file in files:
+-    print >> sys.stderr, "Processing file", str(i), "of", len(files), "['" +  file + "']"
++    print("Processing file", str(i), "of", len(files), "['" +  file + "']", file=sys.stderr)
+     cnt = count_sample_snps(path, file, sample_snps)
+-    print >> sys.stderr, "  Found", cnt, "heterozygous SNPs in sample."
++    print("  Found", cnt, "heterozygous SNPs in sample.", file=sys.stderr)
+     i += 1
+ 
+ total_snps = 0
+ for locus in sample_snps:
+     for col in sample_snps[locus]:
+         total_snps += 1
+-print >> sys.stderr, "Found", total_snps, "variable sites across the population."
++print("Found", total_snps, "variable sites across the population.", file=sys.stderr)
+ 
+ #
+ # Count all the SNPs found in the catalog.
+ #
+-print >> sys.stderr, "Processing the catalog"
++print("Processing the catalog", file=sys.stderr)
+ cnt = count_catalog_snps(path, batch_id, catalog_snps)
+-print >> sys.stderr, "  Found", cnt, "heterozygous SNPs in the catalog."
++print("  Found", cnt, "heterozygous SNPs in the catalog.", file=sys.stderr)
+ 
+ #
+ # Count all the SNPs in the catalog but not in any sample: these are the fixed differences cstacks identified.
+@@ -315,7 +315,7 @@ for locus in catalog_snps:
+             fixed_snps += 1
+     for col in sample_snps[locus]:
+         if col not in c:
+-            print "Locus:", locus, "col:", col, "Catalog SNPs:", catalog_snps[locus], "Sample SNPs:", sample_snps[locus]
++            print("Locus:", locus, "col:", col, "Catalog SNPs:", catalog_snps[locus], "Sample SNPs:", sample_snps[locus])
+ 
+-print >> sys.stderr, "Found", total_snps, "SNPs across all samples and in the catalog."
+-print >> sys.stderr, "Found", fixed_snps, "fixed SNPs only in the catalog."
++print("Found", total_snps, "SNPs across all samples and in the catalog.", file=sys.stderr)
++print("Found", fixed_snps, "fixed SNPs only in the catalog.", file=sys.stderr)
+--- a/scripts/integrate_alignments.py
++++ b/scripts/integrate_alignments.py
+@@ -1,4 +1,4 @@
+-#!/usr/bin/env python
++#!/usr/bin/python3
+ 
+ import optparse
+ import sys
+@@ -49,7 +49,7 @@ def parse_command_line():
+         batch_id = int(opts.batch_id)
+ 
+     if len(out_path) == 0 or os.path.exists(out_path) == False:
+-        print >> sys.stderr, "You must specify a valid path to write files to."
++        print("You must specify a valid path to write files to.", file=sys.stderr)
+         p.print_help()
+         sys.exit()
+ 
+@@ -57,12 +57,12 @@ def parse_command_line():
+         out_path += "/"
+ 
+     if len(aln_path) == 0 or os.path.exists(aln_path) == False:
+-        print >> sys.stderr, "You must specify a valid path to a SAM file containing catalog locus alignments."
++        print("You must specify a valid path to a SAM file containing catalog locus alignments.", file=sys.stderr)
+         p.print_help()
+         sys.exit()
+ 
+     if len(path) == 0 or os.path.exists(path) == False:
+-        print >> sys.stderr, "You must specify a valid path to Stacks input files."
++        print("You must specify a valid path to Stacks input files.", file=sys.stderr)
+         p.print_help()
+         sys.exit()
+ 
+@@ -85,10 +85,10 @@ def find_stacks_files(path, files):
+                 pos = entry.find(".matches.tsv")
+             if (pos != -1):
+                 files.append(entry[0:pos])
+-        print >> sys.stderr, "Found", len(files), "Stacks samples."
++        print("Found", len(files), "Stacks samples.", file=sys.stderr)
+ 
+     except:
+-        print >> sys.stderr, "Unable to read files from Stacks directory, '", path, "'"
++        print("Unable to read files from Stacks directory, '", path, "'", file=sys.stderr)
+ 
+ 
+ def parse_catalog_alignments(aln_path, alns):
+@@ -115,7 +115,7 @@ def parse_catalog_alignments(aln_path, a
+             alns[locus] = (chr, bp, "+");
+ 
+     fh.close()
+-    print >> sys.stderr, "Loaded", len(alns), "catalog locus alignments from '", aln_path, "'."
++    print("Loaded", len(alns), "catalog locus alignments from '", aln_path, "'.", file=sys.stderr)
+ 
+ 
+ def convert_sample(path, file, out_path, alns):
+@@ -414,14 +414,14 @@ parse_catalog_alignments(aln_path, alns)
+ 
+ i  = 1
+ for file in files:
+-    print >> sys.stderr, "Processing file", str(i), "of", len(files), "['" +  file + "']"
++    print("Processing file", str(i), "of", len(files), "['" +  file + "']", file=sys.stderr)
+     cnt = convert_sample(path, file, out_path, alns)
+-    print >> sys.stderr, "  Added alignments for", cnt, "loci."
++    print("  Added alignments for", cnt, "loci.", file=sys.stderr)
+     i += 1
+ 
+ #
+ # Now process the catalog.
+ #
+-print >> sys.stderr, "Processing the catalog"
++print("Processing the catalog", file=sys.stderr)
+ cnt = convert_catalog(path, batch_id, out_path, alns)
+-print >> sys.stderr, "  Added alignments for", cnt, "catalog loci."
++print("  Added alignments for", cnt, "catalog loci.", file=sys.stderr)


=====================================
debian/patches/series
=====================================
@@ -1,2 +1,3 @@
 script-exe-paths
 use_debian_packaged_htslib.patch
+2to3.patch


=====================================
debian/rules
=====================================
@@ -8,7 +8,7 @@ export DEB_BUILD_MAINT_OPTIONS = hardening=+all
 include /usr/share/dpkg/default.mk
 
 %:
-	dh $@ --with python2
+	dh $@
 
 override_dh_auto_install:
 	dh_auto_install --no-parallel
@@ -19,13 +19,14 @@ override_dh_auto_configure:
 		 --with-bam-lib-path=/usr/lib
 
 override_dh_install:
-	dh_install
-	# Skip this bit if not building stacks
-	! cd debian/$(DEB_SOURCE)/usr/lib/$(DEB_SOURCE)/bin || \
+	mkdir -p debian/$(DEB_SOURCE)/usr/lib/$(DEB_SOURCE)
+	mv debian/$(DEB_SOURCE)/usr/bin debian/$(DEB_SOURCE)/usr/lib/$(DEB_SOURCE)
+	cd debian/$(DEB_SOURCE)/usr/lib/$(DEB_SOURCE)/bin && \
 	  for f in *.pl ; do \
 	    ln -s "$$f" "`basename $$f .pl`" ; \
 	    sed -i '1s?^#!/usr/bin/env.*perl?#!/usr/bin/perl?' $$f ; \
 	  done
+	dh_install
 
 override_dh_link:
 	dh_link
@@ -37,8 +38,14 @@ override_dh_link:
 
 override_dh_auto_test:
 ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
-	#ln -s /usr/share/automake-1.14/tap-driver.sh tests/tap-driver.sh
-	#dh_auto_test
+	if [ -e /usr/share/automake-1.16/tap-driver.sh ] ; then \
+	    ln -s /usr/share/automake-1.16/tap-driver.sh tests/tap-driver.sh ; \
+	else \
+	    echo "Make sure /usr/share/automake-*/tap-driver.sh exists and is linked" ; \
+	    false ; \
+	fi
+	# dh_auto_test
+	rm tests/tap-driver.sh
 	# FIXME: Does not work even after this trick.  See
 	#   https://groups.google.com/forum/#!msg/stacks-users/TA2tMEqb4Mg/pQy4fUCYi9kJ
 	true


=====================================
debian/stacks.install
=====================================
@@ -1,2 +1 @@
-debian/stacks/usr/bin	usr/lib/stacks
 debian/bin/*		usr/bin



View it on GitLab: https://salsa.debian.org/med-team/stacks/compare/aeb8b8b5a973cb310a69f2870e8cb94c663c1b3b...3cc997883e153c244af9f577f57c5762ca0eb07d

-- 
View it on GitLab: https://salsa.debian.org/med-team/stacks/compare/aeb8b8b5a973cb310a69f2870e8cb94c663c1b3b...3cc997883e153c244af9f577f57c5762ca0eb07d
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20190712/c85b4d72/attachment-0001.html>


More information about the debian-med-commit mailing list