[med-svn] [Git][med-team/smalt][master] Fix the remaining Python3 issues in test scripts
Michael R. Crusoe
gitlab at salsa.debian.org
Fri Jan 3 10:48:42 GMT 2020
Michael R. Crusoe pushed to branch master at Debian Med / smalt
Commits:
8c309fc4 by Michael R. Crusoe at 2020-01-03T11:47:43+01:00
Fix the remaining Python3 issues in test scripts
- - - - -
4 changed files:
- debian/changelog
- debian/control
- debian/patches/2to3.patch
- debian/tests/run-unit-test
Changes:
=====================================
debian/changelog
=====================================
@@ -1,5 +1,8 @@
-smalt (0.7.6-9) UNRELEASED; urgency=medium
+smalt (0.7.6-9) unstable; urgency=medium
+ * Team upload.
+
+ [ Andreas Tille ]
* Use 2to3 to port to Python3
Closes: #938501
* debhelper-compat 12
@@ -9,37 +12,11 @@ smalt (0.7.6-9) UNRELEASED; urgency=medium
* Use secure URI in Homepage field.
* Set upstream metadata fields: Archive, Bug-Submit.
* autopkgtest: s/ADTTMP/AUTOPKGTEST_TMP/g
- TODO: Fix some Python3 issues in test scripts
- make check-TESTS
- make[4]: Entering directory '/build/smalt-0.7.6/test'
- PASS: splitReads_test.py
- PASS: results_split_test.py
- PASS: ouform_cigar_test.py
- mappings don't match for read 'SIM_000000000_MAL11_001337747_10_F_75m/1'
- FAIL: sample_test.py
- PASS: cigar_test.py
- Discrepancy:
- cigar:A:60 SIM_000000000_MAL11_001337747_10_F_75m/1 1 75 + MAL11 1337747 1337821 + 75 M 75
- cigar:A:60 SIM_000000000_MAL11_001337747_10_F_75m/1 1 75 + MAL11 1337747 1337821 + 75 M 75
- cigA1.mapq=60 > MAPQ_THRESH=6 and cigB1.mapq=60 > MAPQ_THRESH=6
- FAIL: mthread_test.py
- PASS: ioform_test.py
- PASS: xali_test.py
- Traceback (most recent call last):
- File "./bam_cigar_test.py", line 254, in <module>
- isOK = testSAMfilesAreIdentical(sambamnam, samoufilnam)
- File "./bam_cigar_test.py", line 149, in testSAMfilesAreIdentical
- linA = infilA.readline()
- File "/usr/lib/python3.7/codecs.py", line 322, in decode
- (result, consumed) = self._buffer_decode(data, self.errors, final)
- UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 366: invalid start byte
- FAIL: bam_cigar_test.py
- =================================
- 3 of 9 tests failed
- Please report to hp3 at sanger.ac.uk
- =================================
-
- -- Andreas Tille <tille at debian.org> Thu, 05 Sep 2019 15:07:37 +0200
+
+ [ Michael R. Crusoe ]
+ * Fix some Python3 issues in test scripts
+
+ -- Michael R. Crusoe <michael.crusoe at gmail.com> Fri, 03 Jan 2020 11:44:39 +0100
smalt (0.7.6-8) unstable; urgency=medium
=====================================
debian/control
=====================================
@@ -41,8 +41,7 @@ Description: Sequence Mapping and Alignment Tool
Package: smalt-examples
Architecture: all
-Depends: ${shlibs:Depends},
- ${misc:Depends}
+Depends: ${misc:Depends}
Description: Sequence Mapping and Alignment Tool (examples)
SMALT efficiently aligns DNA sequencing reads with a reference genome.
Reads from a wide range of sequencing platforms, for example Illumina,
=====================================
debian/patches/2to3.patch
=====================================
@@ -3,9 +3,9 @@ Bug-Debian: https://bugs.debian.org/938501
Author: Andreas Tille <tille at debian.org>
Last-Update: Thu, 05 Sep 2019 15:07:37 +0200
---- a/misc/SAM.py
-+++ b/misc/SAM.py
-@@ -85,7 +85,7 @@ class Sam:
+--- smalt.orig/misc/SAM.py
++++ smalt/misc/SAM.py
+@@ -85,7 +85,7 @@
self.tags[tagnam] = (typ, fld)
self.ok = True
else:
@@ -14,7 +14,7 @@ Last-Update: Thu, 05 Sep 2019 15:07:37 +0200
self.blank()
def clip(self):
-@@ -106,7 +106,7 @@ class Sam:
+@@ -106,7 +106,7 @@
return (typ, isCorrect, s, e)
def strand(self):
@@ -23,7 +23,7 @@ Last-Update: Thu, 05 Sep 2019 15:07:37 +0200
return bool(self.flag & Sam.FLAG_STRAND)
def calcUnclippedStart(self):
-@@ -207,7 +207,7 @@ class Sam:
+@@ -207,7 +207,7 @@
if bool(self.flag & Sam.FLAG_STRAND):
(seq, qual, okflg) = self.reverseComplement()
if not okflg:
@@ -32,7 +32,7 @@ Last-Update: Thu, 05 Sep 2019 15:07:37 +0200
exit(1)
else:
seq = self.nt
-@@ -218,7 +218,7 @@ class Sam:
+@@ -218,7 +218,7 @@
def asFastq(self, clip=0):
namstr, seq, qual = self.asFastqStr()
if clip >= len(self.nt):
@@ -41,7 +41,7 @@ Last-Update: Thu, 05 Sep 2019 15:07:37 +0200
return Sam.FASTQ_FORMAT % (namstr, seq[clip:], qual[clip:])
def reverseComplement(self):
-@@ -245,7 +245,7 @@ class Sam:
+@@ -245,7 +245,7 @@
if not lin: break
self.parse(lin, is_verbose)
if self.ok: break
@@ -50,7 +50,7 @@ Last-Update: Thu, 05 Sep 2019 15:07:37 +0200
return not lin # True if EOF
-@@ -259,7 +259,7 @@ def fetchNextRead(infil, read):
+@@ -259,7 +259,7 @@
break
read.parse(lin)
if not read.ok:
@@ -59,7 +59,7 @@ Last-Update: Thu, 05 Sep 2019 15:07:37 +0200
continue
break
#print read.target.varnum()
-@@ -291,8 +291,8 @@ def fetchNextPair(infil, samA, samB):
+@@ -291,8 +291,8 @@
errflg = True
if errflg:
@@ -70,7 +70,7 @@ Last-Update: Thu, 05 Sep 2019 15:07:37 +0200
exit(1)
return (isEOF, switch_flag)
-@@ -307,7 +307,7 @@ def openFile(filnam, mode):
+@@ -307,7 +307,7 @@
else:
oufil = open(filnam, mode)
except:
@@ -79,7 +79,7 @@ Last-Update: Thu, 05 Sep 2019 15:07:37 +0200
exit(1)
return oufil
-@@ -316,7 +316,7 @@ if __name__ == '__main__':
+@@ -316,7 +316,7 @@
from sys import argv, exit
if len(argv) < 3:
@@ -88,7 +88,7 @@ Last-Update: Thu, 05 Sep 2019 15:07:37 +0200
exit(1)
infilnam = argv[1]
-@@ -360,36 +360,36 @@ if __name__ == '__main__':
+@@ -360,36 +360,36 @@
if mnam == old_qnam:
if read.rname != old_rnam:
chimictr = chimictr + 1
@@ -140,9 +140,37 @@ Last-Update: Thu, 05 Sep 2019 15:07:37 +0200
+ print("There were no reads mapped as pairs.")
exit(0)
---- a/test/bam_cigar_test.py
-+++ b/test/bam_cigar_test.py
-@@ -164,19 +164,19 @@ def testSAMfilesAreIdentical(filnamA, fi
+--- smalt.orig/test/bam_cigar_test.py
++++ smalt/test/bam_cigar_test.py
+@@ -142,30 +142,30 @@
+ def testSAMfilesAreIdentical(filnamA, filnamB):
+ from testdata import openFile
+
+- infilA = openFile(filnamA)
+- infilB = openFile(filnamB)
++ infilA = openFile(filnamA, 'rb')
++ infilB = openFile(filnamB, 'rb')
+
+ while 1:
+ linA = infilA.readline()
+- if not linA or linA[0]!="@":
++ if not linA or linA[0]!= 64: # same as b"@"
+ break
+
+ while 1:
+ linB = infilB.readline()
+- if not linB or linB[0]!="@":
++ if not linB or linB[0]!= 64: # same as b"@"
+ break
+
+ okflg = False
+
+ while linA and linB:
+- fldA = linA.split('\t')
+- fldB = linB.split('\t')
++ fldA = linA.split(b'\t')
++ fldB = linB.split(b'\t')
+
okflg = len(fldA) == len(fldB)
if not okflg:
@@ -152,11 +180,8 @@ Last-Update: Thu, 05 Sep 2019 15:07:37 +0200
+ (linA.strip(), linB.strip()))
break
-- for i in SAM_TEST_FIELDS.keys():
-+ for i in list(SAM_TEST_FIELDS.keys()):
- okflg = fldA[i] == fldB[i]
- if not okflg and i == 0:
- # samtools-0.1.18 view -h produces non-printing char
+ for i in SAM_TEST_FIELDS.keys():
+@@ -175,8 +175,8 @@
# directly after header
okflg = fldA[i][1:] == fldB[i] or fldA[i] == fldB[i][1:]
if not okflg:
@@ -167,9 +192,17 @@ Last-Update: Thu, 05 Sep 2019 15:07:37 +0200
break
if not okflg:
break
---- a/test/formats.py
-+++ b/test/formats.py
-@@ -45,9 +45,9 @@ class Cigar:
+--- smalt.orig/test/formats.py
++++ smalt/test/formats.py
+@@ -24,6 +24,7 @@
+ # #
+ #############################################################################
+ #############################################################################
++from operator import ne
+
+ class Cigar:
+ from re import compile
+@@ -45,9 +46,9 @@
self.parse(lin)
okflg = self.ok
if Cigar.DEBUG:
@@ -181,7 +214,7 @@ Last-Update: Thu, 05 Sep 2019 15:07:37 +0200
return isEOF
def parse(self, lin):
-@@ -66,11 +66,11 @@ class Cigar:
+@@ -66,11 +67,11 @@
self.cigar.strip()
self.ok = True
if Cigar.DEBUG:
@@ -195,7 +228,23 @@ Last-Update: Thu, 05 Sep 2019 15:07:37 +0200
self._blank()
def getMateNo(self):
-@@ -118,10 +118,10 @@ def getNextCigarPair(infil, cigA, cigB,
+@@ -101,6 +102,15 @@
+ if rv: return rv
+
+ return cmp(other.sseg[1], self.sseg[1])
++
++ def __ne__(self, other):
++ rv = ne(self.snam, other.snam)
++ if rv: return rv
++
++ rv = ne(self.sseg[0], other.sseg[0])
++ if rv: return rv
++
++ return ne(other.sseg[1], self.sseg[1])
+
+ def getNextCigarPair(infil, cigA, cigB, mateno_check = True):
+ isOk = False
+@@ -118,10 +128,10 @@
isOk = True
if not isEOF and mateno_check:
if cigA.qnam[-2] != cigB.qnam[-2]:
@@ -208,7 +257,7 @@ Last-Update: Thu, 05 Sep 2019 15:07:37 +0200
isOk = False
return (isOk, isEOF)
-@@ -151,6 +151,6 @@ if __name__ == "__main__":
+@@ -151,6 +161,6 @@
infil = openFile(argv[1])
while not cig.next(infil):
@@ -216,9 +265,9 @@ Last-Update: Thu, 05 Sep 2019 15:07:37 +0200
+ print(cig.qnam)
infil.close()
---- a/test/mthread_test.py
-+++ b/test/mthread_test.py
-@@ -57,12 +57,12 @@ def cmpCigarFiles(cigfilA, cigfilB, is_v
+--- smalt.orig/test/mthread_test.py
++++ smalt/test/mthread_test.py
+@@ -57,12 +57,12 @@
break
if cigA1 != cigB1:
if is_verbose:
@@ -234,7 +283,7 @@ Last-Update: Thu, 05 Sep 2019 15:07:37 +0200
if cigA2.mapq > MAPQ_THRESH and cigB2.mapq > MAPQ_THRESH:
exit("Discrepancy:\n%s\n%s" % (cigA2.lin, cigB2.lin))
ctr = ctr + 1
-@@ -93,7 +93,7 @@ if __name__ == '__main__':
+@@ -93,7 +93,7 @@
isOK, pairctr = cmpCigarFiles(oufilnam_ref, oufilnam_thread, VERBOSE)
if VERBOSE:
@@ -243,9 +292,9 @@ Last-Update: Thu, 05 Sep 2019 15:07:37 +0200
if not isOK or pairctr != n_pairs_expected:
exit("Using smalt in multi-threaded mode gave inconsistent results!")
---- a/test/results_split_test.py
-+++ b/test/results_split_test.py
-@@ -35,7 +35,7 @@ READSEQS = ("@SIM_000000000_contig5121_0
+--- smalt.orig/test/results_split_test.py
++++ smalt/test/results_split_test.py
+@@ -35,7 +35,7 @@
"AAAAGAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAA\n"\
"+\n"\
"daBZddeYdBfe`fBf`ecfdfcf`c\eacXdbLe^b``ccadK]e]^_T"\
@@ -254,9 +303,9 @@ Last-Update: Thu, 05 Sep 2019 15:07:37 +0200
)
# cigar:S:16 SIM_000000000_contig5121_000000001_5120_R_20m/1 20 1 - contig5121 1 20 + 20 M 20
---- a/test/splitReads_test.py
-+++ b/test/splitReads_test.py
-@@ -79,13 +79,13 @@ def checkOutput(cigfilnam, expected_tup)
+--- smalt.orig/test/splitReads_test.py
++++ smalt/test/splitReads_test.py
+@@ -79,13 +79,13 @@
while not cig.next(infil):
if linctr > n_tup:
allok = False
@@ -273,7 +322,7 @@ Last-Update: Thu, 05 Sep 2019 15:07:37 +0200
allok = False
break
-@@ -94,7 +94,7 @@ def checkOutput(cigfilnam, expected_tup)
+@@ -94,7 +94,7 @@
for i in range(n_tup):
if not okflgs[i]:
@@ -282,9 +331,9 @@ Last-Update: Thu, 05 Sep 2019 15:07:37 +0200
allok = False
if not allok:
---- a/test/testdata.py
-+++ b/test/testdata.py
-@@ -62,7 +62,7 @@ class DataFiles:
+--- smalt.orig/test/testdata.py
++++ smalt/test/testdata.py
+@@ -62,7 +62,7 @@
if len(filnam) < 4 or filnam[-3:] != '.gz': fn_from = fn_from + '.gz'
fn_to = path.join(DataFiles.WORKDIR, filnam)
infil = openFile(fn_from, 'r')
@@ -293,7 +342,7 @@ Last-Update: Thu, 05 Sep 2019 15:07:37 +0200
self.logfil_out.write("unpacking '%s' -> '%s'\n" % (fn_from, fn_to))
while 1:
lin = infil.readline()
-@@ -139,9 +139,9 @@ class DataFiles:
+@@ -139,9 +139,9 @@
for filnam in (self.datafiles + self.tmpfiles):
if access(filnam, F_OK):
remove(filnam)
@@ -305,7 +354,7 @@ Last-Update: Thu, 05 Sep 2019 15:07:37 +0200
self.datafiles = []
self.tmpfiles = []
try:
-@@ -159,7 +159,7 @@ def openFile(filnam, mode = 'r'):
+@@ -159,7 +159,7 @@
else:
oufil = open(filnam, mode)
except:
@@ -314,8 +363,8 @@ Last-Update: Thu, 05 Sep 2019 15:07:37 +0200
exit(1)
return oufil
---- a/test/sample_test.py
-+++ b/test/sample_test.py
+--- smalt.orig/test/sample_test.py
++++ smalt/test/sample_test.py
@@ -1,5 +1,7 @@
# test sampling of insert lengths
@@ -324,7 +373,7 @@ Last-Update: Thu, 05 Sep 2019 15:07:37 +0200
PROGNAM = "../src/smalt"
REF_FASTA_NAME = "genome_1.fa.gz"
READ_PREFIX = "gen1l75i300e0"
-@@ -105,10 +107,10 @@ def compare_mapping(oufilnam1, oufilnam2
+@@ -105,12 +107,12 @@
break
ctr2 = ctr2 + 1
@@ -333,7 +382,11 @@ Last-Update: Thu, 05 Sep 2019 15:07:37 +0200
exit("readnames don't match: '%s' vs '%s'" % \
(cig1.qnam, cig2.qnam))
- if cmp(cig1,cig2) and cig1.mapq > 5 and cig2.mapq > 5:
+- exit("mappings don't match for read '%s'" % \
+- cig1.qnam)
+ if ne(cig1,cig2) and cig1.mapq > 5 and cig2.mapq > 5:
- exit("mappings don't match for read '%s'" % \
- cig1.qnam)
++ exit("mappings don't match for read '{}'; cig1: {}, cig2: {}, sig1.mapq: {}, sig2.mapq: {}".format(
++ cig1.qnam, cig1, cig2, cig1.mapq, cig2.mapq))
infil2.close()
+ infil1.close()
+
=====================================
debian/tests/run-unit-test
=====================================
@@ -35,7 +35,7 @@ for tst in $TESTS ; do
#python $tst
#rm -f smalt_Xali_test
else
- python $tst
+ python3 $tst
fi
done
View it on GitLab: https://salsa.debian.org/med-team/smalt/commit/8c309fc405dee49e5d26a90dc504bd5cbd7b5365
--
View it on GitLab: https://salsa.debian.org/med-team/smalt/commit/8c309fc405dee49e5d26a90dc504bd5cbd7b5365
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/20200103/805f4e66/attachment-0001.html>
More information about the debian-med-commit
mailing list