cope with change to Tabix index format
authorMichael R. Crusoe <michael.crusoe@gmail.com>
Wed, 20 Feb 2019 08:38:20 +0000 (00:38 -0800)
committerMichael R. Crusoe <michael.crusoe@gmail.com>
Wed, 20 Feb 2019 09:50:11 +0000 (01:50 -0800)
debian/changelog
debian/patches/series
debian/patches/test_index_not_compression [new file with mode: 0644]

index 1d5eaad3d93d711b6dbf41bc01eafc517ecc74bf..9aaaff13d35ae3dbcf2528f95de3a56519b55cee 100644 (file)
@@ -1,3 +1,11 @@
+python-pysam (0.15.2+ds-2) UNRELEASED; urgency=medium
+
+  * Team upload.
+  * For the Tabix tests: test the index contents, not the compression scheme.
+    Closes: #919928, #920250
+
+ -- Michael R. Crusoe <michael.crusoe@gmail.com>  Wed, 20 Feb 2019 01:34:19 -0800
+
 python-pysam (0.15.2+ds-1) unstable; urgency=medium
 
   * Team upload.
index d87fe71f354b58d4a8fb2d7dd7f04d8880cbb989..b6c4823590c7373583f1be818cae390fd8abc085 100644 (file)
@@ -1,3 +1,4 @@
 skip_test_remote.patch
 skip_test_needing_missing_data.patch
 spelling
+test_index_not_compression
diff --git a/debian/patches/test_index_not_compression b/debian/patches/test_index_not_compression
new file mode 100644 (file)
index 0000000..b5ca774
--- /dev/null
@@ -0,0 +1,70 @@
+From: Michael R. Crusoe <michael.crusoe@gmail.com>
+Subject: Test Tabix index contents, not the compression
+
+Fixes: https://github.com/samtools/htslib/issues/827
+
+--- python-pysam.orig/tests/tabix_test.py
++++ python-pysam/tests/tabix_test.py
+@@ -14,8 +14,6 @@
+ import subprocess
+ import glob
+ import re
+-import copy
+-import tempfile
+ from TestUtils import check_url, load_and_convert, TABIX_DATADIR, get_temp_filename
+ IS_PYTHON3 = sys.version_info[0] >= 3
+@@ -64,6 +62,17 @@
+     return found
++def checkGZBinaryEqual(filename1, filename2):
++    '''return true if the two files are binary equal.'''
++    with gzip.open(filename1, "rb") as infile1:
++        d1 = infile1.read()
++        with gzip.open(filename2, "rb") as infile2:
++            d2 = infile2.read()
++        if d1 == d2:
++            return True
++    return False
++
++
+ class TestIndexing(unittest.TestCase):
+     filename = os.path.join(TABIX_DATADIR, "example.gtf.gz")
+     filename_idx = os.path.join(TABIX_DATADIR, "example.gtf.gz.tbi")
+@@ -77,7 +86,7 @@
+         '''test indexing via preset.'''
+         pysam.tabix_index(self.tmpfilename, preset="gff")
+-        self.assertTrue(checkBinaryEqual(
++        self.assertTrue(checkGZBinaryEqual(
+             self.tmpfilename + ".tbi", self.filename_idx))
+     def test_indexing_to_custom_location_works(self):
+@@ -86,7 +95,7 @@
+         index_path = get_temp_filename(suffix='custom.tbi')
+         pysam.tabix_index(self.tmpfilename, preset="gff",
+                           index=index_path, force=True)
+-        self.assertTrue(checkBinaryEqual(index_path, self.filename_idx))
++        self.assertTrue(checkGZBinaryEqual(index_path, self.filename_idx))
+         os.unlink(index_path)
+     def test_indexing_with_explict_columns_works(self):
+@@ -98,7 +107,7 @@
+                           end_col=4,
+                           line_skip=0,
+                           zerobased=False)
+-        self.assertTrue(checkBinaryEqual(
++        self.assertTrue(checkGZBinaryEqual(
+             self.tmpfilename + ".tbi", self.filename_idx))
+     def test_indexing_with_lineskipping_works(self):
+@@ -109,7 +118,7 @@
+                           end_col=4,
+                           line_skip=1,
+                           zerobased=False)
+-        self.assertFalse(checkBinaryEqual(
++        self.assertFalse(checkGZBinaryEqual(
+             self.tmpfilename + ".tbi", self.filename_idx))
+     def tearDown(self):