New upstream version 0.15.1+ds
authorSteffen Moeller <moeller@debian.org>
Fri, 14 Sep 2018 08:43:38 +0000 (10:43 +0200)
committerSteffen Moeller <moeller@debian.org>
Fri, 14 Sep 2018 08:43:38 +0000 (10:43 +0200)
.gitignore
NEWS
bcftools/config.h [deleted file]
doc/release.rst
pysam/libcalignmentfile.pyx
tests/AlignmentFileHeader_test.py
tests/AlignmentFile_test.py
tests/pysam_data/Makefile
tests/samtools_test.py

index 74fde571bc60b9522c960ecb55290d59da96c161..fd28d6d2e22a76fc0840fa2db8ba2f8451aabf67 100644 (file)
@@ -17,6 +17,7 @@ tests/cbcf_data
 tests/tabix_data
 
 samtools/config.h
+bcftools/config.g
 htslib/config.status
 htslib/config.h
 htslib/config.log
diff --git a/NEWS b/NEWS
index 61b925427c2fe80178b7c0e2e91158be78682553..0ac73032f1fc9231c92299faabd231959ef27174 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -5,10 +5,19 @@ http://pysam.readthedocs.io/en/latest/release.html
 Release notes
 =============
 
+Release 0.15.1
+==============
+
+Bugfix release.
+
+* [#716] raise ValueError if tid is out of range when writing
+* [#697] release version using cython 0.28.5 for python 3.7
+  compatibility
+
 Release 0.15.0
 ==============
 
-This release wraps htslib/samtools/bcftools version 1.9.0.
+This release wraps htslib (and friends) version 1.9.
 
 * [#673] permit dash in chromosome name of region string
 * [#656] Support `text` when opening a SAM file for writing
@@ -67,13 +76,13 @@ Backwards incompatible changes:
 
   The rationale for this change is to have consistency between
   AlignmentFile and VariantFile.
-             
+
 * AlignmentFile and FastaFile now raise IOError instead of OSError
 
 Medium term we plan to have a 1.0 release. The pysam
 interface has grown over the years and the API is cluttered with
 deprecated names (Samfile, getrname(), gettid(), ...). To work towards
-this, the next release (0.15.0) will yield DeprecationWarnings 
+this, the next release (0.15.0) will yield DeprecationWarnings
 for any parts of the API that are considered obsolete and will not be
 in 1.0. Once 1.0 has been reached, we will use semantic versioning.
 
@@ -142,7 +151,7 @@ are created will need to change as the constructor requires a header::
     header = pysam.AlignmentHeader(
         reference_names=["chr1", "chr2"],
         reference_lengths=[1000, 1000])
-        
+
     read = pysam.AlignedSegment(header)
 
 This will affect all code that instantiates AlignedSegment objects
@@ -212,7 +221,7 @@ Release 0.11.0
 This release wraps the latest versions of htslib/samtools/bcftools and
 implements a few bugfixes.
 
-* [#413] Wrap HTSlib/Samtools/BCFtools 1.4 
+* [#413] Wrap HTSlib/Samtools/BCFtools 1.4
 * [#422] Fix missing pysam.sort.usage() message
 * [#411] Fix BGZfile initialization bug
 * [#412] Add seek support for BGZFile
@@ -355,7 +364,7 @@ Potential isses when upgrading from v0.8.3:
 
 * binary tags are now returned as python arrays
 
-* renamed several methods for pep8 compatibility, old names still retained for 
+* renamed several methods for pep8 compatibility, old names still retained for
   backwards compatibility, but should be considered deprecated.
    * gettid() is now get_tid()
    * getrname() is now get_reference_name()
@@ -365,7 +374,7 @@ Potential isses when upgrading from v0.8.3:
   names being present:
    * fromQualityString() is now qualitystring_to_array()
    * toQualityString() is now qualities_to_qualitystring()
-   
+
 * faidx now returns strings and not binary strings in py3.
 
 * The cython components have been broken up into smaller files with
@@ -474,7 +483,7 @@ Release 0.8.2
   with reading and writing capability. However, the interface is still
   incomplete and preliminary and lacks capability to mutate the
   resulting data.
-  
+
 Release 0.8.1
 =============
 
@@ -485,8 +494,8 @@ Release 0.8.1
   * issue #42: skip tests requiring network if none available
   * issue #19: multiple iterators can now be made to work on the same tabix file
   * issue #24: All strings returned from/passed to the pysam API are now unicode in python 3
-  * issue #5:  type guessing for lists of integers fixed    
-    
+  * issue #5:  type guessing for lists of integers fixed
+
 * API changes for consistency. The old API is still present,
   but deprecated.
   In particular:
@@ -516,7 +525,7 @@ Release 0.8.1
      * qstart -> query_alignment_start
      * qend -> query_alignment_end
      * qlen -> query_alignment_length
-     * mrnm -> next_reference_id   
+     * mrnm -> next_reference_id
      * mpos -> next_reference_start
      * rname -> reference_id
      * isize -> template_length
@@ -539,7 +548,7 @@ Backwards incompatible changes
 * Empty cigarstring now returns None (intstead of '')
 * Empty cigar now returns None (instead of [])
 * When using the extension classes in cython modules, AlignedRead
-  needs to be substituted with AlignedSegment. 
+  needs to be substituted with AlignedSegment.
 * fancy_str() has been removed
 * qual, qqual now return arrays
 
@@ -603,18 +612,18 @@ Release 0.7.5
 
 Release 0.7.4
 =============
-       
+
 * further bugfixes to setup.py and package layout
 
 Release 0.7.3
 =============
-       
+
 * further bugfixes to setup.py
 * upgraded distribute_setup.py to 0.6.34
 
 Release 0.7.2
 =============
-  
+
 * bugfix in installer - failed when cython not present
 * changed installation locations of shared libraries
 
diff --git a/bcftools/config.h b/bcftools/config.h
deleted file mode 100644 (file)
index f8fff59..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-/* empty config.h created by pysam */
-/* conservative compilation options */
index 0e3b96360c8bc3ceebd4dec27f600118383617ae..ed3afb2d50da5b7f61cd6e296b4dcfcb63429dcf 100644 (file)
@@ -2,6 +2,15 @@
 Release notes
 =============
 
+Release 0.15.1
+==============
+
+Bugfix release.
+
+* [#716] raise ValueError if tid is out of range when writing
+* [#697] release version using cython 0.28.5 for python 3.7
+  compatibility
+
 Release 0.15.0
 ==============
 
index 9e4f5a71c797b6a6e95aa241617070f25d937722..1d42dda9bc0a86beab914d8af1f6fdd89cd8c4d2 100644 (file)
@@ -1713,8 +1713,13 @@ cdef class AlignmentFile(HTSFile):
         if not self.is_open:
             return 0
 
+        if self.header.ptr.n_targets <= read._delegate.core.tid:
+            raise ValueError(
+                "AlignedSegment refers to reference number {} that "
+                "is larger than the number of references ({}) in the header".format(
+                    read._delegate.core.tid, self.header.ptr.n_targets))
+        
         cdef int ret
-
         with nogil:
             ret = sam_write1(self.htsfile,
                              self.header.ptr,
index 1cf733e0eff2e980405e46ef1f3201379aeddea1..b72c8ef3148c69bf1b521ef55bf0a0ad85fc0e62 100644 (file)
@@ -120,8 +120,7 @@ class TestHeaderConstruction(unittest.TestCase):
             reference_lengths=[1575, 1584])
         self.compare_headers(header, self.header_without_text)
         self.check_name_mapping(header)
-        
-        
+
 class TestHeaderSAM(unittest.TestCase):
     """testing header manipulation"""
 
index 0068bb7ac5e8f38468dc23a58acdb02632f60020..ec0f5e1d42ecf081a78e1f98f57a99b97c5c7629 100644 (file)
@@ -1259,7 +1259,7 @@ class TestWrongFormat(unittest.TestCase):
                           'rb')
 
 
-class TestRegionParsiong(unittest.TestCase):
+class TestRegionParsing(unittest.TestCase):
 
     def test_dash_in_chr(self):
         with pysam.AlignmentFile(
@@ -1290,7 +1290,7 @@ class TestDeNovoConstruction(unittest.TestCase):
     def setUp(self):
 
         header = pysam.AlignmentHeader.from_dict(self.header)
-        
+
         a = pysam.AlignedSegment(header)
         a.query_name = "read_28833_29006_6945"
         a.query_sequence = "AGCTTAGCTAGCTACCTATATCTTGGTCTTGGCCG"
@@ -1407,7 +1407,30 @@ class TestEmptyHeader(unittest.TestCase):
         self.assertTrue("SQ" in s.header.to_dict())
         self.assertTrue("@SQ" in str(s.header))
 
-        
+
+class TestMismatchingHeader(unittest.TestCase):
+    '''see issue 716.'''
+
+    def testMismatchingHeader(self):
+        # Note: no chr2
+        header = {
+            'SQ': [{'SN': 'chr1', 'LN': 1575}],
+            'PG': [{'ID': 'bwa', 'PN': 'bwa', 'VN': '0.7.15', 'CL': 'bwa mem xx -'}],
+        }
+
+        dest = get_temp_filename("tmp_ex3.bam")
+        with pysam.AlignmentFile(os.path.join(BAM_DATADIR, 'ex3.bam')) as inf:
+            with pysam.AlignmentFile(dest, mode="wb", header=header) as outf:
+                for read in inf:
+                    if read.reference_name == "chr1":
+                        outf.write(read)
+                    else:
+                        self.assertRaises(ValueError,
+                                          outf.write,
+                                          read)
+        os.unlink(dest)
+
+
 class TestHeaderWithProgramOptions(unittest.TestCase):
 
     '''see issue 39.'''
@@ -1436,7 +1459,7 @@ class TestTruncatedBAM(unittest.TestCase):
                           pysam.AlignmentFile,
                           os.path.join(BAM_DATADIR, 'ex2_truncated.bam'))
 
-    def testTruncatedBam2(self):
+    def testTruncatedBamIterator(self):
         s = pysam.AlignmentFile(os.path.join(BAM_DATADIR, 'ex2_truncated.bam'),
                                 ignore_truncation=True)
 
index bb38a4f4548327c3ae96e4cce624b271adea6f30..bae50db8b6472b574d4591e189c1646612678bea 100644 (file)
@@ -91,6 +91,7 @@ clean:
        rm -fr *.bam *.bai *.fai *.pileup* *.cram \
        *~ calDepth *.dSYM pysam_*.sam \
        ex2.sam ex2.sam.gz ex1.sam \
+       with_md.sam.gz \
        *.fq.gz
 
 %.fq.gz: %.fq
index e84c7e55c95cf20ecf8990b2d13523654800f2c8..40d84c08f8a79db88cfbde19d211052dd1dba61d 100644 (file)
@@ -266,7 +266,8 @@ class SamtoolsTest(unittest.TestCase):
             # ignore commands that exit or cause other failures
             # TODO: check - if reheader or phase is run in testStatements, sort fails
             # here
-            if command in ("view", "sort", "bam2fq", "flagstat", "reheader", "stats"):
+            if command in ("view", "sort", "bam2fq", "flagstat", "reheader",
+                           "stats", "idxstats"):
                 continue
             mapped_command = self.get_command(statement, map_to_internal=True)
             pysam_method = getattr(self.module, mapped_command)