Imported Upstream version 0.5
[pysam.git] / pysam / csamtools.c
index ca5fb4ea00c05ad980ef6a497207aa035c50d2ec..6e18ed67e74be88d34b093dda8deb09205244cda 100644 (file)
@@ -1,4 +1,4 @@
-/* Generated by Cython 0.14.1 on Fri Nov 25 19:51:23 2011 */
+/* Generated by Cython 0.13 on Tue Jun  7 17:24:36 2011 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
   #define PyBytes_Repr                 PyString_Repr
   #define PyBytes_Concat               PyString_Concat
   #define PyBytes_ConcatAndDel         PyString_ConcatAndDel
-#endif
-
-#if PY_VERSION_HEX < 0x02060000
   #define PySet_Check(obj)             PyObject_TypeCheck(obj, &PySet_Type)
   #define PyFrozenSet_Check(obj)       PyObject_TypeCheck(obj, &PyFrozenSet_Type)
 #endif
+
 #ifndef PySet_CheckExact
-  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
+#  define PySet_CheckExact(obj)          (Py_TYPE(obj) == &PySet_Type)
 #endif
 
-#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
-
 #if PY_MAJOR_VERSION >= 3
-  #define PyIntObject                  PyLongObject
   #define PyInt_Type                   PyLong_Type
   #define PyInt_Check(op)              PyLong_Check(op)
   #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
 #endif
 
 #if PY_MAJOR_VERSION >= 3
-  #define PyBoolObject                 PyLongObject
+  #define PyBoolObject PyLongObject
 #endif
 
 
   #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
 #endif
 
-#if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300)
-  #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b)
-  #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value)
-  #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b)
-#else
-  #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \
-        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \
-        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \
-            (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0)))
-  #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \
-        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
-        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \
-            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1)))
-  #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \
-        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
-        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \
-            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1)))
-#endif
-
 #if PY_MAJOR_VERSION >= 3
   #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
 #endif
 #include "stdint.h"
 #include "bam.h"
 #include "sam.h"
+#include "glf.h"
+#include "bam_maqcns.h"
 #include "faidx.h"
 #include "pysam_util.h"
 #include "pythread.h"
 
-#ifdef PYREX_WITHOUT_ASSERTIONS
-#define CYTHON_WITHOUT_ASSERTIONS
-#endif
-
-
 /* inline attribute */
 #ifndef CYTHON_INLINE
   #if defined(__GNUC__)
   #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
     #define CYTHON_INLINE inline
   #else
-    #define CYTHON_INLINE
+    #define CYTHON_INLINE 
   #endif
 #endif
 
 #ifndef CYTHON_UNUSED
 # if defined(__GNUC__)
 #   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
-#     define CYTHON_UNUSED __attribute__ ((__unused__))
+#     define CYTHON_UNUSED __attribute__ ((__unused__)) 
 #   else
 #     define CYTHON_UNUSED
 #   endif
 # elif defined(__ICC) || defined(__INTEL_COMPILER)
-#   define CYTHON_UNUSED __attribute__ ((__unused__))
+#   define CYTHON_UNUSED __attribute__ ((__unused__)) 
 # else
-#   define CYTHON_UNUSED
+#   define CYTHON_UNUSED 
 # endif
 #endif
 
@@ -289,7 +262,7 @@ static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);
 
 #ifdef __GNUC__
 /* Test for GCC > 2.95 */
-#if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95))
+#if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) 
 #define likely(x)   __builtin_expect(!!(x), 1)
 #define unlikely(x) __builtin_expect(!!(x), 0)
 #else /* __GNUC__ > 2 ... */
@@ -315,12 +288,11 @@ static const char *__pyx_f[] = {
   "csamtools.pyx",
   "csamtools.pxd",
   "bool.pxd",
-  "complex.pxd",
 };
 
 /* Type declarations */
 
-/* "csamtools.pyx":388
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":388
  *      counter[0] += 1;
  * 
  * ctypedef struct MateData:             # <<<<<<<<<<<<<<
@@ -334,7 +306,7 @@ typedef struct {
   uint32_t flag;
 } __pyx_t_9csamtools_MateData;
 
-/* "csamtools.pyx":1537
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1478
  * ##-------------------------------------------------------------------
  * ##-------------------------------------------------------------------
  * ctypedef struct __iterdata:             # <<<<<<<<<<<<<<
@@ -351,7 +323,7 @@ typedef struct {
   int seq_len;
 } __pyx_t_9csamtools___iterdata;
 
-/* "csamtools.pyx":1717
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1655
  *         bam_plp_set_mask( self.pileup_iter, self.mask )
  * 
  *     cdef setupIteratorData( self,             # <<<<<<<<<<<<<<
@@ -364,7 +336,99 @@ struct __pyx_opt_args_9csamtools_14IteratorColumn_setupIteratorData {
   int reopen;
 };
 
-/* "csamtools.pyx":91
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3192
+ *         bam_maqindel_ret_destroy(self._r)
+ * 
+ * cdef class IndelCallerBase:             # <<<<<<<<<<<<<<
+ *     '''Base class for SNP callers.
+ * 
+ */
+
+struct __pyx_obj_9csamtools_IndelCallerBase {
+  PyObject_HEAD
+  bam_maqindel_opt_t *options;
+  struct __pyx_obj_9csamtools_IteratorColumn *iter;
+  int cap_mapQ;
+  int max_depth;
+};
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3330
+ *         return self._call()
+ * 
+ * cdef class IteratorIndelCalls( IndelCallerBase ):             # <<<<<<<<<<<<<<
+ *     """*(IteratorColumn iterator)*
+ * 
+ */
+
+struct __pyx_obj_9csamtools_IteratorIndelCalls {
+  struct __pyx_obj_9csamtools_IndelCallerBase __pyx_base;
+};
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":244
+ * ## Public methods
+ * ######################################################################
+ * cdef class Fastafile:             # <<<<<<<<<<<<<<
+ *     '''*(filename)*
+ * 
+ */
+
+struct __pyx_obj_9csamtools_Fastafile {
+  PyObject_HEAD
+  struct __pyx_vtabstruct_9csamtools_Fastafile *__pyx_vtab;
+  char *_filename;
+  faidx_t *fastafile;
+};
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3103
+ *         return call
+ * 
+ * cdef class IndelCall:             # <<<<<<<<<<<<<<
+ *     '''the results of an indel call.'''
+ *     cdef int _tid
+ */
+
+struct __pyx_obj_9csamtools_IndelCall {
+  PyObject_HEAD
+  int _tid;
+  int _pos;
+  int _coverage;
+  int _rms_mapping_quality;
+  bam_maqindel_ret_t *_r;
+};
+
+/* "pysam/csamtools.pxd":388
+ *     cdef bam1_t * _delegate
+ * 
+ * cdef class Samfile:             # <<<<<<<<<<<<<<
+ *     cdef char * _filename
+ *     # pointer to samfile
+ */
+
+struct __pyx_obj_9csamtools_Samfile {
+  PyObject_HEAD
+  struct __pyx_vtabstruct_9csamtools_Samfile *__pyx_vtab;
+  char *_filename;
+  samfile_t *samfile;
+  bam_index_t *index;
+  int isbam;
+  int isremote;
+  bam1_t *b;
+  char *mode;
+};
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3287
+ *         return call
+ * 
+ * cdef class IndelCaller( IndelCallerBase ):             # <<<<<<<<<<<<<<
+ *     '''*(IteratorColumn iterator_column )*
+ * 
+ */
+
+struct __pyx_obj_9csamtools_IndelCaller {
+  struct __pyx_obj_9csamtools_IndelCallerBase __pyx_base;
+};
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":91
  *      return dest
  * 
  * cdef class PileupRead             # <<<<<<<<<<<<<<
@@ -383,66 +447,103 @@ struct __pyx_obj_9csamtools_PileupRead {
   uint32_t _is_tail;
 };
 
-/* "csamtools.pxd":423
- *     cdef char * _getrname( self, int tid )
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2816
+ *     return retval, out_stderr, out_stdout
  * 
- * cdef class IteratorRow:             # <<<<<<<<<<<<<<
- *     pass
+ * cdef class SNPCall:             # <<<<<<<<<<<<<<
+ *     '''the results of a SNP call.'''
+ *     cdef int _tid
+ */
+
+struct __pyx_obj_9csamtools_SNPCall {
+  PyObject_HEAD
+  int _tid;
+  int _pos;
+  char _reference_base;
+  char _genotype;
+  int _consensus_quality;
+  int _snp_quality;
+  int _rms_mapping_quality;
+  int _coverage;
+};
+
+/* "pysam/csamtools.pxd":383
+ * 
+ * # need to declare all C fields and methods here
+ * cdef class AlignedRead:             # <<<<<<<<<<<<<<
  * 
+ *     # object that this AlignedRead represents
  */
 
-struct __pyx_obj_9csamtools_IteratorRow {
+struct __pyx_obj_9csamtools_AlignedRead {
   PyObject_HEAD
+  bam1_t *_delegate;
 };
 
-/* "csamtools.pyx":1415
- *         if self.owns_samfile: samclose( self.fp )
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1542
+ *     return ret
+ * 
+ * cdef class IteratorColumn:             # <<<<<<<<<<<<<<
+ *     '''abstract base class for iterators over columns.
  * 
- * cdef class IteratorRowAllRefs(IteratorRow):             # <<<<<<<<<<<<<<
- *     """iterates over all mapped reads by chaining iterators over each reference
- *     """
  */
 
-struct __pyx_obj_9csamtools_IteratorRowAllRefs {
-  struct __pyx_obj_9csamtools_IteratorRow __pyx_base;
-  struct __pyx_obj_9csamtools_Samfile *samfile;
+struct __pyx_obj_9csamtools_IteratorColumn {
+  PyObject_HEAD
+  struct __pyx_vtabstruct_9csamtools_IteratorColumn *__pyx_vtab;
+  struct __pyx_obj_9csamtools_IteratorRowRegion *iter;
   int tid;
-  struct __pyx_obj_9csamtools_IteratorRowRegion *rowiter;
+  int pos;
+  int n_plp;
+  int mask;
+  const bam_pileup1_t * plp;
+  bam_plp_t pileup_iter;
+  __pyx_t_9csamtools___iterdata iterdata;
+  struct __pyx_obj_9csamtools_Samfile *samfile;
+  struct __pyx_obj_9csamtools_Fastafile *fastafile;
+  PyObject *stepper;
 };
 
-/* "csamtools.pxd":426
- *     pass
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1712
+ *             self.iterdata.seq = NULL
  * 
- * cdef class IteratorRowAll(IteratorRow):             # <<<<<<<<<<<<<<
- *     cdef bam1_t * b
- *     cdef samfile_t * fp
+ * cdef class IteratorColumnRegion(IteratorColumn):             # <<<<<<<<<<<<<<
+ *     '''iterates over a region only.
+ *     '''
  */
 
-struct __pyx_obj_9csamtools_IteratorRowAll {
-  struct __pyx_obj_9csamtools_IteratorRow __pyx_base;
-  struct __pyx_vtabstruct_9csamtools_IteratorRowAll *__pyx_vtab;
-  bam1_t *b;
-  samfile_t *fp;
-  int owns_samfile;
+struct __pyx_obj_9csamtools_IteratorColumnRegion {
+  struct __pyx_obj_9csamtools_IteratorColumn __pyx_base;
 };
 
-/* "csamtools.pyx":82
- *     return dest
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1187
+ * ##-------------------------------------------------------------------
+ * ##-------------------------------------------------------------------
+ * cdef class IteratorRow:             # <<<<<<<<<<<<<<
+ *     '''abstract base class for iterators over mapped reads.
  * 
- * cdef class PileupProxy             # <<<<<<<<<<<<<<
- * cdef makePileupProxy( bam_pileup1_t * plp, int tid, int pos, int n ):
- *      cdef PileupProxy dest = PileupProxy.__new__(PileupProxy)
  */
 
-struct __pyx_obj_9csamtools_PileupProxy {
+struct __pyx_obj_9csamtools_IteratorRow {
   PyObject_HEAD
-  bam_pileup1_t *plp;
+};
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1356
+ *         if self.owns_samfile: samclose( self.fp )
+ * 
+ * cdef class IteratorRowAllRefs(IteratorRow):             # <<<<<<<<<<<<<<
+ *     """iterates over all mapped reads by chaining iterators over each reference
+ *     """
+ */
+
+struct __pyx_obj_9csamtools_IteratorRowAllRefs {
+  struct __pyx_obj_9csamtools_IteratorRow __pyx_base;
+  struct __pyx_obj_9csamtools_Samfile *samfile;
   int tid;
-  int pos;
-  int n_pu;
+  struct __pyx_obj_9csamtools_IteratorRowRegion *rowiter;
 };
 
-/* "csamtools.pyx":1265
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1206
  *     pass
  * 
  * cdef class IteratorRowRegion(IteratorRow):             # <<<<<<<<<<<<<<
@@ -461,22 +562,19 @@ struct __pyx_obj_9csamtools_IteratorRowRegion {
   int owns_samfile;
 };
 
-/* "csamtools.pyx":244
- * ## Public methods
- * ######################################################################
- * cdef class Fastafile:             # <<<<<<<<<<<<<<
- *     '''*(filename)*
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1741
+ *                                      self.n_plp )
  * 
+ * cdef class IteratorColumnAllRefs(IteratorColumn):             # <<<<<<<<<<<<<<
+ *     """iterates over all columns by chaining iterators over each reference
+ *     """
  */
 
-struct __pyx_obj_9csamtools_Fastafile {
-  PyObject_HEAD
-  struct __pyx_vtabstruct_9csamtools_Fastafile *__pyx_vtab;
-  char *_filename;
-  faidx_t *fastafile;
+struct __pyx_obj_9csamtools_IteratorColumnAllRefs {
+  struct __pyx_obj_9csamtools_IteratorColumn __pyx_base;
 };
 
-/* "csamtools.pyx":1461
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1402
  *                 raise StopIteration
  * 
  * cdef class IteratorRowSelection(IteratorRow):             # <<<<<<<<<<<<<<
@@ -494,86 +592,62 @@ struct __pyx_obj_9csamtools_IteratorRowSelection {
   int owns_samfile;
 };
 
-/* "csamtools.pyx":1601
- *     return ret
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2873
  * 
- * cdef class IteratorColumn:             # <<<<<<<<<<<<<<
- *     '''abstract base class for iterators over columns.
+ * 
+ * cdef class SNPCallerBase:             # <<<<<<<<<<<<<<
+ *     '''Base class for SNP callers.
  * 
  */
 
-struct __pyx_obj_9csamtools_IteratorColumn {
+struct __pyx_obj_9csamtools_SNPCallerBase {
   PyObject_HEAD
-  struct __pyx_vtabstruct_9csamtools_IteratorColumn *__pyx_vtab;
-  struct __pyx_obj_9csamtools_IteratorRowRegion *iter;
-  int tid;
-  int pos;
-  int n_plp;
-  int mask;
-  const bam_pileup1_t * plp;
-  bam_plp_t pileup_iter;
-  __pyx_t_9csamtools___iterdata iterdata;
-  struct __pyx_obj_9csamtools_Samfile *samfile;
-  struct __pyx_obj_9csamtools_Fastafile *fastafile;
-  PyObject *stepper;
-  int max_depth;
+  struct __pyx_vtabstruct_9csamtools_SNPCallerBase *__pyx_vtab;
+  bam_maqcns_t *c;
+  struct __pyx_obj_9csamtools_IteratorColumn *iter;
 };
 
-/* "csamtools.pyx":1806
- *                                      self.n_plp )
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3021
+ *         return call
+ * 
+ * cdef class SNPCaller( SNPCallerBase ):             # <<<<<<<<<<<<<<
+ *     '''*(IteratorColumn iterator_column )*
  * 
- * cdef class IteratorColumnAllRefs(IteratorColumn):             # <<<<<<<<<<<<<<
- *     """iterates over all columns by chaining iterators over each reference
- *     """
  */
 
-struct __pyx_obj_9csamtools_IteratorColumnAllRefs {
-  struct __pyx_obj_9csamtools_IteratorColumn __pyx_base;
+struct __pyx_obj_9csamtools_SNPCaller {
+  struct __pyx_obj_9csamtools_SNPCallerBase __pyx_base;
 };
 
-/* "csamtools.pxd":394
- *     cdef bam1_t * _delegate
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2946
+ *         sys.stdout.flush()
+ * 
+ * cdef class IteratorSNPCalls( SNPCallerBase ):             # <<<<<<<<<<<<<<
+ *     """*(IteratorColumn iterator)*
  * 
- * cdef class Samfile:             # <<<<<<<<<<<<<<
- *     cdef char * _filename
- *     # pointer to samfile
  */
 
-struct __pyx_obj_9csamtools_Samfile {
-  PyObject_HEAD
-  struct __pyx_vtabstruct_9csamtools_Samfile *__pyx_vtab;
-  char *_filename;
-  samfile_t *samfile;
-  bam_index_t *index;
-  int isbam;
-  int isstream;
-  int isremote;
-  bam1_t *b;
-  char *mode;
-  int64_t start_offset;
+struct __pyx_obj_9csamtools_IteratorSNPCalls {
+  struct __pyx_obj_9csamtools_SNPCallerBase __pyx_base;
 };
 
-/* "csamtools.pyx":2902
- *     return retval, out_stderr, out_stdout
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1292
+ *         if self.owns_samfile: samclose( self.fp )
+ * 
+ * cdef class IteratorRowAll(IteratorRow):             # <<<<<<<<<<<<<<
+ *     """*(Samfile samfile, int reopen = True)*
  * 
- * cdef class SNPCall:             # <<<<<<<<<<<<<<
- *     '''the results of a SNP call.'''
- *     cdef int _tid
  */
 
-struct __pyx_obj_9csamtools_SNPCall {
-  PyObject_HEAD
-  int _tid;
-  int _pos;
-  char _reference_base;
-  char _genotype;
-  int _consensus_quality;
-  int _snp_quality;
-  int _rms_mapping_quality;
-  int _coverage;
+struct __pyx_obj_9csamtools_IteratorRowAll {
+  struct __pyx_obj_9csamtools_IteratorRow __pyx_base;
+  struct __pyx_vtabstruct_9csamtools_IteratorRowAll *__pyx_vtab;
+  bam1_t *b;
+  samfile_t *fp;
+  int owns_samfile;
 };
 
-/* "csamtools.pyx":3456
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3370
  * 
  * 
  * cdef class IndexedReads:             # <<<<<<<<<<<<<<
@@ -589,33 +663,24 @@ struct __pyx_obj_9csamtools_IndexedReads {
   int owns_samfile;
 };
 
-/* "csamtools.pyx":1777
- *             self.iterdata.seq = NULL
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":82
+ *     return dest
  * 
- * cdef class IteratorColumnRegion(IteratorColumn):             # <<<<<<<<<<<<<<
- *     '''iterates over a region only.
- *     '''
+ * cdef class PileupProxy             # <<<<<<<<<<<<<<
+ * cdef makePileupProxy( bam_pileup1_t * plp, int tid, int pos, int n ):
+ *      cdef PileupProxy dest = PileupProxy.__new__(PileupProxy)
  */
 
-struct __pyx_obj_9csamtools_IteratorColumnRegion {
-  struct __pyx_obj_9csamtools_IteratorColumn __pyx_base;
-};
-
-/* "csamtools.pxd":389
- * 
- * # need to declare all C fields and methods here
- * cdef class AlignedRead:             # <<<<<<<<<<<<<<
- * 
- *     # object that this AlignedRead represents
- */
-
-struct __pyx_obj_9csamtools_AlignedRead {
+struct __pyx_obj_9csamtools_PileupProxy {
   PyObject_HEAD
-  bam1_t *_delegate;
+  bam_pileup1_t *plp;
+  int tid;
+  int pos;
+  int n_pu;
 };
 
 
-/* "csamtools.pyx":1601
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1542
  *     return ret
  * 
  * cdef class IteratorColumn:             # <<<<<<<<<<<<<<
@@ -633,7 +698,7 @@ struct __pyx_vtabstruct_9csamtools_IteratorColumn {
 static struct __pyx_vtabstruct_9csamtools_IteratorColumn *__pyx_vtabptr_9csamtools_IteratorColumn;
 
 
-/* "csamtools.pyx":1777
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1712
  *             self.iterdata.seq = NULL
  * 
  * cdef class IteratorColumnRegion(IteratorColumn):             # <<<<<<<<<<<<<<
@@ -647,7 +712,35 @@ struct __pyx_vtabstruct_9csamtools_IteratorColumnRegion {
 static struct __pyx_vtabstruct_9csamtools_IteratorColumnRegion *__pyx_vtabptr_9csamtools_IteratorColumnRegion;
 
 
-/* "csamtools.pyx":1265
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2873
+ * 
+ * 
+ * cdef class SNPCallerBase:             # <<<<<<<<<<<<<<
+ *     '''Base class for SNP callers.
+ * 
+ */
+
+struct __pyx_vtabstruct_9csamtools_SNPCallerBase {
+  PyObject *(*__dump)(struct __pyx_obj_9csamtools_SNPCallerBase *, glf1_t *, uint32_t, int);
+};
+static struct __pyx_vtabstruct_9csamtools_SNPCallerBase *__pyx_vtabptr_9csamtools_SNPCallerBase;
+
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3021
+ *         return call
+ * 
+ * cdef class SNPCaller( SNPCallerBase ):             # <<<<<<<<<<<<<<
+ *     '''*(IteratorColumn iterator_column )*
+ * 
+ */
+
+struct __pyx_vtabstruct_9csamtools_SNPCaller {
+  struct __pyx_vtabstruct_9csamtools_SNPCallerBase __pyx_base;
+};
+static struct __pyx_vtabstruct_9csamtools_SNPCaller *__pyx_vtabptr_9csamtools_SNPCaller;
+
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1206
  *     pass
  * 
  * cdef class IteratorRowRegion(IteratorRow):             # <<<<<<<<<<<<<<
@@ -662,7 +755,7 @@ struct __pyx_vtabstruct_9csamtools_IteratorRowRegion {
 static struct __pyx_vtabstruct_9csamtools_IteratorRowRegion *__pyx_vtabptr_9csamtools_IteratorRowRegion;
 
 
-/* "csamtools.pyx":1461
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1402
  *                 raise StopIteration
  * 
  * cdef class IteratorRowSelection(IteratorRow):             # <<<<<<<<<<<<<<
@@ -677,7 +770,7 @@ struct __pyx_vtabstruct_9csamtools_IteratorRowSelection {
 static struct __pyx_vtabstruct_9csamtools_IteratorRowSelection *__pyx_vtabptr_9csamtools_IteratorRowSelection;
 
 
-/* "csamtools.pyx":1806
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1741
  *                                      self.n_plp )
  * 
  * cdef class IteratorColumnAllRefs(IteratorColumn):             # <<<<<<<<<<<<<<
@@ -691,12 +784,12 @@ struct __pyx_vtabstruct_9csamtools_IteratorColumnAllRefs {
 static struct __pyx_vtabstruct_9csamtools_IteratorColumnAllRefs *__pyx_vtabptr_9csamtools_IteratorColumnAllRefs;
 
 
-/* "csamtools.pyx":415
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":415
  * 
  * 
  * cdef class Samfile:             # <<<<<<<<<<<<<<
- *     '''*(filename, mode=None, template = None, referencenames = None, referencelengths = None, text = NULL, header = None,
- *          add_sq_text = False )*
+ *     '''*(filename, mode=None, template = None, referencenames = None, referencelengths = None, text = NULL, header = None)*
+ * 
  */
 
 struct __pyx_vtabstruct_9csamtools_Samfile {
@@ -709,7 +802,7 @@ struct __pyx_vtabstruct_9csamtools_Samfile {
 static struct __pyx_vtabstruct_9csamtools_Samfile *__pyx_vtabptr_9csamtools_Samfile;
 
 
-/* "csamtools.pyx":244
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":244
  * ## Public methods
  * ######################################################################
  * cdef class Fastafile:             # <<<<<<<<<<<<<<
@@ -723,7 +816,7 @@ struct __pyx_vtabstruct_9csamtools_Fastafile {
 static struct __pyx_vtabstruct_9csamtools_Fastafile *__pyx_vtabptr_9csamtools_Fastafile;
 
 
-/* "csamtools.pyx":1351
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1292
  *         if self.owns_samfile: samclose( self.fp )
  * 
  * cdef class IteratorRowAll(IteratorRow):             # <<<<<<<<<<<<<<
@@ -737,6 +830,20 @@ struct __pyx_vtabstruct_9csamtools_IteratorRowAll {
 };
 static struct __pyx_vtabstruct_9csamtools_IteratorRowAll *__pyx_vtabptr_9csamtools_IteratorRowAll;
 
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2946
+ *         sys.stdout.flush()
+ * 
+ * cdef class IteratorSNPCalls( SNPCallerBase ):             # <<<<<<<<<<<<<<
+ *     """*(IteratorColumn iterator)*
+ * 
+ */
+
+struct __pyx_vtabstruct_9csamtools_IteratorSNPCalls {
+  struct __pyx_vtabstruct_9csamtools_SNPCallerBase __pyx_base;
+};
+static struct __pyx_vtabstruct_9csamtools_IteratorSNPCalls *__pyx_vtabptr_9csamtools_IteratorSNPCalls;
+
 #ifndef CYTHON_REFNANNY
   #define CYTHON_REFNANNY 0
 #endif
@@ -810,7 +917,7 @@ static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
   #define __Pyx_TraceDeclarations                                  \
   static PyCodeObject *__pyx_frame_code = NULL;                      \
   CYTHON_FRAME_MODIFIER PyFrameObject *__pyx_frame = NULL;           \
-  int __Pyx_use_tracing = 0;
+  int __Pyx_use_tracing = 0;                                                         
 
   #define __Pyx_TraceCall(funcname, srcfile, firstlineno)                            \
   if (unlikely(PyThreadState_GET()->use_tracing && PyThreadState_GET()->c_profilefunc)) {      \
@@ -840,9 +947,9 @@ static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
 #else
 
   #define __Pyx_TraceDeclarations
-  #define __Pyx_TraceCall(funcname, srcfile, firstlineno)
-  #define __Pyx_TraceException()
-  #define __Pyx_TraceReturn(result)
+  #define __Pyx_TraceCall(funcname, srcfile, firstlineno) 
+  #define __Pyx_TraceException() 
+  #define __Pyx_TraceReturn(result) 
 
 #endif /* CYTHON_PROFILE */
 
@@ -863,19 +970,17 @@ static int __Pyx_EndUnpack(PyObject *, Py_ssize_t expected); /*proto*/
 static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict,
     const char* function_name, int kw_allowed); /*proto*/
 
-static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
-static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
-
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
-
 static void __Pyx_RaiseDoubleKeywordsError(
     const char* func_name, PyObject* kw_name); /*proto*/
 
-static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,     const char* function_name); /*proto*/
-
 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
     Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/
 
+static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,     const char* function_name); /*proto*/
+
+static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
+static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
+
 static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
     const char *name, int exact); /*proto*/
 
@@ -960,6 +1065,8 @@ static CYTHON_INLINE PyObject* __Pyx_PyBoolOrNull_FromLong(long b) {
     return unlikely(b < 0) ? NULL : __Pyx_PyBool_FromLong(b);
 }
 
+static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);
+
 static CYTHON_INLINE PyObject* __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
     if (likely(PyList_CheckExact(L))) {
         if (PyList_Append(L, x) < 0) return NULL;
@@ -978,6 +1085,7 @@ static CYTHON_INLINE PyObject* __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
 
 static CYTHON_INLINE void __Pyx_RaiseNoneIndexingError(void);
 
+
 #if PY_MAJOR_VERSION >= 3
 static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
     PyObject *value;
@@ -1058,27 +1166,12 @@ static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb);
 
 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/
 
-static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases); /*proto*/
-
-static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name,
-                                   PyObject *modname); /*proto*/
-
-#define __pyx_binding_PyCFunctionType_USED 1
-
-typedef struct {
-    PyCFunctionObject func;
-} __pyx_binding_PyCFunctionType_object;
-
-static PyTypeObject __pyx_binding_PyCFunctionType_type;
-static PyTypeObject *__pyx_binding_PyCFunctionType = NULL;
-
-static PyObject *__pyx_binding_PyCFunctionType_NewEx(PyMethodDef *ml, PyObject *self, PyObject *module); /* proto */
-#define __pyx_binding_PyCFunctionType_New(ml, self) __pyx_binding_PyCFunctionType_NewEx(ml, self, NULL)
-
-static int __pyx_binding_PyCFunctionType_init(void); /* proto */
+static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, const char *modname); /*proto*/
 
 static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint32_t(uint32_t);
 
+static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
+
 static CYTHON_INLINE uint32_t __Pyx_PyInt_from_py_uint32_t(PyObject *);
 
 static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_int32_t(int32_t);
@@ -1091,6 +1184,14 @@ static CYTHON_INLINE int32_t __Pyx_PyInt_from_py_int32_t(PyObject *);
 
 static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint8_t(uint8_t);
 
+static int __Pyx_Print(PyObject*, PyObject *, int); /*proto*/
+#if PY_MAJOR_VERSION >= 3
+static PyObject* __pyx_print = 0;
+static PyObject* __pyx_print_kwargs = 0;
+#endif
+
+static int __Pyx_PrintOne(PyObject* stream, PyObject *o); /*proto*/
+
 static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint64_t(uint64_t);
 
 static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);
@@ -1177,11 +1278,8 @@ static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0;
 
 /* Module declarations from cpython.float */
 
-/* Module declarations from __builtin__ */
-
 /* Module declarations from cpython.complex */
 
-static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0;
 /* Module declarations from cpython.string */
 
 /* Module declarations from cpython.unicode */
@@ -1219,18 +1317,25 @@ static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0;
 static PyTypeObject *__pyx_ptype_9csamtools_file = 0;
 static PyTypeObject *__pyx_ptype_9csamtools_AlignedRead = 0;
 static PyTypeObject *__pyx_ptype_9csamtools_Samfile = 0;
-static PyTypeObject *__pyx_ptype_9csamtools_IteratorRow = 0;
-static PyTypeObject *__pyx_ptype_9csamtools_IteratorRowAll = 0;
 static PyTypeObject *__pyx_ptype_9csamtools_PileupProxy = 0;
 static PyTypeObject *__pyx_ptype_9csamtools_PileupRead = 0;
 static PyTypeObject *__pyx_ptype_9csamtools_Fastafile = 0;
+static PyTypeObject *__pyx_ptype_9csamtools_IteratorRow = 0;
 static PyTypeObject *__pyx_ptype_9csamtools_IteratorRowRegion = 0;
+static PyTypeObject *__pyx_ptype_9csamtools_IteratorRowAll = 0;
 static PyTypeObject *__pyx_ptype_9csamtools_IteratorRowAllRefs = 0;
 static PyTypeObject *__pyx_ptype_9csamtools_IteratorRowSelection = 0;
 static PyTypeObject *__pyx_ptype_9csamtools_IteratorColumn = 0;
 static PyTypeObject *__pyx_ptype_9csamtools_IteratorColumnRegion = 0;
 static PyTypeObject *__pyx_ptype_9csamtools_IteratorColumnAllRefs = 0;
 static PyTypeObject *__pyx_ptype_9csamtools_SNPCall = 0;
+static PyTypeObject *__pyx_ptype_9csamtools_SNPCallerBase = 0;
+static PyTypeObject *__pyx_ptype_9csamtools_IteratorSNPCalls = 0;
+static PyTypeObject *__pyx_ptype_9csamtools_SNPCaller = 0;
+static PyTypeObject *__pyx_ptype_9csamtools_IndelCall = 0;
+static PyTypeObject *__pyx_ptype_9csamtools_IndelCallerBase = 0;
+static PyTypeObject *__pyx_ptype_9csamtools_IndelCaller = 0;
+static PyTypeObject *__pyx_ptype_9csamtools_IteratorIndelCalls = 0;
 static PyTypeObject *__pyx_ptype_9csamtools_IndexedReads = 0;
 static char *__pyx_v_9csamtools_bam_nt16_rev_table;
 static int __pyx_v_9csamtools_max_pos;
@@ -1249,7 +1354,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_end(bam1_t *); /*proto*/
 static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_seq_range(bam1_t *, uint32_t, uint32_t); /*proto*/
 static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_qual_range(bam1_t *, uint32_t, uint32_t); /*proto*/
 #define __Pyx_MODULE_NAME "csamtools"
-static int __pyx_module_is_main_csamtools = 0;
+int __pyx_module_is_main_csamtools = 0;
 
 /* Implementation of csamtools */
 static PyObject *__pyx_builtin_open;
@@ -1259,65 +1364,106 @@ static PyObject *__pyx_builtin_ValueError;
 static PyObject *__pyx_builtin_IOError;
 static PyObject *__pyx_builtin_OverflowError;
 static PyObject *__pyx_builtin_NotImplementedError;
-static PyObject *__pyx_builtin_OSError;
-static PyObject *__pyx_builtin_AttributeError;
 static PyObject *__pyx_builtin_KeyError;
 static PyObject *__pyx_builtin_StopIteration;
 static PyObject *__pyx_builtin_cmp;
 static PyObject *__pyx_builtin_chr;
 static PyObject *__pyx_builtin_TypeError;
+static PyObject *__pyx_builtin_range;
 static char __pyx_k_1[] = "\t";
 static char __pyx_k_2[] = "\n";
 static char __pyx_k_3[] = "calling len() on closed file";
-static char __pyx_k_5[] = "could not open file `%s`";
-static char __pyx_k_6[] = "I/O operation on closed file";
-static char __pyx_k_9[] = "no sequence/region supplied.";
-static char __pyx_k_11[] = "invalid region: start (%i) > end (%i)";
-static char __pyx_k_12[] = "";
-static char __pyx_k_13[] = "start out of range (%i)";
-static char __pyx_k_14[] = "end out of range (%i)";
-static char __pyx_k_15[] = "%s:%i-%i";
-static char __pyx_k_17[] = "invalid file opening mode `%s`";
-static char __pyx_k_18[] = "-";
-static char __pyx_k_19[] = "http:";
-static char __pyx_k_20[] = "ftp:";
-static char __pyx_k_21[] = "either supply options `template`, `header` or  both `referencenames` and `referencelengths` for writing";
-static char __pyx_k_22[] = "unequal names and lengths of reference sequences";
-static char __pyx_k_23[] = "@SQ\tSN:%s\tLN:%s\n";
-static char __pyx_k_24[] = "file `%s` not found";
-static char __pyx_k_25[] = "could not open file (mode='%s') - is it SAM/BAM format?";
-static char __pyx_k_26[] = "file does not have valid header (mode='%s') - is it SAM/BAM format?";
-static char __pyx_k_27[] = ".bai";
-static char __pyx_k_28[] = "error while opening index `%s` ";
-static char __pyx_k_31[] = "tid %i out of range 0<=tid<%i";
-static char __pyx_k_33[] = "[:-]";
-static char __pyx_k_35[] = "invalid reference `%s`";
-static char __pyx_k_36[] = "invalid coordinates: start (%i) > end (%i)";
-static char __pyx_k_38[] = "seek only available in bam files";
-static char __pyx_k_40[] = "seek no available in streams";
-static char __pyx_k_46[] = "fetch called on bamfile without index";
-static char __pyx_k_48[] = "callback functionality requires a region/reference";
-static char __pyx_k_50[] = "no index available for fetch";
-static char __pyx_k_52[] = "fetching by region is not available for sam files";
-static char __pyx_k_54[] = "fetch called for samfile without header";
-static char __pyx_k_56[] = "callback not implemented yet";
-static char __pyx_k_58[] = "read %s: is unpaired";
-static char __pyx_k_59[] = "mate %s: is unmapped";
-static char __pyx_k_60[] = "mate not found";
-static char __pyx_k_65[] = "counting functionality requires a region/reference";
-static char __pyx_k_68[] = "count for a region is not available for sam files";
-static char __pyx_k_71[] = "no index available for pileup";
-static char __pyx_k_74[] = "pileup of samfiles not implemented yet";
-static char __pyx_k_81[] = "Samfile.mapped only available in bam files";
-static char __pyx_k_84[] = "Samfile.unmapped only available in bam files";
-static char __pyx_k_89[] = "@";
-static char __pyx_k_91[] = "header line without '@': '%s'";
-static char __pyx_k_93[] = "header line with invalid type '%s': '%s'";
-static char __pyx_k_94[] = ":";
-static char __pyx_k_96[] = "unknown field code '%s' in record '%s'";
-static char __pyx_k_97[] = "multiple '%s' lines are not permitted";
-static char __pyx_k_98[] = "@%s";
-static char __pyx_k_99[] = "%s:%s";
+static char __pyx_k_4[] = "could not open file `%s`";
+static char __pyx_k_5[] = "I/O operation on closed file";
+static char __pyx_k_6[] = "no sequence/region supplied.";
+static char __pyx_k_7[] = "invalid region: start (%i) > end (%i)";
+static char __pyx_k_8[] = "";
+static char __pyx_k_9[] = "start out of range (%i)";
+static char __pyx_k_10[] = "end out of range (%i)";
+static char __pyx_k_11[] = "%s:%i-%i";
+static char __pyx_k_12[] = "invalid file opening mode `%s`";
+static char __pyx_k_13[] = "http:";
+static char __pyx_k_14[] = "ftp:";
+static char __pyx_k_15[] = "either supply options `template`, `header` or  both `referencenames` and `referencelengths` for writing";
+static char __pyx_k_16[] = "unequal names and lengths of reference sequences";
+static char __pyx_k_17[] = "-";
+static char __pyx_k_18[] = "file `%s` not found";
+static char __pyx_k_19[] = "could not open file (mode='%s') - is it SAM/BAM format?";
+static char __pyx_k_20[] = "file does not have valid header (mode='%s') - is it SAM/BAM format?";
+static char __pyx_k_21[] = "file header is empty (mode='%s') - is it SAM/BAM format?";
+static char __pyx_k_22[] = ".bai";
+static char __pyx_k_23[] = "error while opening index `%s` ";
+static char __pyx_k_24[] = "tid %i out of range 0<=tid<%i";
+static char __pyx_k_25[] = "[:-]";
+static char __pyx_k_26[] = "invalid reference `%s`";
+static char __pyx_k_27[] = "invalid coordinates: start (%i) > end (%i)";
+static char __pyx_k_28[] = "seek only available in bam files";
+static char __pyx_k_30[] = "fetch called on bamfile without index";
+static char __pyx_k_31[] = "callback functionality requires a region/reference";
+static char __pyx_k_32[] = "no index available for fetch";
+static char __pyx_k_33[] = "fetch called for samfile without header";
+static char __pyx_k_34[] = "fetch for a region is not available for sam files";
+static char __pyx_k_35[] = "callback not implemented yet";
+static char __pyx_k_36[] = "read %s: is unpaired";
+static char __pyx_k_37[] = "mate %s: is unmapped";
+static char __pyx_k_38[] = "mate not found";
+static char __pyx_k_40[] = "counting functionality requires a region/reference";
+static char __pyx_k_41[] = "count for a region is not available for sam files";
+static char __pyx_k_42[] = "no index available for pileup";
+static char __pyx_k_43[] = "pileup of samfiles not implemented yet";
+static char __pyx_k_44[] = "@";
+static char __pyx_k_45[] = "header line without '@': '%s'";
+static char __pyx_k_46[] = "header line with invalid type '%s': '%s'";
+static char __pyx_k_47[] = ":";
+static char __pyx_k_48[] = "unknown field code '%s' in record '%s'";
+static char __pyx_k_49[] = "multiple '%s' lines are not permitted";
+static char __pyx_k_50[] = "@%s";
+static char __pyx_k_51[] = "%s:%s";
+static char __pyx_k_52[] = "invalid type for record %s: %s, expected %s";
+static char __pyx_k_53[] = "incomplete sequence information in '%s'";
+static char __pyx_k_54[] = "no index available for iteration";
+static char __pyx_k_55[] = "can only use this iterator on bam files";
+static char __pyx_k_56[] = "reference sequence for '%s' (tid=%i) not found";
+static char __pyx_k_57[] = "unknown stepper option `%s` in IteratorColumn";
+static char __pyx_k_59[] = "error during iteration";
+static char __pyx_k_60[] = "Invalid clipping in CIGAR string";
+static char __pyx_k_61[] = "quality and sequence mismatch: %i != %i";
+static char __pyx_k_62[] = "%c";
+static char __pyx_k_63[] = "create_string_buffer";
+static char __pyx_k_64[] = "<cccf";
+static char __pyx_k_65[] = "<cccb";
+static char __pyx_k_66[] = "<ccch";
+static char __pyx_k_67[] = "integer %i out of range of BAM/SAM specification";
+static char __pyx_k_68[] = "<ccci";
+static char __pyx_k_69[] = "<cccB";
+static char __pyx_k_70[] = "<cccH";
+static char __pyx_k_71[] = "<cccI";
+static char __pyx_k_72[] = "<cccc";
+static char __pyx_k_73[] = "<ccc%is";
+static char __pyx_k_74[] = "tags field too large";
+static char __pyx_k_75[] = "tag '%s' not present";
+static char __pyx_k_76[] = "Contig index";
+static char __pyx_k_77[] = "Mapped position on contig";
+static char __pyx_k_78[] = "Contig index for mate pair";
+static char __pyx_k_79[] = "Position of mate pair";
+static char __pyx_k_80[] = "Insert size";
+static char __pyx_k_81[] = "Binary flag";
+static char __pyx_k_82[] = "Count of cigar entries";
+static char __pyx_k_83[] = "Cigar entries";
+static char __pyx_k_84[] = "Mapping quality";
+static char __pyx_k_85[] = "Bam index bin number";
+static char __pyx_k_86[] = "Length of query name";
+static char __pyx_k_87[] = "Query name";
+static char __pyx_k_88[] = "Length of query sequence";
+static char __pyx_k_89[] = "Query sequence";
+static char __pyx_k_90[] = "Quality scores";
+static char __pyx_k_91[] = "Length of auxilary data";
+static char __pyx_k_92[] = "Maximum data length";
+static char __pyx_k_93[] = "Current data length";
+static char __pyx_k_94[] = "%-30s %-10s= %s";
+static char __pyx_k_95[] = "(";
+static char __pyx_k_96[] = ")";
+static char __pyx_k_97[] = "This class cannot be instantiated from Python";
 static char __pyx_k__A[] = "A";
 static char __pyx_k__C[] = "C";
 static char __pyx_k__D[] = "D";
@@ -1335,123 +1481,127 @@ static char __pyx_k__r[] = "r";
 static char __pyx_k__s[] = "s";
 static char __pyx_k__w[] = "w";
 static char __pyx_k__x[] = "x";
-static char __pyx_k_100[] = "invalid type for record %s: %s, expected %s";
-static char __pyx_k_101[] = "incomplete sequence information in '%s'";
-static char __pyx_k_103[] = "can not iterate over samfile without header";
-static char __pyx_k_106[] = "no index available for iteration";
-static char __pyx_k_112[] = "can only use this iterator on bam files";
-static char __pyx_k_113[] = "reference sequence for '%s' (tid=%i) not found";
-static char __pyx_k_114[] = "unknown stepper option `%s` in IteratorColumn";
-static char __pyx_k_116[] = "error during iteration";
-static char __pyx_k_119[] = "Invalid clipping in CIGAR string";
-static char __pyx_k_120[] = "quality and sequence mismatch: %i != %i";
-static char __pyx_k_121[] = "%c";
-static char __pyx_k_122[] = "create_string_buffer";
-static char __pyx_k_123[] = "<cccf";
-static char __pyx_k_124[] = "<cccb";
-static char __pyx_k_125[] = "<ccch";
-static char __pyx_k_126[] = "integer %i out of range of BAM/SAM specification";
-static char __pyx_k_127[] = "<ccci";
-static char __pyx_k_128[] = "<cccB";
-static char __pyx_k_129[] = "<cccH";
-static char __pyx_k_130[] = "<cccI";
-static char __pyx_k_131[] = "<cccc";
-static char __pyx_k_132[] = "<ccc%is";
-static char __pyx_k_133[] = "tags field too large";
-static char __pyx_k_135[] = "tag '%s' not present";
-static char __pyx_k_136[] = "Contig index";
-static char __pyx_k_137[] = "Mapped position on contig";
-static char __pyx_k_138[] = "Contig index for mate pair";
-static char __pyx_k_139[] = "Position of mate pair";
-static char __pyx_k_140[] = "Insert size";
-static char __pyx_k_141[] = "Binary flag";
-static char __pyx_k_142[] = "Count of cigar entries";
-static char __pyx_k_143[] = "Cigar entries";
-static char __pyx_k_144[] = "Mapping quality";
-static char __pyx_k_145[] = "Bam index bin number";
-static char __pyx_k_146[] = "Length of query name";
-static char __pyx_k_147[] = "Query name";
-static char __pyx_k_148[] = "Length of query sequence";
-static char __pyx_k_149[] = "Query sequence";
-static char __pyx_k_150[] = "Quality scores";
-static char __pyx_k_151[] = "Length of auxilary data";
-static char __pyx_k_152[] = "Maximum data length";
-static char __pyx_k_153[] = "Current data length";
-static char __pyx_k_154[] = "%-30s %-10s= %s";
-static char __pyx_k_155[] = "(";
-static char __pyx_k_156[] = ")";
-static char __pyx_k_157[] = "This class cannot be instantiated from Python";
-static char __pyx_k_162[] = "No such file or directory: '%s'";
-static char __pyx_k_163[] = "-o";
-static char __pyx_k_164[] = "option -o is forbidden in samtools view";
-static char __pyx_k_166[] = "_rms_mapping_quality";
-static char __pyx_k_167[] = "can only IndexReads on bam files";
-static char __pyx_k_168[] = "read %s not found";
-static char __pyx_k_169[] = "the query name (None if not present)";
-static char __pyx_k_170[] = "the :term:`cigar` alignment (None if not present).\n        ";
-static char __pyx_k_171[] = "read sequence bases, including :term:`soft clipped` bases (None if not present)";
-static char __pyx_k_172[] = "read sequence base qualities, including :term:`soft clipped` bases (None if not present)";
-static char __pyx_k_173[] = "aligned portion of the read and excludes any flanking bases that were :term:`soft clipped` (None if not present)\n\n        SAM/BAM files may included extra flanking bases sequences that were\n        not part of the alignment.  These bases may be the result of the\n        Smith-Waterman or other algorithms, which may not require alignments\n        that begin at the first residue or end at the last.  In addition,\n        extra sequencing adapters, multiplex identifiers, and low-quality bases that\n        were not considered for alignment may have been retained.";
-static char __pyx_k_174[] = "aligned query sequence quality values (None if not present)";
-static char __pyx_k_175[] = "start index of the aligned query portion of the sequence (0-based, inclusive)";
-static char __pyx_k_176[] = "end index of the aligned query portion of the sequence (0-based, exclusive)";
-static char __pyx_k_177[] = "Length of the aligned query sequence";
-static char __pyx_k_178[] = "the tags in the AUX field.\n\n        This property permits convenience access to \n        the tags. Changes it the returned list will\n        not update the tags automatically. Instead,\n        the following is required for adding a \n        new tag::\n\n            read.tags = read.tags + [(\"RG\",0)]\n\n\n        This method will happily write the same tag\n        multiple times.\n        ";
-static char __pyx_k_179[] = "properties flag";
-static char __pyx_k_180[] = "\n        :term:`target` ID\n\n        DEPRECATED from pysam-0.4 - use tid in the future.\n        The rname field caused a lot of confusion as it returns\n        the :term:`target` ID instead of the reference sequence\n        name.\n\n        .. note::\n\n            This field contains the index of the reference sequence \n            in the sequence dictionary. To obtain the name\n            of the reference sequence, use :meth:`pysam.Samfile.getrname()`\n            \n        ";
-static char __pyx_k_181[] = "\n        :term:`target` ID\n\n        .. note::\n\n            This field contains the index of the reference sequence \n            in the sequence dictionary. To obtain the name\n            of the reference sequence, use :meth:`pysam.Samfile.getrname()`\n            \n        ";
-static char __pyx_k_182[] = "0-based leftmost coordinate";
-static char __pyx_k_183[] = "properties bin";
-static char __pyx_k_184[] = "length of the read (read only). Returns 0 if not given.";
-static char __pyx_k_185[] = "aligned end position of the read on the reference genome.  Returns\n        None if not available.";
-static char __pyx_k_186[] = "aligned length of the read on the reference genome.  Returns None if\n        not available.";
-static char __pyx_k_187[] = "mapping quality";
-static char __pyx_k_188[] = "the :term:`reference` id of the mate \n        deprecated, use RNEXT instead.\n        ";
-static char __pyx_k_189[] = "the :term:`reference` id of the mate ";
-static char __pyx_k_190[] = "the position of the mate\n        deprecated, use PNEXT instead.";
-static char __pyx_k_191[] = "the position of the mate";
-static char __pyx_k_192[] = "the insert size\n        deprecated: use tlen instead";
-static char __pyx_k_193[] = "the insert size";
-static char __pyx_k_194[] = "true if read is paired in sequencing";
-static char __pyx_k_195[] = "true if read is mapped in a proper pair";
-static char __pyx_k_196[] = "true if read itself is unmapped";
-static char __pyx_k_197[] = "true if the mate is unmapped";
-static char __pyx_k_198[] = "true if read is mapped to reverse strand";
-static char __pyx_k_199[] = "true is read is mapped to reverse strand";
-static char __pyx_k_200[] = "true if this is read1";
-static char __pyx_k_201[] = "true if this is read2";
-static char __pyx_k_202[] = "true if not primary alignment";
-static char __pyx_k_203[] = "true if QC failure";
-static char __pyx_k_204[] = "true if optical or PCR duplicate";
-static char __pyx_k_205[] = "a list of reference positions that this read aligns to.";
-static char __pyx_k_206[] = "number of :term:`filename` associated with this object.";
-static char __pyx_k_207[] = "number of :term:`reference` sequences in the file.";
-static char __pyx_k_208[] = "tuple with the names of :term:`reference` sequences.";
-static char __pyx_k_209[] = "tuple of the lengths of the :term:`reference` sequences. The lengths are in the same order as \n        :attr:`pysam.Samfile.references`\n        ";
-static char __pyx_k_210[] = "total number of mapped reads in file.\n        ";
-static char __pyx_k_211[] = "total number of unmapped reads in file.\n        ";
-static char __pyx_k_212[] = "full contents of the :term:`sam file` header as a string.";
-static char __pyx_k_213[] = "header information within the :term:`sam file`. The records and fields are returned as \n        a two-level dictionary.\n        ";
-static char __pyx_k_214[] = "the chromosome ID as is defined in the header";
-static char __pyx_k_215[] = "number of reads mapping to this column.";
-static char __pyx_k_216[] = "list of reads (:class:`pysam.PileupRead`) aligned to this column";
-static char __pyx_k_217[] = "a :class:`pysam.AlignedRead` object of the aligned read";
-static char __pyx_k_218[] = "position of the read base at the pileup site, 0-based";
-static char __pyx_k_219[] = "indel length; 0 for no indel, positive for ins and negative for del";
-static char __pyx_k_220[] = "1 iff the base on the padded read is a deletion";
-static char __pyx_k_221[] = "current sequence length.";
-static char __pyx_k_222[] = "nucleotide position of SNP.";
-static char __pyx_k_223[] = "reference base at pos. ``N`` if no reference sequence supplied.";
-static char __pyx_k_224[] = "the genotype called.";
-static char __pyx_k_225[] = "the genotype quality (Phred-scaled).";
-static char __pyx_k_226[] = "the snp quality (Phred scaled) - probability of consensus being identical to reference sequence.";
-static char __pyx_k_227[] = "the root mean square (rms) of the mapping quality of all reads involved in the call.";
-static char __pyx_k_228[] = "coverage or read depth - the number of reads involved in the call.";
-static char __pyx_k_229[] = "=ACMGRSVTWYHKDBN";
-static char __pyx_k_230[] = "A pileup column. A pileup column contains  \n    all the reads that map to a certain target base.\n\n    tid      \n        chromosome ID as is defined in the header      \n    pos      \n        the target base coordinate (0-based)    \n    n \n        number of reads mapping to this column  \n    pileups  \n        list of reads (:class:`pysam.PileupRead`) aligned to this column    \n    ";
-static char __pyx_k_231[] = "\n    stderr is captured. \n    ";
-static char __pyx_k_232[] = "does nothing. stderr can't be redirected on windows";
-static char __pyx_k_238[] = "http://mail.python.org/pipermail/python-list/2000-June/038406.html";
+static char __pyx_k_100[] = "No such file or directory: '%s'";
+static char __pyx_k_101[] = "-o";
+static char __pyx_k_102[] = "option -o is forbidden in samtools view";
+static char __pyx_k_103[] = "_rms_mapping_quality";
+static char __pyx_k_104[] = "--> read %i %s %i";
+static char __pyx_k_105[] = "pos=%i, cns=%i, q_r = %f, depth=%i, n=%i, rb=%i, cns-cq=%i %i %i %i";
+static char __pyx_k_106[] = "-------------------------------------\n";
+static char __pyx_k_107[] = "IteratorSNPCalls requires an pileup iterator with reference sequence";
+static char __pyx_k_108[] = "position %i out of bounds on reference sequence (len=%i)";
+static char __pyx_k_109[] = "no reads in region - no call";
+static char __pyx_k_110[] = "%s/%s";
+static char __pyx_k_111[] = "IndelCallerBase requires an pileup iterator with reference sequence";
+static char __pyx_k_112[] = "can only IndexReads on bam files";
+static char __pyx_k_113[] = "read %s not found";
+static char __pyx_k_114[] = "the query name (None if not present)";
+static char __pyx_k_115[] = "the :term:`cigar` alignment (None if not present).\n        ";
+static char __pyx_k_116[] = "read sequence bases, including :term:`soft clipped` bases (None if not present)";
+static char __pyx_k_117[] = "read sequence base qualities, including :term:`soft clipped` bases (None if not present)";
+static char __pyx_k_118[] = "aligned portion of the read and excludes any flanking bases that were :term:`soft clipped` (None if not present)\n\n        SAM/BAM files may included extra flanking bases sequences that were\n        not part of the alignment.  These bases may be the result of the\n        Smith-Waterman or other algorithms, which may not require alignments\n        that begin at the first residue or end at the last.  In addition,\n        extra sequencing adapters, multiplex identifiers, and low-quality bases that\n        were not considered for alignment may have been retained.";
+static char __pyx_k_119[] = "aligned query sequence quality values (None if not present)";
+static char __pyx_k_120[] = "start index of the aligned query portion of the sequence (0-based, inclusive)";
+static char __pyx_k_121[] = "end index of the aligned query portion of the sequence (0-based, exclusive)";
+static char __pyx_k_122[] = "Length of the aligned query sequence";
+static char __pyx_k_123[] = "the tags in the AUX field.\n\n        This property permits convenience access to \n        the tags. Changes it the returned list will\n        not update the tags automatically. Instead,\n        the following is required for adding a \n        new tag::\n\n            read.tags = read.tags + [(\"RG\",0)]\n\n        ";
+static char __pyx_k_124[] = "properties flag";
+static char __pyx_k_125[] = "\n        :term:`target` ID\n\n        DEPRECATED from pysam-0.4 - use tid in the future.\n        The rname field caused a lot of confusion as it returns\n        the :term:`target` ID instead of the reference sequence\n        name.\n\n        .. note::\n\n            This field contains the index of the reference sequence \n            in the sequence dictionary. To obtain the name\n            of the reference sequence, use :meth:`pysam.Samfile.getrname()`\n            \n        ";
+static char __pyx_k_126[] = "\n        :term:`target` ID\n\n        .. note::\n\n            This field contains the index of the reference sequence \n            in the sequence dictionary. To obtain the name\n            of the reference sequence, use :meth:`pysam.Samfile.getrname()`\n            \n        ";
+static char __pyx_k_127[] = "0-based leftmost coordinate";
+static char __pyx_k_128[] = "properties bin";
+static char __pyx_k_129[] = "length of the read (read only). Returns 0 if not given.";
+static char __pyx_k_130[] = "aligned end position of the read (read only).  Returns\n        None if not available.";
+static char __pyx_k_131[] = "aligned length of the read (read only).  Returns None if\n        not available.";
+static char __pyx_k_132[] = "mapping quality";
+static char __pyx_k_133[] = "the :term:`reference` id of the mate ";
+static char __pyx_k_134[] = "the position of the mate";
+static char __pyx_k_135[] = "the insert size";
+static char __pyx_k_136[] = "true if read is paired in sequencing";
+static char __pyx_k_137[] = "true if read is mapped in a proper pair";
+static char __pyx_k_138[] = "true if read itself is unmapped";
+static char __pyx_k_139[] = "true if the mate is unmapped";
+static char __pyx_k_140[] = "true if read is mapped to reverse strand";
+static char __pyx_k_141[] = "true is read is mapped to reverse strand";
+static char __pyx_k_142[] = "true if this is read1";
+static char __pyx_k_143[] = "true if this is read2";
+static char __pyx_k_144[] = "true if not primary alignment";
+static char __pyx_k_145[] = "true if QC failure";
+static char __pyx_k_146[] = "true if optical or PCR duplicate";
+static char __pyx_k_147[] = "a list of reference positions that this read aligns to.";
+static char __pyx_k_148[] = "number of :term:`filename` associated with this object.";
+static char __pyx_k_149[] = "number of :term:`reference` sequences in the file.";
+static char __pyx_k_150[] = "tuple with the names of :term:`reference` sequences.";
+static char __pyx_k_151[] = "tuple of the lengths of the :term:`reference` sequences. The lengths are in the same order as \n        :attr:`pysam.Samfile.references`\n        ";
+static char __pyx_k_152[] = "full contents of the :term:`sam file` header as a string.";
+static char __pyx_k_153[] = "header information within the :term:`sam file`. The records and fields are returned as \n        a two-level dictionary.\n        ";
+static char __pyx_k_154[] = "the chromosome ID as is defined in the header";
+static char __pyx_k_155[] = "number of reads mapping to this column.";
+static char __pyx_k_156[] = "list of reads (:class:`pysam.PileupRead`) aligned to this column";
+static char __pyx_k_157[] = "a :class:`pysam.AlignedRead` object of the aligned read";
+static char __pyx_k_158[] = "position of the read base at the pileup site, 0-based";
+static char __pyx_k_159[] = "indel length; 0 for no indel, positive for ins and negative for del";
+static char __pyx_k_160[] = "1 iff the base on the padded read is a deletion";
+static char __pyx_k_161[] = "current sequence length.";
+static char __pyx_k_162[] = "nucleotide position of SNP.";
+static char __pyx_k_163[] = "reference base at pos. ``N`` if no reference sequence supplied.";
+static char __pyx_k_164[] = "the genotype called.";
+static char __pyx_k_165[] = "the genotype quality (Phred-scaled).";
+static char __pyx_k_166[] = "the snp quality (Phred scaled) - probability of consensus being identical to reference sequence.";
+static char __pyx_k_167[] = "the root mean square (rms) of the mapping quality of all reads involved in the call.";
+static char __pyx_k_168[] = "coverage or read depth - the number of reads involved in the call.";
+static char __pyx_k_169[] = "sequence of first allele.";
+static char __pyx_k_170[] = "sequence of second allele.";
+static char __pyx_k_171[] = "reads supporting first allele.";
+static char __pyx_k_172[] = "=ACMGRSVTWYHKDBN";
+static char __pyx_k_173[] = "A pileup column. A pileup column contains  \n    all the reads that map to a certain target base.\n\n    tid      \n        chromosome ID as is defined in the header      \n    pos      \n        the target base coordinate (0-based)    \n    n \n        number of reads mapping to this column  \n    pileups  \n        list of reads (:class:`pysam.PileupRead`) aligned to this column    \n    ";
+static char __pyx_k_174[] = "\n    stderr is captured. \n    ";
+static char __pyx_k_175[] = "does nothing. stderr can't be redirected on windows";
+static char __pyx_k_176[] = "http://mail.python.org/pipermail/python-list/2000-June/038406.html";
+static char __pyx_k_177[] = "Fastafile._isOpen (line 265)";
+static char __pyx_k_178[] = "Fastafile._open (line 275)";
+static char __pyx_k_179[] = "Fastafile.fetch (line 306)";
+static char __pyx_k_180[] = "Samfile._isOpen (line 464)";
+static char __pyx_k_181[] = "Samfile._hasIndex (line 468)";
+static char __pyx_k_182[] = "Samfile._open (line 472)";
+static char __pyx_k_183[] = "Samfile.gettid (line 612)";
+static char __pyx_k_184[] = "Samfile.getrname (line 621)";
+static char __pyx_k_185[] = "Samfile._parseRegion (line 637)";
+static char __pyx_k_186[] = "Samfile.seek (line 691)";
+static char __pyx_k_187[] = "Samfile.tell (line 702)";
+static char __pyx_k_188[] = "Samfile.fetch (line 713)";
+static char __pyx_k_189[] = "Samfile.mate (line 782)";
+static char __pyx_k_190[] = "Samfile.count (line 825)";
+static char __pyx_k_191[] = "Samfile.pileup (line 869)";
+static char __pyx_k_192[] = "Samfile.close (line 953)";
+static char __pyx_k_193[] = "Samfile.write (line 969)";
+static char __pyx_k_194[] = "Samfile._buildLine (line 1078)";
+static char __pyx_k_195[] = "Samfile.__next__ (line 1173)";
+static char __pyx_k_196[] = "IteratorRowRegion.__next__ (line 1281)";
+static char __pyx_k_197[] = "IteratorRowAll.__next__ (line 1340)";
+static char __pyx_k_198[] = "IteratorRowAllRefs.__next__ (line 1375)";
+static char __pyx_k_199[] = "IteratorRowSelection.__next__ (line 1459)";
+static char __pyx_k_200[] = "IteratorRowSelection";
+static char __pyx_k_201[] = "IteratorColumn.addReference (line 1634)";
+static char __pyx_k_202[] = "IteratorColumn.hasReference (line 1642)";
+static char __pyx_k_203[] = "IteratorColumnRegion.__next__ (line 1724)";
+static char __pyx_k_204[] = "IteratorColumnRegion";
+static char __pyx_k_205[] = "IteratorColumnAllRefs.__next__ (line 1755)";
+static char __pyx_k_206[] = "IteratorColumnAllRefs";
+static char __pyx_k_207[] = "AlignedRead.__str__ (line 1903)";
+static char __pyx_k_208[] = "AlignedRead.compare (line 1928)";
+static char __pyx_k_209[] = "AlignedRead.overlap (line 2512)";
+static char __pyx_k_210[] = "AlignedRead.opt (line 2541)";
+static char __pyx_k_211[] = "AlignedRead.fancy_str (line 2563)";
+static char __pyx_k_212[] = "Outs.setdevice (line 2705)";
+static char __pyx_k_213[] = "Outs.setfile (line 2710)";
+static char __pyx_k_214[] = "Outs.restore (line 2723)";
+static char __pyx_k_215[] = "_samtools_dispatch (line 2734)";
+static char __pyx_k_216[] = "IteratorSNPCalls.__next__ (line 2969)";
+static char __pyx_k_217[] = "SNPCaller.call (line 3041)";
+static char __pyx_k_218[] = "IndelCaller.call (line 3306)";
+static char __pyx_k_219[] = "IteratorIndelCalls.__next__ (line 3353)";
+static char __pyx_k_220[] = "IndexedReads.build (line 3406)";
 static char __pyx_k__AS[] = "AS";
 static char __pyx_k__CL[] = "CL";
 static char __pyx_k__CN[] = "CN";
@@ -1477,11 +1627,11 @@ static char __pyx_k__SP[] = "SP";
 static char __pyx_k__SQ[] = "SQ";
 static char __pyx_k__UR[] = "UR";
 static char __pyx_k__VN[] = "VN";
+static char __pyx_k___r[] = "_r";
 static char __pyx_k__fd[] = "fd";
 static char __pyx_k__fp[] = "fp";
 static char __pyx_k__id[] = "id";
 static char __pyx_k__os[] = "os";
-static char __pyx_k__rU[] = "rU";
 static char __pyx_k__rb[] = "rb";
 static char __pyx_k__re[] = "re";
 static char __pyx_k__wb[] = "wb";
@@ -1495,8 +1645,10 @@ static char __pyx_k__cmp[] = "cmp";
 static char __pyx_k__dup[] = "dup";
 static char __pyx_k__end[] = "end";
 static char __pyx_k__map[] = "map";
+static char __pyx_k__opt[] = "opt";
 static char __pyx_k__plp[] = "plp";
 static char __pyx_k__pos[] = "pos";
+static char __pyx_k__q_r[] = "q_r";
 static char __pyx_k__raw[] = "raw";
 static char __pyx_k__seq[] = "seq";
 static char __pyx_k__sys[] = "sys";
@@ -1506,6 +1658,9 @@ static char __pyx_k__Outs[] = "Outs";
 static char __pyx_k___pos[] = "_pos";
 static char __pyx_k___tid[] = "_tid";
 static char __pyx_k__args[] = "args";
+static char __pyx_k__call[] = "call";
+static char __pyx_k__cnt1[] = "cnt1";
+static char __pyx_k__cnt2[] = "cnt2";
 static char __pyx_k__core[] = "core";
 static char __pyx_k__data[] = "data";
 static char __pyx_k__dup2[] = "dup2";
@@ -1532,14 +1687,19 @@ static char __pyx_k__rlen[] = "rlen";
 static char __pyx_k__seek[] = "seek";
 static char __pyx_k__self[] = "self";
 static char __pyx_k__tags[] = "tags";
+static char __pyx_k__tell[] = "tell";
 static char __pyx_k__text[] = "text";
 static char __pyx_k__view[] = "view";
+static char __pyx_k___call[] = "_call";
 static char __pyx_k___open[] = "_open";
 static char __pyx_k___qpos[] = "_qpos";
 static char __pyx_k__bqual[] = "bqual";
+static char __pyx_k__build[] = "build";
 static char __pyx_k__cigar[] = "cigar";
 static char __pyx_k__close[] = "close";
 static char __pyx_k__cnext[] = "cnext";
+static char __pyx_k__count[] = "count";
+static char __pyx_k__fetch[] = "fetch";
 static char __pyx_k__flush[] = "flush";
 static char __pyx_k__indel[] = "indel";
 static char __pyx_k__index[] = "index";
@@ -1547,25 +1707,33 @@ static char __pyx_k__isbam[] = "isbam";
 static char __pyx_k__isize[] = "isize";
 static char __pyx_k__l_aux[] = "l_aux";
 static char __pyx_k__level[] = "level";
+static char __pyx_k__n_hap[] = "n_hap";
 static char __pyx_k__n_plp[] = "n_plp";
+static char __pyx_k__q_cns[] = "q_cns";
+static char __pyx_k__q_ref[] = "q_ref";
 static char __pyx_k__qname[] = "qname";
+static char __pyx_k__range[] = "range";
+static char __pyx_k__reset[] = "reset";
 static char __pyx_k__rname[] = "rname";
 static char __pyx_k__setfd[] = "setfd";
 static char __pyx_k__split[] = "split";
 static char __pyx_k__start[] = "start";
 static char __pyx_k__strip[] = "strip";
+static char __pyx_k__theta[] = "theta";
 static char __pyx_k__types[] = "types";
 static char __pyx_k__where[] = "where";
 static char __pyx_k__write[] = "write";
 static char __pyx_k___indel[] = "_indel";
 static char __pyx_k___level[] = "_level";
-static char __pyx_k__append[] = "append";
 static char __pyx_k__ctypes[] = "ctypes";
+static char __pyx_k__errmod[] = "errmod";
 static char __pyx_k__exists[] = "exists";
 static char __pyx_k__fields[] = "fields";
 static char __pyx_k__fileno[] = "fileno";
 static char __pyx_k__gettid[] = "gettid";
 static char __pyx_k__header[] = "header";
+static char __pyx_k__indel1[] = "indel1";
+static char __pyx_k__indel2[] = "indel2";
 static char __pyx_k__is_del[] = "is_del";
 static char __pyx_k__l_qseq[] = "l_qseq";
 static char __pyx_k__l_text[] = "l_text";
@@ -1573,6 +1741,7 @@ static char __pyx_k__m_data[] = "m_data";
 static char __pyx_k__method[] = "method";
 static char __pyx_k__object[] = "object";
 static char __pyx_k__offset[] = "offset";
+static char __pyx_k__pileup[] = "pileup";
 static char __pyx_k__record[] = "record";
 static char __pyx_k__region[] = "region";
 static char __pyx_k__remove[] = "remove";
@@ -1585,7 +1754,6 @@ static char __pyx_k__struct[] = "struct";
 static char __pyx_k__system[] = "system";
 static char __pyx_k__IOError[] = "IOError";
 static char __pyx_k__IntType[] = "IntType";
-static char __pyx_k__OSError[] = "OSError";
 static char __pyx_k__O_CREAT[] = "O_CREAT";
 static char __pyx_k__Samfile[] = "Samfile";
 static char __pyx_k__Windows[] = "Windows";
@@ -1594,6 +1762,7 @@ static char __pyx_k____del__[] = "__del__";
 static char __pyx_k____str__[] = "__str__";
 static char __pyx_k___isOpen[] = "_isOpen";
 static char __pyx_k___is_del[] = "_is_del";
+static char __pyx_k__compare[] = "compare";
 static char __pyx_k__devnull[] = "devnull";
 static char __pyx_k__is_head[] = "is_head";
 static char __pyx_k__is_tail[] = "is_tail";
@@ -1601,7 +1770,11 @@ static char __pyx_k__isupper[] = "isupper";
 static char __pyx_k__l_qname[] = "l_qname";
 static char __pyx_k__mkstemp[] = "mkstemp";
 static char __pyx_k__n_cigar[] = "n_cigar";
+static char __pyx_k__options[] = "options";
+static char __pyx_k__overlap[] = "overlap";
 static char __pyx_k__pileups[] = "pileups";
+static char __pyx_k__q_indel[] = "q_indel";
+static char __pyx_k__r_indel[] = "r_indel";
 static char __pyx_k__release[] = "release";
 static char __pyx_k__restore[] = "restore";
 static char __pyx_k__rowiter[] = "rowiter";
@@ -1616,19 +1789,23 @@ static char __pyx_k__O_WRONLY[] = "O_WRONLY";
 static char __pyx_k____dict__[] = "__dict__";
 static char __pyx_k____init__[] = "__init__";
 static char __pyx_k____main__[] = "__main__";
+static char __pyx_k____next__[] = "__next__";
 static char __pyx_k____test__[] = "__test__";
 static char __pyx_k___is_head[] = "_is_head";
 static char __pyx_k___is_tail[] = "_is_tail";
 static char __pyx_k___logfile[] = "_logfile";
 static char __pyx_k__calcsize[] = "calcsize";
 static char __pyx_k__callback[] = "callback";
+static char __pyx_k__cap_mapQ[] = "cap_mapQ";
+static char __pyx_k__cnt_anti[] = "cnt_anti";
 static char __pyx_k__coverage[] = "coverage";
 static char __pyx_k__data_len[] = "data_len";
 static char __pyx_k__exc_type[] = "exc_type";
 static char __pyx_k__filename[] = "filename";
 static char __pyx_k__genotype[] = "genotype";
+static char __pyx_k__getrname[] = "getrname";
+static char __pyx_k__het_rate[] = "het_rate";
 static char __pyx_k__isremote[] = "isremote";
-static char __pyx_k__isstream[] = "isstream";
 static char __pyx_k__iterdata[] = "iterdata";
 static char __pyx_k__nextiter[] = "nextiter";
 static char __pyx_k__platform[] = "platform";
@@ -1639,6 +1816,7 @@ static char __pyx_k__tempfile[] = "tempfile";
 static char __pyx_k__template[] = "template";
 static char __pyx_k__Fastafile[] = "Fastafile";
 static char __pyx_k__FloatType[] = "FloatType";
+static char __pyx_k__SNPCaller[] = "SNPCaller";
 static char __pyx_k__TypeError[] = "TypeError";
 static char __pyx_k___coverage[] = "_coverage";
 static char __pyx_k___delegate[] = "_delegate";
@@ -1646,11 +1824,12 @@ static char __pyx_k___filename[] = "_filename";
 static char __pyx_k___genotype[] = "_genotype";
 static char __pyx_k___hasIndex[] = "_hasIndex";
 static char __pyx_k__alignment[] = "alignment";
-static char __pyx_k__csamtools[] = "csamtools";
 static char __pyx_k__exc_value[] = "exc_value";
+static char __pyx_k__fancy_str[] = "fancy_str";
 static char __pyx_k__fastafile[] = "fastafile";
 static char __pyx_k__itertools[] = "itertools";
 static char __pyx_k__max_depth[] = "max_depth";
+static char __pyx_k__min_baseQ[] = "min_baseQ";
 static char __pyx_k__n_targets[] = "n_targets";
 static char __pyx_k__pack_into[] = "pack_into";
 static char __pyx_k__positions[] = "positions";
@@ -1663,18 +1842,21 @@ static char __pyx_k__PileupRead[] = "PileupRead";
 static char __pyx_k__ValueError[] = "ValueError";
 static char __pyx_k___alignment[] = "_alignment";
 static char __pyx_k___buildLine[] = "_buildLine";
+static char __pyx_k__reads_diff[] = "reads_diff";
 static char __pyx_k__startswith[] = "startswith";
 static char __pyx_k__target_len[] = "target_len";
 static char __pyx_k__AlignedRead[] = "AlignedRead";
+static char __pyx_k__IndelCaller[] = "IndelCaller";
 static char __pyx_k__IteratorRow[] = "IteratorRow";
 static char __pyx_k__PileupProxy[] = "PileupProxy";
 static char __pyx_k__StderrStore[] = "StderrStore";
-static char __pyx_k__add_sq_text[] = "add_sq_text";
 static char __pyx_k__collections[] = "collections";
 static char __pyx_k__current_pos[] = "current_pos";
 static char __pyx_k__defaultdict[] = "defaultdict";
+static char __pyx_k__getSequence[] = "getSequence";
 static char __pyx_k__nreferences[] = "nreferences";
 static char __pyx_k__pileup_iter[] = "pileup_iter";
+static char __pyx_k__reads_first[] = "reads_first";
 static char __pyx_k__snp_quality[] = "snp_quality";
 static char __pyx_k__stderr_save[] = "stderr_save";
 static char __pyx_k__target_name[] = "target_name";
@@ -1683,24 +1865,34 @@ static char __pyx_k__PileupColumn[] = "PileupColumn";
 static char __pyx_k___buildHeader[] = "_buildHeader";
 static char __pyx_k___parseRegion[] = "_parseRegion";
 static char __pyx_k___snp_quality[] = "_snp_quality";
+static char __pyx_k__addReference[] = "addReference";
 static char __pyx_k__catch_stderr[] = "catch_stderr";
 static char __pyx_k__catch_stdout[] = "catch_stdout";
+static char __pyx_k__first_allele[] = "first_allele";
+static char __pyx_k__hasReference[] = "hasReference";
+static char __pyx_k__n_haplotypes[] = "n_haplotypes";
 static char __pyx_k__owns_samfile[] = "owns_samfile";
-static char __pyx_k__start_offset[] = "start_offset";
+static char __pyx_k__reads_second[] = "reads_second";
 static char __pyx_k__OverflowError[] = "OverflowError";
 static char __pyx_k__StopIteration[] = "StopIteration";
 static char __pyx_k__VALID_HEADERS[] = "VALID_HEADERS";
-static char __pyx_k__AttributeError[] = "AttributeError";
+static char __pyx_k__second_allele[] = "second_allele";
 static char __pyx_k__IteratorColumn[] = "IteratorColumn";
+static char __pyx_k__IteratorRowAll[] = "IteratorRowAll";
 static char __pyx_k__readAndRelease[] = "readAndRelease";
 static char __pyx_k__reference_base[] = "reference_base";
 static char __pyx_k__referencenames[] = "referencenames";
 static char __pyx_k___reference_base[] = "_reference_base";
+static char __pyx_k__iterator_column[] = "iterator_column";
 static char __pyx_k__mapping_quality[] = "mapping_quality";
+static char __pyx_k__IteratorSNPCalls[] = "IteratorSNPCalls";
 static char __pyx_k____getattribute__[] = "__getattribute__";
 static char __pyx_k__referencelengths[] = "referencelengths";
+static char __pyx_k__IteratorRowRegion[] = "IteratorRowRegion";
 static char __pyx_k__consensus_quality[] = "consensus_quality";
 static char __pyx_k__setupIteratorData[] = "setupIteratorData";
+static char __pyx_k__IteratorIndelCalls[] = "IteratorIndelCalls";
+static char __pyx_k__IteratorRowAllRefs[] = "IteratorRowAllRefs";
 static char __pyx_k__StderrStoreWindows[] = "StderrStoreWindows";
 static char __pyx_k__VALID_HEADER_ORDER[] = "VALID_HEADER_ORDER";
 static char __pyx_k__VALID_HEADER_TYPES[] = "VALID_HEADER_TYPES";
@@ -1709,113 +1901,159 @@ static char __pyx_k___samtools_dispatch[] = "_samtools_dispatch";
 static char __pyx_k__NotImplementedError[] = "NotImplementedError";
 static char __pyx_k__VALID_HEADER_FIELDS[] = "VALID_HEADER_FIELDS";
 static PyObject *__pyx_kp_s_1;
+static PyObject *__pyx_kp_s_10;
 static PyObject *__pyx_kp_s_100;
 static PyObject *__pyx_kp_s_101;
-static PyObject *__pyx_kp_s_103;
-static PyObject *__pyx_kp_s_106;
+static PyObject *__pyx_kp_s_102;
+static PyObject *__pyx_n_s_103;
+static PyObject *__pyx_kp_s_104;
+static PyObject *__pyx_kp_s_105;
+static PyObject *__pyx_kp_s_107;
+static PyObject *__pyx_kp_s_108;
+static PyObject *__pyx_kp_s_109;
 static PyObject *__pyx_kp_s_11;
+static PyObject *__pyx_kp_s_110;
+static PyObject *__pyx_kp_s_111;
 static PyObject *__pyx_kp_s_112;
 static PyObject *__pyx_kp_s_113;
-static PyObject *__pyx_kp_s_114;
-static PyObject *__pyx_kp_s_116;
 static PyObject *__pyx_kp_s_12;
-static PyObject *__pyx_kp_s_120;
-static PyObject *__pyx_kp_s_121;
-static PyObject *__pyx_n_s_122;
-static PyObject *__pyx_kp_s_123;
-static PyObject *__pyx_kp_s_124;
-static PyObject *__pyx_kp_s_125;
-static PyObject *__pyx_kp_s_126;
-static PyObject *__pyx_kp_s_127;
-static PyObject *__pyx_kp_s_128;
-static PyObject *__pyx_kp_s_129;
-static PyObject *__pyx_kp_s_13;
-static PyObject *__pyx_kp_s_130;
-static PyObject *__pyx_kp_s_131;
-static PyObject *__pyx_kp_s_132;
-static PyObject *__pyx_kp_s_133;
-static PyObject *__pyx_kp_s_135;
-static PyObject *__pyx_kp_s_136;
-static PyObject *__pyx_kp_s_137;
-static PyObject *__pyx_kp_s_138;
-static PyObject *__pyx_kp_s_139;
-static PyObject *__pyx_kp_s_14;
-static PyObject *__pyx_kp_s_140;
-static PyObject *__pyx_kp_s_141;
-static PyObject *__pyx_kp_s_142;
-static PyObject *__pyx_kp_s_143;
-static PyObject *__pyx_kp_s_144;
-static PyObject *__pyx_kp_s_145;
-static PyObject *__pyx_kp_s_146;
-static PyObject *__pyx_kp_s_147;
-static PyObject *__pyx_kp_s_148;
-static PyObject *__pyx_kp_s_149;
 static PyObject *__pyx_kp_s_15;
-static PyObject *__pyx_kp_s_150;
-static PyObject *__pyx_kp_s_151;
-static PyObject *__pyx_kp_s_152;
-static PyObject *__pyx_kp_s_153;
-static PyObject *__pyx_kp_s_154;
-static PyObject *__pyx_kp_s_155;
-static PyObject *__pyx_kp_s_156;
-static PyObject *__pyx_kp_s_157;
-static PyObject *__pyx_kp_s_162;
-static PyObject *__pyx_kp_s_163;
-static PyObject *__pyx_kp_s_164;
-static PyObject *__pyx_n_s_166;
-static PyObject *__pyx_kp_s_167;
-static PyObject *__pyx_kp_s_168;
-static PyObject *__pyx_kp_s_17;
+static PyObject *__pyx_kp_s_16;
+static PyObject *__pyx_kp_s_173;
+static PyObject *__pyx_kp_s_174;
+static PyObject *__pyx_kp_s_175;
+static PyObject *__pyx_kp_s_176;
+static PyObject *__pyx_kp_u_177;
+static PyObject *__pyx_kp_u_178;
+static PyObject *__pyx_kp_u_179;
+static PyObject *__pyx_kp_s_18;
+static PyObject *__pyx_kp_u_180;
+static PyObject *__pyx_kp_u_181;
+static PyObject *__pyx_kp_u_182;
+static PyObject *__pyx_kp_u_183;
+static PyObject *__pyx_kp_u_184;
+static PyObject *__pyx_kp_u_185;
+static PyObject *__pyx_kp_u_186;
+static PyObject *__pyx_kp_u_187;
+static PyObject *__pyx_kp_u_188;
+static PyObject *__pyx_kp_u_189;
+static PyObject *__pyx_kp_s_19;
+static PyObject *__pyx_kp_u_190;
+static PyObject *__pyx_kp_u_191;
+static PyObject *__pyx_kp_u_192;
+static PyObject *__pyx_kp_u_193;
+static PyObject *__pyx_kp_u_194;
+static PyObject *__pyx_kp_u_195;
+static PyObject *__pyx_kp_u_196;
+static PyObject *__pyx_kp_u_197;
+static PyObject *__pyx_kp_u_198;
+static PyObject *__pyx_kp_u_199;
 static PyObject *__pyx_kp_s_2;
+static PyObject *__pyx_kp_s_20;
+static PyObject *__pyx_n_s_200;
+static PyObject *__pyx_kp_u_201;
+static PyObject *__pyx_kp_u_202;
+static PyObject *__pyx_kp_u_203;
+static PyObject *__pyx_n_s_204;
+static PyObject *__pyx_kp_u_205;
+static PyObject *__pyx_n_s_206;
+static PyObject *__pyx_kp_u_207;
+static PyObject *__pyx_kp_u_208;
+static PyObject *__pyx_kp_u_209;
 static PyObject *__pyx_kp_s_21;
+static PyObject *__pyx_kp_u_210;
+static PyObject *__pyx_kp_u_211;
+static PyObject *__pyx_kp_u_212;
+static PyObject *__pyx_kp_u_213;
+static PyObject *__pyx_kp_u_214;
+static PyObject *__pyx_kp_u_215;
+static PyObject *__pyx_kp_u_216;
+static PyObject *__pyx_kp_u_217;
+static PyObject *__pyx_kp_u_218;
+static PyObject *__pyx_kp_u_219;
 static PyObject *__pyx_kp_s_22;
+static PyObject *__pyx_kp_u_220;
 static PyObject *__pyx_kp_s_23;
-static PyObject *__pyx_kp_s_230;
-static PyObject *__pyx_kp_s_231;
-static PyObject *__pyx_kp_s_232;
-static PyObject *__pyx_kp_s_238;
 static PyObject *__pyx_kp_s_24;
 static PyObject *__pyx_kp_s_25;
 static PyObject *__pyx_kp_s_26;
 static PyObject *__pyx_kp_s_27;
 static PyObject *__pyx_kp_s_28;
 static PyObject *__pyx_kp_s_3;
+static PyObject *__pyx_kp_s_30;
 static PyObject *__pyx_kp_s_31;
+static PyObject *__pyx_kp_s_32;
 static PyObject *__pyx_kp_s_33;
+static PyObject *__pyx_kp_s_34;
 static PyObject *__pyx_kp_s_35;
 static PyObject *__pyx_kp_s_36;
+static PyObject *__pyx_kp_s_37;
 static PyObject *__pyx_kp_s_38;
+static PyObject *__pyx_kp_s_4;
 static PyObject *__pyx_kp_s_40;
+static PyObject *__pyx_kp_s_41;
+static PyObject *__pyx_kp_s_42;
+static PyObject *__pyx_kp_s_43;
+static PyObject *__pyx_kp_s_44;
+static PyObject *__pyx_kp_s_45;
 static PyObject *__pyx_kp_s_46;
+static PyObject *__pyx_kp_s_47;
 static PyObject *__pyx_kp_s_48;
+static PyObject *__pyx_kp_s_49;
 static PyObject *__pyx_kp_s_5;
 static PyObject *__pyx_kp_s_50;
+static PyObject *__pyx_kp_s_51;
 static PyObject *__pyx_kp_s_52;
+static PyObject *__pyx_kp_s_53;
 static PyObject *__pyx_kp_s_54;
+static PyObject *__pyx_kp_s_55;
 static PyObject *__pyx_kp_s_56;
-static PyObject *__pyx_kp_s_58;
+static PyObject *__pyx_kp_s_57;
 static PyObject *__pyx_kp_s_59;
 static PyObject *__pyx_kp_s_6;
-static PyObject *__pyx_kp_s_60;
+static PyObject *__pyx_kp_s_61;
+static PyObject *__pyx_kp_s_62;
+static PyObject *__pyx_n_s_63;
+static PyObject *__pyx_kp_s_64;
 static PyObject *__pyx_kp_s_65;
+static PyObject *__pyx_kp_s_66;
+static PyObject *__pyx_kp_s_67;
 static PyObject *__pyx_kp_s_68;
+static PyObject *__pyx_kp_s_69;
+static PyObject *__pyx_kp_s_7;
+static PyObject *__pyx_kp_s_70;
 static PyObject *__pyx_kp_s_71;
+static PyObject *__pyx_kp_s_72;
+static PyObject *__pyx_kp_s_73;
 static PyObject *__pyx_kp_s_74;
+static PyObject *__pyx_kp_s_75;
+static PyObject *__pyx_kp_s_76;
+static PyObject *__pyx_kp_s_77;
+static PyObject *__pyx_kp_s_78;
+static PyObject *__pyx_kp_s_79;
+static PyObject *__pyx_kp_s_8;
+static PyObject *__pyx_kp_s_80;
 static PyObject *__pyx_kp_s_81;
+static PyObject *__pyx_kp_s_82;
+static PyObject *__pyx_kp_s_83;
 static PyObject *__pyx_kp_s_84;
+static PyObject *__pyx_kp_s_85;
+static PyObject *__pyx_kp_s_86;
+static PyObject *__pyx_kp_s_87;
+static PyObject *__pyx_kp_s_88;
 static PyObject *__pyx_kp_s_89;
 static PyObject *__pyx_kp_s_9;
+static PyObject *__pyx_kp_s_90;
 static PyObject *__pyx_kp_s_91;
+static PyObject *__pyx_kp_s_92;
 static PyObject *__pyx_kp_s_93;
 static PyObject *__pyx_kp_s_94;
+static PyObject *__pyx_kp_s_95;
 static PyObject *__pyx_kp_s_96;
 static PyObject *__pyx_kp_s_97;
-static PyObject *__pyx_kp_s_98;
-static PyObject *__pyx_kp_s_99;
 static PyObject *__pyx_n_s__A;
 static PyObject *__pyx_n_s__AS;
 static PyObject *__pyx_n_s__AlignedRead;
-static PyObject *__pyx_n_s__AttributeError;
 static PyObject *__pyx_n_s__C;
 static PyObject *__pyx_n_s__CL;
 static PyObject *__pyx_n_s__CN;
@@ -1832,16 +2070,21 @@ static PyObject *__pyx_n_s__HD;
 static PyObject *__pyx_n_s__I;
 static PyObject *__pyx_n_s__ID;
 static PyObject *__pyx_n_s__IOError;
+static PyObject *__pyx_n_s__IndelCaller;
 static PyObject *__pyx_n_s__IndexedReads;
 static PyObject *__pyx_n_s__IntType;
 static PyObject *__pyx_n_s__IteratorColumn;
+static PyObject *__pyx_n_s__IteratorIndelCalls;
 static PyObject *__pyx_n_s__IteratorRow;
+static PyObject *__pyx_n_s__IteratorRowAll;
+static PyObject *__pyx_n_s__IteratorRowAllRefs;
+static PyObject *__pyx_n_s__IteratorRowRegion;
+static PyObject *__pyx_n_s__IteratorSNPCalls;
 static PyObject *__pyx_n_s__KeyError;
 static PyObject *__pyx_n_s__LB;
 static PyObject *__pyx_n_s__LN;
 static PyObject *__pyx_n_s__M5;
 static PyObject *__pyx_n_s__NotImplementedError;
-static PyObject *__pyx_n_s__OSError;
 static PyObject *__pyx_n_s__O_CREAT;
 static PyObject *__pyx_n_s__O_WRONLY;
 static PyObject *__pyx_n_s__Outs;
@@ -1858,6 +2101,7 @@ static PyObject *__pyx_n_s__RG;
 static PyObject *__pyx_n_s__S;
 static PyObject *__pyx_n_s__SM;
 static PyObject *__pyx_n_s__SN;
+static PyObject *__pyx_n_s__SNPCaller;
 static PyObject *__pyx_n_s__SO;
 static PyObject *__pyx_n_s__SP;
 static PyObject *__pyx_n_s__SQ;
@@ -1881,11 +2125,13 @@ static PyObject *__pyx_n_s____dict__;
 static PyObject *__pyx_n_s____getattribute__;
 static PyObject *__pyx_n_s____init__;
 static PyObject *__pyx_n_s____main__;
+static PyObject *__pyx_n_s____next__;
 static PyObject *__pyx_n_s____str__;
 static PyObject *__pyx_n_s____test__;
 static PyObject *__pyx_n_s___alignment;
 static PyObject *__pyx_n_s___buildHeader;
 static PyObject *__pyx_n_s___buildLine;
+static PyObject *__pyx_n_s___call;
 static PyObject *__pyx_n_s___consensus_quality;
 static PyObject *__pyx_n_s___coverage;
 static PyObject *__pyx_n_s___delegate;
@@ -1903,23 +2149,26 @@ static PyObject *__pyx_n_s___open;
 static PyObject *__pyx_n_s___parseRegion;
 static PyObject *__pyx_n_s___pos;
 static PyObject *__pyx_n_s___qpos;
+static PyObject *__pyx_n_s___r;
 static PyObject *__pyx_n_s___reference_base;
 static PyObject *__pyx_n_s___samtools_dispatch;
 static PyObject *__pyx_n_s___snp_quality;
 static PyObject *__pyx_n_s___tid;
-static PyObject *__pyx_n_s__add_sq_text;
+static PyObject *__pyx_n_s__addReference;
 static PyObject *__pyx_n_s__alignment;
 static PyObject *__pyx_n_s__all;
-static PyObject *__pyx_n_s__append;
 static PyObject *__pyx_n_s__args;
 static PyObject *__pyx_n_s__b;
 static PyObject *__pyx_n_s__bam;
 static PyObject *__pyx_n_s__beg;
 static PyObject *__pyx_n_s__bin;
 static PyObject *__pyx_n_s__bqual;
+static PyObject *__pyx_n_s__build;
 static PyObject *__pyx_n_s__c;
 static PyObject *__pyx_n_s__calcsize;
+static PyObject *__pyx_n_s__call;
 static PyObject *__pyx_n_s__callback;
+static PyObject *__pyx_n_s__cap_mapQ;
 static PyObject *__pyx_n_s__catch_stderr;
 static PyObject *__pyx_n_s__catch_stdout;
 static PyObject *__pyx_n_s__chr;
@@ -1927,11 +2176,15 @@ static PyObject *__pyx_n_s__cigar;
 static PyObject *__pyx_n_s__close;
 static PyObject *__pyx_n_s__cmp;
 static PyObject *__pyx_n_s__cnext;
+static PyObject *__pyx_n_s__cnt1;
+static PyObject *__pyx_n_s__cnt2;
+static PyObject *__pyx_n_s__cnt_anti;
 static PyObject *__pyx_n_s__collections;
+static PyObject *__pyx_n_s__compare;
 static PyObject *__pyx_n_s__consensus_quality;
 static PyObject *__pyx_n_s__core;
+static PyObject *__pyx_n_s__count;
 static PyObject *__pyx_n_s__coverage;
-static PyObject *__pyx_n_s__csamtools;
 static PyObject *__pyx_n_s__ctypes;
 static PyObject *__pyx_n_s__current_pos;
 static PyObject *__pyx_n_s__d;
@@ -1942,25 +2195,35 @@ static PyObject *__pyx_n_s__devnull;
 static PyObject *__pyx_n_s__dup;
 static PyObject *__pyx_n_s__dup2;
 static PyObject *__pyx_n_s__end;
+static PyObject *__pyx_n_s__errmod;
 static PyObject *__pyx_n_s__exc_type;
 static PyObject *__pyx_n_s__exc_value;
 static PyObject *__pyx_n_s__exists;
 static PyObject *__pyx_n_s__f;
+static PyObject *__pyx_n_s__fancy_str;
 static PyObject *__pyx_n_s__fastafile;
 static PyObject *__pyx_n_s__fd;
+static PyObject *__pyx_n_s__fetch;
 static PyObject *__pyx_n_s__fields;
 static PyObject *__pyx_n_s__filename;
 static PyObject *__pyx_n_s__fileno;
+static PyObject *__pyx_n_s__first_allele;
 static PyObject *__pyx_n_s__flag;
 static PyObject *__pyx_n_s__flush;
 static PyObject *__pyx_n_s__fp;
 static PyObject *__pyx_n_s__genotype;
+static PyObject *__pyx_n_s__getSequence;
+static PyObject *__pyx_n_s__getrname;
 static PyObject *__pyx_n_s__gettid;
+static PyObject *__pyx_n_s__hasReference;
 static PyObject *__pyx_n_s__hash;
 static PyObject *__pyx_n_s__header;
+static PyObject *__pyx_n_s__het_rate;
 static PyObject *__pyx_n_s__i;
 static PyObject *__pyx_n_s__id;
 static PyObject *__pyx_n_s__indel;
+static PyObject *__pyx_n_s__indel1;
+static PyObject *__pyx_n_s__indel2;
 static PyObject *__pyx_n_s__index;
 static PyObject *__pyx_n_s__is_del;
 static PyObject *__pyx_n_s__is_head;
@@ -1968,9 +2231,9 @@ static PyObject *__pyx_n_s__is_tail;
 static PyObject *__pyx_n_s__isbam;
 static PyObject *__pyx_n_s__isize;
 static PyObject *__pyx_n_s__isremote;
-static PyObject *__pyx_n_s__isstream;
 static PyObject *__pyx_n_s__isupper;
 static PyObject *__pyx_n_s__iter;
+static PyObject *__pyx_n_s__iterator_column;
 static PyObject *__pyx_n_s__iterdata;
 static PyObject *__pyx_n_s__itertools;
 static PyObject *__pyx_n_s__join;
@@ -1987,6 +2250,7 @@ static PyObject *__pyx_n_s__mask;
 static PyObject *__pyx_n_s__mate;
 static PyObject *__pyx_n_s__max_depth;
 static PyObject *__pyx_n_s__method;
+static PyObject *__pyx_n_s__min_baseQ;
 static PyObject *__pyx_n_s__mkstemp;
 static PyObject *__pyx_n_s__mode;
 static PyObject *__pyx_n_s__mpos;
@@ -1994,6 +2258,8 @@ static PyObject *__pyx_n_s__mrnm;
 static PyObject *__pyx_n_s__mtid;
 static PyObject *__pyx_n_s__n;
 static PyObject *__pyx_n_s__n_cigar;
+static PyObject *__pyx_n_s__n_hap;
+static PyObject *__pyx_n_s__n_haplotypes;
 static PyObject *__pyx_n_s__n_plp;
 static PyObject *__pyx_n_s__n_pu;
 static PyObject *__pyx_n_s__n_targets;
@@ -2003,10 +2269,14 @@ static PyObject *__pyx_n_s__nreferences;
 static PyObject *__pyx_n_s__object;
 static PyObject *__pyx_n_s__offset;
 static PyObject *__pyx_n_s__open;
+static PyObject *__pyx_n_s__opt;
+static PyObject *__pyx_n_s__options;
 static PyObject *__pyx_n_s__os;
+static PyObject *__pyx_n_s__overlap;
 static PyObject *__pyx_n_s__owns_samfile;
 static PyObject *__pyx_n_s__pack_into;
 static PyObject *__pyx_n_s__path;
+static PyObject *__pyx_n_s__pileup;
 static PyObject *__pyx_n_s__pileup_iter;
 static PyObject *__pyx_n_s__pileups;
 static PyObject *__pyx_n_s__platform;
@@ -2014,17 +2284,25 @@ static PyObject *__pyx_n_s__plp;
 static PyObject *__pyx_n_s__port;
 static PyObject *__pyx_n_s__pos;
 static PyObject *__pyx_n_s__positions;
+static PyObject *__pyx_n_s__q_cns;
+static PyObject *__pyx_n_s__q_indel;
+static PyObject *__pyx_n_s__q_r;
+static PyObject *__pyx_n_s__q_ref;
 static PyObject *__pyx_n_s__qname;
 static PyObject *__pyx_n_s__qpos;
 static PyObject *__pyx_n_s__qseq;
 static PyObject *__pyx_n_s__qual;
 static PyObject *__pyx_n_s__r;
-static PyObject *__pyx_n_s__rU;
+static PyObject *__pyx_n_s__r_indel;
+static PyObject *__pyx_n_s__range;
 static PyObject *__pyx_n_s__raw;
 static PyObject *__pyx_n_s__rb;
 static PyObject *__pyx_n_s__re;
 static PyObject *__pyx_n_s__readAndRelease;
 static PyObject *__pyx_n_s__readlines;
+static PyObject *__pyx_n_s__reads_diff;
+static PyObject *__pyx_n_s__reads_first;
+static PyObject *__pyx_n_s__reads_second;
 static PyObject *__pyx_n_s__record;
 static PyObject *__pyx_n_s__reference;
 static PyObject *__pyx_n_s__reference_base;
@@ -2034,6 +2312,7 @@ static PyObject *__pyx_n_s__region;
 static PyObject *__pyx_n_s__release;
 static PyObject *__pyx_n_s__remove;
 static PyObject *__pyx_n_s__reopen;
+static PyObject *__pyx_n_s__reset;
 static PyObject *__pyx_n_s__restore;
 static PyObject *__pyx_n_s__retval;
 static PyObject *__pyx_n_s__rg2lib;
@@ -2043,6 +2322,7 @@ static PyObject *__pyx_n_s__rowiter;
 static PyObject *__pyx_n_s__s;
 static PyObject *__pyx_n_s__samfile;
 static PyObject *__pyx_n_s__samtools;
+static PyObject *__pyx_n_s__second_allele;
 static PyObject *__pyx_n_s__seek;
 static PyObject *__pyx_n_s__self;
 static PyObject *__pyx_n_s__seq;
@@ -2054,7 +2334,6 @@ static PyObject *__pyx_n_s__setupIteratorData;
 static PyObject *__pyx_n_s__snp_quality;
 static PyObject *__pyx_n_s__split;
 static PyObject *__pyx_n_s__start;
-static PyObject *__pyx_n_s__start_offset;
 static PyObject *__pyx_n_s__startswith;
 static PyObject *__pyx_n_s__stderr;
 static PyObject *__pyx_n_s__stderr_f;
@@ -2070,9 +2349,11 @@ static PyObject *__pyx_n_s__system;
 static PyObject *__pyx_n_s__tags;
 static PyObject *__pyx_n_s__target_len;
 static PyObject *__pyx_n_s__target_name;
+static PyObject *__pyx_n_s__tell;
 static PyObject *__pyx_n_s__tempfile;
 static PyObject *__pyx_n_s__template;
 static PyObject *__pyx_n_s__text;
+static PyObject *__pyx_n_s__theta;
 static PyObject *__pyx_n_s__tid;
 static PyObject *__pyx_n_s__traceback;
 static PyObject *__pyx_n_s__types;
@@ -2090,8 +2371,11 @@ static PyObject *__pyx_int_1;
 static PyObject *__pyx_int_2;
 static PyObject *__pyx_int_4;
 static PyObject *__pyx_int_8;
+static PyObject *__pyx_int_13;
 static PyObject *__pyx_int_16;
 static PyObject *__pyx_int_32;
+static PyObject *__pyx_int_40;
+static PyObject *__pyx_int_60;
 static PyObject *__pyx_int_64;
 static PyObject *__pyx_int_128;
 static PyObject *__pyx_int_255;
@@ -2100,83 +2384,18 @@ static PyObject *__pyx_int_512;
 static PyObject *__pyx_int_neg_127;
 static PyObject *__pyx_int_0660;
 static PyObject *__pyx_int_1024;
-static PyObject *__pyx_int_8000;
 static PyObject *__pyx_int_65535;
 static PyObject *__pyx_int_neg_32767;
 static PyObject *__pyx_int_536870912;
 static PyObject *__pyx_int_4294967295;
 static PyObject *__pyx_int_neg_2147483648;
-static PyObject *__pyx_k_16;
-static PyObject *__pyx_k_44;
-static PyObject *__pyx_k_62;
-static int __pyx_k_115;
-static PyObject *__pyx_k_160;
-static PyObject *__pyx_k_161;
-static PyObject *__pyx_k_tuple_4;
-static PyObject *__pyx_k_tuple_7;
-static PyObject *__pyx_k_tuple_8;
-static PyObject *__pyx_k_tuple_10;
-static PyObject *__pyx_k_tuple_29;
-static PyObject *__pyx_k_tuple_30;
-static PyObject *__pyx_k_tuple_32;
-static PyObject *__pyx_k_tuple_34;
-static PyObject *__pyx_k_tuple_37;
-static PyObject *__pyx_k_tuple_39;
-static PyObject *__pyx_k_tuple_41;
-static PyObject *__pyx_k_tuple_42;
-static PyObject *__pyx_k_tuple_43;
-static PyObject *__pyx_k_tuple_45;
-static PyObject *__pyx_k_tuple_47;
-static PyObject *__pyx_k_tuple_49;
-static PyObject *__pyx_k_tuple_51;
-static PyObject *__pyx_k_tuple_53;
-static PyObject *__pyx_k_tuple_55;
-static PyObject *__pyx_k_tuple_57;
-static PyObject *__pyx_k_tuple_61;
-static PyObject *__pyx_k_tuple_63;
-static PyObject *__pyx_k_tuple_64;
-static PyObject *__pyx_k_tuple_66;
-static PyObject *__pyx_k_tuple_67;
-static PyObject *__pyx_k_tuple_69;
-static PyObject *__pyx_k_tuple_70;
-static PyObject *__pyx_k_tuple_72;
-static PyObject *__pyx_k_tuple_73;
-static PyObject *__pyx_k_tuple_75;
-static PyObject *__pyx_k_tuple_76;
-static PyObject *__pyx_k_tuple_77;
-static PyObject *__pyx_k_tuple_78;
-static PyObject *__pyx_k_tuple_79;
-static PyObject *__pyx_k_tuple_80;
-static PyObject *__pyx_k_tuple_82;
-static PyObject *__pyx_k_tuple_83;
-static PyObject *__pyx_k_tuple_85;
-static PyObject *__pyx_k_tuple_86;
-static PyObject *__pyx_k_tuple_87;
-static PyObject *__pyx_k_tuple_88;
-static PyObject *__pyx_k_tuple_90;
-static PyObject *__pyx_k_tuple_92;
-static PyObject *__pyx_k_tuple_95;
-static PyObject *__pyx_k_tuple_102;
-static PyObject *__pyx_k_tuple_104;
-static PyObject *__pyx_k_tuple_105;
-static PyObject *__pyx_k_tuple_107;
-static PyObject *__pyx_k_tuple_108;
-static PyObject *__pyx_k_tuple_109;
-static PyObject *__pyx_k_tuple_110;
-static PyObject *__pyx_k_tuple_111;
-static PyObject *__pyx_k_tuple_117;
-static PyObject *__pyx_k_tuple_118;
-static PyObject *__pyx_k_tuple_134;
-static PyObject *__pyx_k_tuple_158;
-static PyObject *__pyx_k_tuple_159;
-static PyObject *__pyx_k_tuple_165;
-static PyObject *__pyx_k_tuple_233;
-static PyObject *__pyx_k_tuple_234;
-static PyObject *__pyx_k_tuple_235;
-static PyObject *__pyx_k_tuple_236;
-static PyObject *__pyx_k_tuple_237;
-
-/* "csamtools.pyx":76
+static PyObject *__pyx_k_29;
+static PyObject *__pyx_k_39;
+static int __pyx_k_58;
+static PyObject *__pyx_k_98;
+static PyObject *__pyx_k_99;
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":76
  * #####################################################################
  * cdef class AlignedRead
  * cdef makeAlignedRead(bam1_t * src):             # <<<<<<<<<<<<<<
@@ -2192,7 +2411,7 @@ static  PyObject *__pyx_f_9csamtools_makeAlignedRead(bam1_t *__pyx_v_src) {
   __Pyx_RefNannySetupContext("makeAlignedRead");
   __Pyx_TraceCall("makeAlignedRead", __pyx_f[0], 76);
 
-  /* "csamtools.pyx":78
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":78
  * cdef makeAlignedRead(bam1_t * src):
  *     '''enter src into AlignedRead.'''
  *     cdef AlignedRead dest = AlignedRead.__new__(AlignedRead)             # <<<<<<<<<<<<<<
@@ -2205,7 +2424,7 @@ static  PyObject *__pyx_f_9csamtools_makeAlignedRead(bam1_t *__pyx_v_src) {
   __pyx_v_dest = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_t_1);
   __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":79
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":79
  *     '''enter src into AlignedRead.'''
  *     cdef AlignedRead dest = AlignedRead.__new__(AlignedRead)
  *     dest._delegate = bam_dup1(src)             # <<<<<<<<<<<<<<
@@ -2214,7 +2433,7 @@ static  PyObject *__pyx_f_9csamtools_makeAlignedRead(bam1_t *__pyx_v_src) {
  */
   __pyx_v_dest->_delegate = bam_dup1(__pyx_v_src);
 
-  /* "csamtools.pyx":80
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":80
  *     cdef AlignedRead dest = AlignedRead.__new__(AlignedRead)
  *     dest._delegate = bam_dup1(src)
  *     return dest             # <<<<<<<<<<<<<<
@@ -2240,7 +2459,7 @@ static  PyObject *__pyx_f_9csamtools_makeAlignedRead(bam1_t *__pyx_v_src) {
   return __pyx_r;
 }
 
-/* "csamtools.pyx":83
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":83
  * 
  * cdef class PileupProxy
  * cdef makePileupProxy( bam_pileup1_t * plp, int tid, int pos, int n ):             # <<<<<<<<<<<<<<
@@ -2256,7 +2475,7 @@ static  PyObject *__pyx_f_9csamtools_makePileupProxy(bam_pileup1_t *__pyx_v_plp,
   __Pyx_RefNannySetupContext("makePileupProxy");
   __Pyx_TraceCall("makePileupProxy", __pyx_f[0], 83);
 
-  /* "csamtools.pyx":84
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":84
  * cdef class PileupProxy
  * cdef makePileupProxy( bam_pileup1_t * plp, int tid, int pos, int n ):
  *      cdef PileupProxy dest = PileupProxy.__new__(PileupProxy)             # <<<<<<<<<<<<<<
@@ -2269,7 +2488,7 @@ static  PyObject *__pyx_f_9csamtools_makePileupProxy(bam_pileup1_t *__pyx_v_plp,
   __pyx_v_dest = ((struct __pyx_obj_9csamtools_PileupProxy *)__pyx_t_1);
   __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":85
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":85
  * cdef makePileupProxy( bam_pileup1_t * plp, int tid, int pos, int n ):
  *      cdef PileupProxy dest = PileupProxy.__new__(PileupProxy)
  *      dest.plp = plp             # <<<<<<<<<<<<<<
@@ -2278,7 +2497,7 @@ static  PyObject *__pyx_f_9csamtools_makePileupProxy(bam_pileup1_t *__pyx_v_plp,
  */
   __pyx_v_dest->plp = __pyx_v_plp;
 
-  /* "csamtools.pyx":86
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":86
  *      cdef PileupProxy dest = PileupProxy.__new__(PileupProxy)
  *      dest.plp = plp
  *      dest.tid = tid             # <<<<<<<<<<<<<<
@@ -2287,7 +2506,7 @@ static  PyObject *__pyx_f_9csamtools_makePileupProxy(bam_pileup1_t *__pyx_v_plp,
  */
   __pyx_v_dest->tid = __pyx_v_tid;
 
-  /* "csamtools.pyx":87
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":87
  *      dest.plp = plp
  *      dest.tid = tid
  *      dest.pos = pos             # <<<<<<<<<<<<<<
@@ -2296,7 +2515,7 @@ static  PyObject *__pyx_f_9csamtools_makePileupProxy(bam_pileup1_t *__pyx_v_plp,
  */
   __pyx_v_dest->pos = __pyx_v_pos;
 
-  /* "csamtools.pyx":88
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":88
  *      dest.tid = tid
  *      dest.pos = pos
  *      dest.n = n             # <<<<<<<<<<<<<<
@@ -2308,7 +2527,7 @@ static  PyObject *__pyx_f_9csamtools_makePileupProxy(bam_pileup1_t *__pyx_v_plp,
   if (PyObject_SetAttr(((PyObject *)__pyx_v_dest), __pyx_n_s__n, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":89
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":89
  *      dest.pos = pos
  *      dest.n = n
  *      return dest             # <<<<<<<<<<<<<<
@@ -2334,7 +2553,7 @@ static  PyObject *__pyx_f_9csamtools_makePileupProxy(bam_pileup1_t *__pyx_v_plp,
   return __pyx_r;
 }
 
-/* "csamtools.pyx":92
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":92
  * 
  * cdef class PileupRead
  * cdef makePileupRead( bam_pileup1_t * src ):             # <<<<<<<<<<<<<<
@@ -2350,7 +2569,7 @@ static  PyObject *__pyx_f_9csamtools_makePileupRead(bam_pileup1_t *__pyx_v_src)
   __Pyx_RefNannySetupContext("makePileupRead");
   __Pyx_TraceCall("makePileupRead", __pyx_f[0], 92);
 
-  /* "csamtools.pyx":94
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":94
  * cdef makePileupRead( bam_pileup1_t * src ):
  *     '''fill a  PileupRead object from a bam_pileup1_t * object.'''
  *     cdef PileupRead dest = PileupRead.__new__(PileupRead)             # <<<<<<<<<<<<<<
@@ -2363,7 +2582,7 @@ static  PyObject *__pyx_f_9csamtools_makePileupRead(bam_pileup1_t *__pyx_v_src)
   __pyx_v_dest = ((struct __pyx_obj_9csamtools_PileupRead *)__pyx_t_1);
   __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":95
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":95
  *     '''fill a  PileupRead object from a bam_pileup1_t * object.'''
  *     cdef PileupRead dest = PileupRead.__new__(PileupRead)
  *     dest._alignment = makeAlignedRead( src.b )             # <<<<<<<<<<<<<<
@@ -2379,7 +2598,7 @@ static  PyObject *__pyx_f_9csamtools_makePileupRead(bam_pileup1_t *__pyx_v_src)
   __pyx_v_dest->_alignment = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_t_1);
   __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":96
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":96
  *     cdef PileupRead dest = PileupRead.__new__(PileupRead)
  *     dest._alignment = makeAlignedRead( src.b )
  *     dest._qpos = src.qpos             # <<<<<<<<<<<<<<
@@ -2388,7 +2607,7 @@ static  PyObject *__pyx_f_9csamtools_makePileupRead(bam_pileup1_t *__pyx_v_src)
  */
   __pyx_v_dest->_qpos = __pyx_v_src->qpos;
 
-  /* "csamtools.pyx":97
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":97
  *     dest._alignment = makeAlignedRead( src.b )
  *     dest._qpos = src.qpos
  *     dest._indel = src.indel             # <<<<<<<<<<<<<<
@@ -2397,7 +2616,7 @@ static  PyObject *__pyx_f_9csamtools_makePileupRead(bam_pileup1_t *__pyx_v_src)
  */
   __pyx_v_dest->_indel = __pyx_v_src->indel;
 
-  /* "csamtools.pyx":98
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":98
  *     dest._qpos = src.qpos
  *     dest._indel = src.indel
  *     dest._level = src.level             # <<<<<<<<<<<<<<
@@ -2406,7 +2625,7 @@ static  PyObject *__pyx_f_9csamtools_makePileupRead(bam_pileup1_t *__pyx_v_src)
  */
   __pyx_v_dest->_level = __pyx_v_src->level;
 
-  /* "csamtools.pyx":99
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":99
  *     dest._indel = src.indel
  *     dest._level = src.level
  *     dest._is_del = src.is_del             # <<<<<<<<<<<<<<
@@ -2415,7 +2634,7 @@ static  PyObject *__pyx_f_9csamtools_makePileupRead(bam_pileup1_t *__pyx_v_src)
  */
   __pyx_v_dest->_is_del = __pyx_v_src->is_del;
 
-  /* "csamtools.pyx":100
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":100
  *     dest._level = src.level
  *     dest._is_del = src.is_del
  *     dest._is_head = src.is_head             # <<<<<<<<<<<<<<
@@ -2424,7 +2643,7 @@ static  PyObject *__pyx_f_9csamtools_makePileupRead(bam_pileup1_t *__pyx_v_src)
  */
   __pyx_v_dest->_is_head = __pyx_v_src->is_head;
 
-  /* "csamtools.pyx":101
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":101
  *     dest._is_del = src.is_del
  *     dest._is_head = src.is_head
  *     dest._is_tail = src.is_tail             # <<<<<<<<<<<<<<
@@ -2433,7 +2652,7 @@ static  PyObject *__pyx_f_9csamtools_makePileupRead(bam_pileup1_t *__pyx_v_src)
  */
   __pyx_v_dest->_is_tail = __pyx_v_src->is_tail;
 
-  /* "csamtools.pyx":102
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":102
  *     dest._is_head = src.is_head
  *     dest._is_tail = src.is_tail
  *     return dest             # <<<<<<<<<<<<<<
@@ -2459,7 +2678,7 @@ static  PyObject *__pyx_f_9csamtools_makePileupRead(bam_pileup1_t *__pyx_v_src)
   return __pyx_r;
 }
 
-/* "csamtools.pyx":109
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":109
  * ## Generic callbacks for inserting python callbacks.
  * #####################################################################
  * cdef int fetch_callback( bam1_t *alignment, void *f):             # <<<<<<<<<<<<<<
@@ -2477,7 +2696,7 @@ static  int __pyx_f_9csamtools_fetch_callback(bam1_t *__pyx_v_alignment, void *_
   __Pyx_TraceCall("fetch_callback", __pyx_f[0], 109);
   __pyx_v_a = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "csamtools.pyx":114
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":114
  *     calls function in *f* with a new :class:`AlignedRead` object as parameter.
  *     '''
  *     a = makeAlignedRead( alignment )             # <<<<<<<<<<<<<<
@@ -2490,7 +2709,7 @@ static  int __pyx_f_9csamtools_fetch_callback(bam1_t *__pyx_v_alignment, void *_
   __pyx_v_a = __pyx_t_1;
   __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":115
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":115
  *     '''
  *     a = makeAlignedRead( alignment )
  *     (<object>f)(a)             # <<<<<<<<<<<<<<
@@ -2498,13 +2717,13 @@ static  int __pyx_f_9csamtools_fetch_callback(bam1_t *__pyx_v_alignment, void *_
  * class PileupColumn(object):
  */
   __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  __Pyx_GOTREF(__pyx_t_1);
   __Pyx_INCREF(__pyx_v_a);
   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_a);
   __Pyx_GIVEREF(__pyx_v_a);
-  __pyx_t_2 = PyObject_Call(((PyObject *)__pyx_v_f), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(((PyObject *)__pyx_v_f), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
   __pyx_r = 0;
@@ -2521,7 +2740,7 @@ static  int __pyx_f_9csamtools_fetch_callback(bam1_t *__pyx_v_alignment, void *_
   return __pyx_r;
 }
 
-/* "csamtools.pyx":130
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":130
  *         list of reads (:class:`pysam.PileupRead`) aligned to this column
  *     '''
  *     def __str__(self):             # <<<<<<<<<<<<<<
@@ -2544,7 +2763,7 @@ static PyObject *__pyx_pf_9csamtools_12PileupColumn___str__(PyObject *__pyx_self
   __Pyx_TraceCall("__str__", __pyx_f[0], 130);
   __pyx_self = __pyx_self;
 
-  /* "csamtools.pyx":131
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":131
  *     '''
  *     def __str__(self):
  *         return "\t".join( map(str, (self.tid, self.pos, self.n))) +\             # <<<<<<<<<<<<<<
@@ -2553,7 +2772,7 @@ static PyObject *__pyx_pf_9csamtools_12PileupColumn___str__(PyObject *__pyx_self
  */
   __Pyx_XDECREF(__pyx_r);
 
-  /* "csamtools.pyx":132
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":132
  *     def __str__(self):
  *         return "\t".join( map(str, (self.tid, self.pos, self.n))) +\
  *             "\n" + "\n".join( map(str, self.pileups) )             # <<<<<<<<<<<<<<
@@ -2563,7 +2782,7 @@ static PyObject *__pyx_pf_9csamtools_12PileupColumn___str__(PyObject *__pyx_self
   __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_1), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
 
-  /* "csamtools.pyx":131
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":131
  *     '''
  *     def __str__(self):
  *         return "\t".join( map(str, (self.tid, self.pos, self.n))) +\             # <<<<<<<<<<<<<<
@@ -2577,7 +2796,7 @@ static PyObject *__pyx_pf_9csamtools_12PileupColumn___str__(PyObject *__pyx_self
   __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__n); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+  __Pyx_GOTREF(__pyx_t_5);
   PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
   __Pyx_GIVEREF(__pyx_t_2);
   PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
@@ -2588,30 +2807,30 @@ static PyObject *__pyx_pf_9csamtools_12PileupColumn___str__(PyObject *__pyx_self
   __pyx_t_3 = 0;
   __pyx_t_4 = 0;
   __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
-  __Pyx_INCREF(((PyObject *)((PyObject*)(&PyString_Type))));
-  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)((PyObject*)(&PyString_Type))));
-  __Pyx_GIVEREF(((PyObject *)((PyObject*)(&PyString_Type))));
-  PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_t_5));
-  __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
+  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)((PyObject*)&PyString_Type)));
+  __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
+  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5);
+  __Pyx_GIVEREF(__pyx_t_5);
   __pyx_t_5 = 0;
-  __pyx_t_5 = PyObject_Call(__pyx_builtin_map, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_Call(__pyx_builtin_map, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
-  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
+  __Pyx_GOTREF(__pyx_t_4);
   PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
   __Pyx_GIVEREF(__pyx_t_5);
   __pyx_t_5 = 0;
-  __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   __pyx_t_4 = PyNumber_Add(__pyx_t_5, ((PyObject *)__pyx_kp_s_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
-  /* "csamtools.pyx":132
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":132
  *     def __str__(self):
  *         return "\t".join( map(str, (self.tid, self.pos, self.n))) +\
  *             "\n" + "\n".join( map(str, self.pileups) )             # <<<<<<<<<<<<<<
@@ -2623,25 +2842,25 @@ static PyObject *__pyx_pf_9csamtools_12PileupColumn___str__(PyObject *__pyx_self
   __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__pileups); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-  __Pyx_INCREF(((PyObject *)((PyObject*)(&PyString_Type))));
-  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)((PyObject*)(&PyString_Type))));
-  __Pyx_GIVEREF(((PyObject *)((PyObject*)(&PyString_Type))));
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
+  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)((PyObject*)&PyString_Type)));
+  __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
   __Pyx_GIVEREF(__pyx_t_1);
   __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_Call(__pyx_builtin_map, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(__pyx_builtin_map, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+  __Pyx_GOTREF(__pyx_t_3);
   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
   __Pyx_GIVEREF(__pyx_t_1);
   __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(__pyx_t_5, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   __pyx_t_3 = PyNumber_Add(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
@@ -2667,7 +2886,7 @@ static PyObject *__pyx_pf_9csamtools_12PileupColumn___str__(PyObject *__pyx_self
   return __pyx_r;
 }
 
-/* "csamtools.pyx":134
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":134
  *             "\n" + "\n".join( map(str, self.pileups) )
  * 
  * cdef int pileup_callback( uint32_t tid, uint32_t pos, int n, bam_pileup1_t *pl, void *f):             # <<<<<<<<<<<<<<
@@ -2688,9 +2907,9 @@ static  int __pyx_f_9csamtools_pileup_callback(uint32_t __pyx_v_tid, uint32_t __
   __Pyx_RefNannySetupContext("pileup_callback");
   __Pyx_TraceCall("pileup_callback", __pyx_f[0], 134);
   __pyx_v_p = Py_None; __Pyx_INCREF(Py_None);
-  __pyx_v_pileups = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
+  __pyx_v_pileups = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
 
-  /* "csamtools.pyx":151
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":151
  *     '''
  * 
  *     p = PileupColumn()             # <<<<<<<<<<<<<<
@@ -2706,7 +2925,7 @@ static  int __pyx_f_9csamtools_pileup_callback(uint32_t __pyx_v_tid, uint32_t __
   __pyx_v_p = __pyx_t_2;
   __pyx_t_2 = 0;
 
-  /* "csamtools.pyx":152
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":152
  * 
  *     p = PileupColumn()
  *     p.tid = tid             # <<<<<<<<<<<<<<
@@ -2718,7 +2937,7 @@ static  int __pyx_f_9csamtools_pileup_callback(uint32_t __pyx_v_tid, uint32_t __
   if (PyObject_SetAttr(__pyx_v_p, __pyx_n_s__tid, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-  /* "csamtools.pyx":153
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":153
  *     p = PileupColumn()
  *     p.tid = tid
  *     p.pos = pos             # <<<<<<<<<<<<<<
@@ -2730,7 +2949,7 @@ static  int __pyx_f_9csamtools_pileup_callback(uint32_t __pyx_v_tid, uint32_t __
   if (PyObject_SetAttr(__pyx_v_p, __pyx_n_s__pos, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-  /* "csamtools.pyx":154
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":154
  *     p.tid = tid
  *     p.pos = pos
  *     p.n = n             # <<<<<<<<<<<<<<
@@ -2742,7 +2961,7 @@ static  int __pyx_f_9csamtools_pileup_callback(uint32_t __pyx_v_tid, uint32_t __
   if (PyObject_SetAttr(__pyx_v_p, __pyx_n_s__n, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-  /* "csamtools.pyx":155
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":155
  *     p.pos = pos
  *     p.n = n
  *     pileups = []             # <<<<<<<<<<<<<<
@@ -2755,7 +2974,7 @@ static  int __pyx_f_9csamtools_pileup_callback(uint32_t __pyx_v_tid, uint32_t __
   __pyx_v_pileups = __pyx_t_2;
   __pyx_t_2 = 0;
 
-  /* "csamtools.pyx":158
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":158
  * 
  *     cdef int x
  *     for x from 0 <= x < n:             # <<<<<<<<<<<<<<
@@ -2765,7 +2984,7 @@ static  int __pyx_f_9csamtools_pileup_callback(uint32_t __pyx_v_tid, uint32_t __
   __pyx_t_3 = __pyx_v_n;
   for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_3; __pyx_v_x++) {
 
-    /* "csamtools.pyx":159
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":159
  *     cdef int x
  *     for x from 0 <= x < n:
  *         pileups.append( makePileupRead( &(pl[x]) ) )             # <<<<<<<<<<<<<<
@@ -2777,11 +2996,11 @@ static  int __pyx_f_9csamtools_pileup_callback(uint32_t __pyx_v_tid, uint32_t __
     }
     __pyx_t_2 = __pyx_f_9csamtools_makePileupRead((&(__pyx_v_pl[__pyx_v_x]))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_4 = PyList_Append(__pyx_v_pileups, __pyx_t_2); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyList_Append(((PyObject *)__pyx_v_pileups), __pyx_t_2); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   }
 
-  /* "csamtools.pyx":160
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":160
  *     for x from 0 <= x < n:
  *         pileups.append( makePileupRead( &(pl[x]) ) )
  *     p.pileups = pileups             # <<<<<<<<<<<<<<
@@ -2790,7 +3009,7 @@ static  int __pyx_f_9csamtools_pileup_callback(uint32_t __pyx_v_tid, uint32_t __
  */
   if (PyObject_SetAttr(__pyx_v_p, __pyx_n_s__pileups, ((PyObject *)__pyx_v_pileups)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "csamtools.pyx":162
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":162
  *     p.pileups = pileups
  * 
  *     (<object>f)(p)             # <<<<<<<<<<<<<<
@@ -2798,13 +3017,13 @@ static  int __pyx_f_9csamtools_pileup_callback(uint32_t __pyx_v_tid, uint32_t __
  * cdef int pileup_fetch_callback( bam1_t *b, void *data):
  */
   __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+  __Pyx_GOTREF(__pyx_t_2);
   __Pyx_INCREF(__pyx_v_p);
   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_p);
   __Pyx_GIVEREF(__pyx_v_p);
-  __pyx_t_1 = PyObject_Call(((PyObject *)__pyx_v_f), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(((PyObject *)__pyx_v_f), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
   __pyx_r = 0;
@@ -2822,7 +3041,7 @@ static  int __pyx_f_9csamtools_pileup_callback(uint32_t __pyx_v_tid, uint32_t __
   return __pyx_r;
 }
 
-/* "csamtools.pyx":164
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":164
  *     (<object>f)(p)
  * 
  * cdef int pileup_fetch_callback( bam1_t *b, void *data):             # <<<<<<<<<<<<<<
@@ -2837,7 +3056,7 @@ static  int __pyx_f_9csamtools_pileup_fetch_callback(bam1_t *__pyx_v_b, void *__
   __Pyx_RefNannySetupContext("pileup_fetch_callback");
   __Pyx_TraceCall("pileup_fetch_callback", __pyx_f[0], 164);
 
-  /* "csamtools.pyx":170
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":170
  *     '''
  *     cdef bam_plbuf_t * buf
  *     buf = <bam_plbuf_t*>data             # <<<<<<<<<<<<<<
@@ -2846,7 +3065,7 @@ static  int __pyx_f_9csamtools_pileup_fetch_callback(bam1_t *__pyx_v_b, void *__
  */
   __pyx_v_buf = ((bam_plbuf_t *)__pyx_v_data);
 
-  /* "csamtools.pyx":171
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":171
  *     cdef bam_plbuf_t * buf
  *     buf = <bam_plbuf_t*>data
  *     bam_plbuf_push(b, buf)             # <<<<<<<<<<<<<<
@@ -2855,7 +3074,7 @@ static  int __pyx_f_9csamtools_pileup_fetch_callback(bam1_t *__pyx_v_b, void *__
  */
   bam_plbuf_push(__pyx_v_b, __pyx_v_buf);
 
-  /* "csamtools.pyx":172
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":172
  *     buf = <bam_plbuf_t*>data
  *     bam_plbuf_push(b, buf)
  *     return 0             # <<<<<<<<<<<<<<
@@ -2872,7 +3091,7 @@ static  int __pyx_f_9csamtools_pileup_fetch_callback(bam1_t *__pyx_v_b, void *__
   return __pyx_r;
 }
 
-/* "csamtools.pyx":178
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":178
  *     stderr is captured.
  *     '''
  *     def __init__(self):             # <<<<<<<<<<<<<<
@@ -2894,7 +3113,7 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore___init__(PyObject *__pyx_self
   __Pyx_TraceCall("__init__", __pyx_f[0], 178);
   __pyx_self = __pyx_self;
 
-  /* "csamtools.pyx":179
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":179
  *     '''
  *     def __init__(self):
  *         return             # <<<<<<<<<<<<<<
@@ -2905,7 +3124,7 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore___init__(PyObject *__pyx_self
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   goto __pyx_L0;
 
-  /* "csamtools.pyx":180
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":180
  *     def __init__(self):
  *         return
  *         self.stderr_h, self.stderr_f = tempfile.mkstemp()             # <<<<<<<<<<<<<<
@@ -2945,7 +3164,7 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore___init__(PyObject *__pyx_self
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   }
 
-  /* "csamtools.pyx":181
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":181
  *         return
  *         self.stderr_h, self.stderr_f = tempfile.mkstemp()
  *         self.stderr_save = Outs( sys.stderr.fileno() )             # <<<<<<<<<<<<<<
@@ -2966,18 +3185,18 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore___init__(PyObject *__pyx_self
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+  __Pyx_GOTREF(__pyx_t_3);
   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
   __Pyx_GIVEREF(__pyx_t_2);
   __pyx_t_2 = 0;
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__stderr_save, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-  /* "csamtools.pyx":182
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":182
  *         self.stderr_h, self.stderr_f = tempfile.mkstemp()
  *         self.stderr_save = Outs( sys.stderr.fileno() )
  *         self.stderr_save.setfd( self.stderr_h )             # <<<<<<<<<<<<<<
@@ -2992,14 +3211,14 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore___init__(PyObject *__pyx_self
   __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__stderr_h); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  __Pyx_GOTREF(__pyx_t_1);
   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
   __Pyx_GIVEREF(__pyx_t_2);
   __pyx_t_2 = 0;
-  __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
@@ -3018,7 +3237,7 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore___init__(PyObject *__pyx_self
   return __pyx_r;
 }
 
-/* "csamtools.pyx":184
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":184
  *         self.stderr_save.setfd( self.stderr_h )
  * 
  *     def readAndRelease( self ):             # <<<<<<<<<<<<<<
@@ -3026,10 +3245,10 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore___init__(PyObject *__pyx_self
  *         self.stderr_save.restore()
  */
 
-static PyObject *__pyx_pf_9csamtools_11StderrStore_1readAndRelease(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
-static char __pyx_doc_9csamtools_11StderrStore_1readAndRelease[] = "StderrStore.readAndRelease(self)";
-static PyMethodDef __pyx_mdef_9csamtools_11StderrStore_1readAndRelease = {__Pyx_NAMESTR("readAndRelease"), (PyCFunction)__pyx_pf_9csamtools_11StderrStore_1readAndRelease, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_11StderrStore_1readAndRelease)};
-static PyObject *__pyx_pf_9csamtools_11StderrStore_1readAndRelease(PyObject *__pyx_self, PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_11StderrStore_readAndRelease(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
+static char __pyx_doc_9csamtools_11StderrStore_readAndRelease[] = "StderrStore.readAndRelease(self)";
+static PyMethodDef __pyx_mdef_9csamtools_11StderrStore_readAndRelease = {__Pyx_NAMESTR("readAndRelease"), (PyCFunction)__pyx_pf_9csamtools_11StderrStore_readAndRelease, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_11StderrStore_readAndRelease)};
+static PyObject *__pyx_pf_9csamtools_11StderrStore_readAndRelease(PyObject *__pyx_self, PyObject *__pyx_v_self) {
   PyObject *__pyx_v_lines;
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
@@ -3042,7 +3261,7 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore_1readAndRelease(PyObject *__p
   __pyx_self = __pyx_self;
   __pyx_v_lines = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "csamtools.pyx":185
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":185
  * 
  *     def readAndRelease( self ):
  *         return []             # <<<<<<<<<<<<<<
@@ -3056,7 +3275,7 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore_1readAndRelease(PyObject *__p
   __pyx_t_1 = 0;
   goto __pyx_L0;
 
-  /* "csamtools.pyx":186
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":186
  *     def readAndRelease( self ):
  *         return []
  *         self.stderr_save.restore()             # <<<<<<<<<<<<<<
@@ -3073,7 +3292,7 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore_1readAndRelease(PyObject *__p
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":187
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":187
  *         return []
  *         self.stderr_save.restore()
  *         lines = []             # <<<<<<<<<<<<<<
@@ -3086,7 +3305,7 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore_1readAndRelease(PyObject *__p
   __pyx_v_lines = ((PyObject *)__pyx_t_1);
   __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":188
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":188
  *         self.stderr_save.restore()
  *         lines = []
  *         if os.path.exists(self.stderr_f):             # <<<<<<<<<<<<<<
@@ -3104,19 +3323,19 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore_1readAndRelease(PyObject *__p
   __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__stderr_f); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+  __Pyx_GOTREF(__pyx_t_3);
   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
   __Pyx_GIVEREF(__pyx_t_2);
   __pyx_t_2 = 0;
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   if (__pyx_t_4) {
 
-    /* "csamtools.pyx":189
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":189
  *         lines = []
  *         if os.path.exists(self.stderr_f):
  *             lines = open( self.stderr_f, "r" ).readlines()             # <<<<<<<<<<<<<<
@@ -3126,16 +3345,16 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore_1readAndRelease(PyObject *__p
     __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__stderr_f); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+    __Pyx_GOTREF(__pyx_t_3);
     PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
     __Pyx_GIVEREF(__pyx_t_2);
     __Pyx_INCREF(((PyObject *)__pyx_n_s__r));
     PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_n_s__r));
     __Pyx_GIVEREF(((PyObject *)__pyx_n_s__r));
     __pyx_t_2 = 0;
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_open, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_open, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__readlines); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
@@ -3146,7 +3365,7 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore_1readAndRelease(PyObject *__p
     __pyx_v_lines = __pyx_t_2;
     __pyx_t_2 = 0;
 
-    /* "csamtools.pyx":190
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":190
  *         if os.path.exists(self.stderr_f):
  *             lines = open( self.stderr_f, "r" ).readlines()
  *             os.remove( self.stderr_f )             # <<<<<<<<<<<<<<
@@ -3161,20 +3380,20 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore_1readAndRelease(PyObject *__p
     __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__stderr_f); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+    __Pyx_GOTREF(__pyx_t_1);
     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
     __Pyx_GIVEREF(__pyx_t_2);
     __pyx_t_2 = 0;
-    __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":191
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":191
  *             lines = open( self.stderr_f, "r" ).readlines()
  *             os.remove( self.stderr_f )
  *         return lines             # <<<<<<<<<<<<<<
@@ -3202,7 +3421,7 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore_1readAndRelease(PyObject *__p
   return __pyx_r;
 }
 
-/* "csamtools.pyx":193
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":193
  *         return lines
  * 
  *     def release(self):             # <<<<<<<<<<<<<<
@@ -3210,10 +3429,10 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore_1readAndRelease(PyObject *__p
  *         self.stderr_save.restore()
  */
 
-static PyObject *__pyx_pf_9csamtools_11StderrStore_2release(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
-static char __pyx_doc_9csamtools_11StderrStore_2release[] = "StderrStore.release(self)";
-static PyMethodDef __pyx_mdef_9csamtools_11StderrStore_2release = {__Pyx_NAMESTR("release"), (PyCFunction)__pyx_pf_9csamtools_11StderrStore_2release, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_11StderrStore_2release)};
-static PyObject *__pyx_pf_9csamtools_11StderrStore_2release(PyObject *__pyx_self, PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_11StderrStore_release(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
+static char __pyx_doc_9csamtools_11StderrStore_release[] = "StderrStore.release(self)";
+static PyMethodDef __pyx_mdef_9csamtools_11StderrStore_release = {__Pyx_NAMESTR("release"), (PyCFunction)__pyx_pf_9csamtools_11StderrStore_release, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_11StderrStore_release)};
+static PyObject *__pyx_pf_9csamtools_11StderrStore_release(PyObject *__pyx_self, PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   PyObject *__pyx_t_2 = NULL;
@@ -3224,7 +3443,7 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore_2release(PyObject *__pyx_self
   __Pyx_TraceCall("release", __pyx_f[0], 193);
   __pyx_self = __pyx_self;
 
-  /* "csamtools.pyx":194
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":194
  * 
  *     def release(self):
  *         return             # <<<<<<<<<<<<<<
@@ -3235,7 +3454,7 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore_2release(PyObject *__pyx_self
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   goto __pyx_L0;
 
-  /* "csamtools.pyx":195
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":195
  *     def release(self):
  *         return
  *         self.stderr_save.restore()             # <<<<<<<<<<<<<<
@@ -3252,7 +3471,7 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore_2release(PyObject *__pyx_self
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":196
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":196
  *         return
  *         self.stderr_save.restore()
  *         if os.path.exists(self.stderr_f):             # <<<<<<<<<<<<<<
@@ -3270,19 +3489,19 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore_2release(PyObject *__pyx_self
   __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__stderr_f); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+  __Pyx_GOTREF(__pyx_t_3);
   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
   __Pyx_GIVEREF(__pyx_t_2);
   __pyx_t_2 = 0;
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   if (__pyx_t_4) {
 
-    /* "csamtools.pyx":197
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":197
  *         self.stderr_save.restore()
  *         if os.path.exists(self.stderr_f):
  *             os.remove( self.stderr_f )             # <<<<<<<<<<<<<<
@@ -3297,14 +3516,14 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore_2release(PyObject *__pyx_self
     __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__stderr_f); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+    __Pyx_GOTREF(__pyx_t_1);
     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
     __Pyx_GIVEREF(__pyx_t_2);
     __pyx_t_2 = 0;
-    __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     goto __pyx_L5;
   }
@@ -3325,7 +3544,7 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore_2release(PyObject *__pyx_self
   return __pyx_r;
 }
 
-/* "csamtools.pyx":199
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":199
  *             os.remove( self.stderr_f )
  * 
  *     def __del__(self):             # <<<<<<<<<<<<<<
@@ -3333,10 +3552,10 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore_2release(PyObject *__pyx_self
  * 
  */
 
-static PyObject *__pyx_pf_9csamtools_11StderrStore_3__del__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
-static char __pyx_doc_9csamtools_11StderrStore_3__del__[] = "StderrStore.__del__(self)";
-static PyMethodDef __pyx_mdef_9csamtools_11StderrStore_3__del__ = {__Pyx_NAMESTR("__del__"), (PyCFunction)__pyx_pf_9csamtools_11StderrStore_3__del__, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_11StderrStore_3__del__)};
-static PyObject *__pyx_pf_9csamtools_11StderrStore_3__del__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_11StderrStore___del__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
+static char __pyx_doc_9csamtools_11StderrStore___del__[] = "StderrStore.__del__(self)";
+static PyMethodDef __pyx_mdef_9csamtools_11StderrStore___del__ = {__Pyx_NAMESTR("__del__"), (PyCFunction)__pyx_pf_9csamtools_11StderrStore___del__, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_11StderrStore___del__)};
+static PyObject *__pyx_pf_9csamtools_11StderrStore___del__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   PyObject *__pyx_t_2 = NULL;
@@ -3345,7 +3564,7 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore_3__del__(PyObject *__pyx_self
   __Pyx_TraceCall("__del__", __pyx_f[0], 199);
   __pyx_self = __pyx_self;
 
-  /* "csamtools.pyx":200
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":200
  * 
  *     def __del__(self):
  *         self.release()             # <<<<<<<<<<<<<<
@@ -3373,7 +3592,7 @@ static PyObject *__pyx_pf_9csamtools_11StderrStore_3__del__(PyObject *__pyx_self
   return __pyx_r;
 }
 
-/* "csamtools.pyx":204
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":204
  * class StderrStoreWindows():
  *     '''does nothing. stderr can't be redirected on windows'''
  *     def __init__(self): pass             # <<<<<<<<<<<<<<
@@ -3398,7 +3617,7 @@ static PyObject *__pyx_pf_9csamtools_18StderrStoreWindows___init__(PyObject *__p
   return __pyx_r;
 }
 
-/* "csamtools.pyx":205
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":205
  *     '''does nothing. stderr can't be redirected on windows'''
  *     def __init__(self): pass
  *     def readAndRelease(self): return []             # <<<<<<<<<<<<<<
@@ -3406,10 +3625,10 @@ static PyObject *__pyx_pf_9csamtools_18StderrStoreWindows___init__(PyObject *__p
  * 
  */
 
-static PyObject *__pyx_pf_9csamtools_18StderrStoreWindows_1readAndRelease(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
-static char __pyx_doc_9csamtools_18StderrStoreWindows_1readAndRelease[] = "StderrStoreWindows.readAndRelease(self)";
-static PyMethodDef __pyx_mdef_9csamtools_18StderrStoreWindows_1readAndRelease = {__Pyx_NAMESTR("readAndRelease"), (PyCFunction)__pyx_pf_9csamtools_18StderrStoreWindows_1readAndRelease, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_18StderrStoreWindows_1readAndRelease)};
-static PyObject *__pyx_pf_9csamtools_18StderrStoreWindows_1readAndRelease(PyObject *__pyx_self, PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_18StderrStoreWindows_readAndRelease(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
+static char __pyx_doc_9csamtools_18StderrStoreWindows_readAndRelease[] = "StderrStoreWindows.readAndRelease(self)";
+static PyMethodDef __pyx_mdef_9csamtools_18StderrStoreWindows_readAndRelease = {__Pyx_NAMESTR("readAndRelease"), (PyCFunction)__pyx_pf_9csamtools_18StderrStoreWindows_readAndRelease, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_18StderrStoreWindows_readAndRelease)};
+static PyObject *__pyx_pf_9csamtools_18StderrStoreWindows_readAndRelease(PyObject *__pyx_self, PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
@@ -3436,7 +3655,7 @@ static PyObject *__pyx_pf_9csamtools_18StderrStoreWindows_1readAndRelease(PyObje
   return __pyx_r;
 }
 
-/* "csamtools.pyx":206
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":206
  *     def __init__(self): pass
  *     def readAndRelease(self): return []
  *     def release(self): pass             # <<<<<<<<<<<<<<
@@ -3444,10 +3663,10 @@ static PyObject *__pyx_pf_9csamtools_18StderrStoreWindows_1readAndRelease(PyObje
  * if platform.system()=='Windows':
  */
 
-static PyObject *__pyx_pf_9csamtools_18StderrStoreWindows_2release(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
-static char __pyx_doc_9csamtools_18StderrStoreWindows_2release[] = "StderrStoreWindows.release(self)";
-static PyMethodDef __pyx_mdef_9csamtools_18StderrStoreWindows_2release = {__Pyx_NAMESTR("release"), (PyCFunction)__pyx_pf_9csamtools_18StderrStoreWindows_2release, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_18StderrStoreWindows_2release)};
-static PyObject *__pyx_pf_9csamtools_18StderrStoreWindows_2release(PyObject *__pyx_self, PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_18StderrStoreWindows_release(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
+static char __pyx_doc_9csamtools_18StderrStoreWindows_release[] = "StderrStoreWindows.release(self)";
+static PyMethodDef __pyx_mdef_9csamtools_18StderrStoreWindows_release = {__Pyx_NAMESTR("release"), (PyCFunction)__pyx_pf_9csamtools_18StderrStoreWindows_release, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_18StderrStoreWindows_release)};
+static PyObject *__pyx_pf_9csamtools_18StderrStoreWindows_release(PyObject *__pyx_self, PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("release");
@@ -3461,7 +3680,7 @@ static PyObject *__pyx_pf_9csamtools_18StderrStoreWindows_2release(PyObject *__p
   return __pyx_r;
 }
 
-/* "csamtools.pyx":260
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":260
  *     cdef faidx_t * fastafile
  * 
  *     def __cinit__(self, *args, **kwargs ):             # <<<<<<<<<<<<<<
@@ -3487,7 +3706,7 @@ static int __pyx_pf_9csamtools_9Fastafile___cinit__(PyObject *__pyx_v_self, PyOb
   __Pyx_INCREF(__pyx_args);
   __pyx_v_args = __pyx_args;
 
-  /* "csamtools.pyx":261
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":261
  * 
  *     def __cinit__(self, *args, **kwargs ):
  *         self.fastafile = NULL             # <<<<<<<<<<<<<<
@@ -3496,7 +3715,7 @@ static int __pyx_pf_9csamtools_9Fastafile___cinit__(PyObject *__pyx_v_self, PyOb
  */
   ((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile = NULL;
 
-  /* "csamtools.pyx":262
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":262
  *     def __cinit__(self, *args, **kwargs ):
  *         self.fastafile = NULL
  *         self._filename = NULL             # <<<<<<<<<<<<<<
@@ -3505,7 +3724,7 @@ static int __pyx_pf_9csamtools_9Fastafile___cinit__(PyObject *__pyx_v_self, PyOb
  */
   ((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->_filename = NULL;
 
-  /* "csamtools.pyx":263
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":263
  *         self.fastafile = NULL
  *         self._filename = NULL
  *         self._open( *args, **kwargs )             # <<<<<<<<<<<<<<
@@ -3538,7 +3757,7 @@ static int __pyx_pf_9csamtools_9Fastafile___cinit__(PyObject *__pyx_v_self, PyOb
   return __pyx_r;
 }
 
-/* "csamtools.pyx":265
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":265
  *         self._open( *args, **kwargs )
  * 
  *     def _isOpen( self ):             # <<<<<<<<<<<<<<
@@ -3546,16 +3765,16 @@ static int __pyx_pf_9csamtools_9Fastafile___cinit__(PyObject *__pyx_v_self, PyOb
  *         return self.fastafile != NULL
  */
 
-static PyObject *__pyx_pf_9csamtools_9Fastafile_1_isOpen(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_9csamtools_9Fastafile_1_isOpen[] = "Fastafile._isOpen(self)\nreturn true if samfile has been opened.";
-static PyObject *__pyx_pf_9csamtools_9Fastafile_1_isOpen(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+static PyObject *__pyx_pf_9csamtools_9Fastafile__isOpen(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static char __pyx_doc_9csamtools_9Fastafile__isOpen[] = "Fastafile._isOpen(self)\nreturn true if samfile has been opened.";
+static PyObject *__pyx_pf_9csamtools_9Fastafile__isOpen(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("_isOpen");
   __Pyx_TraceCall("_isOpen", __pyx_f[0], 265);
 
-  /* "csamtools.pyx":267
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":267
  *     def _isOpen( self ):
  *         '''return true if samfile has been opened.'''
  *         return self.fastafile != NULL             # <<<<<<<<<<<<<<
@@ -3582,7 +3801,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_1_isOpen(PyObject *__pyx_v_self,
   return __pyx_r;
 }
 
-/* "csamtools.pyx":269
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":269
  *         return self.fastafile != NULL
  * 
  *     def __len__(self):             # <<<<<<<<<<<<<<
@@ -3590,16 +3809,17 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_1_isOpen(PyObject *__pyx_v_self,
  *             raise ValueError( "calling len() on closed file" )
  */
 
-static Py_ssize_t __pyx_pf_9csamtools_9Fastafile_2__len__(PyObject *__pyx_v_self); /*proto*/
-static Py_ssize_t __pyx_pf_9csamtools_9Fastafile_2__len__(PyObject *__pyx_v_self) {
+static Py_ssize_t __pyx_pf_9csamtools_9Fastafile___len__(PyObject *__pyx_v_self); /*proto*/
+static Py_ssize_t __pyx_pf_9csamtools_9Fastafile___len__(PyObject *__pyx_v_self) {
   Py_ssize_t __pyx_r;
   int __pyx_t_1;
   PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__len__");
   __Pyx_TraceCall("__len__", __pyx_f[0], 269);
 
-  /* "csamtools.pyx":270
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":270
  * 
  *     def __len__(self):
  *         if self.fastafile == NULL:             # <<<<<<<<<<<<<<
@@ -3609,23 +3829,29 @@ static Py_ssize_t __pyx_pf_9csamtools_9Fastafile_2__len__(PyObject *__pyx_v_self
   __pyx_t_1 = (((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile == NULL);
   if (__pyx_t_1) {
 
-    /* "csamtools.pyx":271
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":271
  *     def __len__(self):
  *         if self.fastafile == NULL:
  *             raise ValueError( "calling len() on closed file" )             # <<<<<<<<<<<<<<
  * 
  *         return faidx_fetch_nseq(self.fastafile)
  */
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_Raise(__pyx_t_2, 0, 0);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_3));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
+    __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_Raise(__pyx_t_3, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":273
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":273
  *             raise ValueError( "calling len() on closed file" )
  * 
  *         return faidx_fetch_nseq(self.fastafile)             # <<<<<<<<<<<<<<
@@ -3639,6 +3865,7 @@ static Py_ssize_t __pyx_pf_9csamtools_9Fastafile_2__len__(PyObject *__pyx_v_self
   goto __pyx_L0;
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
   __Pyx_AddTraceback("csamtools.Fastafile.__len__");
   __pyx_r = -1;
   __pyx_L0:;
@@ -3647,7 +3874,7 @@ static Py_ssize_t __pyx_pf_9csamtools_9Fastafile_2__len__(PyObject *__pyx_v_self
   return __pyx_r;
 }
 
-/* "csamtools.pyx":275
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":275
  *         return faidx_fetch_nseq(self.fastafile)
  * 
  *     def _open( self,             # <<<<<<<<<<<<<<
@@ -3655,9 +3882,9 @@ static Py_ssize_t __pyx_pf_9csamtools_9Fastafile_2__len__(PyObject *__pyx_v_self
  *         '''open an indexed fasta file.
  */
 
-static PyObject *__pyx_pf_9csamtools_9Fastafile_3_open(PyObject *__pyx_v_self, PyObject *__pyx_arg_filename); /*proto*/
-static char __pyx_doc_9csamtools_9Fastafile_3_open[] = "Fastafile._open(self, char *filename)\nopen an indexed fasta file.\n\n        This method expects an indexed fasta file.\n        ";
-static PyObject *__pyx_pf_9csamtools_9Fastafile_3_open(PyObject *__pyx_v_self, PyObject *__pyx_arg_filename) {
+static PyObject *__pyx_pf_9csamtools_9Fastafile__open(PyObject *__pyx_v_self, PyObject *__pyx_arg_filename); /*proto*/
+static char __pyx_doc_9csamtools_9Fastafile__open[] = "Fastafile._open(self, char *filename)\nopen an indexed fasta file.\n\n        This method expects an indexed fasta file.\n        ";
+static PyObject *__pyx_pf_9csamtools_9Fastafile__open(PyObject *__pyx_v_self, PyObject *__pyx_arg_filename) {
   char *__pyx_v_filename;
   PyObject *__pyx_r = NULL;
   int __pyx_t_1;
@@ -3676,7 +3903,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_3_open(PyObject *__pyx_v_self, P
   return NULL;
   __pyx_L4_argument_unpacking_done:;
 
-  /* "csamtools.pyx":283
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":283
  * 
  *         # close a previously opened file
  *         if self.fastafile != NULL: self.close()             # <<<<<<<<<<<<<<
@@ -3695,7 +3922,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_3_open(PyObject *__pyx_v_self, P
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":284
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":284
  *         # close a previously opened file
  *         if self.fastafile != NULL: self.close()
  *         if self._filename != NULL: free(self._filename)             # <<<<<<<<<<<<<<
@@ -3709,7 +3936,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_3_open(PyObject *__pyx_v_self, P
   }
   __pyx_L6:;
 
-  /* "csamtools.pyx":285
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":285
  *         if self.fastafile != NULL: self.close()
  *         if self._filename != NULL: free(self._filename)
  *         self._filename = strdup(filename)             # <<<<<<<<<<<<<<
@@ -3718,7 +3945,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_3_open(PyObject *__pyx_v_self, P
  */
   ((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->_filename = strdup(__pyx_v_filename);
 
-  /* "csamtools.pyx":286
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":286
  *         if self._filename != NULL: free(self._filename)
  *         self._filename = strdup(filename)
  *         self.fastafile = fai_load( filename )             # <<<<<<<<<<<<<<
@@ -3727,7 +3954,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_3_open(PyObject *__pyx_v_self, P
  */
   ((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile = fai_load(__pyx_v_filename);
 
-  /* "csamtools.pyx":288
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":288
  *         self.fastafile = fai_load( filename )
  * 
  *         if self.fastafile == NULL:             # <<<<<<<<<<<<<<
@@ -3737,7 +3964,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_3_open(PyObject *__pyx_v_self, P
   __pyx_t_1 = (((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile == NULL);
   if (__pyx_t_1) {
 
-    /* "csamtools.pyx":289
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":289
  * 
  *         if self.fastafile == NULL:
  *             raise IOError("could not open file `%s`" % filename )             # <<<<<<<<<<<<<<
@@ -3746,17 +3973,17 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_3_open(PyObject *__pyx_v_self, P
  */
     __pyx_t_3 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_5), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_4), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_2));
     __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
     __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+    __Pyx_GOTREF(__pyx_t_3);
     PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
     __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
     __pyx_t_2 = 0;
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __Pyx_Raise(__pyx_t_2, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
@@ -3778,7 +4005,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_3_open(PyObject *__pyx_v_self, P
   return __pyx_r;
 }
 
-/* "csamtools.pyx":291
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":291
  *             raise IOError("could not open file `%s`" % filename )
  * 
  *     def close( self ):             # <<<<<<<<<<<<<<
@@ -3786,16 +4013,16 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_3_open(PyObject *__pyx_v_self, P
  *             fai_destroy( self.fastafile )
  */
 
-static PyObject *__pyx_pf_9csamtools_9Fastafile_4close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_9csamtools_9Fastafile_4close[] = "Fastafile.close(self)";
-static PyObject *__pyx_pf_9csamtools_9Fastafile_4close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+static PyObject *__pyx_pf_9csamtools_9Fastafile_close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static char __pyx_doc_9csamtools_9Fastafile_close[] = "Fastafile.close(self)";
+static PyObject *__pyx_pf_9csamtools_9Fastafile_close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
   PyObject *__pyx_r = NULL;
   int __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("close");
   __Pyx_TraceCall("close", __pyx_f[0], 291);
 
-  /* "csamtools.pyx":292
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":292
  * 
  *     def close( self ):
  *         if self.fastafile != NULL:             # <<<<<<<<<<<<<<
@@ -3805,7 +4032,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_4close(PyObject *__pyx_v_self, C
   __pyx_t_1 = (((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile != NULL);
   if (__pyx_t_1) {
 
-    /* "csamtools.pyx":293
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":293
  *     def close( self ):
  *         if self.fastafile != NULL:
  *             fai_destroy( self.fastafile )             # <<<<<<<<<<<<<<
@@ -3814,7 +4041,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_4close(PyObject *__pyx_v_self, C
  */
     fai_destroy(((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile);
 
-    /* "csamtools.pyx":294
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":294
  *         if self.fastafile != NULL:
  *             fai_destroy( self.fastafile )
  *             self.fastafile = NULL             # <<<<<<<<<<<<<<
@@ -3833,7 +4060,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_4close(PyObject *__pyx_v_self, C
   return __pyx_r;
 }
 
-/* "csamtools.pyx":296
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":296
  *             self.fastafile = NULL
  * 
  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
@@ -3841,8 +4068,8 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_4close(PyObject *__pyx_v_self, C
  *         if self._filename != NULL: free(self._filename)
  */
 
-static void __pyx_pf_9csamtools_9Fastafile_5__dealloc__(PyObject *__pyx_v_self); /*proto*/
-static void __pyx_pf_9csamtools_9Fastafile_5__dealloc__(PyObject *__pyx_v_self) {
+static void __pyx_pf_9csamtools_9Fastafile___dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_pf_9csamtools_9Fastafile___dealloc__(PyObject *__pyx_v_self) {
   PyObject *__pyx_t_1 = NULL;
   PyObject *__pyx_t_2 = NULL;
   int __pyx_t_3;
@@ -3850,7 +4077,7 @@ static void __pyx_pf_9csamtools_9Fastafile_5__dealloc__(PyObject *__pyx_v_self)
   __Pyx_RefNannySetupContext("__dealloc__");
   __Pyx_TraceCall("__dealloc__", __pyx_f[0], 296);
 
-  /* "csamtools.pyx":297
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":297
  * 
  *     def __dealloc__(self):
  *         self.close()             # <<<<<<<<<<<<<<
@@ -3864,7 +4091,7 @@ static void __pyx_pf_9csamtools_9Fastafile_5__dealloc__(PyObject *__pyx_v_self)
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-  /* "csamtools.pyx":298
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":298
  *     def __dealloc__(self):
  *         self.close()
  *         if self._filename != NULL: free(self._filename)             # <<<<<<<<<<<<<<
@@ -3888,7 +4115,7 @@ static void __pyx_pf_9csamtools_9Fastafile_5__dealloc__(PyObject *__pyx_v_self)
   __Pyx_RefNannyFinishContext();
 }
 
-/* "csamtools.pyx":302
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":302
  *     property filename:
  *         '''number of :term:`filename` associated with this object.'''
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -3907,7 +4134,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_8filename___get__(PyObject *__py
   __Pyx_RefNannySetupContext("__get__");
   __Pyx_TraceCall("__get__", __pyx_f[0], 302);
 
-  /* "csamtools.pyx":303
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":303
  *         '''number of :term:`filename` associated with this object.'''
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
@@ -3923,16 +4150,22 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_8filename___get__(PyObject *__py
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_7), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_Raise(__pyx_t_2, 0, 0);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_Raise(__pyx_t_1, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":304
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":304
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *             return self._filename             # <<<<<<<<<<<<<<
@@ -3940,10 +4173,10 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_8filename___get__(PyObject *__py
  *     def fetch( self,
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = PyBytes_FromString(((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->_filename); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-  __pyx_r = ((PyObject *)__pyx_t_2);
-  __pyx_t_2 = 0;
+  __pyx_t_1 = PyBytes_FromString(((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->_filename); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  __pyx_r = ((PyObject *)__pyx_t_1);
+  __pyx_t_1 = 0;
   goto __pyx_L0;
 
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
@@ -3960,7 +4193,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_8filename___get__(PyObject *__py
   return __pyx_r;
 }
 
-/* "csamtools.pyx":306
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":306
  *             return self._filename
  * 
  *     def fetch( self,             # <<<<<<<<<<<<<<
@@ -3968,9 +4201,9 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_8filename___get__(PyObject *__py
  *                start = None,
  */
 
-static PyObject *__pyx_pf_9csamtools_9Fastafile_6fetch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_9csamtools_9Fastafile_6fetch[] = "Fastafile.fetch(self, reference=None, start=None, end=None, region=None)\n*(reference = None, start = None, end = None, region = None)*\n               \n        fetch :meth:`AlignedRead` objects in a :term:`region` using 0-based indexing. \n        \n        The region is specified by :term:`reference`, *start* and *end*. \n        \n        fetch returns an empty string if the region is out of range or addresses an unknown *reference*.\n\n        If *reference* is given and *start* is None, the sequence from the \n        first base is returned. Similarly, if *end* is None, the sequence \n        until the last base is returned.\n        \n        Alternatively, a samtools :term:`region` string can be supplied.\n        ";
-static PyObject *__pyx_pf_9csamtools_9Fastafile_6fetch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+static PyObject *__pyx_pf_9csamtools_9Fastafile_fetch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_9csamtools_9Fastafile_fetch[] = "Fastafile.fetch(self, reference=None, start=None, end=None, region=None)\n*(reference = None, start = None, end = None, region = None)*\n               \n        fetch :meth:`AlignedRead` objects in a :term:`region` using 0-based indexing. \n        \n        The region is specified by :term:`reference`, *start* and *end*. \n        \n        fetch returns an empty string if the region is out of range or addresses an unknown *reference*.\n\n        If *reference* is given and *start* is None, the sequence from the \n        first base is returned. Similarly, if *end* is None, the sequence \n        until the last base is returned.\n        \n        Alternatively, a samtools :term:`region` string can be supplied.\n        ";
+static PyObject *__pyx_pf_9csamtools_9Fastafile_fetch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   PyObject *__pyx_v_reference = 0;
   PyObject *__pyx_v_start = 0;
   PyObject *__pyx_v_end = 0;
@@ -3992,7 +4225,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_6fetch(PyObject *__pyx_v_self, P
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[4] = {0,0,0,0};
 
-    /* "csamtools.pyx":307
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":307
  * 
  *     def fetch( self,
  *                reference = None,             # <<<<<<<<<<<<<<
@@ -4001,7 +4234,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_6fetch(PyObject *__pyx_v_self, P
  */
     values[0] = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":308
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":308
  *     def fetch( self,
  *                reference = None,
  *                start = None,             # <<<<<<<<<<<<<<
@@ -4010,7 +4243,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_6fetch(PyObject *__pyx_v_self, P
  */
     values[1] = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":309
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":309
  *                reference = None,
  *                start = None,
  *                end = None,             # <<<<<<<<<<<<<<
@@ -4019,7 +4252,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_6fetch(PyObject *__pyx_v_self, P
  */
     values[2] = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":310
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":310
  *                start = None,
  *                end = None,
  *                region = None):             # <<<<<<<<<<<<<<
@@ -4066,7 +4299,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_6fetch(PyObject *__pyx_v_self, P
     __pyx_v_region = values[3];
   } else {
 
-    /* "csamtools.pyx":307
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":307
  * 
  *     def fetch( self,
  *                reference = None,             # <<<<<<<<<<<<<<
@@ -4075,7 +4308,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_6fetch(PyObject *__pyx_v_self, P
  */
     __pyx_v_reference = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":308
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":308
  *     def fetch( self,
  *                reference = None,
  *                start = None,             # <<<<<<<<<<<<<<
@@ -4084,7 +4317,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_6fetch(PyObject *__pyx_v_self, P
  */
     __pyx_v_start = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":309
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":309
  *                reference = None,
  *                start = None,
  *                end = None,             # <<<<<<<<<<<<<<
@@ -4093,7 +4326,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_6fetch(PyObject *__pyx_v_self, P
  */
     __pyx_v_end = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":310
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":310
  *                start = None,
  *                end = None,
  *                region = None):             # <<<<<<<<<<<<<<
@@ -4123,7 +4356,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_6fetch(PyObject *__pyx_v_self, P
   __Pyx_INCREF(__pyx_v_region);
   __pyx_v_py_seq = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "csamtools.pyx":327
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":327
  *         '''
  * 
  *         if not self._isOpen():             # <<<<<<<<<<<<<<
@@ -4140,23 +4373,29 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_6fetch(PyObject *__pyx_v_self, P
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
 
-    /* "csamtools.pyx":328
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":328
  * 
  *         if not self._isOpen():
  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  * 
  *         cdef int length
  */
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_8), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_Raise(__pyx_t_2, 0, 0);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_Raise(__pyx_t_1, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   __pyx_L6:;
 
-  /* "csamtools.pyx":333
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":333
  *         cdef char * seq
  * 
  *         if not region:             # <<<<<<<<<<<<<<
@@ -4167,7 +4406,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_6fetch(PyObject *__pyx_v_self, P
   __pyx_t_3 = (!__pyx_t_4);
   if (__pyx_t_3) {
 
-    /* "csamtools.pyx":334
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":334
  * 
  *         if not region:
  *             if reference is None: raise ValueError( 'no sequence/region supplied.' )             # <<<<<<<<<<<<<<
@@ -4176,8 +4415,14 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_6fetch(PyObject *__pyx_v_self, P
  */
     __pyx_t_3 = (__pyx_v_reference == Py_None);
     if (__pyx_t_3) {
-      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_10), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
+      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_6));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
+      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
       __Pyx_Raise(__pyx_t_2, 0, 0);
       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
@@ -4185,7 +4430,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_6fetch(PyObject *__pyx_v_self, P
     }
     __pyx_L8:;
 
-    /* "csamtools.pyx":335
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":335
  *         if not region:
  *             if reference is None: raise ValueError( 'no sequence/region supplied.' )
  *             if start is None: start = 0             # <<<<<<<<<<<<<<
@@ -4201,7 +4446,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_6fetch(PyObject *__pyx_v_self, P
     }
     __pyx_L9:;
 
-    /* "csamtools.pyx":336
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":336
  *             if reference is None: raise ValueError( 'no sequence/region supplied.' )
  *             if start is None: start = 0
  *             if end is None: end = max_pos -1             # <<<<<<<<<<<<<<
@@ -4219,7 +4464,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_6fetch(PyObject *__pyx_v_self, P
     }
     __pyx_L10:;
 
-    /* "csamtools.pyx":338
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":338
  *             if end is None: end = max_pos -1
  * 
  *             if start > end: raise ValueError( 'invalid region: start (%i) > end (%i)' % (start, end) )             # <<<<<<<<<<<<<<
@@ -4232,24 +4477,24 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_6fetch(PyObject *__pyx_v_self, P
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     if (__pyx_t_3) {
       __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+      __Pyx_GOTREF(__pyx_t_2);
       __Pyx_INCREF(__pyx_v_start);
       PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_start);
       __Pyx_GIVEREF(__pyx_v_start);
       __Pyx_INCREF(__pyx_v_end);
       PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_end);
       __Pyx_GIVEREF(__pyx_v_end);
-      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_11), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_7), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
       __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+      __Pyx_GOTREF(__pyx_t_2);
       PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
       __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
       __pyx_t_1 = 0;
-      __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
       __Pyx_Raise(__pyx_t_1, 0, 0);
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
@@ -4257,7 +4502,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_6fetch(PyObject *__pyx_v_self, P
     }
     __pyx_L11:;
 
-    /* "csamtools.pyx":339
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":339
  * 
  *             if start > end: raise ValueError( 'invalid region: start (%i) > end (%i)' % (start, end) )
  *             if start == end: return ""             # <<<<<<<<<<<<<<
@@ -4270,14 +4515,14 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_6fetch(PyObject *__pyx_v_self, P
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     if (__pyx_t_3) {
       __Pyx_XDECREF(__pyx_r);
-      __Pyx_INCREF(((PyObject *)__pyx_kp_s_12));
-      __pyx_r = ((PyObject *)__pyx_kp_s_12);
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_8));
+      __pyx_r = ((PyObject *)__pyx_kp_s_8);
       goto __pyx_L0;
       goto __pyx_L12;
     }
     __pyx_L12:;
 
-    /* "csamtools.pyx":341
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":341
  *             if start == end: return ""
  *             # valid ranges are from 0 to 2^29-1
  *             if not 0 <= start < max_pos: raise ValueError( 'start out of range (%i)' % start )             # <<<<<<<<<<<<<<
@@ -4298,16 +4543,16 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_6fetch(PyObject *__pyx_v_self, P
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __pyx_t_4 = (!__pyx_t_3);
     if (__pyx_t_4) {
-      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_13), __pyx_v_start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_9), __pyx_v_start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_1));
       __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+      __Pyx_GOTREF(__pyx_t_2);
       PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
       __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
       __pyx_t_1 = 0;
-      __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
       __Pyx_Raise(__pyx_t_1, 0, 0);
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
@@ -4315,7 +4560,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_6fetch(PyObject *__pyx_v_self, P
     }
     __pyx_L13:;
 
-    /* "csamtools.pyx":342
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":342
  *             # valid ranges are from 0 to 2^29-1
  *             if not 0 <= start < max_pos: raise ValueError( 'start out of range (%i)' % start )
  *             if not 0 <= end < max_pos: raise ValueError( 'end out of range (%i)' % end )             # <<<<<<<<<<<<<<
@@ -4336,16 +4581,16 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_6fetch(PyObject *__pyx_v_self, P
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __pyx_t_3 = (!__pyx_t_4);
     if (__pyx_t_3) {
-      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_14), __pyx_v_end); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_10), __pyx_v_end); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_1));
       __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+      __Pyx_GOTREF(__pyx_t_2);
       PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
       __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
       __pyx_t_1 = 0;
-      __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
       __Pyx_Raise(__pyx_t_1, 0, 0);
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
@@ -4353,7 +4598,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_6fetch(PyObject *__pyx_v_self, P
     }
     __pyx_L14:;
 
-    /* "csamtools.pyx":351
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":351
  *             #                       end-1,
  *             #                       &length)
  *             region = "%s:%i-%i" % (reference, start+1, end)             # <<<<<<<<<<<<<<
@@ -4363,7 +4608,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_6fetch(PyObject *__pyx_v_self, P
     __pyx_t_1 = PyNumber_Add(__pyx_v_start, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+    __Pyx_GOTREF(__pyx_t_2);
     __Pyx_INCREF(__pyx_v_reference);
     PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_reference);
     __Pyx_GIVEREF(__pyx_v_reference);
@@ -4373,14 +4618,14 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_6fetch(PyObject *__pyx_v_self, P
     PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_end);
     __Pyx_GIVEREF(__pyx_v_end);
     __pyx_t_1 = 0;
-    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_15), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_11), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_DECREF(__pyx_v_region);
     __pyx_v_region = ((PyObject *)__pyx_t_1);
     __pyx_t_1 = 0;
 
-    /* "csamtools.pyx":353
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":353
  *             region = "%s:%i-%i" % (reference, start+1, end)
  *             seq = fai_fetch( self.fastafile,
  *                              region,             # <<<<<<<<<<<<<<
@@ -4389,7 +4634,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_6fetch(PyObject *__pyx_v_self, P
  */
     __pyx_t_5 = PyBytes_AsString(__pyx_v_region); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-    /* "csamtools.pyx":354
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":354
  *             seq = fai_fetch( self.fastafile,
  *                              region,
  *                              &length )             # <<<<<<<<<<<<<<
@@ -4401,7 +4646,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_6fetch(PyObject *__pyx_v_self, P
   }
   /*else*/ {
 
-    /* "csamtools.pyx":357
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":357
  *         else:
  *             # samtools adds a '\0' at the end
  *             seq = fai_fetch( self.fastafile, region, &length )             # <<<<<<<<<<<<<<
@@ -4413,7 +4658,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_6fetch(PyObject *__pyx_v_self, P
   }
   __pyx_L7:;
 
-  /* "csamtools.pyx":360
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":360
  * 
  *         # copy to python
  *         if seq == NULL:             # <<<<<<<<<<<<<<
@@ -4423,7 +4668,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_6fetch(PyObject *__pyx_v_self, P
   __pyx_t_3 = (__pyx_v_seq == NULL);
   if (__pyx_t_3) {
 
-    /* "csamtools.pyx":361
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":361
  *         # copy to python
  *         if seq == NULL:
  *             return ""             # <<<<<<<<<<<<<<
@@ -4431,14 +4676,14 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_6fetch(PyObject *__pyx_v_self, P
  *             try:
  */
     __Pyx_XDECREF(__pyx_r);
-    __Pyx_INCREF(((PyObject *)__pyx_kp_s_12));
-    __pyx_r = ((PyObject *)__pyx_kp_s_12);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_8));
+    __pyx_r = ((PyObject *)__pyx_kp_s_8);
     goto __pyx_L0;
     goto __pyx_L15;
   }
   /*else*/ {
 
-    /* "csamtools.pyx":363
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":363
  *             return ""
  *         else:
  *             try:             # <<<<<<<<<<<<<<
@@ -4447,7 +4692,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_6fetch(PyObject *__pyx_v_self, P
  */
     /*try:*/ {
 
-      /* "csamtools.pyx":364
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":364
  *         else:
  *             try:
  *                 py_seq = PyString_FromStringAndSize(seq, length)             # <<<<<<<<<<<<<<
@@ -4461,7 +4706,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_6fetch(PyObject *__pyx_v_self, P
       __pyx_t_1 = 0;
     }
 
-    /* "csamtools.pyx":366
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":366
  *                 py_seq = PyString_FromStringAndSize(seq, length)
  *             finally:
  *                 free(seq)             # <<<<<<<<<<<<<<
@@ -4498,7 +4743,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_6fetch(PyObject *__pyx_v_self, P
   }
   __pyx_L15:;
 
-  /* "csamtools.pyx":368
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":368
  *                 free(seq)
  * 
  *         return py_seq             # <<<<<<<<<<<<<<
@@ -4528,7 +4773,7 @@ static PyObject *__pyx_pf_9csamtools_9Fastafile_6fetch(PyObject *__pyx_v_self, P
   return __pyx_r;
 }
 
-/* "csamtools.pyx":370
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":370
  *         return py_seq
  * 
  *     cdef char * _fetch( self, char * reference, int start, int end, int * length ):             # <<<<<<<<<<<<<<
@@ -4542,7 +4787,7 @@ static  char *__pyx_f_9csamtools_9Fastafile__fetch(struct __pyx_obj_9csamtools_F
   __Pyx_RefNannySetupContext("_fetch");
   __Pyx_TraceCall("_fetch", __pyx_f[0], 370);
 
-  /* "csamtools.pyx":377
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":377
  *                                start,
  *                                end-1,
  *                                length )             # <<<<<<<<<<<<<<
@@ -4559,7 +4804,7 @@ static  char *__pyx_f_9csamtools_9Fastafile__fetch(struct __pyx_obj_9csamtools_F
   return __pyx_r;
 }
 
-/* "csamtools.pyx":382
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":382
  * #------------------------------------------------------------------------
  * #------------------------------------------------------------------------
  * cdef int count_callback( bam1_t *alignment, void *f):             # <<<<<<<<<<<<<<
@@ -4570,12 +4815,11 @@ static  char *__pyx_f_9csamtools_9Fastafile__fetch(struct __pyx_obj_9csamtools_F
 static  int __pyx_f_9csamtools_count_callback(bam1_t *__pyx_v_alignment, void *__pyx_v_f) {
   int *__pyx_v_counter;
   int __pyx_r;
-  long __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("count_callback");
   __Pyx_TraceCall("count_callback", __pyx_f[0], 382);
 
-  /* "csamtools.pyx":385
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":385
  *      '''callback for bam_fetch - count number of reads.
  *      '''
  *      cdef int* counter = (<int*>f)             # <<<<<<<<<<<<<<
@@ -4584,15 +4828,14 @@ static  int __pyx_f_9csamtools_count_callback(bam1_t *__pyx_v_alignment, void *_
  */
   __pyx_v_counter = ((int *)__pyx_v_f);
 
-  /* "csamtools.pyx":386
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":386
  *      '''
  *      cdef int* counter = (<int*>f)
  *      counter[0] += 1;             # <<<<<<<<<<<<<<
  * 
  * ctypedef struct MateData:
  */
-  __pyx_t_1 = 0;
-  (__pyx_v_counter[__pyx_t_1]) = ((__pyx_v_counter[__pyx_t_1]) + 1);
+  (__pyx_v_counter[0]) += 1;
 
   __pyx_r = 0;
   __Pyx_TraceReturn(Py_None);
@@ -4600,7 +4843,7 @@ static  int __pyx_f_9csamtools_count_callback(bam1_t *__pyx_v_alignment, void *_
   return __pyx_r;
 }
 
-/* "csamtools.pyx":396
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":396
  * #------------------------------------------------------------------------
  * #------------------------------------------------------------------------
  * cdef int mate_callback( bam1_t *alignment, void *f):             # <<<<<<<<<<<<<<
@@ -4618,7 +4861,7 @@ static  int __pyx_f_9csamtools_mate_callback(bam1_t *__pyx_v_alignment, void *__
   __Pyx_RefNannySetupContext("mate_callback");
   __Pyx_TraceCall("mate_callback", __pyx_f[0], 396);
 
-  /* "csamtools.pyx":399
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":399
  *      '''callback for bam_fetch = filter mate
  *      '''
  *      cdef MateData * d = (<MateData*>f)             # <<<<<<<<<<<<<<
@@ -4627,7 +4870,7 @@ static  int __pyx_f_9csamtools_mate_callback(bam1_t *__pyx_v_alignment, void *__
  */
   __pyx_v_d = ((__pyx_t_9csamtools_MateData *)__pyx_v_f);
 
-  /* "csamtools.pyx":404
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":404
  *      #        d.flag, alignment.core.flag, alignment.core.flag & d.flag)
  * 
  *      if d.mate == NULL:             # <<<<<<<<<<<<<<
@@ -4637,7 +4880,7 @@ static  int __pyx_f_9csamtools_mate_callback(bam1_t *__pyx_v_alignment, void *__
   __pyx_t_1 = (__pyx_v_d->mate == NULL);
   if (__pyx_t_1) {
 
-    /* "csamtools.pyx":410
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":410
  *          # also, make sure that we get the other read by comparing
  *          # the flags
  *          if alignment.core.flag & d.flag != 0 and \             # <<<<<<<<<<<<<<
@@ -4647,7 +4890,7 @@ static  int __pyx_f_9csamtools_mate_callback(bam1_t *__pyx_v_alignment, void *__
     __pyx_t_1 = ((__pyx_v_alignment->core.flag & __pyx_v_d->flag) != 0);
     if (__pyx_t_1) {
 
-      /* "csamtools.pyx":411
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":411
  *          # the flags
  *          if alignment.core.flag & d.flag != 0 and \
  *                  strcmp( bam1_qname( alignment ), d.name ) == 0:             # <<<<<<<<<<<<<<
@@ -4661,7 +4904,7 @@ static  int __pyx_f_9csamtools_mate_callback(bam1_t *__pyx_v_alignment, void *__
     }
     if (__pyx_t_3) {
 
-      /* "csamtools.pyx":412
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":412
  *          if alignment.core.flag & d.flag != 0 and \
  *                  strcmp( bam1_qname( alignment ), d.name ) == 0:
  *              d.mate = bam_dup1( alignment )             # <<<<<<<<<<<<<<
@@ -4682,7 +4925,7 @@ static  int __pyx_f_9csamtools_mate_callback(bam1_t *__pyx_v_alignment, void *__
   return __pyx_r;
 }
 
-/* "csamtools.pyx":458
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":455
  *     '''
  * 
  *     def __cinit__(self, *args, **kwargs ):             # <<<<<<<<<<<<<<
@@ -4700,7 +4943,7 @@ static int __pyx_pf_9csamtools_7Samfile___cinit__(PyObject *__pyx_v_self, PyObje
   PyObject *__pyx_t_3 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__cinit__");
-  __Pyx_TraceCall("__cinit__", __pyx_f[0], 458);
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 455);
   if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 1))) return -1;
   __pyx_v_kwargs = (__pyx_kwds) ? PyDict_Copy(__pyx_kwds) : PyDict_New();
   if (unlikely(!__pyx_v_kwargs)) return -1;
@@ -4708,7 +4951,7 @@ static int __pyx_pf_9csamtools_7Samfile___cinit__(PyObject *__pyx_v_self, PyObje
   __Pyx_INCREF(__pyx_args);
   __pyx_v_args = __pyx_args;
 
-  /* "csamtools.pyx":459
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":456
  * 
  *     def __cinit__(self, *args, **kwargs ):
  *         self.samfile = NULL             # <<<<<<<<<<<<<<
@@ -4717,51 +4960,42 @@ static int __pyx_pf_9csamtools_7Samfile___cinit__(PyObject *__pyx_v_self, PyObje
  */
   ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile = NULL;
 
-  /* "csamtools.pyx":460
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":457
  *     def __cinit__(self, *args, **kwargs ):
  *         self.samfile = NULL
  *         self._filename = NULL             # <<<<<<<<<<<<<<
  *         self.isbam = False
- *         self.isstream = False
+ *         self._open( *args, **kwargs )
  */
   ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->_filename = NULL;
 
-  /* "csamtools.pyx":461
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":458
  *         self.samfile = NULL
  *         self._filename = NULL
  *         self.isbam = False             # <<<<<<<<<<<<<<
- *         self.isstream = False
  *         self._open( *args, **kwargs )
+ * 
  */
   ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam = 0;
 
-  /* "csamtools.pyx":462
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":459
  *         self._filename = NULL
  *         self.isbam = False
- *         self.isstream = False             # <<<<<<<<<<<<<<
- *         self._open( *args, **kwargs )
- * 
- */
-  ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isstream = 0;
-
-  /* "csamtools.pyx":463
- *         self.isbam = False
- *         self.isstream = False
  *         self._open( *args, **kwargs )             # <<<<<<<<<<<<<<
  * 
  *         # allocate memory for iterator
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___open); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___open); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PySequence_Tuple(((PyObject *)__pyx_v_args)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PySequence_Tuple(((PyObject *)__pyx_v_args)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-  __pyx_t_3 = PyEval_CallObjectWithKeywords(__pyx_t_1, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_v_kwargs)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyEval_CallObjectWithKeywords(__pyx_t_1, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_v_kwargs)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
-  /* "csamtools.pyx":466
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":462
  * 
  *         # allocate memory for iterator
  *         self.b = <bam1_t*>calloc(1, sizeof(bam1_t))             # <<<<<<<<<<<<<<
@@ -4786,7 +5020,7 @@ static int __pyx_pf_9csamtools_7Samfile___cinit__(PyObject *__pyx_v_self, PyObje
   return __pyx_r;
 }
 
-/* "csamtools.pyx":468
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":464
  *         self.b = <bam1_t*>calloc(1, sizeof(bam1_t))
  * 
  *     def _isOpen( self ):             # <<<<<<<<<<<<<<
@@ -4794,16 +5028,16 @@ static int __pyx_pf_9csamtools_7Samfile___cinit__(PyObject *__pyx_v_self, PyObje
  *         return self.samfile != NULL
  */
 
-static PyObject *__pyx_pf_9csamtools_7Samfile_1_isOpen(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_9csamtools_7Samfile_1_isOpen[] = "Samfile._isOpen(self)\nreturn true if samfile has been opened.";
-static PyObject *__pyx_pf_9csamtools_7Samfile_1_isOpen(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+static PyObject *__pyx_pf_9csamtools_7Samfile__isOpen(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static char __pyx_doc_9csamtools_7Samfile__isOpen[] = "Samfile._isOpen(self)\nreturn true if samfile has been opened.";
+static PyObject *__pyx_pf_9csamtools_7Samfile__isOpen(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("_isOpen");
-  __Pyx_TraceCall("_isOpen", __pyx_f[0], 468);
+  __Pyx_TraceCall("_isOpen", __pyx_f[0], 464);
 
-  /* "csamtools.pyx":470
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":466
  *     def _isOpen( self ):
  *         '''return true if samfile has been opened.'''
  *         return self.samfile != NULL             # <<<<<<<<<<<<<<
@@ -4811,7 +5045,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_1_isOpen(PyObject *__pyx_v_self, C
  *     def _hasIndex( self ):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyBool_FromLong((((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile != NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyBool_FromLong((((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile != NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -4830,7 +5064,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_1_isOpen(PyObject *__pyx_v_self, C
   return __pyx_r;
 }
 
-/* "csamtools.pyx":472
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":468
  *         return self.samfile != NULL
  * 
  *     def _hasIndex( self ):             # <<<<<<<<<<<<<<
@@ -4838,16 +5072,16 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_1_isOpen(PyObject *__pyx_v_self, C
  *         return self.index != NULL
  */
 
-static PyObject *__pyx_pf_9csamtools_7Samfile_2_hasIndex(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_9csamtools_7Samfile_2_hasIndex[] = "Samfile._hasIndex(self)\nreturn true if samfile has an existing (and opened) index.";
-static PyObject *__pyx_pf_9csamtools_7Samfile_2_hasIndex(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+static PyObject *__pyx_pf_9csamtools_7Samfile__hasIndex(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static char __pyx_doc_9csamtools_7Samfile__hasIndex[] = "Samfile._hasIndex(self)\nreturn true if samfile has an existing (and opened) index.";
+static PyObject *__pyx_pf_9csamtools_7Samfile__hasIndex(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("_hasIndex");
-  __Pyx_TraceCall("_hasIndex", __pyx_f[0], 472);
+  __Pyx_TraceCall("_hasIndex", __pyx_f[0], 468);
 
-  /* "csamtools.pyx":474
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":470
  *     def _hasIndex( self ):
  *         '''return true if samfile has an existing (and opened) index.'''
  *         return self.index != NULL             # <<<<<<<<<<<<<<
@@ -4855,7 +5089,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_2_hasIndex(PyObject *__pyx_v_self,
  *     def _open( self,
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyBool_FromLong((((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index != NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyBool_FromLong((((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index != NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -4874,7 +5108,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_2_hasIndex(PyObject *__pyx_v_self,
   return __pyx_r;
 }
 
-/* "csamtools.pyx":476
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":472
  *         return self.index != NULL
  * 
  *     def _open( self,             # <<<<<<<<<<<<<<
@@ -4882,9 +5116,9 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_2_hasIndex(PyObject *__pyx_v_self,
  *                mode = None,
  */
 
-static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_9csamtools_7Samfile_3_open[] = "Samfile._open(self, char *filename, mode=None, Samfile template=None, referencenames=None, referencelengths=None, text=None, header=None, port=None, add_sq_text=True)\nopen a sam/bam file.\n\n        If _open is called on an existing bamfile, the current file will be\n        closed and a new file will be opened.\n        ";
-static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_9csamtools_7Samfile__open[] = "Samfile._open(self, char *filename, mode=None, Samfile template=None, referencenames=None, referencelengths=None, text=None, header=None, port=None)\nopen a sam/bam file.\n\n        If _open is called on an existing bamfile, the current file will be\n        closed and a new file will be opened.\n        ";
+static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   char *__pyx_v_filename;
   PyObject *__pyx_v_mode = 0;
   struct __pyx_obj_9csamtools_Samfile *__pyx_v_template = 0;
@@ -4893,7 +5127,6 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
   PyObject *__pyx_v_text = 0;
   PyObject *__pyx_v_header = 0;
   PyObject *__pyx_v_port = 0;
-  PyObject *__pyx_v_add_sq_text = 0;
   PyObject *__pyx_v_msg;
   bam_header_t *__pyx_v_header_to_write;
   char *__pyx_v_ctext;
@@ -4918,15 +5151,15 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
   uint32_t __pyx_t_14;
   char *__pyx_t_15;
   int __pyx_t_16;
-  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__filename,&__pyx_n_s__mode,&__pyx_n_s__template,&__pyx_n_s__referencenames,&__pyx_n_s__referencelengths,&__pyx_n_s__text,&__pyx_n_s__header,&__pyx_n_s__port,&__pyx_n_s__add_sq_text,0};
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__filename,&__pyx_n_s__mode,&__pyx_n_s__template,&__pyx_n_s__referencenames,&__pyx_n_s__referencelengths,&__pyx_n_s__text,&__pyx_n_s__header,&__pyx_n_s__port,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("_open");
-  __Pyx_TraceCall("_open", __pyx_f[0], 476);
+  __Pyx_TraceCall("_open", __pyx_f[0], 472);
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
-    PyObject* values[9] = {0,0,0,0,0,0,0,0,0};
+    PyObject* values[8] = {0,0,0,0,0,0,0,0};
 
-    /* "csamtools.pyx":478
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":474
  *     def _open( self,
  *                char * filename,
  *                mode = None,             # <<<<<<<<<<<<<<
@@ -4935,7 +5168,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
  */
     values[1] = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":479
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":475
  *                char * filename,
  *                mode = None,
  *                Samfile template = None,             # <<<<<<<<<<<<<<
@@ -4944,7 +5177,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
  */
     values[2] = (PyObject *)((struct __pyx_obj_9csamtools_Samfile *)Py_None);
 
-    /* "csamtools.pyx":480
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":476
  *                mode = None,
  *                Samfile template = None,
  *                referencenames = None,             # <<<<<<<<<<<<<<
@@ -4953,7 +5186,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
  */
     values[3] = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":481
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":477
  *                Samfile template = None,
  *                referencenames = None,
  *                referencelengths = None,             # <<<<<<<<<<<<<<
@@ -4962,7 +5195,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
  */
     values[4] = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":482
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":478
  *                referencenames = None,
  *                referencelengths = None,
  *                text = None,             # <<<<<<<<<<<<<<
@@ -4971,26 +5204,24 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
  */
     values[5] = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":483
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":479
  *                referencelengths = None,
  *                text = None,
  *                header = None,             # <<<<<<<<<<<<<<
  *                port = None,
- *                add_sq_text = True,
+ *               ):
  */
     values[6] = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":484
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":480
  *                text = None,
  *                header = None,
  *                port = None,             # <<<<<<<<<<<<<<
- *                add_sq_text = True,
  *               ):
+ *         '''open a sam/bam file.
  */
     values[7] = ((PyObject *)Py_None);
-    values[8] = __pyx_k_16;
     switch (PyTuple_GET_SIZE(__pyx_args)) {
-      case  9: values[8] = PyTuple_GET_ITEM(__pyx_args, 8);
       case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
       case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
       case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
@@ -5042,16 +5273,11 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__port);
         if (value) { values[7] = value; kw_args--; }
       }
-      case  8:
-      if (kw_args > 0) {
-        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__add_sq_text);
-        if (value) { values[8] = value; kw_args--; }
-      }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_open") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_open") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
-    __pyx_v_filename = PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 477; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_filename = PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     __pyx_v_mode = values[1];
     __pyx_v_template = ((struct __pyx_obj_9csamtools_Samfile *)values[2]);
     __pyx_v_referencenames = values[3];
@@ -5059,10 +5285,9 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
     __pyx_v_text = values[5];
     __pyx_v_header = values[6];
     __pyx_v_port = values[7];
-    __pyx_v_add_sq_text = values[8];
   } else {
 
-    /* "csamtools.pyx":478
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":474
  *     def _open( self,
  *                char * filename,
  *                mode = None,             # <<<<<<<<<<<<<<
@@ -5071,7 +5296,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
  */
     __pyx_v_mode = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":479
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":475
  *                char * filename,
  *                mode = None,
  *                Samfile template = None,             # <<<<<<<<<<<<<<
@@ -5080,7 +5305,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
  */
     __pyx_v_template = ((struct __pyx_obj_9csamtools_Samfile *)Py_None);
 
-    /* "csamtools.pyx":480
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":476
  *                mode = None,
  *                Samfile template = None,
  *                referencenames = None,             # <<<<<<<<<<<<<<
@@ -5089,7 +5314,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
  */
     __pyx_v_referencenames = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":481
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":477
  *                Samfile template = None,
  *                referencenames = None,
  *                referencelengths = None,             # <<<<<<<<<<<<<<
@@ -5098,7 +5323,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
  */
     __pyx_v_referencelengths = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":482
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":478
  *                referencenames = None,
  *                referencelengths = None,
  *                text = None,             # <<<<<<<<<<<<<<
@@ -5107,26 +5332,24 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
  */
     __pyx_v_text = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":483
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":479
  *                referencelengths = None,
  *                text = None,
  *                header = None,             # <<<<<<<<<<<<<<
  *                port = None,
- *                add_sq_text = True,
+ *               ):
  */
     __pyx_v_header = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":484
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":480
  *                text = None,
  *                header = None,
  *                port = None,             # <<<<<<<<<<<<<<
- *                add_sq_text = True,
  *               ):
+ *         '''open a sam/bam file.
  */
     __pyx_v_port = ((PyObject *)Py_None);
-    __pyx_v_add_sq_text = __pyx_k_16;
     switch (PyTuple_GET_SIZE(__pyx_args)) {
-      case  9: __pyx_v_add_sq_text = PyTuple_GET_ITEM(__pyx_args, 8);
       case  8: __pyx_v_port = PyTuple_GET_ITEM(__pyx_args, 7);
       case  7: __pyx_v_header = PyTuple_GET_ITEM(__pyx_args, 6);
       case  6: __pyx_v_text = PyTuple_GET_ITEM(__pyx_args, 5);
@@ -5134,42 +5357,41 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
       case  4: __pyx_v_referencenames = PyTuple_GET_ITEM(__pyx_args, 3);
       case  3: __pyx_v_template = ((struct __pyx_obj_9csamtools_Samfile *)PyTuple_GET_ITEM(__pyx_args, 2));
       case  2: __pyx_v_mode = PyTuple_GET_ITEM(__pyx_args, 1);
-      case  1: __pyx_v_filename = PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 477; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      case  1: __pyx_v_filename = PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       break;
       default: goto __pyx_L5_argtuple_error;
     }
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("_open", 0, 1, 9, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("_open", 0, 1, 8, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("csamtools.Samfile._open");
   __Pyx_RefNannyFinishContext();
   return NULL;
   __pyx_L4_argument_unpacking_done:;
-  __Pyx_INCREF(__pyx_v_text);
   __pyx_v_msg = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_n = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_x = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_name = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_store = Py_None; __Pyx_INCREF(Py_None);
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_template), __pyx_ptype_9csamtools_Samfile, 1, "template", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_template), __pyx_ptype_9csamtools_Samfile, 1, "template", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "csamtools.pyx":494
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":489
  * 
  *         # read mode autodetection
  *         if mode is None:             # <<<<<<<<<<<<<<
  *             try:
- *                 self._open(filename, 'rb', template=template,
+ *                 self._open(filename, 'r', template=template,
  */
   __pyx_t_1 = (__pyx_v_mode == Py_None);
   if (__pyx_t_1) {
 
-    /* "csamtools.pyx":495
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":490
  *         # read mode autodetection
  *         if mode is None:
  *             try:             # <<<<<<<<<<<<<<
- *                 self._open(filename, 'rb', template=template,
+ *                 self._open(filename, 'r', template=template,
  *                            referencenames=referencenames,
  */
     {
@@ -5180,65 +5402,65 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
       __Pyx_XGOTREF(__pyx_save_exc_tb);
       /*try:*/ {
 
-        /* "csamtools.pyx":496
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":491
  *         if mode is None:
  *             try:
- *                 self._open(filename, 'rb', template=template,             # <<<<<<<<<<<<<<
+ *                 self._open(filename, 'r', template=template,             # <<<<<<<<<<<<<<
  *                            referencenames=referencenames,
  *                            referencelengths=referencelengths,
  */
-        __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___open); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___open); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
         __Pyx_GOTREF(__pyx_t_2);
-        __pyx_t_3 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        __pyx_t_3 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
         __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-        __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
-        __Pyx_GOTREF(((PyObject *)__pyx_t_4));
+        __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        __Pyx_GOTREF(__pyx_t_4);
         PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3));
         __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
-        __Pyx_INCREF(((PyObject *)__pyx_n_s__rb));
-        PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_n_s__rb));
-        __Pyx_GIVEREF(((PyObject *)__pyx_n_s__rb));
+        __Pyx_INCREF(((PyObject *)__pyx_n_s__r));
+        PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_n_s__r));
+        __Pyx_GIVEREF(((PyObject *)__pyx_n_s__r));
         __pyx_t_3 = 0;
-        __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
         __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-        if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__template), ((PyObject *)__pyx_v_template)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__template), ((PyObject *)__pyx_v_template)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
 
-        /* "csamtools.pyx":497
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":492
  *             try:
- *                 self._open(filename, 'rb', template=template,
+ *                 self._open(filename, 'r', template=template,
  *                            referencenames=referencenames,             # <<<<<<<<<<<<<<
  *                            referencelengths=referencelengths,
  *                            text=text, header=header, port=port)
  */
-        if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__referencenames), __pyx_v_referencenames) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__referencenames), __pyx_v_referencenames) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
 
-        /* "csamtools.pyx":498
- *                 self._open(filename, 'rb', template=template,
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":493
+ *                 self._open(filename, 'r', template=template,
  *                            referencenames=referencenames,
  *                            referencelengths=referencelengths,             # <<<<<<<<<<<<<<
  *                            text=text, header=header, port=port)
  *                 return
  */
-        if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__referencelengths), __pyx_v_referencelengths) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__referencelengths), __pyx_v_referencelengths) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
 
-        /* "csamtools.pyx":499
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":494
  *                            referencenames=referencenames,
  *                            referencelengths=referencelengths,
  *                            text=text, header=header, port=port)             # <<<<<<<<<<<<<<
  *                 return
  *             except ValueError, msg:
  */
-        if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__text), __pyx_v_text) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
-        if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__header), __pyx_v_header) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
-        if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__port), __pyx_v_port) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
-        __pyx_t_5 = PyEval_CallObjectWithKeywords(__pyx_t_2, ((PyObject *)__pyx_t_4), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__text), __pyx_v_text) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__header), __pyx_v_header) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__port), __pyx_v_port) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        __pyx_t_5 = PyEval_CallObjectWithKeywords(__pyx_t_2, __pyx_t_4, ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
         __Pyx_GOTREF(__pyx_t_5);
         __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-        __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
         __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
-        /* "csamtools.pyx":500
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":495
  *                            referencelengths=referencelengths,
  *                            text=text, header=header, port=port)
  *                 return             # <<<<<<<<<<<<<<
@@ -5265,17 +5487,17 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
       __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
       __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
 
-      /* "csamtools.pyx":501
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":496
  *                            text=text, header=header, port=port)
  *                 return
  *             except ValueError, msg:             # <<<<<<<<<<<<<<
  *                 pass
- * 
+ *             self._open(filename, 'rb', template=template,
  */
       __pyx_t_6 = PyErr_ExceptionMatches(__pyx_builtin_ValueError);
       if (__pyx_t_6) {
         __Pyx_AddTraceback("csamtools.Samfile._open");
-        if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_3, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
+        if (__Pyx_GetException(&__pyx_t_5, &__pyx_t_3, &__pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 496; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
         __Pyx_GOTREF(__pyx_t_5);
         __Pyx_GOTREF(__pyx_t_3);
         __Pyx_GOTREF(__pyx_t_4);
@@ -5301,70 +5523,70 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
       __pyx_L14_try_end:;
     }
 
-    /* "csamtools.pyx":504
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":498
+ *             except ValueError, msg:
  *                 pass
- * 
- *             self._open(filename, 'r', template=template,             # <<<<<<<<<<<<<<
+ *             self._open(filename, 'rb', template=template,             # <<<<<<<<<<<<<<
  *                        referencenames=referencenames,
  *                        referencelengths=referencelengths,
  */
-    __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___open); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___open); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
-    __pyx_t_3 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
     PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_3));
     __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
-    __Pyx_INCREF(((PyObject *)__pyx_n_s__r));
-    PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_n_s__r));
-    __Pyx_GIVEREF(((PyObject *)__pyx_n_s__r));
+    __Pyx_INCREF(((PyObject *)__pyx_n_s__rb));
+    PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_n_s__rb));
+    __Pyx_GIVEREF(((PyObject *)__pyx_n_s__rb));
     __pyx_t_3 = 0;
-    __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__template), ((PyObject *)__pyx_v_template)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__template), ((PyObject *)__pyx_v_template)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-    /* "csamtools.pyx":505
- * 
- *             self._open(filename, 'r', template=template,
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":499
+ *                 pass
+ *             self._open(filename, 'rb', template=template,
  *                        referencenames=referencenames,             # <<<<<<<<<<<<<<
  *                        referencelengths=referencelengths,
  *                        text=text, header=header, port=port)
  */
-    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__referencenames), __pyx_v_referencenames) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__referencenames), __pyx_v_referencenames) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-    /* "csamtools.pyx":506
- *             self._open(filename, 'r', template=template,
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":500
+ *             self._open(filename, 'rb', template=template,
  *                        referencenames=referencenames,
  *                        referencelengths=referencelengths,             # <<<<<<<<<<<<<<
  *                        text=text, header=header, port=port)
  *             return
  */
-    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__referencelengths), __pyx_v_referencelengths) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__referencelengths), __pyx_v_referencelengths) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-    /* "csamtools.pyx":507
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":501
  *                        referencenames=referencenames,
  *                        referencelengths=referencelengths,
  *                        text=text, header=header, port=port)             # <<<<<<<<<<<<<<
  *             return
  * 
  */
-    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__text), __pyx_v_text) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__header), __pyx_v_header) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__port), __pyx_v_port) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_t_2 = PyEval_CallObjectWithKeywords(__pyx_t_4, ((PyObject *)__pyx_t_5), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__text), __pyx_v_text) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__header), __pyx_v_header) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__port), __pyx_v_port) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyEval_CallObjectWithKeywords(__pyx_t_4, __pyx_t_5, ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
     __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-    /* "csamtools.pyx":508
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":502
  *                        referencelengths=referencelengths,
  *                        text=text, header=header, port=port)
  *             return             # <<<<<<<<<<<<<<
  * 
- *         assert mode in ( "r","w","rb","wb", "wh", "wbu", "rU" ), "invalid file opening mode `%s`" % mode
+ *         assert mode in ( "r","w","rb","wb", "wh", "wbu" ), "invalid file opening mode `%s`" % mode
  */
     __Pyx_XDECREF(__pyx_r);
     __pyx_r = Py_None; __Pyx_INCREF(Py_None);
@@ -5373,25 +5595,25 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
   }
   __pyx_L6:;
 
-  /* "csamtools.pyx":510
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":504
  *             return
  * 
- *         assert mode in ( "r","w","rb","wb", "wh", "wbu", "rU" ), "invalid file opening mode `%s`" % mode             # <<<<<<<<<<<<<<
+ *         assert mode in ( "r","w","rb","wb", "wh", "wbu" ), "invalid file opening mode `%s`" % mode             # <<<<<<<<<<<<<<
  *         assert filename != NULL
  * 
  */
-  #ifndef CYTHON_WITHOUT_ASSERTIONS
+  #ifndef PYREX_WITHOUT_ASSERTIONS
   __Pyx_INCREF(__pyx_v_mode);
   __pyx_t_2 = __pyx_v_mode;
-  __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__r), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__r), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   __pyx_t_7 = __pyx_t_1;
   if (!__pyx_t_7) {
-    __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__w), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__w), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __pyx_t_8 = __pyx_t_1;
     __pyx_t_1 = __pyx_t_8;
@@ -5399,9 +5621,9 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
     __pyx_t_1 = __pyx_t_7;
   }
   if (!__pyx_t_1) {
-    __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__rb), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__rb), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __pyx_t_8 = __pyx_t_7;
     __pyx_t_7 = __pyx_t_8;
@@ -5409,9 +5631,9 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
     __pyx_t_7 = __pyx_t_1;
   }
   if (!__pyx_t_7) {
-    __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__wb), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__wb), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __pyx_t_8 = __pyx_t_1;
     __pyx_t_1 = __pyx_t_8;
@@ -5419,9 +5641,9 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
     __pyx_t_1 = __pyx_t_7;
   }
   if (!__pyx_t_1) {
-    __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__wh), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__wh), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __pyx_t_8 = __pyx_t_7;
     __pyx_t_7 = __pyx_t_8;
@@ -5429,61 +5651,51 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
     __pyx_t_7 = __pyx_t_1;
   }
   if (!__pyx_t_7) {
-    __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__wbu), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__wbu), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __pyx_t_8 = __pyx_t_1;
     __pyx_t_1 = __pyx_t_8;
   } else {
     __pyx_t_1 = __pyx_t_7;
   }
-  if (!__pyx_t_1) {
-    __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__rU), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __pyx_t_8 = __pyx_t_7;
-    __pyx_t_7 = __pyx_t_8;
-  } else {
-    __pyx_t_7 = __pyx_t_1;
-  }
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  if (unlikely(!__pyx_t_7)) {
-    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_17), __pyx_v_mode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__pyx_t_1)) {
+    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_12), __pyx_v_mode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_2));
     PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_t_2));
     __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 510; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   #endif
 
-  /* "csamtools.pyx":511
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":505
  * 
- *         assert mode in ( "r","w","rb","wb", "wh", "wbu", "rU" ), "invalid file opening mode `%s`" % mode
+ *         assert mode in ( "r","w","rb","wb", "wh", "wbu" ), "invalid file opening mode `%s`" % mode
  *         assert filename != NULL             # <<<<<<<<<<<<<<
  * 
  *         # close a previously opened file
  */
-  #ifndef CYTHON_WITHOUT_ASSERTIONS
+  #ifndef PYREX_WITHOUT_ASSERTIONS
   if (unlikely(!(__pyx_v_filename != NULL))) {
     PyErr_SetNone(PyExc_AssertionError);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 511; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   #endif
 
-  /* "csamtools.pyx":514
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":508
  * 
  *         # close a previously opened file
  *         if self.samfile != NULL: self.close()             # <<<<<<<<<<<<<<
  *         self.samfile = NULL
  * 
  */
-  __pyx_t_7 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile != NULL);
-  if (__pyx_t_7) {
-    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__close); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile != NULL);
+  if (__pyx_t_1) {
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__close); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
@@ -5491,7 +5703,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
   }
   __pyx_L17:;
 
-  /* "csamtools.pyx":515
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":509
  *         # close a previously opened file
  *         if self.samfile != NULL: self.close()
  *         self.samfile = NULL             # <<<<<<<<<<<<<<
@@ -5500,7 +5712,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
  */
   ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile = NULL;
 
-  /* "csamtools.pyx":518
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":512
  * 
  *         cdef bam_header_t * header_to_write
  *         header_to_write = NULL             # <<<<<<<<<<<<<<
@@ -5509,54 +5721,45 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
  */
   __pyx_v_header_to_write = NULL;
 
-  /* "csamtools.pyx":520
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":514
  *         header_to_write = NULL
  * 
  *         if self._filename != NULL: free(self._filename )             # <<<<<<<<<<<<<<
  *         self._filename = strdup( filename )
- *         self.isstream = strcmp( filename, "-" ) == 0
+ * 
  */
-  __pyx_t_7 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->_filename != NULL);
-  if (__pyx_t_7) {
+  __pyx_t_1 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->_filename != NULL);
+  if (__pyx_t_1) {
     free(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->_filename);
     goto __pyx_L18;
   }
   __pyx_L18:;
 
-  /* "csamtools.pyx":521
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":515
  * 
  *         if self._filename != NULL: free(self._filename )
  *         self._filename = strdup( filename )             # <<<<<<<<<<<<<<
- *         self.isstream = strcmp( filename, "-" ) == 0
  * 
+ *         self.isbam = len(mode) > 1 and mode[1] == 'b'
  */
   ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->_filename = strdup(__pyx_v_filename);
 
-  /* "csamtools.pyx":522
- *         if self._filename != NULL: free(self._filename )
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":517
  *         self._filename = strdup( filename )
- *         self.isstream = strcmp( filename, "-" ) == 0             # <<<<<<<<<<<<<<
- * 
- *         self.isbam = len(mode) > 1 and mode[1] == 'b'
- */
-  ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isstream = (strcmp(__pyx_v_filename, __pyx_k_18) == 0);
-
-  /* "csamtools.pyx":524
- *         self.isstream = strcmp( filename, "-" ) == 0
  * 
  *         self.isbam = len(mode) > 1 and mode[1] == 'b'             # <<<<<<<<<<<<<<
  * 
  *         self.isremote = strncmp(filename,"http:",5) == 0 or \
  */
-  __pyx_t_9 = PyObject_Length(__pyx_v_mode); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 524; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_3 = __Pyx_PyBool_FromLong((__pyx_t_9 > 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 524; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_9 = PyObject_Length(__pyx_v_mode); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyBool_FromLong((__pyx_t_9 > 1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 524; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__pyx_t_7) {
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__pyx_t_1) {
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_mode, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 524; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_mode, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_5 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__b), Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 524; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__b), Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __pyx_t_2 = __pyx_t_5;
@@ -5565,34 +5768,34 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
     __pyx_t_2 = __pyx_t_3;
     __pyx_t_3 = 0;
   }
-  __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 524; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam = __pyx_t_6;
 
-  /* "csamtools.pyx":526
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":519
  *         self.isbam = len(mode) > 1 and mode[1] == 'b'
  * 
  *         self.isremote = strncmp(filename,"http:",5) == 0 or \             # <<<<<<<<<<<<<<
  *             strncmp(filename,"ftp:",4) == 0
  * 
  */
-  __pyx_t_7 = (strncmp(__pyx_v_filename, __pyx_k_19, 5) == 0);
-  if (!__pyx_t_7) {
+  __pyx_t_1 = (strncmp(__pyx_v_filename, __pyx_k_13, 5) == 0);
+  if (!__pyx_t_1) {
 
-    /* "csamtools.pyx":527
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":520
  * 
  *         self.isremote = strncmp(filename,"http:",5) == 0 or \
  *             strncmp(filename,"ftp:",4) == 0             # <<<<<<<<<<<<<<
  * 
  *         cdef char * ctext
  */
-    __pyx_t_1 = (strncmp(__pyx_v_filename, __pyx_k_20, 4) == 0);
-    __pyx_t_8 = __pyx_t_1;
-  } else {
+    __pyx_t_7 = (strncmp(__pyx_v_filename, __pyx_k_14, 4) == 0);
     __pyx_t_8 = __pyx_t_7;
+  } else {
+    __pyx_t_8 = __pyx_t_1;
   }
 
-  /* "csamtools.pyx":526
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":519
  *         self.isbam = len(mode) > 1 and mode[1] == 'b'
  * 
  *         self.isremote = strncmp(filename,"http:",5) == 0 or \             # <<<<<<<<<<<<<<
@@ -5601,7 +5804,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
  */
   ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isremote = __pyx_t_8;
 
-  /* "csamtools.pyx":530
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":523
  * 
  *         cdef char * ctext
  *         ctext = NULL             # <<<<<<<<<<<<<<
@@ -5610,33 +5813,33 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
  */
   __pyx_v_ctext = NULL;
 
-  /* "csamtools.pyx":532
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":525
  *         ctext = NULL
  * 
  *         if mode[0] == 'w':             # <<<<<<<<<<<<<<
  *             # open file for writing
  * 
  */
-  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_mode, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_mode, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__w), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__w), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   if (__pyx_t_8) {
 
-    /* "csamtools.pyx":536
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":529
  * 
  *             # header structure (used for writing)
  *             if template:             # <<<<<<<<<<<<<<
  *                 # copy header from another file
  *                 header_to_write = template.samfile.header
  */
-    __pyx_t_8 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_template)); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 536; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_template)); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (__pyx_t_8) {
 
-      /* "csamtools.pyx":538
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":531
  *             if template:
  *                 # copy header from another file
  *                 header_to_write = template.samfile.header             # <<<<<<<<<<<<<<
@@ -5647,17 +5850,17 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
       goto __pyx_L20;
     }
 
-    /* "csamtools.pyx":540
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":533
  *                 header_to_write = template.samfile.header
  * 
  *             elif header:             # <<<<<<<<<<<<<<
  *                 header_to_write = self._buildHeader( header )
  * 
  */
-    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_header); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 540; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_header); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (__pyx_t_8) {
 
-      /* "csamtools.pyx":541
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":534
  * 
  *             elif header:
  *                 header_to_write = self._buildHeader( header )             # <<<<<<<<<<<<<<
@@ -5669,44 +5872,44 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
     }
     /*else*/ {
 
-      /* "csamtools.pyx":545
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":538
  *             else:
  *                 # build header from a target names and lengths
  *                 assert referencenames and referencelengths, "either supply options `template`, `header` or  both `referencenames` and `referencelengths` for writing"             # <<<<<<<<<<<<<<
  *                 assert len(referencenames) == len(referencelengths), "unequal names and lengths of reference sequences"
  * 
  */
-      #ifndef CYTHON_WITHOUT_ASSERTIONS
-      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_referencenames); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      #ifndef PYREX_WITHOUT_ASSERTIONS
+      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_referencenames); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       if (__pyx_t_8) {
-        __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_referencelengths); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __pyx_t_1 = __pyx_t_7;
+        __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_referencelengths); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = __pyx_t_1;
       } else {
-        __pyx_t_1 = __pyx_t_8;
+        __pyx_t_7 = __pyx_t_8;
       }
-      if (unlikely(!__pyx_t_1)) {
-        PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_21));
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      if (unlikely(!__pyx_t_7)) {
+        PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_15));
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       }
       #endif
 
-      /* "csamtools.pyx":546
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":539
  *                 # build header from a target names and lengths
  *                 assert referencenames and referencelengths, "either supply options `template`, `header` or  both `referencenames` and `referencelengths` for writing"
  *                 assert len(referencenames) == len(referencelengths), "unequal names and lengths of reference sequences"             # <<<<<<<<<<<<<<
  * 
  *                 # allocate and fill header
  */
-      #ifndef CYTHON_WITHOUT_ASSERTIONS
-      __pyx_t_9 = PyObject_Length(__pyx_v_referencenames); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __pyx_t_10 = PyObject_Length(__pyx_v_referencelengths); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      #ifndef PYREX_WITHOUT_ASSERTIONS
+      __pyx_t_9 = PyObject_Length(__pyx_v_referencenames); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_10 = PyObject_Length(__pyx_v_referencelengths); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       if (unlikely(!(__pyx_t_9 == __pyx_t_10))) {
-        PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_22));
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_16));
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       }
       #endif
 
-      /* "csamtools.pyx":549
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":542
  * 
  *                 # allocate and fill header
  *                 header_to_write = bam_header_init()             # <<<<<<<<<<<<<<
@@ -5715,17 +5918,17 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
  */
       __pyx_v_header_to_write = bam_header_init();
 
-      /* "csamtools.pyx":550
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":543
  *                 # allocate and fill header
  *                 header_to_write = bam_header_init()
  *                 header_to_write.n_targets = len(referencenames)             # <<<<<<<<<<<<<<
  *                 n = 0
  *                 for x in referencenames: n += len(x) + 1
  */
-      __pyx_t_10 = PyObject_Length(__pyx_v_referencenames); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_10 = PyObject_Length(__pyx_v_referencenames); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __pyx_v_header_to_write->n_targets = __pyx_t_10;
 
-      /* "csamtools.pyx":551
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":544
  *                 header_to_write = bam_header_init()
  *                 header_to_write.n_targets = len(referencenames)
  *                 n = 0             # <<<<<<<<<<<<<<
@@ -5736,7 +5939,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
       __Pyx_DECREF(__pyx_v_n);
       __pyx_v_n = __pyx_int_0;
 
-      /* "csamtools.pyx":552
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":545
  *                 header_to_write.n_targets = len(referencenames)
  *                 n = 0
  *                 for x in referencenames: n += len(x) + 1             # <<<<<<<<<<<<<<
@@ -5746,7 +5949,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
       if (PyList_CheckExact(__pyx_v_referencenames) || PyTuple_CheckExact(__pyx_v_referencenames)) {
         __pyx_t_10 = 0; __pyx_t_3 = __pyx_v_referencenames; __Pyx_INCREF(__pyx_t_3);
       } else {
-        __pyx_t_10 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_referencenames); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_10 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_referencenames); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_3);
       }
       for (;;) {
@@ -5759,7 +5962,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
         } else {
           __pyx_t_2 = PyIter_Next(__pyx_t_3);
           if (!__pyx_t_2) {
-            if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             break;
           }
           __Pyx_GOTREF(__pyx_t_2);
@@ -5767,10 +5970,10 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
         __Pyx_DECREF(__pyx_v_x);
         __pyx_v_x = __pyx_t_2;
         __pyx_t_2 = 0;
-        __pyx_t_9 = PyObject_Length(__pyx_v_x); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __pyx_t_2 = PyInt_FromSsize_t((__pyx_t_9 + 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_9 = PyObject_Length(__pyx_v_x); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_2 = PyInt_FromSsize_t((__pyx_t_9 + 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_2);
-        __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_v_n, __pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_v_n, __pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_5);
         __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
         __Pyx_DECREF(__pyx_v_n);
@@ -5779,27 +5982,27 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
       }
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
-      /* "csamtools.pyx":553
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":546
  *                 n = 0
  *                 for x in referencenames: n += len(x) + 1
  *                 header_to_write.target_name = <char**>calloc(n, sizeof(char*))             # <<<<<<<<<<<<<<
  *                 header_to_write.target_len = <uint32_t*>calloc(n, sizeof(uint32_t))
  *                 for x from 0 <= x < header_to_write.n_targets:
  */
-      __pyx_t_11 = __Pyx_PyInt_AsSize_t(__pyx_v_n); if (unlikely((__pyx_t_11 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_11 = __Pyx_PyInt_AsSize_t(__pyx_v_n); if (unlikely((__pyx_t_11 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __pyx_v_header_to_write->target_name = ((char **)calloc(__pyx_t_11, (sizeof(char *))));
 
-      /* "csamtools.pyx":554
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":547
  *                 for x in referencenames: n += len(x) + 1
  *                 header_to_write.target_name = <char**>calloc(n, sizeof(char*))
  *                 header_to_write.target_len = <uint32_t*>calloc(n, sizeof(uint32_t))             # <<<<<<<<<<<<<<
  *                 for x from 0 <= x < header_to_write.n_targets:
  *                     header_to_write.target_len[x] = referencelengths[x]
  */
-      __pyx_t_11 = __Pyx_PyInt_AsSize_t(__pyx_v_n); if (unlikely((__pyx_t_11 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_11 = __Pyx_PyInt_AsSize_t(__pyx_v_n); if (unlikely((__pyx_t_11 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __pyx_v_header_to_write->target_len = ((uint32_t *)calloc(__pyx_t_11, (sizeof(uint32_t))));
 
-      /* "csamtools.pyx":555
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":548
  *                 header_to_write.target_name = <char**>calloc(n, sizeof(char*))
  *                 header_to_write.target_len = <uint32_t*>calloc(n, sizeof(uint32_t))
  *                 for x from 0 <= x < header_to_write.n_targets:             # <<<<<<<<<<<<<<
@@ -5808,208 +6011,119 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
  */
       __pyx_t_12 = __pyx_v_header_to_write->n_targets;
       for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13++) {
-        __pyx_t_3 = PyInt_FromLong(__pyx_t_13); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 555; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_3 = PyInt_FromLong(__pyx_t_13); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_3);
         __Pyx_DECREF(__pyx_v_x);
         __pyx_v_x = __pyx_t_3;
         __pyx_t_3 = 0;
 
-        /* "csamtools.pyx":556
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":549
  *                 header_to_write.target_len = <uint32_t*>calloc(n, sizeof(uint32_t))
  *                 for x from 0 <= x < header_to_write.n_targets:
  *                     header_to_write.target_len[x] = referencelengths[x]             # <<<<<<<<<<<<<<
  *                     name = referencenames[x]
  *                     header_to_write.target_name[x] = <char*>calloc(len(name)+1, sizeof(char))
  */
-        __pyx_t_3 = PyObject_GetItem(__pyx_v_referencelengths, __pyx_v_x); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_3 = PyObject_GetItem(__pyx_v_referencelengths, __pyx_v_x); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_3);
-        __pyx_t_14 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_3); if (unlikely((__pyx_t_14 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_14 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_3); if (unlikely((__pyx_t_14 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-        __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_v_x); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_v_x); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         (__pyx_v_header_to_write->target_len[__pyx_t_10]) = __pyx_t_14;
 
-        /* "csamtools.pyx":557
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":550
  *                 for x from 0 <= x < header_to_write.n_targets:
  *                     header_to_write.target_len[x] = referencelengths[x]
  *                     name = referencenames[x]             # <<<<<<<<<<<<<<
  *                     header_to_write.target_name[x] = <char*>calloc(len(name)+1, sizeof(char))
  *                     strncpy( header_to_write.target_name[x], name, len(name) )
  */
-        __pyx_t_3 = PyObject_GetItem(__pyx_v_referencenames, __pyx_v_x); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_3 = PyObject_GetItem(__pyx_v_referencenames, __pyx_v_x); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_3);
         __Pyx_DECREF(__pyx_v_name);
         __pyx_v_name = __pyx_t_3;
         __pyx_t_3 = 0;
 
-        /* "csamtools.pyx":558
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":551
  *                     header_to_write.target_len[x] = referencelengths[x]
  *                     name = referencenames[x]
  *                     header_to_write.target_name[x] = <char*>calloc(len(name)+1, sizeof(char))             # <<<<<<<<<<<<<<
  *                     strncpy( header_to_write.target_name[x], name, len(name) )
  * 
  */
-        __pyx_t_10 = PyObject_Length(__pyx_v_name); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_v_x); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_10 = PyObject_Length(__pyx_v_name); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_v_x); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         (__pyx_v_header_to_write->target_name[__pyx_t_9]) = ((char *)calloc((__pyx_t_10 + 1), (sizeof(char))));
 
-        /* "csamtools.pyx":559
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":552
  *                     name = referencenames[x]
  *                     header_to_write.target_name[x] = <char*>calloc(len(name)+1, sizeof(char))
  *                     strncpy( header_to_write.target_name[x], name, len(name) )             # <<<<<<<<<<<<<<
  * 
- *                 # Optionally, if there is no text, add a SAM compatible header to output
+ *                 if text != None:
  */
-        __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_v_x); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __pyx_t_15 = PyBytes_AsString(__pyx_v_name); if (unlikely((!__pyx_t_15) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __pyx_t_9 = PyObject_Length(__pyx_v_name); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_10 = __Pyx_PyIndex_AsSsize_t(__pyx_v_x); if (unlikely((__pyx_t_10 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_15 = PyBytes_AsString(__pyx_v_name); if (unlikely((!__pyx_t_15) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_9 = PyObject_Length(__pyx_v_name); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         strncpy((__pyx_v_header_to_write->target_name[__pyx_t_10]), __pyx_t_15, __pyx_t_9);
-        __pyx_t_13 = __Pyx_PyInt_AsLong(__pyx_v_x); if (unlikely((__pyx_t_13 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 555; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_13 = __Pyx_PyInt_AsLong(__pyx_v_x); if (unlikely((__pyx_t_13 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       }
 
-      /* "csamtools.pyx":555
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":548
  *                 header_to_write.target_name = <char**>calloc(n, sizeof(char*))
  *                 header_to_write.target_len = <uint32_t*>calloc(n, sizeof(uint32_t))
  *                 for x from 0 <= x < header_to_write.n_targets:             # <<<<<<<<<<<<<<
  *                     header_to_write.target_len[x] = referencelengths[x]
  *                     name = referencenames[x]
  */
-      __pyx_t_3 = PyInt_FromLong(__pyx_t_13); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 555; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyInt_FromLong(__pyx_t_13); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
       __Pyx_DECREF(__pyx_v_x);
       __pyx_v_x = __pyx_t_3;
       __pyx_t_3 = 0;
 
-      /* "csamtools.pyx":563
- *                 # Optionally, if there is no text, add a SAM compatible header to output
- *                 # file.
- *                 if text is None and add_sq_text:             # <<<<<<<<<<<<<<
- *                     text = ''
- *                     for x from 0 <= x < header_to_write.n_targets:
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":554
+ *                     strncpy( header_to_write.target_name[x], name, len(name) )
+ * 
+ *                 if text != None:             # <<<<<<<<<<<<<<
+ *                     # copy without \0
+ *                     ctext = text
  */
-      __pyx_t_1 = (__pyx_v_text == Py_None);
-      if (__pyx_t_1) {
-        __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_v_add_sq_text); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 563; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __pyx_t_7 = __pyx_t_8;
-      } else {
-        __pyx_t_7 = __pyx_t_1;
-      }
+      __pyx_t_3 = PyObject_RichCompare(__pyx_v_text, Py_None, Py_NE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
       if (__pyx_t_7) {
 
-        /* "csamtools.pyx":564
- *                 # file.
- *                 if text is None and add_sq_text:
- *                     text = ''             # <<<<<<<<<<<<<<
- *                     for x from 0 <= x < header_to_write.n_targets:
- *                         text += "@SQ\tSN:%s\tLN:%s\n" % (referencenames[x], referencelengths[x] )
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":556
+ *                 if text != None:
+ *                     # copy without \0
+ *                     ctext = text             # <<<<<<<<<<<<<<
+ *                     header_to_write.l_text = strlen(ctext)
+ *                     header_to_write.text = <char*>calloc( strlen(ctext), sizeof(char) )
  */
-        __Pyx_INCREF(((PyObject *)__pyx_kp_s_12));
-        __Pyx_DECREF(__pyx_v_text);
-        __pyx_v_text = ((PyObject *)__pyx_kp_s_12);
+        __pyx_t_15 = PyBytes_AsString(__pyx_v_text); if (unlikely((!__pyx_t_15) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_v_ctext = __pyx_t_15;
 
-        /* "csamtools.pyx":565
- *                 if text is None and add_sq_text:
- *                     text = ''
- *                     for x from 0 <= x < header_to_write.n_targets:             # <<<<<<<<<<<<<<
- *                         text += "@SQ\tSN:%s\tLN:%s\n" % (referencenames[x], referencelengths[x] )
- * 
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":557
+ *                     # copy without \0
+ *                     ctext = text
+ *                     header_to_write.l_text = strlen(ctext)             # <<<<<<<<<<<<<<
+ *                     header_to_write.text = <char*>calloc( strlen(ctext), sizeof(char) )
+ *                     memcpy( header_to_write.text, ctext, strlen(ctext) )
  */
-        __pyx_t_12 = __pyx_v_header_to_write->n_targets;
-        for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13++) {
-          __pyx_t_3 = PyInt_FromLong(__pyx_t_13); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __Pyx_GOTREF(__pyx_t_3);
-          __Pyx_DECREF(__pyx_v_x);
-          __pyx_v_x = __pyx_t_3;
-          __pyx_t_3 = 0;
+        __pyx_v_header_to_write->l_text = strlen(__pyx_v_ctext);
 
-          /* "csamtools.pyx":566
- *                     text = ''
- *                     for x from 0 <= x < header_to_write.n_targets:
- *                         text += "@SQ\tSN:%s\tLN:%s\n" % (referencenames[x], referencelengths[x] )             # <<<<<<<<<<<<<<
- * 
- *                 if text != None:
- */
-          __pyx_t_3 = PyObject_GetItem(__pyx_v_referencenames, __pyx_v_x); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __Pyx_GOTREF(__pyx_t_3);
-          __pyx_t_5 = PyObject_GetItem(__pyx_v_referencelengths, __pyx_v_x); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __Pyx_GOTREF(__pyx_t_5);
-          __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-          PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3);
-          __Pyx_GIVEREF(__pyx_t_3);
-          PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_5);
-          __Pyx_GIVEREF(__pyx_t_5);
-          __pyx_t_3 = 0;
-          __pyx_t_5 = 0;
-          __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_23), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __Pyx_GOTREF(((PyObject *)__pyx_t_5));
-          __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
-          __pyx_t_2 = PyNumber_InPlaceAdd(__pyx_v_text, ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __Pyx_GOTREF(__pyx_t_2);
-          __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
-          __Pyx_DECREF(__pyx_v_text);
-          __pyx_v_text = __pyx_t_2;
-          __pyx_t_2 = 0;
-          __pyx_t_13 = __Pyx_PyInt_AsLong(__pyx_v_x); if (unlikely((__pyx_t_13 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        }
-
-        /* "csamtools.pyx":565
- *                 if text is None and add_sq_text:
- *                     text = ''
- *                     for x from 0 <= x < header_to_write.n_targets:             # <<<<<<<<<<<<<<
- *                         text += "@SQ\tSN:%s\tLN:%s\n" % (referencenames[x], referencelengths[x] )
- * 
- */
-        __pyx_t_2 = PyInt_FromLong(__pyx_t_13); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_2);
-        __Pyx_DECREF(__pyx_v_x);
-        __pyx_v_x = __pyx_t_2;
-        __pyx_t_2 = 0;
-        goto __pyx_L25;
-      }
-      __pyx_L25:;
-
-      /* "csamtools.pyx":568
- *                         text += "@SQ\tSN:%s\tLN:%s\n" % (referencenames[x], referencelengths[x] )
- * 
- *                 if text != None:             # <<<<<<<<<<<<<<
- *                     # copy without \0
- *                     ctext = text
- */
-      __pyx_t_2 = PyObject_RichCompare(__pyx_v_text, Py_None, Py_NE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_2);
-      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-      if (__pyx_t_7) {
-
-        /* "csamtools.pyx":570
- *                 if text != None:
- *                     # copy without \0
- *                     ctext = text             # <<<<<<<<<<<<<<
- *                     header_to_write.l_text = strlen(ctext)
- *                     header_to_write.text = <char*>calloc( strlen(ctext), sizeof(char) )
- */
-        __pyx_t_15 = PyBytes_AsString(__pyx_v_text); if (unlikely((!__pyx_t_15) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __pyx_v_ctext = __pyx_t_15;
-
-        /* "csamtools.pyx":571
- *                     # copy without \0
- *                     ctext = text
- *                     header_to_write.l_text = strlen(ctext)             # <<<<<<<<<<<<<<
- *                     header_to_write.text = <char*>calloc( strlen(ctext), sizeof(char) )
- *                     memcpy( header_to_write.text, ctext, strlen(ctext) )
- */
-        __pyx_v_header_to_write->l_text = strlen(__pyx_v_ctext);
-
-        /* "csamtools.pyx":572
- *                     ctext = text
- *                     header_to_write.l_text = strlen(ctext)
- *                     header_to_write.text = <char*>calloc( strlen(ctext), sizeof(char) )             # <<<<<<<<<<<<<<
- *                     memcpy( header_to_write.text, ctext, strlen(ctext) )
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":558
+ *                     ctext = text
+ *                     header_to_write.l_text = strlen(ctext)
+ *                     header_to_write.text = <char*>calloc( strlen(ctext), sizeof(char) )             # <<<<<<<<<<<<<<
+ *                     memcpy( header_to_write.text, ctext, strlen(ctext) )
  * 
  */
         __pyx_v_header_to_write->text = ((char *)calloc(strlen(__pyx_v_ctext), (sizeof(char))));
 
-        /* "csamtools.pyx":573
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":559
  *                     header_to_write.l_text = strlen(ctext)
  *                     header_to_write.text = <char*>calloc( strlen(ctext), sizeof(char) )
  *                     memcpy( header_to_write.text, ctext, strlen(ctext) )             # <<<<<<<<<<<<<<
@@ -6017,11 +6131,11 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
  *                 header_to_write.hash = NULL
  */
         memcpy(__pyx_v_header_to_write->text, __pyx_v_ctext, strlen(__pyx_v_ctext));
-        goto __pyx_L28;
+        goto __pyx_L25;
       }
-      __pyx_L28:;
+      __pyx_L25:;
 
-      /* "csamtools.pyx":575
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":561
  *                     memcpy( header_to_write.text, ctext, strlen(ctext) )
  * 
  *                 header_to_write.hash = NULL             # <<<<<<<<<<<<<<
@@ -6030,7 +6144,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
  */
       __pyx_v_header_to_write->hash = NULL;
 
-      /* "csamtools.pyx":576
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":562
  * 
  *                 header_to_write.hash = NULL
  *                 header_to_write.rg2lib = NULL             # <<<<<<<<<<<<<<
@@ -6041,64 +6155,64 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
     }
     __pyx_L20:;
 
-    /* "csamtools.pyx":580
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":566
  *             # open file. Header gets written to file at the same time for bam files
  *             # and sam files (in the latter case, the mode needs to be wh)
  *             store = StderrStore()             # <<<<<<<<<<<<<<
  *             self.samfile = samopen( filename, mode, header_to_write )
  *             store.release()
  */
-    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__StderrStore); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_5 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__StderrStore); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
-    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __Pyx_DECREF(__pyx_v_store);
     __pyx_v_store = __pyx_t_5;
     __pyx_t_5 = 0;
 
-    /* "csamtools.pyx":581
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":567
  *             # and sam files (in the latter case, the mode needs to be wh)
  *             store = StderrStore()
  *             self.samfile = samopen( filename, mode, header_to_write )             # <<<<<<<<<<<<<<
  *             store.release()
  * 
  */
-    __pyx_t_15 = PyBytes_AsString(__pyx_v_mode); if (unlikely((!__pyx_t_15) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 581; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_15 = PyBytes_AsString(__pyx_v_mode); if (unlikely((!__pyx_t_15) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile = samopen(__pyx_v_filename, __pyx_t_15, __pyx_v_header_to_write);
 
-    /* "csamtools.pyx":582
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":568
  *             store = StderrStore()
  *             self.samfile = samopen( filename, mode, header_to_write )
  *             store.release()             # <<<<<<<<<<<<<<
  * 
  *             # bam_header_destroy takes care of cleaning up of all the members
  */
-    __pyx_t_5 = PyObject_GetAttr(__pyx_v_store, __pyx_n_s__release); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyObject_GetAttr(__pyx_v_store, __pyx_n_s__release); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
-    __pyx_t_2 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_3 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
-    /* "csamtools.pyx":585
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":571
  * 
  *             # bam_header_destroy takes care of cleaning up of all the members
  *             if not template and header_to_write != NULL:             # <<<<<<<<<<<<<<
  *                 bam_header_destroy( header_to_write )
  * 
  */
-    __pyx_t_7 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_template)); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_t_1 = (!__pyx_t_7);
-    if (__pyx_t_1) {
+    __pyx_t_7 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_template)); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 571; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = (!__pyx_t_7);
+    if (__pyx_t_8) {
       __pyx_t_7 = (__pyx_v_header_to_write != NULL);
-      __pyx_t_8 = __pyx_t_7;
+      __pyx_t_1 = __pyx_t_7;
     } else {
-      __pyx_t_8 = __pyx_t_1;
+      __pyx_t_1 = __pyx_t_8;
     }
-    if (__pyx_t_8) {
+    if (__pyx_t_1) {
 
-      /* "csamtools.pyx":586
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":572
  *             # bam_header_destroy takes care of cleaning up of all the members
  *             if not template and header_to_write != NULL:
  *                 bam_header_destroy( header_to_write )             # <<<<<<<<<<<<<<
@@ -6106,298 +6220,332 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
  *         elif mode[0] == "r":
  */
       bam_header_destroy(__pyx_v_header_to_write);
-      goto __pyx_L29;
+      goto __pyx_L26;
     }
-    __pyx_L29:;
+    __pyx_L26:;
     goto __pyx_L19;
   }
 
-  /* "csamtools.pyx":588
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":574
  *                 bam_header_destroy( header_to_write )
  * 
  *         elif mode[0] == "r":             # <<<<<<<<<<<<<<
  *             # open file for reading
  *             if strncmp( filename, "-", 1) != 0 and \
  */
-  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_mode, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_5 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__r), Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_mode, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_5 = PyObject_RichCompare(__pyx_t_3, ((PyObject *)__pyx_n_s__r), Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 574; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-  if (__pyx_t_8) {
+  if (__pyx_t_1) {
 
-    /* "csamtools.pyx":590
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":576
  *         elif mode[0] == "r":
  *             # open file for reading
  *             if strncmp( filename, "-", 1) != 0 and \             # <<<<<<<<<<<<<<
  *                     not self.isremote and \
  *                     not os.path.exists( filename ):
  */
-    __pyx_t_8 = (strncmp(__pyx_v_filename, __pyx_k_18, 1) != 0);
-    if (__pyx_t_8) {
+    __pyx_t_1 = (strncmp(__pyx_v_filename, __pyx_k_17, 1) != 0);
+    if (__pyx_t_1) {
 
-      /* "csamtools.pyx":591
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":577
  *             # open file for reading
  *             if strncmp( filename, "-", 1) != 0 and \
  *                     not self.isremote and \             # <<<<<<<<<<<<<<
  *                     not os.path.exists( filename ):
  *                 raise IOError( "file `%s` not found" % filename)
  */
-      __pyx_t_1 = (!((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isremote);
-      if (__pyx_t_1) {
+      __pyx_t_8 = (!((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isremote);
+      if (__pyx_t_8) {
 
-        /* "csamtools.pyx":592
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":578
  *             if strncmp( filename, "-", 1) != 0 and \
  *                     not self.isremote and \
  *                     not os.path.exists( filename ):             # <<<<<<<<<<<<<<
  *                 raise IOError( "file `%s` not found" % filename)
  * 
  */
-        __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_5);
-        __pyx_t_2 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__path); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_2);
+        __pyx_t_3 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__path); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_3);
         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-        __pyx_t_5 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__exists); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_5 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__exists); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_5);
-        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-        __pyx_t_2 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-        __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+        __pyx_t_3 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-        PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
-        __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
-        __pyx_t_2 = 0;
-        __pyx_t_2 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_2);
+        PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_3));
+        __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
+        __pyx_t_3 = 0;
+        __pyx_t_3 = PyObject_Call(__pyx_t_5, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_3);
         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-        __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
-        __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
         __pyx_t_16 = (!__pyx_t_7);
         __pyx_t_7 = __pyx_t_16;
       } else {
-        __pyx_t_7 = __pyx_t_1;
+        __pyx_t_7 = __pyx_t_8;
       }
-      __pyx_t_1 = __pyx_t_7;
+      __pyx_t_8 = __pyx_t_7;
     } else {
-      __pyx_t_1 = __pyx_t_8;
+      __pyx_t_8 = __pyx_t_1;
     }
-    if (__pyx_t_1) {
+    if (__pyx_t_8) {
 
-      /* "csamtools.pyx":593
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":579
  *                     not self.isremote and \
  *                     not os.path.exists( filename ):
  *                 raise IOError( "file `%s` not found" % filename)             # <<<<<<<<<<<<<<
  * 
  *             # try to detect errors
  */
-      __pyx_t_2 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-      __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_24), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
-      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_18), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_3));
-      __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
-      __pyx_t_3 = 0;
-      __pyx_t_3 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
-      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
-      __Pyx_Raise(__pyx_t_3, 0, 0);
+      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
+      __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
+      __pyx_t_2 = 0;
+      __pyx_t_2 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      goto __pyx_L30;
+      __Pyx_Raise(__pyx_t_2, 0, 0);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      goto __pyx_L27;
     }
-    __pyx_L30:;
+    __pyx_L27:;
 
-    /* "csamtools.pyx":596
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":582
  * 
  *             # try to detect errors
  *             self.samfile = samopen( filename, mode, NULL )             # <<<<<<<<<<<<<<
  *             if self.samfile == NULL:
  *                 raise ValueError( "could not open file (mode='%s') - is it SAM/BAM format?" % mode)
  */
-    __pyx_t_15 = PyBytes_AsString(__pyx_v_mode); if (unlikely((!__pyx_t_15) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_15 = PyBytes_AsString(__pyx_v_mode); if (unlikely((!__pyx_t_15) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile = samopen(__pyx_v_filename, __pyx_t_15, NULL);
 
-    /* "csamtools.pyx":597
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":583
  *             # try to detect errors
  *             self.samfile = samopen( filename, mode, NULL )
  *             if self.samfile == NULL:             # <<<<<<<<<<<<<<
  *                 raise ValueError( "could not open file (mode='%s') - is it SAM/BAM format?" % mode)
  * 
  */
-    __pyx_t_1 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile == NULL);
-    if (__pyx_t_1) {
+    __pyx_t_8 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile == NULL);
+    if (__pyx_t_8) {
 
-      /* "csamtools.pyx":598
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":584
  *             self.samfile = samopen( filename, mode, NULL )
  *             if self.samfile == NULL:
  *                 raise ValueError( "could not open file (mode='%s') - is it SAM/BAM format?" % mode)             # <<<<<<<<<<<<<<
  * 
  *             if self.samfile.header == NULL:
  */
-      __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_25), __pyx_v_mode); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_19), __pyx_v_mode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_3));
-      __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
-      __pyx_t_3 = 0;
-      __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
-      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
-      __Pyx_Raise(__pyx_t_3, 0, 0);
+      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
+      __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
+      __pyx_t_2 = 0;
+      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      goto __pyx_L31;
+      __Pyx_Raise(__pyx_t_2, 0, 0);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      goto __pyx_L28;
     }
-    __pyx_L31:;
+    __pyx_L28:;
 
-    /* "csamtools.pyx":600
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":586
  *                 raise ValueError( "could not open file (mode='%s') - is it SAM/BAM format?" % mode)
  * 
  *             if self.samfile.header == NULL:             # <<<<<<<<<<<<<<
  *                 raise ValueError( "file does not have valid header (mode='%s') - is it SAM/BAM format?" % mode )
  * 
  */
-    __pyx_t_1 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header == NULL);
-    if (__pyx_t_1) {
+    __pyx_t_8 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header == NULL);
+    if (__pyx_t_8) {
 
-      /* "csamtools.pyx":601
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":587
  * 
  *             if self.samfile.header == NULL:
  *                 raise ValueError( "file does not have valid header (mode='%s') - is it SAM/BAM format?" % mode )             # <<<<<<<<<<<<<<
  * 
  *             #disabled for autodetection to work
  */
-      __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_26), __pyx_v_mode); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_20), __pyx_v_mode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_3));
-      __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
-      __pyx_t_3 = 0;
-      __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
-      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
-      __Pyx_Raise(__pyx_t_3, 0, 0);
+      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
+      __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
+      __pyx_t_2 = 0;
+      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_Raise(__pyx_t_2, 0, 0);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      goto __pyx_L29;
+    }
+    __pyx_L29:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":590
+ * 
+ *             #disabled for autodetection to work
+ *             if self.samfile.header.n_targets == 0:             # <<<<<<<<<<<<<<
+ *                 raise ValueError( "file header is empty (mode='%s') - is it SAM/BAM format?" % mode)
+ * 
+ */
+    __pyx_t_8 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->n_targets == 0);
+    if (__pyx_t_8) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":591
+ *             #disabled for autodetection to work
+ *             if self.samfile.header.n_targets == 0:
+ *                 raise ValueError( "file header is empty (mode='%s') - is it SAM/BAM format?" % mode)             # <<<<<<<<<<<<<<
+ * 
+ *         if self.samfile == NULL:
+ */
+      __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_21), __pyx_v_mode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
+      __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
+      __pyx_t_2 = 0;
+      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      goto __pyx_L32;
+      __Pyx_Raise(__pyx_t_2, 0, 0);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      goto __pyx_L30;
     }
-    __pyx_L32:;
+    __pyx_L30:;
     goto __pyx_L19;
   }
   __pyx_L19:;
 
-  /* "csamtools.pyx":608
- *             #    raise ValueError( "file header is empty (mode='%s') - is it SAM/BAM format?" % mode)
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":593
+ *                 raise ValueError( "file header is empty (mode='%s') - is it SAM/BAM format?" % mode)
  * 
  *         if self.samfile == NULL:             # <<<<<<<<<<<<<<
  *             raise IOError("could not open file `%s`" % filename )
  * 
  */
-  __pyx_t_1 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile == NULL);
-  if (__pyx_t_1) {
+  __pyx_t_8 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile == NULL);
+  if (__pyx_t_8) {
 
-    /* "csamtools.pyx":609
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":594
  * 
  *         if self.samfile == NULL:
  *             raise IOError("could not open file `%s`" % filename )             # <<<<<<<<<<<<<<
  * 
  *         # check for index and open if present
  */
-    __pyx_t_3 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_5), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
-    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_4), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
-    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
-    __pyx_t_2 = 0;
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
-    __Pyx_Raise(__pyx_t_2, 0, 0);
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_3));
+    __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
+    __pyx_t_3 = 0;
+    __pyx_t_3 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    goto __pyx_L33;
+    __Pyx_Raise(__pyx_t_3, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L31;
   }
-  __pyx_L33:;
+  __pyx_L31:;
 
-  /* "csamtools.pyx":612
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":597
  * 
  *         # check for index and open if present
  *         if mode[0] == "r" and self.isbam:             # <<<<<<<<<<<<<<
  * 
  *             if not self.isremote:
  */
-  __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_mode, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__r), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_mode, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 612; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, ((PyObject *)__pyx_n_s__r), Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  if (__pyx_t_1) {
-    __pyx_t_8 = ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam;
+  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (__pyx_t_8) {
+    __pyx_t_1 = ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam;
   } else {
-    __pyx_t_8 = __pyx_t_1;
+    __pyx_t_1 = __pyx_t_8;
   }
-  if (__pyx_t_8) {
+  if (__pyx_t_1) {
 
-    /* "csamtools.pyx":614
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":599
  *         if mode[0] == "r" and self.isbam:
  * 
  *             if not self.isremote:             # <<<<<<<<<<<<<<
  *                 if not os.path.exists(filename +".bai"):
  *                     self.index = NULL
  */
-    __pyx_t_8 = (!((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isremote);
-    if (__pyx_t_8) {
+    __pyx_t_1 = (!((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isremote);
+    if (__pyx_t_1) {
 
-      /* "csamtools.pyx":615
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":600
  * 
  *             if not self.isremote:
  *                 if not os.path.exists(filename +".bai"):             # <<<<<<<<<<<<<<
  *                     self.index = NULL
  *                 else:
  */
-      __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_3);
-      __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__path); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
-      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-      __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__exists); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__path); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-      __pyx_t_2 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-      __pyx_t_5 = PyNumber_Add(((PyObject *)__pyx_t_2), ((PyObject *)__pyx_kp_s_27)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__exists); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __pyx_t_3 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+      __pyx_t_5 = PyNumber_Add(((PyObject *)__pyx_t_3), ((PyObject *)__pyx_kp_s_22)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
-      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
-      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-      PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5);
+      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5);
       __Pyx_GIVEREF(__pyx_t_5);
       __pyx_t_5 = 0;
-      __pyx_t_5 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
-      __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      __pyx_t_1 = (!__pyx_t_8);
-      if (__pyx_t_1) {
+      __pyx_t_8 = (!__pyx_t_1);
+      if (__pyx_t_8) {
 
-        /* "csamtools.pyx":616
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":601
  *             if not self.isremote:
  *                 if not os.path.exists(filename +".bai"):
  *                     self.index = NULL             # <<<<<<<<<<<<<<
@@ -6405,11 +6553,11 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
  *                     # returns NULL if there is no index or index could not be opened
  */
         ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index = NULL;
-        goto __pyx_L36;
+        goto __pyx_L34;
       }
       /*else*/ {
 
-        /* "csamtools.pyx":619
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":604
  *                 else:
  *                     # returns NULL if there is no index or index could not be opened
  *                     self.index = bam_index_load(filename)             # <<<<<<<<<<<<<<
@@ -6418,49 +6566,49 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
  */
         ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index = bam_index_load(__pyx_v_filename);
 
-        /* "csamtools.pyx":620
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":605
  *                     # returns NULL if there is no index or index could not be opened
  *                     self.index = bam_index_load(filename)
  *                     if self.index == NULL:             # <<<<<<<<<<<<<<
  *                         raise IOError("error while opening index `%s` " % filename )
  *             else:
  */
-        __pyx_t_1 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index == NULL);
-        if (__pyx_t_1) {
+        __pyx_t_8 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index == NULL);
+        if (__pyx_t_8) {
 
-          /* "csamtools.pyx":621
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":606
  *                     self.index = bam_index_load(filename)
  *                     if self.index == NULL:
  *                         raise IOError("error while opening index `%s` " % filename )             # <<<<<<<<<<<<<<
  *             else:
  *                 self.index = bam_index_load(filename)
  */
-          __pyx_t_5 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __Pyx_GOTREF(((PyObject *)__pyx_t_5));
-          __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_28), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-          __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
-          __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_5 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(((PyObject *)__pyx_t_5));
-          PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_2));
-          __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
-          __pyx_t_2 = 0;
-          __pyx_t_2 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __Pyx_GOTREF(__pyx_t_2);
+          __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_23), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(((PyObject *)__pyx_t_3));
           __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
-          __Pyx_Raise(__pyx_t_2, 0, 0);
-          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          goto __pyx_L37;
+          __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_5);
+          PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_3));
+          __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
+          __pyx_t_3 = 0;
+          __pyx_t_3 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_3);
+          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+          __Pyx_Raise(__pyx_t_3, 0, 0);
+          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          goto __pyx_L35;
         }
-        __pyx_L37:;
+        __pyx_L35:;
       }
-      __pyx_L36:;
-      goto __pyx_L35;
+      __pyx_L34:;
+      goto __pyx_L33;
     }
     /*else*/ {
 
-      /* "csamtools.pyx":623
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":608
  *                         raise IOError("error while opening index `%s` " % filename )
  *             else:
  *                 self.index = bam_index_load(filename)             # <<<<<<<<<<<<<<
@@ -6469,69 +6617,47 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
  */
       ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index = bam_index_load(__pyx_v_filename);
 
-      /* "csamtools.pyx":624
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":609
  *             else:
  *                 self.index = bam_index_load(filename)
  *                 if self.index == NULL:             # <<<<<<<<<<<<<<
  *                     raise IOError("error while opening index `%s` " % filename )
  * 
  */
-      __pyx_t_1 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index == NULL);
-      if (__pyx_t_1) {
+      __pyx_t_8 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index == NULL);
+      if (__pyx_t_8) {
 
-        /* "csamtools.pyx":625
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":610
  *                 self.index = bam_index_load(filename)
  *                 if self.index == NULL:
  *                     raise IOError("error while opening index `%s` " % filename )             # <<<<<<<<<<<<<<
  * 
- *             if not self.isstream:
+ *     def gettid( self, reference ):
  */
-        __pyx_t_2 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-        __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_28), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_3 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+        __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_23), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(((PyObject *)__pyx_t_5));
-        __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
-        __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-        PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_5));
+        __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+        __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_3);
+        PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_5));
         __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
         __pyx_t_5 = 0;
-        __pyx_t_5 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_5 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_5);
-        __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
         __Pyx_Raise(__pyx_t_5, 0, 0);
         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        goto __pyx_L38;
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        goto __pyx_L36;
       }
-      __pyx_L38:;
-    }
-    __pyx_L35:;
-
-    /* "csamtools.pyx":627
- *                     raise IOError("error while opening index `%s` " % filename )
- * 
- *             if not self.isstream:             # <<<<<<<<<<<<<<
- *                 self.start_offset = bam_tell( self.samfile.x.bam )
- * 
- */
-    __pyx_t_1 = (!((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isstream);
-    if (__pyx_t_1) {
-
-      /* "csamtools.pyx":628
- * 
- *             if not self.isstream:
- *                 self.start_offset = bam_tell( self.samfile.x.bam )             # <<<<<<<<<<<<<<
- * 
- *     def gettid( self, reference ):
- */
-      ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->start_offset = bam_tell(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->x.bam);
-      goto __pyx_L39;
+      __pyx_L36:;
     }
-    __pyx_L39:;
-    goto __pyx_L34;
+    __pyx_L33:;
+    goto __pyx_L32;
   }
-  __pyx_L34:;
+  __pyx_L32:;
 
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   goto __pyx_L0;
@@ -6548,24 +6674,23 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_3_open(PyObject *__pyx_v_self, PyO
   __Pyx_DECREF(__pyx_v_x);
   __Pyx_DECREF(__pyx_v_name);
   __Pyx_DECREF(__pyx_v_store);
-  __Pyx_DECREF(__pyx_v_text);
   __Pyx_XGIVEREF(__pyx_r);
   __Pyx_TraceReturn(__pyx_r);
   __Pyx_RefNannyFinishContext();
   return __pyx_r;
 }
 
-/* "csamtools.pyx":630
- *                 self.start_offset = bam_tell( self.samfile.x.bam )
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":612
+ *                     raise IOError("error while opening index `%s` " % filename )
  * 
  *     def gettid( self, reference ):             # <<<<<<<<<<<<<<
  *         '''
  *         convert :term:`reference` name into numerical :term:`tid`
  */
 
-static PyObject *__pyx_pf_9csamtools_7Samfile_4gettid(PyObject *__pyx_v_self, PyObject *__pyx_v_reference); /*proto*/
-static char __pyx_doc_9csamtools_7Samfile_4gettid[] = "Samfile.gettid(self, reference)\n\n        convert :term:`reference` name into numerical :term:`tid`\n\n        returns -1 if reference is not known.\n        ";
-static PyObject *__pyx_pf_9csamtools_7Samfile_4gettid(PyObject *__pyx_v_self, PyObject *__pyx_v_reference) {
+static PyObject *__pyx_pf_9csamtools_7Samfile_gettid(PyObject *__pyx_v_self, PyObject *__pyx_v_reference); /*proto*/
+static char __pyx_doc_9csamtools_7Samfile_gettid[] = "Samfile.gettid(self, reference)\n\n        convert :term:`reference` name into numerical :term:`tid`\n\n        returns -1 if reference is not known.\n        ";
+static PyObject *__pyx_pf_9csamtools_7Samfile_gettid(PyObject *__pyx_v_self, PyObject *__pyx_v_reference) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   PyObject *__pyx_t_2 = NULL;
@@ -6574,34 +6699,40 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_4gettid(PyObject *__pyx_v_self, Py
   char *__pyx_t_5;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("gettid");
-  __Pyx_TraceCall("gettid", __pyx_f[0], 630);
+  __Pyx_TraceCall("gettid", __pyx_f[0], 612);
 
-  /* "csamtools.pyx":636
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":618
  *         returns -1 if reference is not known.
  *         '''
  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *         return pysam_reference2tid( self.samfile.header, reference )
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_29), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_Raise(__pyx_t_2, 0, 0);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_Raise(__pyx_t_1, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":637
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":619
  *         '''
  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *         return pysam_reference2tid( self.samfile.header, reference )             # <<<<<<<<<<<<<<
@@ -6609,11 +6740,11 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_4gettid(PyObject *__pyx_v_self, Py
  *     def getrname( self, tid ):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_5 = PyBytes_AsString(__pyx_v_reference); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_2 = PyInt_FromLong(pysam_reference2tid(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header, __pyx_t_5)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __pyx_r = __pyx_t_2;
-  __pyx_t_2 = 0;
+  __pyx_t_5 = PyBytes_AsString(__pyx_v_reference); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(pysam_reference2tid(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header, __pyx_t_5)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
   goto __pyx_L0;
 
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
@@ -6630,7 +6761,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_4gettid(PyObject *__pyx_v_self, Py
   return __pyx_r;
 }
 
-/* "csamtools.pyx":639
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":621
  *         return pysam_reference2tid( self.samfile.header, reference )
  * 
  *     def getrname( self, tid ):             # <<<<<<<<<<<<<<
@@ -6638,9 +6769,9 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_4gettid(PyObject *__pyx_v_self, Py
  *         convert numerical :term:`tid` into :term:`reference` name.'''
  */
 
-static PyObject *__pyx_pf_9csamtools_7Samfile_5getrname(PyObject *__pyx_v_self, PyObject *__pyx_v_tid); /*proto*/
-static char __pyx_doc_9csamtools_7Samfile_5getrname[] = "Samfile.getrname(self, tid)\n\n        convert numerical :term:`tid` into :term:`reference` name.";
-static PyObject *__pyx_pf_9csamtools_7Samfile_5getrname(PyObject *__pyx_v_self, PyObject *__pyx_v_tid) {
+static PyObject *__pyx_pf_9csamtools_7Samfile_getrname(PyObject *__pyx_v_self, PyObject *__pyx_v_tid); /*proto*/
+static char __pyx_doc_9csamtools_7Samfile_getrname[] = "Samfile.getrname(self, tid)\n\n        convert numerical :term:`tid` into :term:`reference` name.";
+static PyObject *__pyx_pf_9csamtools_7Samfile_getrname(PyObject *__pyx_v_self, PyObject *__pyx_v_tid) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   PyObject *__pyx_t_2 = NULL;
@@ -6649,91 +6780,97 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_5getrname(PyObject *__pyx_v_self,
   Py_ssize_t __pyx_t_5;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("getrname");
-  __Pyx_TraceCall("getrname", __pyx_f[0], 639);
+  __Pyx_TraceCall("getrname", __pyx_f[0], 621);
 
-  /* "csamtools.pyx":642
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":624
  *         '''
  *         convert numerical :term:`tid` into :term:`reference` name.'''
  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *         if not 0 <= tid < self.samfile.header.n_targets:
  *             raise ValueError( "tid %i out of range 0<=tid<%i" % (tid, self.samfile.header.n_targets ) )
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_30), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_Raise(__pyx_t_2, 0, 0);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_Raise(__pyx_t_1, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":643
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":625
  *         convert numerical :term:`tid` into :term:`reference` name.'''
  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *         if not 0 <= tid < self.samfile.header.n_targets:             # <<<<<<<<<<<<<<
  *             raise ValueError( "tid %i out of range 0<=tid<%i" % (tid, self.samfile.header.n_targets ) )
  *         return self.samfile.header.target_name[tid]
  */
-  __pyx_t_2 = PyObject_RichCompare(__pyx_int_0, __pyx_v_tid, Py_LE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  if (__Pyx_PyObject_IsTrue(__pyx_t_2)) {
-    __Pyx_DECREF(__pyx_t_2);
-    __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->n_targets); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_2 = PyObject_RichCompare(__pyx_v_tid, __pyx_t_1, Py_LT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_int_0, __pyx_v_tid, Py_LE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  if (__Pyx_PyObject_IsTrue(__pyx_t_1)) {
+    __Pyx_DECREF(__pyx_t_1);
+    __pyx_t_2 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->n_targets); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_t_1 = PyObject_RichCompare(__pyx_v_tid, __pyx_t_2, Py_LT); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   }
-  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __pyx_t_3 = (!__pyx_t_4);
   if (__pyx_t_3) {
 
-    /* "csamtools.pyx":644
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":626
  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *         if not 0 <= tid < self.samfile.header.n_targets:
  *             raise ValueError( "tid %i out of range 0<=tid<%i" % (tid, self.samfile.header.n_targets ) )             # <<<<<<<<<<<<<<
  *         return self.samfile.header.target_name[tid]
  * 
  */
-    __pyx_t_2 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->n_targets); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->n_targets); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
     __Pyx_INCREF(__pyx_v_tid);
-    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_tid);
+    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_tid);
     __Pyx_GIVEREF(__pyx_v_tid);
-    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
-    __Pyx_GIVEREF(__pyx_t_2);
-    __pyx_t_2 = 0;
-    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_31), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
-    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
+    __Pyx_GIVEREF(__pyx_t_1);
+    __pyx_t_1 = 0;
+    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_24), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_2));
-    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
-    __pyx_t_2 = 0;
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
-    __Pyx_Raise(__pyx_t_2, 0, 0);
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
+    __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
+    __pyx_t_1 = 0;
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_Raise(__pyx_t_1, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   __pyx_L6:;
 
-  /* "csamtools.pyx":645
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":627
  *         if not 0 <= tid < self.samfile.header.n_targets:
  *             raise ValueError( "tid %i out of range 0<=tid<%i" % (tid, self.samfile.header.n_targets ) )
  *         return self.samfile.header.target_name[tid]             # <<<<<<<<<<<<<<
@@ -6741,11 +6878,11 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_5getrname(PyObject *__pyx_v_self,
  *     cdef char * _getrname( self, int tid ):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_v_tid); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_2 = PyBytes_FromString((((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->target_name[__pyx_t_5])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-  __pyx_r = ((PyObject *)__pyx_t_2);
-  __pyx_t_2 = 0;
+  __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_v_tid); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyBytes_FromString((((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->target_name[__pyx_t_5])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  __pyx_r = ((PyObject *)__pyx_t_1);
+  __pyx_t_1 = 0;
   goto __pyx_L0;
 
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
@@ -6762,7 +6899,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_5getrname(PyObject *__pyx_v_self,
   return __pyx_r;
 }
 
-/* "csamtools.pyx":647
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":629
  *         return self.samfile.header.target_name[tid]
  * 
  *     cdef char * _getrname( self, int tid ):             # <<<<<<<<<<<<<<
@@ -6779,34 +6916,40 @@ static  char *__pyx_f_9csamtools_7Samfile__getrname(struct __pyx_obj_9csamtools_
   PyObject *__pyx_t_5 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("_getrname");
-  __Pyx_TraceCall("_getrname", __pyx_f[0], 647);
+  __Pyx_TraceCall("_getrname", __pyx_f[0], 629);
 
-  /* "csamtools.pyx":650
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":632
  *         '''
  *         convert numerical :term:`tid` into :term:`reference` name.'''
  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *         if not 0 <= tid < self.samfile.header.n_targets:
  *             raise ValueError( "tid %i out of range 0<=tid<%i" % (tid, self.samfile.header.n_targets ) )
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_32), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_Raise(__pyx_t_2, 0, 0);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_Raise(__pyx_t_1, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "csamtools.pyx":651
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":633
  *         convert numerical :term:`tid` into :term:`reference` name.'''
  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *         if not 0 <= tid < self.samfile.header.n_targets:             # <<<<<<<<<<<<<<
@@ -6820,44 +6963,44 @@ static  char *__pyx_f_9csamtools_7Samfile__getrname(struct __pyx_obj_9csamtools_
   __pyx_t_3 = (!__pyx_t_4);
   if (__pyx_t_3) {
 
-    /* "csamtools.pyx":652
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":634
  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *         if not 0 <= tid < self.samfile.header.n_targets:
  *             raise ValueError( "tid %i out of range 0<=tid<%i" % (tid, self.samfile.header.n_targets ) )             # <<<<<<<<<<<<<<
  *         return self.samfile.header.target_name[tid]
  * 
  */
-    __pyx_t_2 = PyInt_FromLong(__pyx_v_tid); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->samfile->header->n_targets); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyInt_FromLong(__pyx_v_tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
-    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
-    __Pyx_GIVEREF(__pyx_t_2);
-    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
+    __pyx_t_2 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->samfile->header->n_targets); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
     __Pyx_GIVEREF(__pyx_t_1);
-    __pyx_t_2 = 0;
-    __pyx_t_1 = 0;
-    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_31), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
-    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
-    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_1));
-    __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
+    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
+    __Pyx_GIVEREF(__pyx_t_2);
     __pyx_t_1 = 0;
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_1);
-    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
-    __Pyx_Raise(__pyx_t_1, 0, 0);
-    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = 0;
+    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_24), __pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_2));
+    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
+    __pyx_t_2 = 0;
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __Pyx_Raise(__pyx_t_2, 0, 0);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L4;
   }
   __pyx_L4:;
 
-  /* "csamtools.pyx":653
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":635
  *         if not 0 <= tid < self.samfile.header.n_targets:
  *             raise ValueError( "tid %i out of range 0<=tid<%i" % (tid, self.samfile.header.n_targets ) )
  *         return self.samfile.header.target_name[tid]             # <<<<<<<<<<<<<<
@@ -6881,7 +7024,7 @@ static  char *__pyx_f_9csamtools_7Samfile__getrname(struct __pyx_obj_9csamtools_
   return __pyx_r;
 }
 
-/* "csamtools.pyx":655
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":637
  *         return self.samfile.header.target_name[tid]
  * 
  *     def _parseRegion( self,             # <<<<<<<<<<<<<<
@@ -6889,9 +7032,9 @@ static  char *__pyx_f_9csamtools_7Samfile__getrname(struct __pyx_obj_9csamtools_
  *                       start = None,
  */
 
-static PyObject *__pyx_pf_9csamtools_7Samfile_6_parseRegion(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_9csamtools_7Samfile_6_parseRegion[] = "Samfile._parseRegion(self, reference=None, start=None, end=None, region=None)\n\n        parse region information.\n\n        raise ValueError for for invalid regions.\n\n        returns a tuple of flag, tid, start and end. Flag indicates\n        whether some coordinates were supplied.\n\n        Note that regions are 1-based, while start,end are python coordinates.\n        ";
-static PyObject *__pyx_pf_9csamtools_7Samfile_6_parseRegion(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+static PyObject *__pyx_pf_9csamtools_7Samfile__parseRegion(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_9csamtools_7Samfile__parseRegion[] = "Samfile._parseRegion(self, reference=None, start=None, end=None, region=None)\n\n        parse region information.\n\n        raise ValueError for for invalid regions.\n\n        returns a tuple of flag, tid, start and end. Flag indicates\n        whether some coordinates were supplied.\n\n        Note that regions are 1-based, while start,end are python coordinates.\n        ";
+static PyObject *__pyx_pf_9csamtools_7Samfile__parseRegion(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   PyObject *__pyx_v_reference = 0;
   PyObject *__pyx_v_start = 0;
   PyObject *__pyx_v_end = 0;
@@ -6914,12 +7057,12 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6_parseRegion(PyObject *__pyx_v_se
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__reference,&__pyx_n_s__start,&__pyx_n_s__end,&__pyx_n_s__region,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("_parseRegion");
-  __Pyx_TraceCall("_parseRegion", __pyx_f[0], 655);
+  __Pyx_TraceCall("_parseRegion", __pyx_f[0], 637);
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[4] = {0,0,0,0};
 
-    /* "csamtools.pyx":656
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":638
  * 
  *     def _parseRegion( self,
  *                       reference = None,             # <<<<<<<<<<<<<<
@@ -6928,7 +7071,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6_parseRegion(PyObject *__pyx_v_se
  */
     values[0] = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":657
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":639
  *     def _parseRegion( self,
  *                       reference = None,
  *                       start = None,             # <<<<<<<<<<<<<<
@@ -6937,7 +7080,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6_parseRegion(PyObject *__pyx_v_se
  */
     values[1] = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":658
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":640
  *                       reference = None,
  *                       start = None,
  *                       end = None,             # <<<<<<<<<<<<<<
@@ -6946,7 +7089,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6_parseRegion(PyObject *__pyx_v_se
  */
     values[2] = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":659
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":641
  *                       start = None,
  *                       end = None,
  *                       region = None ):             # <<<<<<<<<<<<<<
@@ -6985,7 +7128,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6_parseRegion(PyObject *__pyx_v_se
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_parseRegion") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_parseRegion") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_reference = values[0];
     __pyx_v_start = values[1];
@@ -6993,7 +7136,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6_parseRegion(PyObject *__pyx_v_se
     __pyx_v_region = values[3];
   } else {
 
-    /* "csamtools.pyx":656
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":638
  * 
  *     def _parseRegion( self,
  *                       reference = None,             # <<<<<<<<<<<<<<
@@ -7002,7 +7145,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6_parseRegion(PyObject *__pyx_v_se
  */
     __pyx_v_reference = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":657
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":639
  *     def _parseRegion( self,
  *                       reference = None,
  *                       start = None,             # <<<<<<<<<<<<<<
@@ -7011,7 +7154,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6_parseRegion(PyObject *__pyx_v_se
  */
     __pyx_v_start = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":658
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":640
  *                       reference = None,
  *                       start = None,
  *                       end = None,             # <<<<<<<<<<<<<<
@@ -7020,7 +7163,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6_parseRegion(PyObject *__pyx_v_se
  */
     __pyx_v_end = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":659
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":641
  *                       start = None,
  *                       end = None,
  *                       region = None ):             # <<<<<<<<<<<<<<
@@ -7039,7 +7182,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6_parseRegion(PyObject *__pyx_v_se
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("_parseRegion", 0, 0, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("_parseRegion", 0, 0, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 637; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("csamtools.Samfile._parseRegion");
   __Pyx_RefNannyFinishContext();
@@ -7048,7 +7191,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6_parseRegion(PyObject *__pyx_v_se
   __Pyx_INCREF(__pyx_v_reference);
   __pyx_v_parts = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "csamtools.pyx":678
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":660
  *         cdef long long rend
  * 
  *         rtid = -1             # <<<<<<<<<<<<<<
@@ -7057,7 +7200,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6_parseRegion(PyObject *__pyx_v_se
  */
   __pyx_v_rtid = -1;
 
-  /* "csamtools.pyx":679
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":661
  * 
  *         rtid = -1
  *         rstart = 0             # <<<<<<<<<<<<<<
@@ -7066,7 +7209,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6_parseRegion(PyObject *__pyx_v_se
  */
   __pyx_v_rstart = 0;
 
-  /* "csamtools.pyx":680
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":662
  *         rtid = -1
  *         rstart = 0
  *         rend = max_pos             # <<<<<<<<<<<<<<
@@ -7075,20 +7218,20 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6_parseRegion(PyObject *__pyx_v_se
  */
   __pyx_v_rend = __pyx_v_9csamtools_max_pos;
 
-  /* "csamtools.pyx":681
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":663
  *         rstart = 0
  *         rend = max_pos
  *         if start != None:             # <<<<<<<<<<<<<<
  *             try:
  *                 rstart = start
  */
-  __pyx_t_1 = PyObject_RichCompare(__pyx_v_start, Py_None, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_start, Py_None, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   if (__pyx_t_2) {
 
-    /* "csamtools.pyx":682
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":664
  *         rend = max_pos
  *         if start != None:
  *             try:             # <<<<<<<<<<<<<<
@@ -7103,14 +7246,14 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6_parseRegion(PyObject *__pyx_v_se
       __Pyx_XGOTREF(__pyx_save_exc_tb);
       /*try:*/ {
 
-        /* "csamtools.pyx":683
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":665
  *         if start != None:
  *             try:
  *                 rstart = start             # <<<<<<<<<<<<<<
  *             except OverflowError:
  *                 raise ValueError( 'start out of range (%i)' % start )
  */
-        __pyx_t_3 = __Pyx_PyInt_AsLongLong(__pyx_v_start); if (unlikely((__pyx_t_3 == (PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
+        __pyx_t_3 = __Pyx_PyInt_AsLongLong(__pyx_v_start); if (unlikely((__pyx_t_3 == (PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 665; __pyx_clineno = __LINE__; goto __pyx_L7_error;}
         __pyx_v_rstart = __pyx_t_3;
       }
       __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
@@ -7120,7 +7263,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6_parseRegion(PyObject *__pyx_v_se
       __pyx_L7_error:;
       __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-      /* "csamtools.pyx":684
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":666
  *             try:
  *                 rstart = start
  *             except OverflowError:             # <<<<<<<<<<<<<<
@@ -7130,31 +7273,31 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6_parseRegion(PyObject *__pyx_v_se
       __pyx_t_4 = PyErr_ExceptionMatches(__pyx_builtin_OverflowError);
       if (__pyx_t_4) {
         __Pyx_AddTraceback("csamtools.Samfile._parseRegion");
-        if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_5, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
+        if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_5, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 666; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
         __Pyx_GOTREF(__pyx_t_1);
         __Pyx_GOTREF(__pyx_t_5);
         __Pyx_GOTREF(__pyx_t_6);
 
-        /* "csamtools.pyx":685
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":667
  *                 rstart = start
  *             except OverflowError:
  *                 raise ValueError( 'start out of range (%i)' % start )             # <<<<<<<<<<<<<<
  * 
  *         if end != None:
  */
-        __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_13), __pyx_v_start); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
+        __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_9), __pyx_v_start); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
         __Pyx_GOTREF(((PyObject *)__pyx_t_7));
-        __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
-        __Pyx_GOTREF(((PyObject *)__pyx_t_8));
+        __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
+        __Pyx_GOTREF(__pyx_t_8);
         PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_t_7));
         __Pyx_GIVEREF(((PyObject *)__pyx_t_7));
         __pyx_t_7 = 0;
-        __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
+        __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
         __Pyx_GOTREF(__pyx_t_7);
-        __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
         __Pyx_Raise(__pyx_t_7, 0, 0);
         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
@@ -7177,20 +7320,20 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6_parseRegion(PyObject *__pyx_v_se
   }
   __pyx_L6:;
 
-  /* "csamtools.pyx":687
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":669
  *                 raise ValueError( 'start out of range (%i)' % start )
  * 
  *         if end != None:             # <<<<<<<<<<<<<<
  *             try:
  *                 rend = end
  */
-  __pyx_t_6 = PyObject_RichCompare(__pyx_v_end, Py_None, Py_NE); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = PyObject_RichCompare(__pyx_v_end, Py_None, Py_NE); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_6);
-  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
   if (__pyx_t_2) {
 
-    /* "csamtools.pyx":688
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":670
  * 
  *         if end != None:
  *             try:             # <<<<<<<<<<<<<<
@@ -7205,14 +7348,14 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6_parseRegion(PyObject *__pyx_v_se
       __Pyx_XGOTREF(__pyx_save_exc_tb);
       /*try:*/ {
 
-        /* "csamtools.pyx":689
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":671
  *         if end != None:
  *             try:
  *                 rend = end             # <<<<<<<<<<<<<<
  *             except OverflowError:
  *                 raise ValueError( 'end out of range (%i)' % end )
  */
-        __pyx_t_3 = __Pyx_PyInt_AsLongLong(__pyx_v_end); if (unlikely((__pyx_t_3 == (PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
+        __pyx_t_3 = __Pyx_PyInt_AsLongLong(__pyx_v_end); if (unlikely((__pyx_t_3 == (PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __pyx_L18_error;}
         __pyx_v_rend = __pyx_t_3;
       }
       __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
@@ -7226,7 +7369,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6_parseRegion(PyObject *__pyx_v_se
       __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
       __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
 
-      /* "csamtools.pyx":690
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":672
  *             try:
  *                 rend = end
  *             except OverflowError:             # <<<<<<<<<<<<<<
@@ -7236,31 +7379,31 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6_parseRegion(PyObject *__pyx_v_se
       __pyx_t_4 = PyErr_ExceptionMatches(__pyx_builtin_OverflowError);
       if (__pyx_t_4) {
         __Pyx_AddTraceback("csamtools.Samfile._parseRegion");
-        if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_5, &__pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
+        if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_5, &__pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
         __Pyx_GOTREF(__pyx_t_6);
         __Pyx_GOTREF(__pyx_t_5);
         __Pyx_GOTREF(__pyx_t_1);
 
-        /* "csamtools.pyx":691
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":673
  *                 rend = end
  *             except OverflowError:
  *                 raise ValueError( 'end out of range (%i)' % end )             # <<<<<<<<<<<<<<
  * 
  *         if region:
  */
-        __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_14), __pyx_v_end); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
+        __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_10), __pyx_v_end); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
         __Pyx_GOTREF(((PyObject *)__pyx_t_7));
-        __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
-        __Pyx_GOTREF(((PyObject *)__pyx_t_8));
+        __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
+        __Pyx_GOTREF(__pyx_t_8);
         PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_t_7));
         __Pyx_GIVEREF(((PyObject *)__pyx_t_7));
         __pyx_t_7 = 0;
-        __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
+        __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
         __Pyx_GOTREF(__pyx_t_7);
-        __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
         __Pyx_Raise(__pyx_t_7, 0, 0);
         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
@@ -7283,108 +7426,108 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6_parseRegion(PyObject *__pyx_v_se
   }
   __pyx_L17:;
 
-  /* "csamtools.pyx":693
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":675
  *                 raise ValueError( 'end out of range (%i)' % end )
  * 
  *         if region:             # <<<<<<<<<<<<<<
  *             parts = re.split( "[:-]", region )
  *             reference = parts[0]
  */
-  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_region); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 693; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_region); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_2) {
 
-    /* "csamtools.pyx":694
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":676
  * 
  *         if region:
  *             parts = re.split( "[:-]", region )             # <<<<<<<<<<<<<<
  *             reference = parts[0]
  *             if len(parts) >= 2: rstart = int(parts[1]) - 1
  */
-    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__re); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__re); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_5 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__split); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__split); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-    __Pyx_INCREF(((PyObject *)__pyx_kp_s_33));
-    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_33));
-    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_33));
+    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_25));
+    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_25));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_25));
     __Pyx_INCREF(__pyx_v_region);
     PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_region);
     __Pyx_GIVEREF(__pyx_v_region);
-    __pyx_t_6 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyObject_Call(__pyx_t_5, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __Pyx_DECREF(__pyx_v_parts);
     __pyx_v_parts = __pyx_t_6;
     __pyx_t_6 = 0;
 
-    /* "csamtools.pyx":695
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":677
  *         if region:
  *             parts = re.split( "[:-]", region )
  *             reference = parts[0]             # <<<<<<<<<<<<<<
  *             if len(parts) >= 2: rstart = int(parts[1]) - 1
  *             if len(parts) >= 3: rend = int(parts[2])
  */
-    __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_parts, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 695; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_parts, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
     __Pyx_DECREF(__pyx_v_reference);
     __pyx_v_reference = __pyx_t_6;
     __pyx_t_6 = 0;
 
-    /* "csamtools.pyx":696
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":678
  *             parts = re.split( "[:-]", region )
  *             reference = parts[0]
  *             if len(parts) >= 2: rstart = int(parts[1]) - 1             # <<<<<<<<<<<<<<
  *             if len(parts) >= 3: rend = int(parts[2])
  * 
  */
-    __pyx_t_9 = PyObject_Length(__pyx_v_parts); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = PyObject_Length(__pyx_v_parts); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_t_2 = (__pyx_t_9 >= 2);
     if (__pyx_t_2) {
-      __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_parts, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_parts, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
-      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
       PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
       __Pyx_GIVEREF(__pyx_t_6);
       __pyx_t_6 = 0;
-      __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)&PyInt_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
-      __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
-      __pyx_t_1 = PyNumber_Subtract(__pyx_t_6, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __pyx_t_1 = PyNumber_Subtract(__pyx_t_6, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-      __pyx_t_3 = __Pyx_PyInt_AsLongLong(__pyx_t_1); if (unlikely((__pyx_t_3 == (PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = __Pyx_PyInt_AsLongLong(__pyx_t_1); if (unlikely((__pyx_t_3 == (PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
       __pyx_v_rstart = __pyx_t_3;
       goto __pyx_L29;
     }
     __pyx_L29:;
 
-    /* "csamtools.pyx":697
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":679
  *             reference = parts[0]
  *             if len(parts) >= 2: rstart = int(parts[1]) - 1
  *             if len(parts) >= 3: rend = int(parts[2])             # <<<<<<<<<<<<<<
  * 
  *         if not reference: return 0, 0, 0, 0
  */
-    __pyx_t_9 = PyObject_Length(__pyx_v_parts); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = PyObject_Length(__pyx_v_parts); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_t_2 = (__pyx_t_9 >= 3);
     if (__pyx_t_2) {
-      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_parts, 2, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_parts, 2, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(((PyObject *)__pyx_t_6));
+      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
       PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
       __Pyx_GIVEREF(__pyx_t_1);
       __pyx_t_1 = 0;
-      __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)&PyInt_Type)), __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
-      __pyx_t_3 = __Pyx_PyInt_AsLongLong(__pyx_t_1); if (unlikely((__pyx_t_3 == (PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __pyx_t_3 = __Pyx_PyInt_AsLongLong(__pyx_t_1); if (unlikely((__pyx_t_3 == (PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
       __pyx_v_rend = __pyx_t_3;
       goto __pyx_L30;
@@ -7394,47 +7537,61 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6_parseRegion(PyObject *__pyx_v_se
   }
   __pyx_L28:;
 
-  /* "csamtools.pyx":699
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":681
  *             if len(parts) >= 3: rend = int(parts[2])
  * 
  *         if not reference: return 0, 0, 0, 0             # <<<<<<<<<<<<<<
  * 
  *         rtid = self.gettid( reference )
  */
-  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_reference); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_reference); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_t_10 = (!__pyx_t_2);
   if (__pyx_t_10) {
     __Pyx_XDECREF(__pyx_r);
-    __Pyx_INCREF(((PyObject *)__pyx_k_tuple_34));
-    __pyx_r = ((PyObject *)__pyx_k_tuple_34);
+    __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_INCREF(__pyx_int_0);
+    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_int_0);
+    __Pyx_GIVEREF(__pyx_int_0);
+    __Pyx_INCREF(__pyx_int_0);
+    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_0);
+    __Pyx_GIVEREF(__pyx_int_0);
+    __Pyx_INCREF(__pyx_int_0);
+    PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_int_0);
+    __Pyx_GIVEREF(__pyx_int_0);
+    __Pyx_INCREF(__pyx_int_0);
+    PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_int_0);
+    __Pyx_GIVEREF(__pyx_int_0);
+    __pyx_r = __pyx_t_1;
+    __pyx_t_1 = 0;
     goto __pyx_L0;
     goto __pyx_L31;
   }
   __pyx_L31:;
 
-  /* "csamtools.pyx":701
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":683
  *         if not reference: return 0, 0, 0, 0
  * 
  *         rtid = self.gettid( reference )             # <<<<<<<<<<<<<<
  *         if rtid < 0: raise ValueError( "invalid reference `%s`" % reference )
  *         if rstart > rend: raise ValueError( 'invalid coordinates: start (%i) > end (%i)' % (rstart, rend) )
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__gettid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__gettid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_6));
+  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_6);
   __Pyx_INCREF(__pyx_v_reference);
   PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_reference);
   __Pyx_GIVEREF(__pyx_v_reference);
-  __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
-  __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_5); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+  __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_5); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
   __pyx_v_rtid = __pyx_t_4;
 
-  /* "csamtools.pyx":702
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":684
  * 
  *         rtid = self.gettid( reference )
  *         if rtid < 0: raise ValueError( "invalid reference `%s`" % reference )             # <<<<<<<<<<<<<<
@@ -7443,24 +7600,24 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6_parseRegion(PyObject *__pyx_v_se
  */
   __pyx_t_10 = (__pyx_v_rtid < 0);
   if (__pyx_t_10) {
-    __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_35), __pyx_v_reference); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_26), __pyx_v_reference); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_5));
-    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_6));
+    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
     PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_5));
     __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
     __pyx_t_5 = 0;
-    __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
-    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
     __Pyx_Raise(__pyx_t_5, 0, 0);
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L32;
   }
   __pyx_L32:;
 
-  /* "csamtools.pyx":703
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":685
  *         rtid = self.gettid( reference )
  *         if rtid < 0: raise ValueError( "invalid reference `%s`" % reference )
  *         if rstart > rend: raise ValueError( 'invalid coordinates: start (%i) > end (%i)' % (rstart, rend) )             # <<<<<<<<<<<<<<
@@ -7469,37 +7626,37 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6_parseRegion(PyObject *__pyx_v_se
  */
   __pyx_t_10 = (__pyx_v_rstart > __pyx_v_rend);
   if (__pyx_t_10) {
-    __pyx_t_5 = PyLong_FromLongLong(__pyx_v_rstart); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyLong_FromLongLong(__pyx_v_rstart); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
-    __pyx_t_6 = PyLong_FromLongLong(__pyx_v_rend); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyLong_FromLongLong(__pyx_v_rend); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
-    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
     __Pyx_GIVEREF(__pyx_t_5);
     PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_6);
     __Pyx_GIVEREF(__pyx_t_6);
     __pyx_t_5 = 0;
     __pyx_t_6 = 0;
-    __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_36), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_27), __pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_6));
-    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
-    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
     PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_6));
     __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
     __pyx_t_6 = 0;
-    __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
-    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __Pyx_Raise(__pyx_t_6, 0, 0);
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L33;
   }
   __pyx_L33:;
 
-  /* "csamtools.pyx":704
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":686
  *         if rtid < 0: raise ValueError( "invalid reference `%s`" % reference )
  *         if rstart > rend: raise ValueError( 'invalid coordinates: start (%i) > end (%i)' % (rstart, rend) )
  *         if not 0 <= rstart < max_pos: raise ValueError( 'start out of range (%i)' % rstart )             # <<<<<<<<<<<<<<
@@ -7512,27 +7669,27 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6_parseRegion(PyObject *__pyx_v_se
   }
   __pyx_t_2 = (!__pyx_t_10);
   if (__pyx_t_2) {
-    __pyx_t_6 = PyLong_FromLongLong(__pyx_v_rstart); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyLong_FromLongLong(__pyx_v_rstart); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
-    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_13), __pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_9), __pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_1));
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_6));
+    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
     PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_1));
     __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
     __pyx_t_1 = 0;
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
     __Pyx_Raise(__pyx_t_1, 0, 0);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L34;
   }
   __pyx_L34:;
 
-  /* "csamtools.pyx":705
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":687
  *         if rstart > rend: raise ValueError( 'invalid coordinates: start (%i) > end (%i)' % (rstart, rend) )
  *         if not 0 <= rstart < max_pos: raise ValueError( 'start out of range (%i)' % rstart )
  *         if not 0 <= rend <= max_pos: raise ValueError( 'end out of range (%i)' % rend )             # <<<<<<<<<<<<<<
@@ -7545,42 +7702,42 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6_parseRegion(PyObject *__pyx_v_se
   }
   __pyx_t_10 = (!__pyx_t_2);
   if (__pyx_t_10) {
-    __pyx_t_1 = PyLong_FromLongLong(__pyx_v_rend); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyLong_FromLongLong(__pyx_v_rend); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_14), __pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_10), __pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_6));
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
     PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_6));
     __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
     __pyx_t_6 = 0;
-    __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
-    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __Pyx_Raise(__pyx_t_6, 0, 0);
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L35;
   }
   __pyx_L35:;
 
-  /* "csamtools.pyx":707
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":689
  *         if not 0 <= rend <= max_pos: raise ValueError( 'end out of range (%i)' % rend )
  * 
  *         return 1, rtid, rstart, rend             # <<<<<<<<<<<<<<
  * 
- *     def reset( self ):
+ *     def seek( self, uint64_t offset, int where = 0):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_6 = PyInt_FromLong(__pyx_v_rtid); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = PyInt_FromLong(__pyx_v_rtid); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_6);
-  __pyx_t_1 = PyLong_FromLongLong(__pyx_v_rstart); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyLong_FromLongLong(__pyx_v_rstart); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_5 = PyLong_FromLongLong(__pyx_v_rend); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyLong_FromLongLong(__pyx_v_rend); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
-  __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_7));
+  __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 689; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_7);
   __Pyx_INCREF(__pyx_int_1);
   PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_int_1);
   __Pyx_GIVEREF(__pyx_int_1);
@@ -7593,7 +7750,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6_parseRegion(PyObject *__pyx_v_se
   __pyx_t_6 = 0;
   __pyx_t_1 = 0;
   __pyx_t_5 = 0;
-  __pyx_r = ((PyObject *)__pyx_t_7);
+  __pyx_r = __pyx_t_7;
   __pyx_t_7 = 0;
   goto __pyx_L0;
 
@@ -7616,79 +7773,17 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6_parseRegion(PyObject *__pyx_v_se
   return __pyx_r;
 }
 
-/* "csamtools.pyx":709
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":691
  *         return 1, rtid, rstart, rend
  * 
- *     def reset( self ):             # <<<<<<<<<<<<<<
- *         '''reset file position to beginning of read section.'''
- *         return self.seek( self.start_offset, 0 )
- */
-
-static PyObject *__pyx_pf_9csamtools_7Samfile_7reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_9csamtools_7Samfile_7reset[] = "Samfile.reset(self)\nreset file position to beginning of read section.";
-static PyObject *__pyx_pf_9csamtools_7Samfile_7reset(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
-  PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
-  PyObject *__pyx_t_2 = NULL;
-  PyObject *__pyx_t_3 = NULL;
-  __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("reset");
-  __Pyx_TraceCall("reset", __pyx_f[0], 709);
-
-  /* "csamtools.pyx":711
- *     def reset( self ):
- *         '''reset file position to beginning of read section.'''
- *         return self.seek( self.start_offset, 0 )             # <<<<<<<<<<<<<<
- * 
- *     def seek( self, uint64_t offset, int where = 0):
- */
-  __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__seek); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 711; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = __Pyx_PyInt_to_py_int64_t(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->start_offset); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 711; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 711; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
-  __Pyx_GIVEREF(__pyx_t_2);
-  __Pyx_INCREF(__pyx_int_0);
-  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_0);
-  __Pyx_GIVEREF(__pyx_int_0);
-  __pyx_t_2 = 0;
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 711; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
-  __pyx_r = __pyx_t_2;
-  __pyx_t_2 = 0;
-  goto __pyx_L0;
-
-  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_XDECREF(__pyx_t_1);
-  __Pyx_XDECREF(__pyx_t_2);
-  __Pyx_XDECREF(__pyx_t_3);
-  __Pyx_AddTraceback("csamtools.Samfile.reset");
-  __pyx_r = NULL;
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_TraceReturn(__pyx_r);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "csamtools.pyx":713
- *         return self.seek( self.start_offset, 0 )
- * 
  *     def seek( self, uint64_t offset, int where = 0):             # <<<<<<<<<<<<<<
  *         '''
  *         move file pointer to position *offset*, see :meth:`pysam.Samfile.tell`.
  */
 
-static PyObject *__pyx_pf_9csamtools_7Samfile_8seek(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_9csamtools_7Samfile_8seek[] = "Samfile.seek(self, uint64_t offset, int where=0)\n\n        move file pointer to position *offset*, see :meth:`pysam.Samfile.tell`.\n        ";
-static PyObject *__pyx_pf_9csamtools_7Samfile_8seek(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+static PyObject *__pyx_pf_9csamtools_7Samfile_seek(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_9csamtools_7Samfile_seek[] = "Samfile.seek(self, uint64_t offset, int where=0)\n\n        move file pointer to position *offset*, see :meth:`pysam.Samfile.tell`.\n        ";
+static PyObject *__pyx_pf_9csamtools_7Samfile_seek(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   uint64_t __pyx_v_offset;
   int __pyx_v_where;
   PyObject *__pyx_r = NULL;
@@ -7699,7 +7794,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_8seek(PyObject *__pyx_v_self, PyOb
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__offset,&__pyx_n_s__where,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("seek");
-  __Pyx_TraceCall("seek", __pyx_f[0], 713);
+  __Pyx_TraceCall("seek", __pyx_f[0], 691);
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[2] = {0,0};
@@ -7721,125 +7816,112 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_8seek(PyObject *__pyx_v_self, PyOb
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "seek") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "seek") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
-    __pyx_v_offset = __Pyx_PyInt_from_py_uint64_t(values[0]); if (unlikely((__pyx_v_offset == (uint64_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_offset = __Pyx_PyInt_from_py_uint64_t(values[0]); if (unlikely((__pyx_v_offset == (uint64_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     if (values[1]) {
-      __pyx_v_where = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_where == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      __pyx_v_where = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_where == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     } else {
       __pyx_v_where = ((int)0);
     }
   } else {
     __pyx_v_where = ((int)0);
     switch (PyTuple_GET_SIZE(__pyx_args)) {
-      case  2: __pyx_v_where = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_where == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-      case  1: __pyx_v_offset = __Pyx_PyInt_from_py_uint64_t(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_offset == (uint64_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      case  2: __pyx_v_where = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_where == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      case  1: __pyx_v_offset = __Pyx_PyInt_from_py_uint64_t(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_offset == (uint64_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       break;
       default: goto __pyx_L5_argtuple_error;
     }
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("seek", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("seek", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("csamtools.Samfile.seek");
   __Pyx_RefNannyFinishContext();
   return NULL;
   __pyx_L4_argument_unpacking_done:;
 
-  /* "csamtools.pyx":718
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":696
  *         '''
  * 
  *         if not self._isOpen():             # <<<<<<<<<<<<<<
  *             raise ValueError( "I/O operation on closed file" )
  *         if not self.isbam:
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
 
-    /* "csamtools.pyx":719
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":697
  * 
  *         if not self._isOpen():
  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *         if not self.isbam:
  *             raise NotImplementedError("seek only available in bam files")
  */
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_37), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_Raise(__pyx_t_2, 0, 0);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_Raise(__pyx_t_1, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   __pyx_L6:;
 
-  /* "csamtools.pyx":720
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":698
  *         if not self._isOpen():
  *             raise ValueError( "I/O operation on closed file" )
  *         if not self.isbam:             # <<<<<<<<<<<<<<
  *             raise NotImplementedError("seek only available in bam files")
- *         if self.isstream:
+ *         return bam_seek( self.samfile.x.bam, offset, where )
  */
   __pyx_t_4 = (!((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam);
   if (__pyx_t_4) {
 
-    /* "csamtools.pyx":721
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":699
  *             raise ValueError( "I/O operation on closed file" )
  *         if not self.isbam:
  *             raise NotImplementedError("seek only available in bam files")             # <<<<<<<<<<<<<<
- *         if self.isstream:
- *             raise OSError("seek no available in streams")
+ *         return bam_seek( self.samfile.x.bam, offset, where )
+ * 
  */
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_NotImplementedError, ((PyObject *)__pyx_k_tuple_39), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_28));
+    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_28));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_28));
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __Pyx_Raise(__pyx_t_2, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L7;
   }
   __pyx_L7:;
 
-  /* "csamtools.pyx":722
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":700
  *         if not self.isbam:
  *             raise NotImplementedError("seek only available in bam files")
- *         if self.isstream:             # <<<<<<<<<<<<<<
- *             raise OSError("seek no available in streams")
- * 
- */
-  if (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isstream) {
-
-    /* "csamtools.pyx":723
- *             raise NotImplementedError("seek only available in bam files")
- *         if self.isstream:
- *             raise OSError("seek no available in streams")             # <<<<<<<<<<<<<<
- * 
- *         return bam_seek( self.samfile.x.bam, offset, where )
- */
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_OSError, ((PyObject *)__pyx_k_tuple_41), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_Raise(__pyx_t_2, 0, 0);
-    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    goto __pyx_L8;
-  }
-  __pyx_L8:;
-
-  /* "csamtools.pyx":725
- *             raise OSError("seek no available in streams")
- * 
  *         return bam_seek( self.samfile.x.bam, offset, where )             # <<<<<<<<<<<<<<
  * 
  *     def tell( self ):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = __Pyx_PyInt_to_py_int64_t(bam_seek(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->x.bam, __pyx_v_offset, __pyx_v_where)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 725; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyInt_to_py_int64_t(bam_seek(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->x.bam, __pyx_v_offset, __pyx_v_where)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
@@ -7859,7 +7941,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_8seek(PyObject *__pyx_v_self, PyOb
   return __pyx_r;
 }
 
-/* "csamtools.pyx":727
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":702
  *         return bam_seek( self.samfile.x.bam, offset, where )
  * 
  *     def tell( self ):             # <<<<<<<<<<<<<<
@@ -7867,9 +7949,9 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_8seek(PyObject *__pyx_v_self, PyOb
  *         return current file position
  */
 
-static PyObject *__pyx_pf_9csamtools_7Samfile_9tell(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_9csamtools_7Samfile_9tell[] = "Samfile.tell(self)\n\n        return current file position\n        ";
-static PyObject *__pyx_pf_9csamtools_7Samfile_9tell(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+static PyObject *__pyx_pf_9csamtools_7Samfile_tell(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static char __pyx_doc_9csamtools_7Samfile_tell[] = "Samfile.tell(self)\n\n        return current file position\n        ";
+static PyObject *__pyx_pf_9csamtools_7Samfile_tell(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   PyObject *__pyx_t_2 = NULL;
@@ -7877,42 +7959,48 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_9tell(PyObject *__pyx_v_self, CYTH
   int __pyx_t_4;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("tell");
-  __Pyx_TraceCall("tell", __pyx_f[0], 727);
+  __Pyx_TraceCall("tell", __pyx_f[0], 702);
 
-  /* "csamtools.pyx":731
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":706
  *         return current file position
  *         '''
  *         if not self._isOpen():             # <<<<<<<<<<<<<<
  *             raise ValueError( "I/O operation on closed file" )
  *         if not self.isbam:
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
 
-    /* "csamtools.pyx":732
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":707
  *         '''
  *         if not self._isOpen():
  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *         if not self.isbam:
  *             raise NotImplementedError("seek only available in bam files")
  */
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_42), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_Raise(__pyx_t_2, 0, 0);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_Raise(__pyx_t_1, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":733
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":708
  *         if not self._isOpen():
  *             raise ValueError( "I/O operation on closed file" )
  *         if not self.isbam:             # <<<<<<<<<<<<<<
@@ -7922,23 +8010,29 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_9tell(PyObject *__pyx_v_self, CYTH
   __pyx_t_4 = (!((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam);
   if (__pyx_t_4) {
 
-    /* "csamtools.pyx":734
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":709
  *             raise ValueError( "I/O operation on closed file" )
  *         if not self.isbam:
  *             raise NotImplementedError("seek only available in bam files")             # <<<<<<<<<<<<<<
  * 
  *         return bam_tell( self.samfile.x.bam )
  */
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_NotImplementedError, ((PyObject *)__pyx_k_tuple_43), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_28));
+    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_28));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_28));
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __Pyx_Raise(__pyx_t_2, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   __pyx_L6:;
 
-  /* "csamtools.pyx":736
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":711
  *             raise NotImplementedError("seek only available in bam files")
  * 
  *         return bam_tell( self.samfile.x.bam )             # <<<<<<<<<<<<<<
@@ -7946,7 +8040,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_9tell(PyObject *__pyx_v_self, CYTH
  *     def fetch( self,
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = __Pyx_PyInt_to_py_int64_t(bam_tell(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->x.bam)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyInt_to_py_int64_t(bam_tell(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->x.bam)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 711; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
@@ -7966,7 +8060,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_9tell(PyObject *__pyx_v_self, CYTH
   return __pyx_r;
 }
 
-/* "csamtools.pyx":738
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":713
  *         return bam_tell( self.samfile.x.bam )
  * 
  *     def fetch( self,             # <<<<<<<<<<<<<<
@@ -7974,9 +8068,9 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_9tell(PyObject *__pyx_v_self, CYTH
  *                start = None,
  */
 
-static PyObject *__pyx_pf_9csamtools_7Samfile_10fetch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_9csamtools_7Samfile_10fetch[] = "Samfile.fetch(self, reference=None, start=None, end=None, region=None, callback=None, until_eof=False)\n\n        fetch aligned reads in a :term:`region` using 0-based indexing. The region is specified by\n        :term:`reference`, *start* and *end*. Alternatively, a samtools :term:`region` string can \n        be supplied.\n\n        Without *reference* or *region* all mapped reads will be fetched. The reads will be returned\n        ordered by reference sequence, which will not necessarily be the order within the file.\n\n        If *until_eof* is given, all reads from the current file position will be returned\n        in order as they are within the file. Using this option will also fetch unmapped reads. \n        \n        If only *reference* is set, all reads aligned to *reference* will be fetched.\n\n        The method returns an iterator of type :class:`pysam.IteratorRow` unless\n        a *callback is provided. If *callback* is given, the callback will be executed \n        for each position within the :term:`region`. Note that callbacks currently work\n        only, if *region* or *reference* is given.\n\n        Note that a :term:`SAM` file does not allow random access. If *region* or *reference* are given,\n        an exception is raised.\n        ";
-static PyObject *__pyx_pf_9csamtools_7Samfile_10fetch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_9csamtools_7Samfile_fetch[] = "Samfile.fetch(self, reference=None, start=None, end=None, region=None, callback=None, until_eof=False)\n\n        fetch aligned reads in a :term:`region` using 0-based indexing. The region is specified by\n        :term:`reference`, *start* and *end*. Alternatively, a samtools :term:`region` string can \n        be supplied.\n\n        Without *reference* or *region* all reads will be fetched. The reads will be returned\n        ordered by reference sequence, which will not necessarily be the order within the file.\n        If *until_eof* is given, all reads from the current file position will be returned\n        *in order as they are within the file*.  \n        \n        If only *reference* is set, all reads aligned to *reference* will be fetched.\n\n        The method returns an iterator of type :class:`pysam.IteratorRow` unless\n        a *callback is provided. If *callback* is given, the callback will be executed \n        for each position within the :term:`region`. Note that callbacks currently work\n        only, if *region* or *reference* is given.\n\n        Note that a :term:`SAM` file does not allow random access. If *region* or *reference* are given,\n        an exception is raised.\n        ";
+static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   PyObject *__pyx_v_reference = 0;
   PyObject *__pyx_v_start = 0;
   PyObject *__pyx_v_end = 0;
@@ -7987,7 +8081,6 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_10fetch(PyObject *__pyx_v_self, Py
   int __pyx_v_rstart;
   int __pyx_v_rend;
   int __pyx_v_has_coord;
-  int __pyx_v_reopen;
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   PyObject *__pyx_t_2 = NULL;
@@ -8006,12 +8099,12 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_10fetch(PyObject *__pyx_v_self, Py
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__reference,&__pyx_n_s__start,&__pyx_n_s__end,&__pyx_n_s__region,&__pyx_n_s__callback,&__pyx_n_s__until_eof,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("fetch");
-  __Pyx_TraceCall("fetch", __pyx_f[0], 738);
+  __Pyx_TraceCall("fetch", __pyx_f[0], 713);
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[6] = {0,0,0,0,0,0};
 
-    /* "csamtools.pyx":739
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":714
  * 
  *     def fetch( self,
  *                reference = None,             # <<<<<<<<<<<<<<
@@ -8020,7 +8113,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_10fetch(PyObject *__pyx_v_self, Py
  */
     values[0] = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":740
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":715
  *     def fetch( self,
  *                reference = None,
  *                start = None,             # <<<<<<<<<<<<<<
@@ -8029,7 +8122,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_10fetch(PyObject *__pyx_v_self, Py
  */
     values[1] = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":741
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":716
  *                reference = None,
  *                start = None,
  *                end = None,             # <<<<<<<<<<<<<<
@@ -8038,7 +8131,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_10fetch(PyObject *__pyx_v_self, Py
  */
     values[2] = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":742
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":717
  *                start = None,
  *                end = None,
  *                region = None,             # <<<<<<<<<<<<<<
@@ -8047,7 +8140,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_10fetch(PyObject *__pyx_v_self, Py
  */
     values[3] = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":743
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":718
  *                end = None,
  *                region = None,
  *                callback = None,             # <<<<<<<<<<<<<<
@@ -8055,7 +8148,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_10fetch(PyObject *__pyx_v_self, Py
  *         '''
  */
     values[4] = ((PyObject *)Py_None);
-    values[5] = __pyx_k_44;
+    values[5] = __pyx_k_29;
     switch (PyTuple_GET_SIZE(__pyx_args)) {
       case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
       case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
@@ -8099,7 +8192,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_10fetch(PyObject *__pyx_v_self, Py
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "fetch") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "fetch") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_reference = values[0];
     __pyx_v_start = values[1];
@@ -8109,7 +8202,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_10fetch(PyObject *__pyx_v_self, Py
     __pyx_v_until_eof = values[5];
   } else {
 
-    /* "csamtools.pyx":739
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":714
  * 
  *     def fetch( self,
  *                reference = None,             # <<<<<<<<<<<<<<
@@ -8118,7 +8211,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_10fetch(PyObject *__pyx_v_self, Py
  */
     __pyx_v_reference = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":740
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":715
  *     def fetch( self,
  *                reference = None,
  *                start = None,             # <<<<<<<<<<<<<<
@@ -8127,7 +8220,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_10fetch(PyObject *__pyx_v_self, Py
  */
     __pyx_v_start = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":741
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":716
  *                reference = None,
  *                start = None,
  *                end = None,             # <<<<<<<<<<<<<<
@@ -8136,7 +8229,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_10fetch(PyObject *__pyx_v_self, Py
  */
     __pyx_v_end = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":742
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":717
  *                start = None,
  *                end = None,
  *                region = None,             # <<<<<<<<<<<<<<
@@ -8145,7 +8238,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_10fetch(PyObject *__pyx_v_self, Py
  */
     __pyx_v_region = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":743
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":718
  *                end = None,
  *                region = None,
  *                callback = None,             # <<<<<<<<<<<<<<
@@ -8153,7 +8246,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_10fetch(PyObject *__pyx_v_self, Py
  *         '''
  */
     __pyx_v_callback = ((PyObject *)Py_None);
-    __pyx_v_until_eof = __pyx_k_44;
+    __pyx_v_until_eof = __pyx_k_29;
     switch (PyTuple_GET_SIZE(__pyx_args)) {
       case  6: __pyx_v_until_eof = PyTuple_GET_ITEM(__pyx_args, 5);
       case  5: __pyx_v_callback = PyTuple_GET_ITEM(__pyx_args, 4);
@@ -8167,86 +8260,92 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_10fetch(PyObject *__pyx_v_self, Py
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("fetch", 0, 0, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("fetch", 0, 0, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("csamtools.Samfile.fetch");
   __Pyx_RefNannyFinishContext();
   return NULL;
   __pyx_L4_argument_unpacking_done:;
 
-  /* "csamtools.pyx":768
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":742
  *         cdef int rtid, rstart, rend, has_coord
  * 
  *         if not self._isOpen():             # <<<<<<<<<<<<<<
  *             raise ValueError( "I/O operation on closed file" )
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 742; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
 
-    /* "csamtools.pyx":769
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":743
  * 
  *         if not self._isOpen():
  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  * 
  *         has_coord, rtid, rstart, rend = self._parseRegion( reference, start, end, region )
  */
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_45), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_Raise(__pyx_t_2, 0, 0);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_Raise(__pyx_t_1, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   __pyx_L6:;
 
-  /* "csamtools.pyx":771
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":745
  *             raise ValueError( "I/O operation on closed file" )
  * 
  *         has_coord, rtid, rstart, rend = self._parseRegion( reference, start, end, region )             # <<<<<<<<<<<<<<
  * 
- *         if self.isstream: reopen = False
+ *         if self.isbam:
  */
-  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___parseRegion); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___parseRegion); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
   __Pyx_INCREF(__pyx_v_reference);
-  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_reference);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_reference);
   __Pyx_GIVEREF(__pyx_v_reference);
   __Pyx_INCREF(__pyx_v_start);
-  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_start);
+  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_start);
   __Pyx_GIVEREF(__pyx_v_start);
   __Pyx_INCREF(__pyx_v_end);
-  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_end);
+  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_end);
   __Pyx_GIVEREF(__pyx_v_end);
   __Pyx_INCREF(__pyx_v_region);
-  PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_v_region);
+  PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_region);
   __Pyx_GIVEREF(__pyx_v_region);
-  __pyx_t_5 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
   if (PyTuple_CheckExact(__pyx_t_5) && likely(PyTuple_GET_SIZE(__pyx_t_5) == 4)) {
     PyObject* tuple = __pyx_t_5;
-    __pyx_t_1 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_1);
-    __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_2 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_2);
-    __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_2);
+    __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_t_1 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_1);
+    __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __pyx_t_6 = PyTuple_GET_ITEM(tuple, 2); __Pyx_INCREF(__pyx_t_6);
-    __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
     __pyx_t_7 = PyTuple_GET_ITEM(tuple, 3); __Pyx_INCREF(__pyx_t_7);
-    __pyx_t_11 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_11 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
     __pyx_v_has_coord = __pyx_t_8;
@@ -8254,26 +8353,26 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_10fetch(PyObject *__pyx_v_self, Py
     __pyx_v_rstart = __pyx_t_10;
     __pyx_v_rend = __pyx_t_11;
   } else {
-    __pyx_t_12 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_12 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_12);
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-    __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_12, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_11 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_2 = __Pyx_UnpackItem(__pyx_t_12, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = __Pyx_UnpackItem(__pyx_t_12, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_11 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    __pyx_t_6 = __Pyx_UnpackItem(__pyx_t_12, 2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_12, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_t_6 = __Pyx_UnpackItem(__pyx_t_12, 2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
-    __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-    __pyx_t_7 = __Pyx_UnpackItem(__pyx_t_12, 3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = __Pyx_UnpackItem(__pyx_t_12, 3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_7);
-    __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-    if (__Pyx_EndUnpack(__pyx_t_12, 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (__Pyx_EndUnpack(__pyx_t_12, 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
     __pyx_v_has_coord = __pyx_t_11;
     __pyx_v_rtid = __pyx_t_10;
@@ -8281,55 +8380,31 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_10fetch(PyObject *__pyx_v_self, Py
     __pyx_v_rend = __pyx_t_8;
   }
 
-  /* "csamtools.pyx":773
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":747
  *         has_coord, rtid, rstart, rend = self._parseRegion( reference, start, end, region )
  * 
- *         if self.isstream: reopen = False             # <<<<<<<<<<<<<<
- *         else: reopen = True
- * 
- */
-  if (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isstream) {
-    __pyx_v_reopen = 0;
-    goto __pyx_L7;
-  }
-  /*else*/ {
-
-    /* "csamtools.pyx":774
- * 
- *         if self.isstream: reopen = False
- *         else: reopen = True             # <<<<<<<<<<<<<<
- * 
- *         if self.isbam:
- */
-    __pyx_v_reopen = 1;
-  }
-  __pyx_L7:;
-
-  /* "csamtools.pyx":776
- *         else: reopen = True
- * 
  *         if self.isbam:             # <<<<<<<<<<<<<<
  *             if not until_eof and not self._hasIndex() and not self.isremote:
  *                 raise ValueError( "fetch called on bamfile without index" )
  */
   if (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam) {
 
-    /* "csamtools.pyx":777
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":748
  * 
  *         if self.isbam:
  *             if not until_eof and not self._hasIndex() and not self.isremote:             # <<<<<<<<<<<<<<
  *                 raise ValueError( "fetch called on bamfile without index" )
  * 
  */
-    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_until_eof); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_until_eof); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_t_3 = (!__pyx_t_4);
     if (__pyx_t_3) {
-      __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
-      __pyx_t_7 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 748; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
       __pyx_t_13 = (!__pyx_t_4);
       if (__pyx_t_13) {
@@ -8344,33 +8419,39 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_10fetch(PyObject *__pyx_v_self, Py
     }
     if (__pyx_t_13) {
 
-      /* "csamtools.pyx":778
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":749
  *         if self.isbam:
  *             if not until_eof and not self._hasIndex() and not self.isremote:
  *                 raise ValueError( "fetch called on bamfile without index" )             # <<<<<<<<<<<<<<
  * 
  *             if callback:
  */
-      __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_47), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
-      __Pyx_Raise(__pyx_t_7, 0, 0);
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_30));
+      PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_kp_s_30));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_30));
+      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      goto __pyx_L9;
+      __Pyx_Raise(__pyx_t_5, 0, 0);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      goto __pyx_L8;
     }
-    __pyx_L9:;
+    __pyx_L8:;
 
-    /* "csamtools.pyx":780
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":751
  *                 raise ValueError( "fetch called on bamfile without index" )
  * 
  *             if callback:             # <<<<<<<<<<<<<<
  *                 if not has_coord: raise ValueError( "callback functionality requires a region/reference" )
  *                 if not self._hasIndex(): raise ValueError( "no index available for fetch" )
  */
-    __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_v_callback); if (unlikely(__pyx_t_13 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_v_callback); if (unlikely(__pyx_t_13 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (__pyx_t_13) {
 
-      /* "csamtools.pyx":781
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":752
  * 
  *             if callback:
  *                 if not has_coord: raise ValueError( "callback functionality requires a region/reference" )             # <<<<<<<<<<<<<<
@@ -8379,41 +8460,53 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_10fetch(PyObject *__pyx_v_self, Py
  */
       __pyx_t_13 = (!__pyx_v_has_coord);
       if (__pyx_t_13) {
-        __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_49), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_5);
+        __Pyx_INCREF(((PyObject *)__pyx_kp_s_31));
+        PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_31));
+        __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_31));
+        __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
         __Pyx_Raise(__pyx_t_7, 0, 0);
         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        goto __pyx_L11;
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        goto __pyx_L10;
       }
-      __pyx_L11:;
+      __pyx_L10:;
 
-      /* "csamtools.pyx":782
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":753
  *             if callback:
  *                 if not has_coord: raise ValueError( "callback functionality requires a region/reference" )
  *                 if not self._hasIndex(): raise ValueError( "no index available for fetch" )             # <<<<<<<<<<<<<<
  *                 return bam_fetch(self.samfile.x.bam,
  *                                  self.index,
  */
-      __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
-      __pyx_t_5 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-      __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_13 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_13 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
       __pyx_t_3 = (!__pyx_t_13);
       if (__pyx_t_3) {
-        __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_51), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_5);
-        __Pyx_Raise(__pyx_t_5, 0, 0);
+        __Pyx_INCREF(((PyObject *)__pyx_kp_s_32));
+        PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_32));
+        __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_32));
+        __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_7);
         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        goto __pyx_L12;
+        __Pyx_Raise(__pyx_t_7, 0, 0);
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        goto __pyx_L11;
       }
-      __pyx_L12:;
+      __pyx_L11:;
 
-      /* "csamtools.pyx":783
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":754
  *                 if not has_coord: raise ValueError( "callback functionality requires a region/reference" )
  *                 if not self._hasIndex(): raise ValueError( "no index available for fetch" )
  *                 return bam_fetch(self.samfile.x.bam,             # <<<<<<<<<<<<<<
@@ -8422,252 +8515,253 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_10fetch(PyObject *__pyx_v_self, Py
  */
       __Pyx_XDECREF(__pyx_r);
 
-      /* "csamtools.pyx":789
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":760
  *                                  rend,
  *                                  <void*>callback,
  *                                  fetch_callback )             # <<<<<<<<<<<<<<
  *             else:
  *                 if has_coord:
  */
-      __pyx_t_5 = PyInt_FromLong(bam_fetch(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->x.bam, ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index, __pyx_v_rtid, __pyx_v_rstart, __pyx_v_rend, ((void *)__pyx_v_callback), __pyx_f_9csamtools_fetch_callback)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_5);
-      __pyx_r = __pyx_t_5;
-      __pyx_t_5 = 0;
+      __pyx_t_7 = PyInt_FromLong(bam_fetch(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->x.bam, ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index, __pyx_v_rtid, __pyx_v_rstart, __pyx_v_rend, ((void *)__pyx_v_callback), __pyx_f_9csamtools_fetch_callback)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __pyx_r = __pyx_t_7;
+      __pyx_t_7 = 0;
       goto __pyx_L0;
-      goto __pyx_L10;
+      goto __pyx_L9;
     }
     /*else*/ {
 
-      /* "csamtools.pyx":791
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":762
  *                                  fetch_callback )
  *             else:
  *                 if has_coord:             # <<<<<<<<<<<<<<
- *                     return IteratorRowRegion( self, rtid, rstart, rend, reopen=reopen )
+ *                     return IteratorRowRegion( self, rtid, rstart, rend )
  *                 else:
  */
       if (__pyx_v_has_coord) {
 
-        /* "csamtools.pyx":792
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":763
  *             else:
  *                 if has_coord:
- *                     return IteratorRowRegion( self, rtid, rstart, rend, reopen=reopen )             # <<<<<<<<<<<<<<
+ *                     return IteratorRowRegion( self, rtid, rstart, rend )             # <<<<<<<<<<<<<<
  *                 else:
  *                     if until_eof:
  */
         __Pyx_XDECREF(__pyx_r);
-        __pyx_t_5 = PyInt_FromLong(__pyx_v_rtid); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_5);
-        __pyx_t_7 = PyInt_FromLong(__pyx_v_rstart); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyInt_FromLong(__pyx_v_rtid); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
-        __pyx_t_6 = PyInt_FromLong(__pyx_v_rend); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_5 = PyInt_FromLong(__pyx_v_rstart); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_5);
+        __pyx_t_6 = PyInt_FromLong(__pyx_v_rend); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
-        __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+        __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_1);
         __Pyx_INCREF(__pyx_v_self);
-        PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self);
+        PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self);
         __Pyx_GIVEREF(__pyx_v_self);
-        PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_5);
-        __Pyx_GIVEREF(__pyx_t_5);
-        PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_t_7);
+        PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_7);
         __Pyx_GIVEREF(__pyx_t_7);
-        PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_6);
+        PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_5);
+        __Pyx_GIVEREF(__pyx_t_5);
+        PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_6);
         __Pyx_GIVEREF(__pyx_t_6);
-        __pyx_t_5 = 0;
         __pyx_t_7 = 0;
+        __pyx_t_5 = 0;
+        __pyx_t_6 = 0;
+        __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorRowRegion)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_6);
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+        __pyx_r = __pyx_t_6;
         __pyx_t_6 = 0;
-        __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(((PyObject *)__pyx_t_6));
-        __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_v_reopen); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_7);
-        if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__reopen), __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-        __pyx_t_7 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorRowRegion)), ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_7);
-        __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
-        __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
-        __pyx_r = __pyx_t_7;
-        __pyx_t_7 = 0;
         goto __pyx_L0;
-        goto __pyx_L13;
+        goto __pyx_L12;
       }
       /*else*/ {
 
-        /* "csamtools.pyx":794
- *                     return IteratorRowRegion( self, rtid, rstart, rend, reopen=reopen )
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":765
+ *                     return IteratorRowRegion( self, rtid, rstart, rend )
  *                 else:
  *                     if until_eof:             # <<<<<<<<<<<<<<
- *                         return IteratorRowAll( self, reopen=reopen )
+ *                         return IteratorRowAll( self )
  *                     else:
  */
-        __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_until_eof); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_until_eof); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         if (__pyx_t_3) {
 
-          /* "csamtools.pyx":795
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":766
  *                 else:
  *                     if until_eof:
- *                         return IteratorRowAll( self, reopen=reopen )             # <<<<<<<<<<<<<<
+ *                         return IteratorRowAll( self )             # <<<<<<<<<<<<<<
  *                     else:
- *                         # AH: check - reason why no reopen for AllRefs?
+ *                         return IteratorRowAllRefs(self)
  */
           __Pyx_XDECREF(__pyx_r);
-          __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __Pyx_GOTREF(((PyObject *)__pyx_t_7));
+          __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_6);
           __Pyx_INCREF(__pyx_v_self);
-          PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_self);
+          PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_self);
           __Pyx_GIVEREF(__pyx_v_self);
-          __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __Pyx_GOTREF(((PyObject *)__pyx_t_6));
-          __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_reopen); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __Pyx_GOTREF(__pyx_t_2);
-          if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__reopen), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-          __pyx_t_2 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorRowAll)), ((PyObject *)__pyx_t_7), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __Pyx_GOTREF(__pyx_t_2);
-          __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
-          __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
-          __pyx_r = __pyx_t_2;
-          __pyx_t_2 = 0;
-          goto __pyx_L0;
-          goto __pyx_L14;
+          __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorRowAll)), __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_1);
+          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+          __pyx_r = __pyx_t_1;
+          __pyx_t_1 = 0;
+          goto __pyx_L0;
+          goto __pyx_L13;
         }
         /*else*/ {
 
-          /* "csamtools.pyx":798
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":768
+ *                         return IteratorRowAll( self )
  *                     else:
- *                         # AH: check - reason why no reopen for AllRefs?
- *                         return IteratorRowAllRefs(self ) # , reopen=reopen )             # <<<<<<<<<<<<<<
+ *                         return IteratorRowAllRefs(self)             # <<<<<<<<<<<<<<
  *         else:
  *             # check if header is present - otherwise sam_read1 aborts
  */
           __Pyx_XDECREF(__pyx_r);
-          __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+          __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_1);
           __Pyx_INCREF(__pyx_v_self);
-          PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self);
+          PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self);
           __Pyx_GIVEREF(__pyx_v_self);
-          __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorRowAllRefs)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorRowAllRefs)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_6);
-          __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
           __pyx_r = __pyx_t_6;
           __pyx_t_6 = 0;
           goto __pyx_L0;
         }
-        __pyx_L14:;
+        __pyx_L13:;
       }
-      __pyx_L13:;
+      __pyx_L12:;
     }
-    __pyx_L10:;
-    goto __pyx_L8;
+    __pyx_L9:;
+    goto __pyx_L7;
   }
   /*else*/ {
 
-    /* "csamtools.pyx":802
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":772
  *             # check if header is present - otherwise sam_read1 aborts
  *             # this happens if a bamfile is opened with mode 'r'
- *             if has_coord:             # <<<<<<<<<<<<<<
- *                 raise ValueError ("fetching by region is not available for sam files" )
+ *             if self.samfile.header.n_targets == 0:             # <<<<<<<<<<<<<<
+ *                 raise ValueError( "fetch called for samfile without header")
  * 
  */
-    if (__pyx_v_has_coord) {
+    __pyx_t_3 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->n_targets == 0);
+    if (__pyx_t_3) {
 
-      /* "csamtools.pyx":803
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":773
  *             # this happens if a bamfile is opened with mode 'r'
- *             if has_coord:
- *                 raise ValueError ("fetching by region is not available for sam files" )             # <<<<<<<<<<<<<<
- * 
  *             if self.samfile.header.n_targets == 0:
+ *                 raise ValueError( "fetch called for samfile without header")             # <<<<<<<<<<<<<<
+ * 
+ *             if region != None:
  */
-      __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_53), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
-      __Pyx_Raise(__pyx_t_6, 0, 0);
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_33));
+      PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_33));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_33));
+      __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      goto __pyx_L15;
+      __Pyx_Raise(__pyx_t_1, 0, 0);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      goto __pyx_L14;
     }
-    __pyx_L15:;
+    __pyx_L14:;
 
-    /* "csamtools.pyx":805
- *                 raise ValueError ("fetching by region is not available for sam files" )
- * 
- *             if self.samfile.header.n_targets == 0:             # <<<<<<<<<<<<<<
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":775
  *                 raise ValueError( "fetch called for samfile without header")
  * 
+ *             if region != None:             # <<<<<<<<<<<<<<
+ *                 raise ValueError ("fetch for a region is not available for sam files" )
+ *             if callback:
  */
-    __pyx_t_3 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->n_targets == 0);
+    __pyx_t_1 = PyObject_RichCompare(__pyx_v_region, Py_None, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     if (__pyx_t_3) {
 
-      /* "csamtools.pyx":806
- * 
- *             if self.samfile.header.n_targets == 0:
- *                 raise ValueError( "fetch called for samfile without header")             # <<<<<<<<<<<<<<
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":776
  * 
+ *             if region != None:
+ *                 raise ValueError ("fetch for a region is not available for sam files" )             # <<<<<<<<<<<<<<
  *             if callback:
+ *                 raise NotImplementedError( "callback not implemented yet" )
  */
-      __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_55), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_34));
+      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_34));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_34));
+      __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
       __Pyx_Raise(__pyx_t_6, 0, 0);
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      goto __pyx_L16;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      goto __pyx_L15;
     }
-    __pyx_L16:;
+    __pyx_L15:;
 
-    /* "csamtools.pyx":808
- *                 raise ValueError( "fetch called for samfile without header")
- * 
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":777
+ *             if region != None:
+ *                 raise ValueError ("fetch for a region is not available for sam files" )
  *             if callback:             # <<<<<<<<<<<<<<
  *                 raise NotImplementedError( "callback not implemented yet" )
  *             else:
  */
-    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_callback); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_callback); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (__pyx_t_3) {
 
-      /* "csamtools.pyx":809
- * 
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":778
+ *                 raise ValueError ("fetch for a region is not available for sam files" )
  *             if callback:
  *                 raise NotImplementedError( "callback not implemented yet" )             # <<<<<<<<<<<<<<
  *             else:
- *                 return IteratorRowAll( self, reopen=reopen )
+ *                 return IteratorRowAll( self )
  */
-      __pyx_t_6 = PyObject_Call(__pyx_builtin_NotImplementedError, ((PyObject *)__pyx_k_tuple_57), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
-      __Pyx_Raise(__pyx_t_6, 0, 0);
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_35));
+      PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_35));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_35));
+      __pyx_t_1 = PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      goto __pyx_L17;
+      __Pyx_Raise(__pyx_t_1, 0, 0);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      goto __pyx_L16;
     }
     /*else*/ {
 
-      /* "csamtools.pyx":811
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":780
  *                 raise NotImplementedError( "callback not implemented yet" )
  *             else:
- *                 return IteratorRowAll( self, reopen=reopen )             # <<<<<<<<<<<<<<
+ *                 return IteratorRowAll( self )             # <<<<<<<<<<<<<<
  * 
  *     def mate( self,
  */
       __Pyx_XDECREF(__pyx_r);
-      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(((PyObject *)__pyx_t_6));
+      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
       __Pyx_INCREF(__pyx_v_self);
-      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_self);
+      PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self);
       __Pyx_GIVEREF(__pyx_v_self);
-      __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-      __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_v_reopen); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_7);
-      if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__reopen), __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-      __pyx_t_7 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorRowAll)), ((PyObject *)__pyx_t_6), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_7);
-      __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
-      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
-      __pyx_r = __pyx_t_7;
-      __pyx_t_7 = 0;
+      __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorRowAll)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __pyx_r = __pyx_t_6;
+      __pyx_t_6 = 0;
       goto __pyx_L0;
     }
-    __pyx_L17:;
+    __pyx_L16:;
   }
-  __pyx_L8:;
+  __pyx_L7:;
 
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   goto __pyx_L0;
@@ -8687,17 +8781,17 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_10fetch(PyObject *__pyx_v_self, Py
   return __pyx_r;
 }
 
-/* "csamtools.pyx":813
- *                 return IteratorRowAll( self, reopen=reopen )
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":782
+ *                 return IteratorRowAll( self )
  * 
  *     def mate( self,             # <<<<<<<<<<<<<<
  *               AlignedRead read ):
  *         '''return the mate of :class:`AlignedRead` *read*.
  */
 
-static PyObject *__pyx_pf_9csamtools_7Samfile_11mate(PyObject *__pyx_v_self, PyObject *__pyx_v_read); /*proto*/
-static char __pyx_doc_9csamtools_7Samfile_11mate[] = "Samfile.mate(self, AlignedRead read)\nreturn the mate of :class:`AlignedRead` *read*.\n\n        Throws a ValueError if read is unpaired or the mate\n        is unmapped.\n\n        .. note::\n            Calling this method will change the file position.\n            This might interfere with any iterators that have\n            not re-opened the file.\n\n        ";
-static PyObject *__pyx_pf_9csamtools_7Samfile_11mate(PyObject *__pyx_v_self, PyObject *__pyx_v_read) {
+static PyObject *__pyx_pf_9csamtools_7Samfile_mate(PyObject *__pyx_v_self, PyObject *__pyx_v_read); /*proto*/
+static char __pyx_doc_9csamtools_7Samfile_mate[] = "Samfile.mate(self, AlignedRead read)\nreturn the mate of :class:`AlignedRead` *read*.\n\n        Throws a ValueError if read is unpaired or the mate\n        is unmapped.\n\n        .. note::\n            Calling this method will change the file position.\n            This might interfere with any iterators that have\n            not re-opened the file.\n\n        ";
+static PyObject *__pyx_pf_9csamtools_7Samfile_mate(PyObject *__pyx_v_self, PyObject *__pyx_v_read) {
   uint32_t __pyx_v_flag;
   __pyx_t_9csamtools_MateData __pyx_v_mate_data;
   int __pyx_v_x;
@@ -8708,10 +8802,10 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_11mate(PyObject *__pyx_v_self, PyO
   PyObject *__pyx_t_3 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("mate");
-  __Pyx_TraceCall("mate", __pyx_f[0], 813);
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_read), __pyx_ptype_9csamtools_AlignedRead, 1, "read", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("mate", __pyx_f[0], 782);
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_read), __pyx_ptype_9csamtools_AlignedRead, 1, "read", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "csamtools.pyx":826
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":795
  * 
  *         '''
  *         cdef uint32_t flag = read._delegate.core.flag             # <<<<<<<<<<<<<<
@@ -8720,7 +8814,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_11mate(PyObject *__pyx_v_self, PyO
  */
   __pyx_v_flag = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_read)->_delegate->core.flag;
 
-  /* "csamtools.pyx":828
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":797
  *         cdef uint32_t flag = read._delegate.core.flag
  * 
  *         if flag & BAM_FPAIRED == 0:             # <<<<<<<<<<<<<<
@@ -8730,34 +8824,34 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_11mate(PyObject *__pyx_v_self, PyO
   __pyx_t_1 = ((__pyx_v_flag & 1) == 0);
   if (__pyx_t_1) {
 
-    /* "csamtools.pyx":829
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":798
  * 
  *         if flag & BAM_FPAIRED == 0:
  *             raise ValueError( "read %s: is unpaired" % (read.qname))             # <<<<<<<<<<<<<<
  *         if flag & BAM_FMUNMAP != 0:
  *             raise ValueError( "mate %s: is unmapped" % (read.qname))
  */
-    __pyx_t_2 = PyObject_GetAttr(__pyx_v_read, __pyx_n_s__qname); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_read, __pyx_n_s__qname); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_58), __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_36), __pyx_t_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_3));
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_3));
     __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
     __pyx_t_3 = 0;
-    __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_Raise(__pyx_t_3, 0, 0);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":830
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":799
  *         if flag & BAM_FPAIRED == 0:
  *             raise ValueError( "read %s: is unpaired" % (read.qname))
  *         if flag & BAM_FMUNMAP != 0:             # <<<<<<<<<<<<<<
@@ -8767,34 +8861,34 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_11mate(PyObject *__pyx_v_self, PyO
   __pyx_t_1 = ((__pyx_v_flag & 8) != 0);
   if (__pyx_t_1) {
 
-    /* "csamtools.pyx":831
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":800
  *             raise ValueError( "read %s: is unpaired" % (read.qname))
  *         if flag & BAM_FMUNMAP != 0:
  *             raise ValueError( "mate %s: is unmapped" % (read.qname))             # <<<<<<<<<<<<<<
  * 
  *         cdef MateData mate_data
  */
-    __pyx_t_3 = PyObject_GetAttr(__pyx_v_read, __pyx_n_s__qname); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(__pyx_v_read, __pyx_n_s__qname); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_59), __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_37), __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_2));
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
     PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
     __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
     __pyx_t_2 = 0;
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __Pyx_Raise(__pyx_t_2, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   __pyx_L6:;
 
-  /* "csamtools.pyx":835
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":804
  *         cdef MateData mate_data
  * 
  *         mate_data.name = <char *>bam1_qname(read._delegate)             # <<<<<<<<<<<<<<
@@ -8803,7 +8897,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_11mate(PyObject *__pyx_v_self, PyO
  */
   __pyx_v_mate_data.name = bam1_qname(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_read)->_delegate);
 
-  /* "csamtools.pyx":836
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":805
  * 
  *         mate_data.name = <char *>bam1_qname(read._delegate)
  *         mate_data.mate = NULL             # <<<<<<<<<<<<<<
@@ -8812,7 +8906,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_11mate(PyObject *__pyx_v_self, PyO
  */
   __pyx_v_mate_data.mate = NULL;
 
-  /* "csamtools.pyx":838
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":807
  *         mate_data.mate = NULL
  *         # xor flags to get the other mate
  *         cdef int x = BAM_FREAD1 + BAM_FREAD2             # <<<<<<<<<<<<<<
@@ -8821,7 +8915,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_11mate(PyObject *__pyx_v_self, PyO
  */
   __pyx_v_x = 192;
 
-  /* "csamtools.pyx":839
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":808
  *         # xor flags to get the other mate
  *         cdef int x = BAM_FREAD1 + BAM_FREAD2
  *         mate_data.flag = ( flag ^ x) & x             # <<<<<<<<<<<<<<
@@ -8830,7 +8924,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_11mate(PyObject *__pyx_v_self, PyO
  */
   __pyx_v_mate_data.flag = ((__pyx_v_flag ^ __pyx_v_x) & __pyx_v_x);
 
-  /* "csamtools.pyx":847
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":816
  *                   read._delegate.core.mpos + 1,
  *                   <void*>&mate_data,
  *                   mate_callback )             # <<<<<<<<<<<<<<
@@ -8839,7 +8933,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_11mate(PyObject *__pyx_v_self, PyO
  */
   bam_fetch(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->x.bam, ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index, ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_read)->_delegate->core.mtid, ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_read)->_delegate->core.mpos, (((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_read)->_delegate->core.mpos + 1), ((void *)(&__pyx_v_mate_data)), __pyx_f_9csamtools_mate_callback);
 
-  /* "csamtools.pyx":849
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":818
  *                   mate_callback )
  * 
  *         if mate_data.mate == NULL:             # <<<<<<<<<<<<<<
@@ -8849,36 +8943,42 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_11mate(PyObject *__pyx_v_self, PyO
   __pyx_t_1 = (__pyx_v_mate_data.mate == NULL);
   if (__pyx_t_1) {
 
-    /* "csamtools.pyx":850
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":819
  * 
  *         if mate_data.mate == NULL:
  *             raise ValueError( "mate not found" )             # <<<<<<<<<<<<<<
  * 
  *         cdef AlignedRead dest = AlignedRead.__new__(AlignedRead)
  */
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_61), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_Raise(__pyx_t_2, 0, 0);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_38));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_38));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_38));
+    __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_Raise(__pyx_t_3, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L7;
   }
   __pyx_L7:;
 
-  /* "csamtools.pyx":852
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":821
  *             raise ValueError( "mate not found" )
  * 
  *         cdef AlignedRead dest = AlignedRead.__new__(AlignedRead)             # <<<<<<<<<<<<<<
  *         dest._delegate = mate_data.mate
  *         return dest
  */
-  __pyx_t_2 = __Pyx_tp_new(((PyObject*)__pyx_ptype_9csamtools_AlignedRead)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  if (!(likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_9csamtools_AlignedRead)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_v_dest = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_t_2);
-  __pyx_t_2 = 0;
+  __pyx_t_3 = __Pyx_tp_new(((PyObject*)__pyx_ptype_9csamtools_AlignedRead)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  if (!(likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_9csamtools_AlignedRead)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_v_dest = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_t_3);
+  __pyx_t_3 = 0;
 
-  /* "csamtools.pyx":853
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":822
  * 
  *         cdef AlignedRead dest = AlignedRead.__new__(AlignedRead)
  *         dest._delegate = mate_data.mate             # <<<<<<<<<<<<<<
@@ -8887,7 +8987,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_11mate(PyObject *__pyx_v_self, PyO
  */
   __pyx_v_dest->_delegate = __pyx_v_mate_data.mate;
 
-  /* "csamtools.pyx":854
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":823
  *         cdef AlignedRead dest = AlignedRead.__new__(AlignedRead)
  *         dest._delegate = mate_data.mate
  *         return dest             # <<<<<<<<<<<<<<
@@ -8914,7 +9014,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_11mate(PyObject *__pyx_v_self, PyO
   return __pyx_r;
 }
 
-/* "csamtools.pyx":856
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":825
  *         return dest
  * 
  *     def count( self,             # <<<<<<<<<<<<<<
@@ -8922,9 +9022,9 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_11mate(PyObject *__pyx_v_self, PyO
  *                start = None,
  */
 
-static PyObject *__pyx_pf_9csamtools_7Samfile_12count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_9csamtools_7Samfile_12count[] = "Samfile.count(self, reference=None, start=None, end=None, region=None, until_eof=False)\n*(reference = None, start = None, end = None, region = None, callback = None, until_eof = False)*\n               \n        count  reads :term:`region` using 0-based indexing. The region is specified by\n        :term:`reference`, *start* and *end*. Alternatively, a samtools :term:`region` string can be supplied.\n\n        Note that a :term:`TAM` file does not allow random access. If *region* or *reference* are given,\n        an exception is raised.\n        ";
-static PyObject *__pyx_pf_9csamtools_7Samfile_12count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+static PyObject *__pyx_pf_9csamtools_7Samfile_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_9csamtools_7Samfile_count[] = "Samfile.count(self, reference=None, start=None, end=None, region=None, until_eof=False)\n*(reference = None, start = None, end = None, region = None, callback = None, until_eof = False)*\n               \n        count  reads :term:`region` using 0-based indexing. The region is specified by\n        :term:`reference`, *start* and *end*. Alternatively, a samtools :term:`region` string can be supplied.\n\n        Note that a :term:`TAM` file does not allow random access. If *region* or *reference* are given,\n        an exception is raised.\n        ";
+static PyObject *__pyx_pf_9csamtools_7Samfile_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   PyObject *__pyx_v_reference = 0;
   PyObject *__pyx_v_start = 0;
   PyObject *__pyx_v_end = 0;
@@ -8951,12 +9051,12 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_12count(PyObject *__pyx_v_self, Py
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__reference,&__pyx_n_s__start,&__pyx_n_s__end,&__pyx_n_s__region,&__pyx_n_s__until_eof,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("count");
-  __Pyx_TraceCall("count", __pyx_f[0], 856);
+  __Pyx_TraceCall("count", __pyx_f[0], 825);
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[5] = {0,0,0,0,0};
 
-    /* "csamtools.pyx":857
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":826
  * 
  *     def count( self,
  *                reference = None,             # <<<<<<<<<<<<<<
@@ -8965,7 +9065,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_12count(PyObject *__pyx_v_self, Py
  */
     values[0] = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":858
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":827
  *     def count( self,
  *                reference = None,
  *                start = None,             # <<<<<<<<<<<<<<
@@ -8974,7 +9074,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_12count(PyObject *__pyx_v_self, Py
  */
     values[1] = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":859
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":828
  *                reference = None,
  *                start = None,
  *                end = None,             # <<<<<<<<<<<<<<
@@ -8983,7 +9083,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_12count(PyObject *__pyx_v_self, Py
  */
     values[2] = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":860
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":829
  *                start = None,
  *                end = None,
  *                region = None,             # <<<<<<<<<<<<<<
@@ -8991,7 +9091,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_12count(PyObject *__pyx_v_self, Py
  *         '''*(reference = None, start = None, end = None, region = None, callback = None, until_eof = False)*
  */
     values[3] = ((PyObject *)Py_None);
-    values[4] = __pyx_k_62;
+    values[4] = __pyx_k_39;
     switch (PyTuple_GET_SIZE(__pyx_args)) {
       case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
       case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
@@ -9029,7 +9129,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_12count(PyObject *__pyx_v_self, Py
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 856; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_reference = values[0];
     __pyx_v_start = values[1];
@@ -9038,7 +9138,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_12count(PyObject *__pyx_v_self, Py
     __pyx_v_until_eof = values[4];
   } else {
 
-    /* "csamtools.pyx":857
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":826
  * 
  *     def count( self,
  *                reference = None,             # <<<<<<<<<<<<<<
@@ -9047,7 +9147,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_12count(PyObject *__pyx_v_self, Py
  */
     __pyx_v_reference = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":858
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":827
  *     def count( self,
  *                reference = None,
  *                start = None,             # <<<<<<<<<<<<<<
@@ -9056,7 +9156,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_12count(PyObject *__pyx_v_self, Py
  */
     __pyx_v_start = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":859
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":828
  *                reference = None,
  *                start = None,
  *                end = None,             # <<<<<<<<<<<<<<
@@ -9065,7 +9165,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_12count(PyObject *__pyx_v_self, Py
  */
     __pyx_v_end = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":860
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":829
  *                start = None,
  *                end = None,
  *                region = None,             # <<<<<<<<<<<<<<
@@ -9073,7 +9173,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_12count(PyObject *__pyx_v_self, Py
  *         '''*(reference = None, start = None, end = None, region = None, callback = None, until_eof = False)*
  */
     __pyx_v_region = ((PyObject *)Py_None);
-    __pyx_v_until_eof = __pyx_k_62;
+    __pyx_v_until_eof = __pyx_k_39;
     switch (PyTuple_GET_SIZE(__pyx_args)) {
       case  5: __pyx_v_until_eof = PyTuple_GET_ITEM(__pyx_args, 4);
       case  4: __pyx_v_region = PyTuple_GET_ITEM(__pyx_args, 3);
@@ -9086,7 +9186,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_12count(PyObject *__pyx_v_self, Py
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("count", 0, 0, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 856; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("count", 0, 0, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("csamtools.Samfile.count");
   __Pyx_RefNannyFinishContext();
@@ -9094,114 +9194,120 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_12count(PyObject *__pyx_v_self, Py
   __pyx_L4_argument_unpacking_done:;
   __Pyx_INCREF(__pyx_v_region);
 
-  /* "csamtools.pyx":874
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":843
  *         cdef int rend
  * 
  *         if not self._isOpen():             # <<<<<<<<<<<<<<
  *             raise ValueError( "I/O operation on closed file" )
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 874; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 874; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 874; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
 
-    /* "csamtools.pyx":875
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":844
  * 
  *         if not self._isOpen():
  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  * 
  *         region, rtid, rstart, rend = self._parseRegion( reference, start, end, region )
  */
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_63), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_Raise(__pyx_t_2, 0, 0);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_Raise(__pyx_t_1, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   __pyx_L6:;
 
-  /* "csamtools.pyx":877
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":846
  *             raise ValueError( "I/O operation on closed file" )
  * 
  *         region, rtid, rstart, rend = self._parseRegion( reference, start, end, region )             # <<<<<<<<<<<<<<
  * 
  *         cdef int counter
  */
-  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___parseRegion); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___parseRegion); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
   __Pyx_INCREF(__pyx_v_reference);
-  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_reference);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_reference);
   __Pyx_GIVEREF(__pyx_v_reference);
   __Pyx_INCREF(__pyx_v_start);
-  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_start);
+  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_start);
   __Pyx_GIVEREF(__pyx_v_start);
   __Pyx_INCREF(__pyx_v_end);
-  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_end);
+  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_end);
   __Pyx_GIVEREF(__pyx_v_end);
   __Pyx_INCREF(__pyx_v_region);
-  PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_v_region);
+  PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_region);
   __Pyx_GIVEREF(__pyx_v_region);
-  __pyx_t_5 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
   if (PyTuple_CheckExact(__pyx_t_5) && likely(PyTuple_GET_SIZE(__pyx_t_5) == 4)) {
     PyObject* tuple = __pyx_t_5;
-    __pyx_t_1 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_1);
-    __pyx_t_2 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_2);
-    __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_t_2 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_2);
+    __pyx_t_1 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_1);
+    __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __pyx_t_6 = PyTuple_GET_ITEM(tuple, 2); __Pyx_INCREF(__pyx_t_6);
-    __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
     __pyx_t_7 = PyTuple_GET_ITEM(tuple, 3); __Pyx_INCREF(__pyx_t_7);
-    __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
     __Pyx_DECREF(__pyx_v_region);
-    __pyx_v_region = __pyx_t_1;
-    __pyx_t_1 = 0;
+    __pyx_v_region = __pyx_t_2;
+    __pyx_t_2 = 0;
     __pyx_v_rtid = __pyx_t_8;
     __pyx_v_rstart = __pyx_t_9;
     __pyx_v_rend = __pyx_t_10;
   } else {
-    __pyx_t_11 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_11 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_11);
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-    __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_11, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_2 = __Pyx_UnpackItem(__pyx_t_11, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = __Pyx_UnpackItem(__pyx_t_11, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    __pyx_t_6 = __Pyx_UnpackItem(__pyx_t_11, 2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_11, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_t_6 = __Pyx_UnpackItem(__pyx_t_11, 2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
-    __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-    __pyx_t_7 = __Pyx_UnpackItem(__pyx_t_11, 3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = __Pyx_UnpackItem(__pyx_t_11, 3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_7);
-    __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-    if (__Pyx_EndUnpack(__pyx_t_11, 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (__Pyx_EndUnpack(__pyx_t_11, 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
     __Pyx_DECREF(__pyx_v_region);
-    __pyx_v_region = __pyx_t_1;
-    __pyx_t_1 = 0;
+    __pyx_v_region = __pyx_t_2;
+    __pyx_t_2 = 0;
     __pyx_v_rtid = __pyx_t_10;
     __pyx_v_rstart = __pyx_t_9;
     __pyx_v_rend = __pyx_t_8;
   }
 
-  /* "csamtools.pyx":880
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":849
  * 
  *         cdef int counter
  *         counter = 0;             # <<<<<<<<<<<<<<
@@ -9210,7 +9316,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_12count(PyObject *__pyx_v_self, Py
  */
   __pyx_v_counter = 0;
 
-  /* "csamtools.pyx":882
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":851
  *         counter = 0;
  * 
  *         if self.isbam:             # <<<<<<<<<<<<<<
@@ -9219,22 +9325,22 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_12count(PyObject *__pyx_v_self, Py
  */
   if (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam) {
 
-    /* "csamtools.pyx":883
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":852
  * 
  *         if self.isbam:
  *             if not until_eof and not self._hasIndex() and not self.isremote:             # <<<<<<<<<<<<<<
  *                 raise ValueError( "fetch called on bamfile without index" )
  * 
  */
-    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_until_eof); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_until_eof); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_t_3 = (!__pyx_t_4);
     if (__pyx_t_3) {
-      __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
-      __pyx_t_7 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 883; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
       __pyx_t_12 = (!__pyx_t_4);
       if (__pyx_t_12) {
@@ -9249,75 +9355,93 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_12count(PyObject *__pyx_v_self, Py
     }
     if (__pyx_t_12) {
 
-      /* "csamtools.pyx":884
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":853
  *         if self.isbam:
  *             if not until_eof and not self._hasIndex() and not self.isremote:
  *                 raise ValueError( "fetch called on bamfile without index" )             # <<<<<<<<<<<<<<
  * 
  *             if not region:
  */
-      __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_64), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
-      __Pyx_Raise(__pyx_t_7, 0, 0);
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_30));
+      PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_kp_s_30));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_30));
+      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_Raise(__pyx_t_5, 0, 0);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L8;
     }
     __pyx_L8:;
 
-    /* "csamtools.pyx":886
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":855
  *                 raise ValueError( "fetch called on bamfile without index" )
  * 
  *             if not region:             # <<<<<<<<<<<<<<
  *                 raise ValueError( "counting functionality requires a region/reference" )
  *             if not self._hasIndex(): raise ValueError( "no index available for fetch" )
  */
-    __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_v_region); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_v_region); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_t_3 = (!__pyx_t_12);
     if (__pyx_t_3) {
 
-      /* "csamtools.pyx":887
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":856
  * 
  *             if not region:
  *                 raise ValueError( "counting functionality requires a region/reference" )             # <<<<<<<<<<<<<<
  *             if not self._hasIndex(): raise ValueError( "no index available for fetch" )
  *             bam_fetch(self.samfile.x.bam,
  */
-      __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_66), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_40));
+      PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_40));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_40));
+      __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
       __Pyx_Raise(__pyx_t_7, 0, 0);
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L9;
     }
     __pyx_L9:;
 
-    /* "csamtools.pyx":888
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":857
  *             if not region:
  *                 raise ValueError( "counting functionality requires a region/reference" )
  *             if not self._hasIndex(): raise ValueError( "no index available for fetch" )             # <<<<<<<<<<<<<<
  *             bam_fetch(self.samfile.x.bam,
  *                              self.index,
  */
-    __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_7);
-    __pyx_t_5 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
     __pyx_t_12 = (!__pyx_t_3);
     if (__pyx_t_12) {
-      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_67), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
-      __Pyx_Raise(__pyx_t_5, 0, 0);
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_32));
+      PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_32));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_32));
+      __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_7);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_Raise(__pyx_t_7, 0, 0);
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L10;
     }
     __pyx_L10:;
 
-    /* "csamtools.pyx":895
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":864
  *                              rend,
  *                              <void*>&counter,
  *                              count_callback )             # <<<<<<<<<<<<<<
@@ -9326,7 +9450,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_12count(PyObject *__pyx_v_self, Py
  */
     bam_fetch(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->x.bam, ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index, __pyx_v_rtid, __pyx_v_rstart, __pyx_v_rend, ((void *)(&__pyx_v_counter)), __pyx_f_9csamtools_count_callback);
 
-    /* "csamtools.pyx":896
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":865
  *                              <void*>&counter,
  *                              count_callback )
  *             return counter             # <<<<<<<<<<<<<<
@@ -9334,27 +9458,33 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_12count(PyObject *__pyx_v_self, Py
  *             raise ValueError ("count for a region is not available for sam files" )
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_5 = PyInt_FromLong(__pyx_v_counter); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_5);
-    __pyx_r = __pyx_t_5;
-    __pyx_t_5 = 0;
+    __pyx_t_7 = PyInt_FromLong(__pyx_v_counter); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_7);
+    __pyx_r = __pyx_t_7;
+    __pyx_t_7 = 0;
     goto __pyx_L0;
     goto __pyx_L7;
   }
   /*else*/ {
 
-    /* "csamtools.pyx":898
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":867
  *             return counter
  *         else:
  *             raise ValueError ("count for a region is not available for sam files" )             # <<<<<<<<<<<<<<
  * 
  *     def pileup( self,
  */
-    __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_69), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 898; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_7);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_41));
+    PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_kp_s_41));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_41));
+    __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
     __Pyx_Raise(__pyx_t_5, 0, 0);
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 898; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   __pyx_L7:;
 
@@ -9377,7 +9507,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_12count(PyObject *__pyx_v_self, Py
   return __pyx_r;
 }
 
-/* "csamtools.pyx":900
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":869
  *             raise ValueError ("count for a region is not available for sam files" )
  * 
  *     def pileup( self,             # <<<<<<<<<<<<<<
@@ -9385,9 +9515,9 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_12count(PyObject *__pyx_v_self, Py
  *                 start = None,
  */
 
-static PyObject *__pyx_pf_9csamtools_7Samfile_13pileup(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_9csamtools_7Samfile_13pileup[] = "Samfile.pileup(self, reference=None, start=None, end=None, region=None, callback=None, **kwargs)\n\n        perform a :term:`pileup` within a :term:`region`. The region is specified by\n        :term:`reference`, *start* and *end* (using 0-based indexing). \n        Alternatively, a samtools *region* string can be supplied.\n\n        Without *reference* or *region* all reads will be used for the pileup. The reads will be returned\n        ordered by :term:`reference` sequence, which will not necessarily be the order within the file.\n\n        The method returns an iterator of type :class:`pysam.IteratorColumn` unless\n        a *callback is provided. If a *callback* is given, the callback will be executed \n        for each column within the :term:`region`. \n\n        Note that :term:`SAM` formatted files do not allow random access. \n        In these files, if a *region* or *reference* are given an exception is raised.\n        \n        Optional *kwargs* to the iterator:\n\n        stepper\n           The stepper controlls how the iterator advances. \n           Possible options for the stepper are \n       \n           ``all``\n              use all reads for pileup.\n           ``samtools``\n              same filter and read processing as in :term:`csamtools` pileup\n\n        fastafile\n           A :class:`FastaFile` object\n\n         mask\n           Skip all reads with bits set in mask.\n\n         max_depth\n           Maximum read depth permitted. The default limit is *8000*.\n\n        .. note::\n\n            *all* reads which overlap the region are returned. The first base returned will be the \n            first base of the first read *not* necessarily the first base of the region used in the query.\n\n        ";
-static PyObject *__pyx_pf_9csamtools_7Samfile_13pileup(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+static PyObject *__pyx_pf_9csamtools_7Samfile_pileup(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_9csamtools_7Samfile_pileup[] = "Samfile.pileup(self, reference=None, start=None, end=None, region=None, callback=None, **kwargs)\n\n        perform a :term:`pileup` within a :term:`region`. The region is specified by\n        :term:`reference`, *start* and *end* (using 0-based indexing). \n        Alternatively, a samtools *region* string can be supplied.\n\n        Without *reference* or *region* all reads will be used for the pileup. The reads will be returned\n        ordered by :term:`reference` sequence, which will not necessarily be the order within the file.\n\n        The method returns an iterator of type :class:`pysam.IteratorColumn` unless\n        a *callback is provided. If a *callback* is given, the callback will be executed \n        for each column within the :term:`region`. \n\n        Note that :term:`SAM` formatted files do not allow random access. \n        In these files, if a *region* or *reference* are given an exception is raised.\n        \n        Optional *kwargs* to the iterator:\n\n        stepper\n           The stepper controlls how the iterator advances. \n           Possible options for the stepper are \n       \n           ``all``\n              use all reads for pileup.\n           ``samtools``\n              same filter and read processing as in :term:`csamtools` pileup\n\n        fastafile\n           A :class:`FastaFile` object\n\n         mask\n           Skip all reads with bits set in mask.\n\n\n        .. note::\n\n            *all* reads which overlap the region are returned. The first base returned will be the \n            first base of the first read *not* necessarily the first base of the region used in the query.\n\n            The maximum number of reads considered for pileup is *8000*. This limit is set by\n            :term:`csamtools`.\n\n        ";
+static PyObject *__pyx_pf_9csamtools_7Samfile_pileup(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   PyObject *__pyx_v_reference = 0;
   PyObject *__pyx_v_start = 0;
   PyObject *__pyx_v_end = 0;
@@ -9415,14 +9545,14 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_13pileup(PyObject *__pyx_v_self, P
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__reference,&__pyx_n_s__start,&__pyx_n_s__end,&__pyx_n_s__region,&__pyx_n_s__callback,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("pileup");
-  __Pyx_TraceCall("pileup", __pyx_f[0], 900);
+  __Pyx_TraceCall("pileup", __pyx_f[0], 869);
   __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL;
   __Pyx_GOTREF(__pyx_v_kwargs);
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[5] = {0,0,0,0,0};
 
-    /* "csamtools.pyx":901
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":870
  * 
  *     def pileup( self,
  *                 reference = None,             # <<<<<<<<<<<<<<
@@ -9431,7 +9561,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_13pileup(PyObject *__pyx_v_self, P
  */
     values[0] = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":902
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":871
  *     def pileup( self,
  *                 reference = None,
  *                 start = None,             # <<<<<<<<<<<<<<
@@ -9440,7 +9570,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_13pileup(PyObject *__pyx_v_self, P
  */
     values[1] = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":903
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":872
  *                 reference = None,
  *                 start = None,
  *                 end = None,             # <<<<<<<<<<<<<<
@@ -9449,7 +9579,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_13pileup(PyObject *__pyx_v_self, P
  */
     values[2] = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":904
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":873
  *                 start = None,
  *                 end = None,
  *                 region = None,             # <<<<<<<<<<<<<<
@@ -9458,7 +9588,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_13pileup(PyObject *__pyx_v_self, P
  */
     values[3] = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":905
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":874
  *                 end = None,
  *                 region = None,
  *                 callback = None,             # <<<<<<<<<<<<<<
@@ -9503,7 +9633,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_13pileup(PyObject *__pyx_v_self, P
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, PyTuple_GET_SIZE(__pyx_args), "pileup") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, PyTuple_GET_SIZE(__pyx_args), "pileup") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 869; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_reference = values[0];
     __pyx_v_start = values[1];
@@ -9512,7 +9642,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_13pileup(PyObject *__pyx_v_self, P
     __pyx_v_callback = values[4];
   } else {
 
-    /* "csamtools.pyx":901
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":870
  * 
  *     def pileup( self,
  *                 reference = None,             # <<<<<<<<<<<<<<
@@ -9521,7 +9651,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_13pileup(PyObject *__pyx_v_self, P
  */
     __pyx_v_reference = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":902
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":871
  *     def pileup( self,
  *                 reference = None,
  *                 start = None,             # <<<<<<<<<<<<<<
@@ -9530,7 +9660,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_13pileup(PyObject *__pyx_v_self, P
  */
     __pyx_v_start = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":903
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":872
  *                 reference = None,
  *                 start = None,
  *                 end = None,             # <<<<<<<<<<<<<<
@@ -9539,7 +9669,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_13pileup(PyObject *__pyx_v_self, P
  */
     __pyx_v_end = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":904
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":873
  *                 start = None,
  *                 end = None,
  *                 region = None,             # <<<<<<<<<<<<<<
@@ -9548,7 +9678,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_13pileup(PyObject *__pyx_v_self, P
  */
     __pyx_v_region = ((PyObject *)Py_None);
 
-    /* "csamtools.pyx":905
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":874
  *                 end = None,
  *                 region = None,
  *                 callback = None,             # <<<<<<<<<<<<<<
@@ -9568,7 +9698,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_13pileup(PyObject *__pyx_v_self, P
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("pileup", 0, 0, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("pileup", 0, 0, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 869; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_DECREF(__pyx_v_kwargs);
   __Pyx_AddTraceback("csamtools.Samfile.pileup");
@@ -9576,79 +9706,85 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_13pileup(PyObject *__pyx_v_self, P
   return NULL;
   __pyx_L4_argument_unpacking_done:;
 
-  /* "csamtools.pyx":951
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":921
  *         cdef bam_plbuf_t *buf
  * 
  *         if not self._isOpen():             # <<<<<<<<<<<<<<
  *             raise ValueError( "I/O operation on closed file" )
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 921; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
 
-    /* "csamtools.pyx":952
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":922
  * 
  *         if not self._isOpen():
  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  * 
  *         has_coord, rtid, rstart, rend = self._parseRegion( reference, start, end, region )
  */
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_70), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_Raise(__pyx_t_2, 0, 0);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_Raise(__pyx_t_1, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   __pyx_L6:;
 
-  /* "csamtools.pyx":954
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":924
  *             raise ValueError( "I/O operation on closed file" )
  * 
  *         has_coord, rtid, rstart, rend = self._parseRegion( reference, start, end, region )             # <<<<<<<<<<<<<<
  * 
  *         if self.isbam:
  */
-  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___parseRegion); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___parseRegion); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
   __Pyx_INCREF(__pyx_v_reference);
-  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_reference);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_reference);
   __Pyx_GIVEREF(__pyx_v_reference);
   __Pyx_INCREF(__pyx_v_start);
-  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_start);
+  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_start);
   __Pyx_GIVEREF(__pyx_v_start);
   __Pyx_INCREF(__pyx_v_end);
-  PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_end);
+  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_end);
   __Pyx_GIVEREF(__pyx_v_end);
   __Pyx_INCREF(__pyx_v_region);
-  PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_v_region);
+  PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_region);
   __Pyx_GIVEREF(__pyx_v_region);
-  __pyx_t_5 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
   if (PyTuple_CheckExact(__pyx_t_5) && likely(PyTuple_GET_SIZE(__pyx_t_5) == 4)) {
     PyObject* tuple = __pyx_t_5;
-    __pyx_t_1 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_1);
-    __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_2 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_2);
-    __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_2);
+    __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_t_1 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_1);
+    __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __pyx_t_6 = PyTuple_GET_ITEM(tuple, 2); __Pyx_INCREF(__pyx_t_6);
-    __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
     __pyx_t_7 = PyTuple_GET_ITEM(tuple, 3); __Pyx_INCREF(__pyx_t_7);
-    __pyx_t_11 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_11 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
     __pyx_v_has_coord = __pyx_t_8;
@@ -9656,26 +9792,26 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_13pileup(PyObject *__pyx_v_self, P
     __pyx_v_rstart = __pyx_t_10;
     __pyx_v_rend = __pyx_t_11;
   } else {
-    __pyx_t_12 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_12 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_12);
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-    __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_12, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_11 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_2 = __Pyx_UnpackItem(__pyx_t_12, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = __Pyx_UnpackItem(__pyx_t_12, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_11 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    __pyx_t_6 = __Pyx_UnpackItem(__pyx_t_12, 2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_12, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_t_6 = __Pyx_UnpackItem(__pyx_t_12, 2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
-    __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-    __pyx_t_7 = __Pyx_UnpackItem(__pyx_t_12, 3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = __Pyx_UnpackItem(__pyx_t_12, 3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_7);
-    __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-    if (__Pyx_EndUnpack(__pyx_t_12, 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (__Pyx_EndUnpack(__pyx_t_12, 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
     __pyx_v_has_coord = __pyx_t_11;
     __pyx_v_rtid = __pyx_t_10;
@@ -9683,7 +9819,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_13pileup(PyObject *__pyx_v_self, P
     __pyx_v_rend = __pyx_t_8;
   }
 
-  /* "csamtools.pyx":956
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":926
  *         has_coord, rtid, rstart, rend = self._parseRegion( reference, start, end, region )
  * 
  *         if self.isbam:             # <<<<<<<<<<<<<<
@@ -9692,42 +9828,48 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_13pileup(PyObject *__pyx_v_self, P
  */
   if (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam) {
 
-    /* "csamtools.pyx":957
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":927
  * 
  *         if self.isbam:
  *             if not self._hasIndex(): raise ValueError( "no index available for pileup" )             # <<<<<<<<<<<<<<
  * 
  *             if callback:
  */
-    __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
-    __pyx_t_7 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_7);
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
     __pyx_t_3 = (!__pyx_t_4);
     if (__pyx_t_3) {
-      __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_72), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
-      __Pyx_Raise(__pyx_t_7, 0, 0);
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_42));
+      PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_kp_s_42));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_42));
+      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_Raise(__pyx_t_5, 0, 0);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L8;
     }
     __pyx_L8:;
 
-    /* "csamtools.pyx":959
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":929
  *             if not self._hasIndex(): raise ValueError( "no index available for pileup" )
  * 
  *             if callback:             # <<<<<<<<<<<<<<
  *                 if not has_coord: raise ValueError( "callback functionality requires a region/reference" )
  * 
  */
-    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_callback); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_callback); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 929; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (__pyx_t_3) {
 
-      /* "csamtools.pyx":960
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":930
  * 
  *             if callback:
  *                 if not has_coord: raise ValueError( "callback functionality requires a region/reference" )             # <<<<<<<<<<<<<<
@@ -9736,16 +9878,22 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_13pileup(PyObject *__pyx_v_self, P
  */
       __pyx_t_3 = (!__pyx_v_has_coord);
       if (__pyx_t_3) {
-        __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_73), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_5);
+        __Pyx_INCREF(((PyObject *)__pyx_kp_s_31));
+        PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_31));
+        __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_31));
+        __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
         __Pyx_Raise(__pyx_t_7, 0, 0);
         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         goto __pyx_L10;
       }
       __pyx_L10:;
 
-      /* "csamtools.pyx":962
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":932
  *                 if not has_coord: raise ValueError( "callback functionality requires a region/reference" )
  * 
  *                 buf = bam_plbuf_init( <bam_pileup_f>pileup_callback, <void*>callback )             # <<<<<<<<<<<<<<
@@ -9754,7 +9902,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_13pileup(PyObject *__pyx_v_self, P
  */
       __pyx_v_buf = bam_plbuf_init(((bam_pileup_f)__pyx_f_9csamtools_pileup_callback), ((void *)__pyx_v_callback));
 
-      /* "csamtools.pyx":965
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":935
  *                 bam_fetch(self.samfile.x.bam,
  *                           self.index, rtid, rstart, rend,
  *                           buf, pileup_fetch_callback )             # <<<<<<<<<<<<<<
@@ -9763,7 +9911,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_13pileup(PyObject *__pyx_v_self, P
  */
       bam_fetch(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->x.bam, ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index, __pyx_v_rtid, __pyx_v_rstart, __pyx_v_rend, __pyx_v_buf, __pyx_f_9csamtools_pileup_fetch_callback);
 
-      /* "csamtools.pyx":968
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":938
  * 
  *                 # finalize pileup
  *                 bam_plbuf_push( NULL, buf)             # <<<<<<<<<<<<<<
@@ -9772,7 +9920,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_13pileup(PyObject *__pyx_v_self, P
  */
       bam_plbuf_push(NULL, __pyx_v_buf);
 
-      /* "csamtools.pyx":969
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":939
  *                 # finalize pileup
  *                 bam_plbuf_push( NULL, buf)
  *                 bam_plbuf_destroy(buf)             # <<<<<<<<<<<<<<
@@ -9784,7 +9932,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_13pileup(PyObject *__pyx_v_self, P
     }
     /*else*/ {
 
-      /* "csamtools.pyx":971
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":941
  *                 bam_plbuf_destroy(buf)
  *             else:
  *                 if has_coord:             # <<<<<<<<<<<<<<
@@ -9793,7 +9941,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_13pileup(PyObject *__pyx_v_self, P
  */
       if (__pyx_v_has_coord) {
 
-        /* "csamtools.pyx":972
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":942
  *             else:
  *                 if has_coord:
  *                     return IteratorColumnRegion( self,             # <<<<<<<<<<<<<<
@@ -9801,61 +9949,61 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_13pileup(PyObject *__pyx_v_self, P
  *                                                  start = rstart,
  */
         __Pyx_XDECREF(__pyx_r);
-        __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(((PyObject *)__pyx_t_7));
+        __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_7);
         __Pyx_INCREF(__pyx_v_self);
         PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_self);
         __Pyx_GIVEREF(__pyx_v_self);
-        __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(((PyObject *)__pyx_t_5));
 
-        /* "csamtools.pyx":973
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":943
  *                 if has_coord:
  *                     return IteratorColumnRegion( self,
  *                                                  tid = rtid,             # <<<<<<<<<<<<<<
  *                                                  start = rstart,
  *                                                  end = rend,
  */
-        __pyx_t_6 = PyInt_FromLong(__pyx_v_rtid); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = PyInt_FromLong(__pyx_v_rtid); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 943; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
-        if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__tid), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__tid), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 
-        /* "csamtools.pyx":974
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":944
  *                     return IteratorColumnRegion( self,
  *                                                  tid = rtid,
  *                                                  start = rstart,             # <<<<<<<<<<<<<<
  *                                                  end = rend,
  *                                                  **kwargs )
  */
-        __pyx_t_6 = PyInt_FromLong(__pyx_v_rstart); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 974; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = PyInt_FromLong(__pyx_v_rstart); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 944; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
-        if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__start), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__start), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 
-        /* "csamtools.pyx":975
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":945
  *                                                  tid = rtid,
  *                                                  start = rstart,
  *                                                  end = rend,             # <<<<<<<<<<<<<<
  *                                                  **kwargs )
  *                 else:
  */
-        __pyx_t_6 = PyInt_FromLong(__pyx_v_rend); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = PyInt_FromLong(__pyx_v_rend); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 945; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
-        if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__end), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__end), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 
-        /* "csamtools.pyx":976
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":946
  *                                                  start = rstart,
  *                                                  end = rend,
  *                                                  **kwargs )             # <<<<<<<<<<<<<<
  *                 else:
  *                     return IteratorColumnAllRefs(self, **kwargs )
  */
-        if (PyDict_Update(((PyObject *)__pyx_t_5), ((PyObject *)__pyx_v_kwargs)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __pyx_t_6 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorColumnRegion)), ((PyObject *)__pyx_t_7), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        if (PyDict_Update(((PyObject *)__pyx_t_5), ((PyObject *)__pyx_v_kwargs)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorColumnRegion)), __pyx_t_7, ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 942; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
-        __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
         __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
         __pyx_r = __pyx_t_6;
         __pyx_t_6 = 0;
@@ -9864,7 +10012,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_13pileup(PyObject *__pyx_v_self, P
       }
       /*else*/ {
 
-        /* "csamtools.pyx":978
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":948
  *                                                  **kwargs )
  *                 else:
  *                     return IteratorColumnAllRefs(self, **kwargs )             # <<<<<<<<<<<<<<
@@ -9872,14 +10020,14 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_13pileup(PyObject *__pyx_v_self, P
  *         else:
  */
         __Pyx_XDECREF(__pyx_r);
-        __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(((PyObject *)__pyx_t_6));
+        __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_6);
         __Pyx_INCREF(__pyx_v_self);
         PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_self);
         __Pyx_GIVEREF(__pyx_v_self);
-        __pyx_t_5 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorColumnAllRefs)), ((PyObject *)__pyx_t_6), ((PyObject *)__pyx_v_kwargs)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_5 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorColumnAllRefs)), __pyx_t_6, ((PyObject *)__pyx_v_kwargs)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_5);
-        __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
         __pyx_r = __pyx_t_5;
         __pyx_t_5 = 0;
         goto __pyx_L0;
@@ -9891,18 +10039,24 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_13pileup(PyObject *__pyx_v_self, P
   }
   /*else*/ {
 
-    /* "csamtools.pyx":981
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":951
  * 
  *         else:
  *             raise NotImplementedError( "pileup of samfiles not implemented yet" )             # <<<<<<<<<<<<<<
  * 
  *     def close( self ):
  */
-    __pyx_t_5 = PyObject_Call(__pyx_builtin_NotImplementedError, ((PyObject *)__pyx_k_tuple_75), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 981; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
-    __Pyx_Raise(__pyx_t_5, 0, 0);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_43));
+    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_43));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_43));
+    __pyx_t_6 = PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 981; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_Raise(__pyx_t_6, 0, 0);
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   __pyx_L7:;
 
@@ -9925,7 +10079,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_13pileup(PyObject *__pyx_v_self, P
   return __pyx_r;
 }
 
-/* "csamtools.pyx":983
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":953
  *             raise NotImplementedError( "pileup of samfiles not implemented yet" )
  * 
  *     def close( self ):             # <<<<<<<<<<<<<<
@@ -9933,16 +10087,16 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_13pileup(PyObject *__pyx_v_self, P
  *         closes the :class:`pysam.Samfile`.'''
  */
 
-static PyObject *__pyx_pf_9csamtools_7Samfile_14close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_9csamtools_7Samfile_14close[] = "Samfile.close(self)\n\n        closes the :class:`pysam.Samfile`.";
-static PyObject *__pyx_pf_9csamtools_7Samfile_14close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+static PyObject *__pyx_pf_9csamtools_7Samfile_close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static char __pyx_doc_9csamtools_7Samfile_close[] = "Samfile.close(self)\n\n        closes the :class:`pysam.Samfile`.";
+static PyObject *__pyx_pf_9csamtools_7Samfile_close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
   PyObject *__pyx_r = NULL;
   int __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("close");
-  __Pyx_TraceCall("close", __pyx_f[0], 983);
+  __Pyx_TraceCall("close", __pyx_f[0], 953);
 
-  /* "csamtools.pyx":986
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":956
  *         '''
  *         closes the :class:`pysam.Samfile`.'''
  *         if self.samfile != NULL:             # <<<<<<<<<<<<<<
@@ -9952,7 +10106,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_14close(PyObject *__pyx_v_self, CY
   __pyx_t_1 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile != NULL);
   if (__pyx_t_1) {
 
-    /* "csamtools.pyx":987
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":957
  *         closes the :class:`pysam.Samfile`.'''
  *         if self.samfile != NULL:
  *             samclose( self.samfile )             # <<<<<<<<<<<<<<
@@ -9961,7 +10115,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_14close(PyObject *__pyx_v_self, CY
  */
     samclose(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile);
 
-    /* "csamtools.pyx":988
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":958
  *         if self.samfile != NULL:
  *             samclose( self.samfile )
  *             bam_index_destroy(self.index);             # <<<<<<<<<<<<<<
@@ -9970,7 +10124,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_14close(PyObject *__pyx_v_self, CY
  */
     bam_index_destroy(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index);
 
-    /* "csamtools.pyx":989
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":959
  *             samclose( self.samfile )
  *             bam_index_destroy(self.index);
  *             self.samfile = NULL             # <<<<<<<<<<<<<<
@@ -9989,7 +10143,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_14close(PyObject *__pyx_v_self, CY
   return __pyx_r;
 }
 
-/* "csamtools.pyx":991
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":961
  *             self.samfile = NULL
  * 
  *     def __dealloc__( self ):             # <<<<<<<<<<<<<<
@@ -9997,30 +10151,30 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_14close(PyObject *__pyx_v_self, CY
  *         # note: no doc string
  */
 
-static void __pyx_pf_9csamtools_7Samfile_15__dealloc__(PyObject *__pyx_v_self); /*proto*/
-static void __pyx_pf_9csamtools_7Samfile_15__dealloc__(PyObject *__pyx_v_self) {
+static void __pyx_pf_9csamtools_7Samfile___dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_pf_9csamtools_7Samfile___dealloc__(PyObject *__pyx_v_self) {
   PyObject *__pyx_t_1 = NULL;
   PyObject *__pyx_t_2 = NULL;
   int __pyx_t_3;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__dealloc__");
-  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 991);
+  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 961);
 
-  /* "csamtools.pyx":995
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":965
  *         # note: no doc string
  *         # note: __del__ is not called.
  *         self.close()             # <<<<<<<<<<<<<<
  *         bam_destroy1(self.b)
  *         if self._filename != NULL: free( self._filename )
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__close); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__close); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-  /* "csamtools.pyx":996
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":966
  *         # note: __del__ is not called.
  *         self.close()
  *         bam_destroy1(self.b)             # <<<<<<<<<<<<<<
@@ -10029,7 +10183,7 @@ static void __pyx_pf_9csamtools_7Samfile_15__dealloc__(PyObject *__pyx_v_self) {
  */
   bam_destroy1(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->b);
 
-  /* "csamtools.pyx":997
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":967
  *         self.close()
  *         bam_destroy1(self.b)
  *         if self._filename != NULL: free( self._filename )             # <<<<<<<<<<<<<<
@@ -10053,7 +10207,7 @@ static void __pyx_pf_9csamtools_7Samfile_15__dealloc__(PyObject *__pyx_v_self) {
   __Pyx_RefNannyFinishContext();
 }
 
-/* "csamtools.pyx":999
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":969
  *         if self._filename != NULL: free( self._filename )
  * 
  *     cpdef int write( self, AlignedRead read ) except -1:             # <<<<<<<<<<<<<<
@@ -10061,7 +10215,7 @@ static void __pyx_pf_9csamtools_7Samfile_15__dealloc__(PyObject *__pyx_v_self) {
  *         write a single :class:`pysam.AlignedRead` to disk.
  */
 
-static PyObject *__pyx_pf_9csamtools_7Samfile_16write(PyObject *__pyx_v_self, PyObject *__pyx_v_read); /*proto*/
+static PyObject *__pyx_pf_9csamtools_7Samfile_write(PyObject *__pyx_v_self, PyObject *__pyx_v_read); /*proto*/
 static  int __pyx_f_9csamtools_7Samfile_write(struct __pyx_obj_9csamtools_Samfile *__pyx_v_self, struct __pyx_obj_9csamtools_AlignedRead *__pyx_v_read, int __pyx_skip_dispatch) {
   int __pyx_r;
   PyObject *__pyx_t_1 = NULL;
@@ -10072,23 +10226,23 @@ static  int __pyx_f_9csamtools_7Samfile_write(struct __pyx_obj_9csamtools_Samfil
   int __pyx_t_6;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("write");
-  __Pyx_TraceCall("write", __pyx_f[0], 999);
+  __Pyx_TraceCall("write", __pyx_f[0], 969);
   /* Check if called by wrapper */
   if (unlikely(__pyx_skip_dispatch)) ;
   /* Check if overriden in Python */
   else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
-    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__write); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 999; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__write); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 969; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_9csamtools_7Samfile_16write)) {
-      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 999; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+    if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_9csamtools_7Samfile_write)) {
+      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 969; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
       __Pyx_INCREF(((PyObject *)__pyx_v_read));
       PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_read));
       __Pyx_GIVEREF(((PyObject *)__pyx_v_read));
-      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 999; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 969; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
-      __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
-      __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 999; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 969; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
       __pyx_r = __pyx_t_4;
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
@@ -10097,24 +10251,24 @@ static  int __pyx_f_9csamtools_7Samfile_write(struct __pyx_obj_9csamtools_Samfil
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   }
 
-  /* "csamtools.pyx":1005
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":975
  *         returns the number of bytes written.
  *         '''
  *         if not self._isOpen():             # <<<<<<<<<<<<<<
  *             return 0
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   __pyx_t_6 = (!__pyx_t_5);
   if (__pyx_t_6) {
 
-    /* "csamtools.pyx":1006
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":976
  *         '''
  *         if not self._isOpen():
  *             return 0             # <<<<<<<<<<<<<<
@@ -10127,7 +10281,7 @@ static  int __pyx_f_9csamtools_7Samfile_write(struct __pyx_obj_9csamtools_Samfil
   }
   __pyx_L3:;
 
-  /* "csamtools.pyx":1008
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":978
  *             return 0
  * 
  *         return samwrite( self.samfile, read._delegate )             # <<<<<<<<<<<<<<
@@ -10151,7 +10305,7 @@ static  int __pyx_f_9csamtools_7Samfile_write(struct __pyx_obj_9csamtools_Samfil
   return __pyx_r;
 }
 
-/* "csamtools.pyx":999
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":969
  *         if self._filename != NULL: free( self._filename )
  * 
  *     cpdef int write( self, AlignedRead read ) except -1:             # <<<<<<<<<<<<<<
@@ -10159,17 +10313,17 @@ static  int __pyx_f_9csamtools_7Samfile_write(struct __pyx_obj_9csamtools_Samfil
  *         write a single :class:`pysam.AlignedRead` to disk.
  */
 
-static PyObject *__pyx_pf_9csamtools_7Samfile_16write(PyObject *__pyx_v_self, PyObject *__pyx_v_read); /*proto*/
-static char __pyx_doc_9csamtools_7Samfile_16write[] = "Samfile.write(self, AlignedRead read) -> int\n\n        write a single :class:`pysam.AlignedRead` to disk.\n\n        returns the number of bytes written.\n        ";
-static PyObject *__pyx_pf_9csamtools_7Samfile_16write(PyObject *__pyx_v_self, PyObject *__pyx_v_read) {
+static PyObject *__pyx_pf_9csamtools_7Samfile_write(PyObject *__pyx_v_self, PyObject *__pyx_v_read); /*proto*/
+static char __pyx_doc_9csamtools_7Samfile_write[] = "Samfile.write(self, AlignedRead read) -> int\n\n        write a single :class:`pysam.AlignedRead` to disk.\n\n        returns the number of bytes written.\n        ";
+static PyObject *__pyx_pf_9csamtools_7Samfile_write(PyObject *__pyx_v_self, PyObject *__pyx_v_read) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("write");
-  __Pyx_TraceCall("write", __pyx_f[0], 999);
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_read), __pyx_ptype_9csamtools_AlignedRead, 1, "read", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 999; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("write", __pyx_f[0], 969);
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_read), __pyx_ptype_9csamtools_AlignedRead, 1, "read", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 969; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_vtabstruct_9csamtools_Samfile *)((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->__pyx_vtab)->write(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self), ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_read), 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 999; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_vtabstruct_9csamtools_Samfile *)((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->__pyx_vtab)->write(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self), ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_read), 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 969; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -10188,7 +10342,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_16write(PyObject *__pyx_v_self, Py
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1010
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":980
  *         return samwrite( self.samfile, read._delegate )
  * 
  *     def __enter__(self):             # <<<<<<<<<<<<<<
@@ -10196,15 +10350,15 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_16write(PyObject *__pyx_v_self, Py
  * 
  */
 
-static PyObject *__pyx_pf_9csamtools_7Samfile_17__enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_9csamtools_7Samfile_17__enter__[] = "Samfile.__enter__(self)";
-static PyObject *__pyx_pf_9csamtools_7Samfile_17__enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+static PyObject *__pyx_pf_9csamtools_7Samfile___enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static char __pyx_doc_9csamtools_7Samfile___enter__[] = "Samfile.__enter__(self)";
+static PyObject *__pyx_pf_9csamtools_7Samfile___enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
   PyObject *__pyx_r = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__enter__");
-  __Pyx_TraceCall("__enter__", __pyx_f[0], 1010);
+  __Pyx_TraceCall("__enter__", __pyx_f[0], 980);
 
-  /* "csamtools.pyx":1011
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":981
  * 
  *     def __enter__(self):
  *         return self             # <<<<<<<<<<<<<<
@@ -10224,7 +10378,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_17__enter__(PyObject *__pyx_v_self
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1013
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":983
  *         return self
  * 
  *     def __exit__(self, exc_type, exc_value, traceback):             # <<<<<<<<<<<<<<
@@ -10232,9 +10386,9 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_17__enter__(PyObject *__pyx_v_self
  *         return False
  */
 
-static PyObject *__pyx_pf_9csamtools_7Samfile_18__exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_9csamtools_7Samfile_18__exit__[] = "Samfile.__exit__(self, exc_type, exc_value, traceback)";
-static PyObject *__pyx_pf_9csamtools_7Samfile_18__exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+static PyObject *__pyx_pf_9csamtools_7Samfile___exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_9csamtools_7Samfile___exit__[] = "Samfile.__exit__(self, exc_type, exc_value, traceback)";
+static PyObject *__pyx_pf_9csamtools_7Samfile___exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   PyObject *__pyx_v_exc_type = 0;
   PyObject *__pyx_v_exc_value = 0;
   PyObject *__pyx_v_traceback = 0;
@@ -10244,7 +10398,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_18__exit__(PyObject *__pyx_v_self,
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__exc_type,&__pyx_n_s__exc_value,&__pyx_n_s__traceback,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__exit__");
-  __Pyx_TraceCall("__exit__", __pyx_f[0], 1013);
+  __Pyx_TraceCall("__exit__", __pyx_f[0], 983);
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[3] = {0,0,0};
@@ -10264,17 +10418,17 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_18__exit__(PyObject *__pyx_v_self,
       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__exc_value);
       if (likely(values[1])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1013; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 983; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
       case  2:
       values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__traceback);
       if (likely(values[2])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1013; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 983; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__exit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1013; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__exit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 983; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_exc_type = values[0];
     __pyx_v_exc_value = values[1];
@@ -10288,28 +10442,28 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_18__exit__(PyObject *__pyx_v_self,
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1013; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 983; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("csamtools.Samfile.__exit__");
   __Pyx_RefNannyFinishContext();
   return NULL;
   __pyx_L4_argument_unpacking_done:;
 
-  /* "csamtools.pyx":1014
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":984
  * 
  *     def __exit__(self, exc_type, exc_value, traceback):
  *         self.close()             # <<<<<<<<<<<<<<
  *         return False
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__close); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1014; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__close); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1014; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-  /* "csamtools.pyx":1015
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":985
  *     def __exit__(self, exc_type, exc_value, traceback):
  *         self.close()
  *         return False             # <<<<<<<<<<<<<<
@@ -10317,7 +10471,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_18__exit__(PyObject *__pyx_v_self,
  *     ###############################################################
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1015; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
@@ -10337,7 +10491,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_18__exit__(PyObject *__pyx_v_self,
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1024
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":994
  *     property filename:
  *         '''number of :term:`filename` associated with this object.'''
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -10354,34 +10508,40 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_8filename___get__(PyObject *__pyx_
   int __pyx_t_4;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 1024);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 994);
 
-  /* "csamtools.pyx":1025
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":995
  *         '''number of :term:`filename` associated with this object.'''
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *             return self._filename
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_76), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_Raise(__pyx_t_2, 0, 0);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_Raise(__pyx_t_1, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":1026
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":996
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *             return self._filename             # <<<<<<<<<<<<<<
@@ -10389,10 +10549,10 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_8filename___get__(PyObject *__pyx_
  *     property nreferences:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = PyBytes_FromString(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->_filename); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-  __pyx_r = ((PyObject *)__pyx_t_2);
-  __pyx_t_2 = 0;
+  __pyx_t_1 = PyBytes_FromString(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->_filename); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 996; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  __pyx_r = ((PyObject *)__pyx_t_1);
+  __pyx_t_1 = 0;
   goto __pyx_L0;
 
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
@@ -10409,7 +10569,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_8filename___get__(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1030
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1000
  *     property nreferences:
  *         '''number of :term:`reference` sequences in the file.'''
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -10426,34 +10586,40 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_11nreferences___get__(PyObject *__
   int __pyx_t_4;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 1030);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 1000);
 
-  /* "csamtools.pyx":1031
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1001
  *         '''number of :term:`reference` sequences in the file.'''
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *             return self.samfile.header.n_targets
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_77), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_Raise(__pyx_t_2, 0, 0);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_Raise(__pyx_t_1, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":1032
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1002
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *             return self.samfile.header.n_targets             # <<<<<<<<<<<<<<
@@ -10461,10 +10627,10 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_11nreferences___get__(PyObject *__
  *     property references:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->n_targets); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __pyx_r = __pyx_t_2;
-  __pyx_t_2 = 0;
+  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->n_targets); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1002; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
   goto __pyx_L0;
 
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
@@ -10481,7 +10647,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_11nreferences___get__(PyObject *__
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1036
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1006
  *     property references:
  *         """tuple with the names of :term:`reference` sequences."""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -10502,48 +10668,54 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_10references___get__(PyObject *__p
   int __pyx_t_6;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 1036);
-  __pyx_v_t = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 1006);
+  __pyx_v_t = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
 
-  /* "csamtools.pyx":1037
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1007
  *         """tuple with the names of :term:`reference` sequences."""
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *             t = []
  *             for x from 0 <= x < self.samfile.header.n_targets:
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1037; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1037; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1037; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_78), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1037; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_Raise(__pyx_t_2, 0, 0);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1037; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_Raise(__pyx_t_1, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":1038
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1008
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *             t = []             # <<<<<<<<<<<<<<
  *             for x from 0 <= x < self.samfile.header.n_targets:
  *                 t.append( self.samfile.header.target_name[x] )
  */
-  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1038; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1008; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
   __Pyx_DECREF(((PyObject *)__pyx_v_t));
-  __pyx_v_t = __pyx_t_2;
-  __pyx_t_2 = 0;
+  __pyx_v_t = __pyx_t_1;
+  __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":1039
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1009
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *             t = []
  *             for x from 0 <= x < self.samfile.header.n_targets:             # <<<<<<<<<<<<<<
@@ -10553,7 +10725,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_10references___get__(PyObject *__p
   __pyx_t_5 = ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->n_targets;
   for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_5; __pyx_v_x++) {
 
-    /* "csamtools.pyx":1040
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1010
  *             t = []
  *             for x from 0 <= x < self.samfile.header.n_targets:
  *                 t.append( self.samfile.header.target_name[x] )             # <<<<<<<<<<<<<<
@@ -10561,15 +10733,15 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_10references___get__(PyObject *__p
  * 
  */
     if (unlikely(__pyx_v_t == Py_None)) {
-      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1010; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
     }
-    __pyx_t_2 = PyBytes_FromString((((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->target_name[__pyx_v_x])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-    __pyx_t_6 = PyList_Append(__pyx_v_t, ((PyObject *)__pyx_t_2)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+    __pyx_t_1 = PyBytes_FromString((((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->target_name[__pyx_v_x])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+    __pyx_t_6 = PyList_Append(((PyObject *)__pyx_v_t), ((PyObject *)__pyx_t_1)); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
   }
 
-  /* "csamtools.pyx":1041
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1011
  *             for x from 0 <= x < self.samfile.header.n_targets:
  *                 t.append( self.samfile.header.target_name[x] )
  *             return tuple(t)             # <<<<<<<<<<<<<<
@@ -10578,12 +10750,12 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_10references___get__(PyObject *__p
  */
   __Pyx_XDECREF(__pyx_r);
   if (unlikely(__pyx_v_t == Py_None)) {
-    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1041; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
   }
-  __pyx_t_2 = ((PyObject *)PyList_AsTuple(__pyx_v_t)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-  __pyx_r = ((PyObject *)__pyx_t_2);
-  __pyx_t_2 = 0;
+  __pyx_t_1 = ((PyObject *)PyList_AsTuple(__pyx_v_t)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  __pyx_r = ((PyObject *)__pyx_t_1);
+  __pyx_t_1 = 0;
   goto __pyx_L0;
 
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
@@ -10601,7 +10773,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_10references___get__(PyObject *__p
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1047
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1017
  *         :attr:`pysam.Samfile.references`
  *         """
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -10622,48 +10794,54 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_7lengths___get__(PyObject *__pyx_v
   int __pyx_t_6;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 1047);
-  __pyx_v_t = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 1017);
+  __pyx_v_t = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
 
-  /* "csamtools.pyx":1048
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1018
  *         """
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *             t = []
  *             for x from 0 <= x < self.samfile.header.n_targets:
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_79), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_Raise(__pyx_t_2, 0, 0);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_Raise(__pyx_t_1, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":1049
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1019
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *             t = []             # <<<<<<<<<<<<<<
  *             for x from 0 <= x < self.samfile.header.n_targets:
  *                 t.append( self.samfile.header.target_len[x] )
  */
-  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1049; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1019; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
   __Pyx_DECREF(((PyObject *)__pyx_v_t));
-  __pyx_v_t = __pyx_t_2;
-  __pyx_t_2 = 0;
+  __pyx_v_t = __pyx_t_1;
+  __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":1050
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1020
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *             t = []
  *             for x from 0 <= x < self.samfile.header.n_targets:             # <<<<<<<<<<<<<<
@@ -10673,7 +10851,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_7lengths___get__(PyObject *__pyx_v
   __pyx_t_5 = ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->n_targets;
   for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_5; __pyx_v_x++) {
 
-    /* "csamtools.pyx":1051
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1021
  *             t = []
  *             for x from 0 <= x < self.samfile.header.n_targets:
  *                 t.append( self.samfile.header.target_len[x] )             # <<<<<<<<<<<<<<
@@ -10681,29 +10859,29 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_7lengths___get__(PyObject *__pyx_v
  * 
  */
     if (unlikely(__pyx_v_t == Py_None)) {
-      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1051; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1021; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
     }
-    __pyx_t_2 = __Pyx_PyInt_to_py_uint32_t((((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->target_len[__pyx_v_x])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_6 = PyList_Append(__pyx_v_t, __pyx_t_2); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t((((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->target_len[__pyx_v_x])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_6 = PyList_Append(((PyObject *)__pyx_v_t), __pyx_t_1); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   }
 
-  /* "csamtools.pyx":1052
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1022
  *             for x from 0 <= x < self.samfile.header.n_targets:
  *                 t.append( self.samfile.header.target_len[x] )
  *             return tuple(t)             # <<<<<<<<<<<<<<
  * 
- *     property mapped:
+ *     property text:
  */
   __Pyx_XDECREF(__pyx_r);
   if (unlikely(__pyx_v_t == Py_None)) {
-    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1052; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
   }
-  __pyx_t_2 = ((PyObject *)PyList_AsTuple(__pyx_v_t)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-  __pyx_r = ((PyObject *)__pyx_t_2);
-  __pyx_t_2 = 0;
+  __pyx_t_1 = ((PyObject *)PyList_AsTuple(__pyx_v_t)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  __pyx_r = ((PyObject *)__pyx_t_1);
+  __pyx_t_1 = 0;
   goto __pyx_L0;
 
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
@@ -10721,315 +10899,68 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_7lengths___get__(PyObject *__pyx_v
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1057
- *         """total number of mapped reads in file.
- *         """
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1026
+ *     property text:
+ *         '''full contents of the :term:`sam file` header as a string.'''
  *         def __get__(self):             # <<<<<<<<<<<<<<
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
- *             if not self.isbam: raise AttributeError( "Samfile.mapped only available in bam files" )
+ *             return PyString_FromStringAndSize(self.samfile.header.text, self.samfile.header.l_text)
  */
 
-static PyObject *__pyx_pf_9csamtools_7Samfile_6mapped___get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_9csamtools_7Samfile_6mapped___get__(PyObject *__pyx_v_self) {
-  int __pyx_v_tid;
-  uint32_t __pyx_v_total;
+static PyObject *__pyx_pf_9csamtools_7Samfile_4text___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_7Samfile_4text___get__(PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   PyObject *__pyx_t_2 = NULL;
   int __pyx_t_3;
   int __pyx_t_4;
-  int32_t __pyx_t_5;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 1057);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 1026);
 
-  /* "csamtools.pyx":1058
- *         """
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1027
+ *         '''full contents of the :term:`sam file` header as a string.'''
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
- *             if not self.isbam: raise AttributeError( "Samfile.mapped only available in bam files" )
+ *             return PyString_FromStringAndSize(self.samfile.header.text, self.samfile.header.l_text)
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_80), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_Raise(__pyx_t_2, 0, 0);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_Raise(__pyx_t_1, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":1059
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1028
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
- *             if not self.isbam: raise AttributeError( "Samfile.mapped only available in bam files" )             # <<<<<<<<<<<<<<
- * 
- *             cdef int tid
- */
-  __pyx_t_4 = (!((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam);
-  if (__pyx_t_4) {
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_AttributeError, ((PyObject *)__pyx_k_tuple_82), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_Raise(__pyx_t_2, 0, 0);
-    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    goto __pyx_L6;
-  }
-  __pyx_L6:;
-
-  /* "csamtools.pyx":1062
- * 
- *             cdef int tid
- *             cdef uint32_t total = 0             # <<<<<<<<<<<<<<
- *             for tid from 0 <= tid < self.samfile.header.n_targets:
- *                 total += pysam_get_mapped( self.index, tid )
- */
-  __pyx_v_total = 0;
-
-  /* "csamtools.pyx":1063
- *             cdef int tid
- *             cdef uint32_t total = 0
- *             for tid from 0 <= tid < self.samfile.header.n_targets:             # <<<<<<<<<<<<<<
- *                 total += pysam_get_mapped( self.index, tid )
- *             return total
- */
-  __pyx_t_5 = ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->n_targets;
-  for (__pyx_v_tid = 0; __pyx_v_tid < __pyx_t_5; __pyx_v_tid++) {
-
-    /* "csamtools.pyx":1064
- *             cdef uint32_t total = 0
- *             for tid from 0 <= tid < self.samfile.header.n_targets:
- *                 total += pysam_get_mapped( self.index, tid )             # <<<<<<<<<<<<<<
- *             return total
- * 
- */
-    __pyx_v_total = (__pyx_v_total + pysam_get_mapped(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index, __pyx_v_tid));
-  }
-
-  /* "csamtools.pyx":1065
- *             for tid from 0 <= tid < self.samfile.header.n_targets:
- *                 total += pysam_get_mapped( self.index, tid )
- *             return total             # <<<<<<<<<<<<<<
+ *             return PyString_FromStringAndSize(self.samfile.header.text, self.samfile.header.l_text)             # <<<<<<<<<<<<<<
  * 
- *     property unmapped:
+ *     property header:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_total); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1065; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __pyx_r = __pyx_t_2;
-  __pyx_t_2 = 0;
-  goto __pyx_L0;
-
-  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_XDECREF(__pyx_t_1);
-  __Pyx_XDECREF(__pyx_t_2);
-  __Pyx_AddTraceback("csamtools.Samfile.mapped.__get__");
-  __pyx_r = NULL;
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_TraceReturn(__pyx_r);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "csamtools.pyx":1070
- *         """total number of unmapped reads in file.
- *         """
- *         def __get__(self):             # <<<<<<<<<<<<<<
- *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
- *             if not self.isbam: raise AttributeError( "Samfile.unmapped only available in bam files" )
- */
-
-static PyObject *__pyx_pf_9csamtools_7Samfile_8unmapped___get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_9csamtools_7Samfile_8unmapped___get__(PyObject *__pyx_v_self) {
-  int __pyx_v_tid;
-  uint32_t __pyx_v_total;
-  PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
-  PyObject *__pyx_t_2 = NULL;
-  int __pyx_t_3;
-  int __pyx_t_4;
-  int32_t __pyx_t_5;
-  __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 1070);
-
-  /* "csamtools.pyx":1071
- *         """
- *         def __get__(self):
- *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
- *             if not self.isbam: raise AttributeError( "Samfile.unmapped only available in bam files" )
- *             cdef int tid
- */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_4 = (!__pyx_t_3);
-  if (__pyx_t_4) {
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_83), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_Raise(__pyx_t_2, 0, 0);
-    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    goto __pyx_L5;
-  }
-  __pyx_L5:;
-
-  /* "csamtools.pyx":1072
- *         def __get__(self):
- *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
- *             if not self.isbam: raise AttributeError( "Samfile.unmapped only available in bam files" )             # <<<<<<<<<<<<<<
- *             cdef int tid
- *             cdef uint32_t total = 0
- */
-  __pyx_t_4 = (!((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam);
-  if (__pyx_t_4) {
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_AttributeError, ((PyObject *)__pyx_k_tuple_85), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_Raise(__pyx_t_2, 0, 0);
-    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    goto __pyx_L6;
-  }
-  __pyx_L6:;
-
-  /* "csamtools.pyx":1074
- *             if not self.isbam: raise AttributeError( "Samfile.unmapped only available in bam files" )
- *             cdef int tid
- *             cdef uint32_t total = 0             # <<<<<<<<<<<<<<
- *             for tid from 0 <= tid < self.samfile.header.n_targets:
- *                 total += pysam_get_unmapped( self.index, tid )
- */
-  __pyx_v_total = 0;
-
-  /* "csamtools.pyx":1075
- *             cdef int tid
- *             cdef uint32_t total = 0
- *             for tid from 0 <= tid < self.samfile.header.n_targets:             # <<<<<<<<<<<<<<
- *                 total += pysam_get_unmapped( self.index, tid )
- *             # get unmapped reads without coordinates
- */
-  __pyx_t_5 = ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->n_targets;
-  for (__pyx_v_tid = 0; __pyx_v_tid < __pyx_t_5; __pyx_v_tid++) {
-
-    /* "csamtools.pyx":1076
- *             cdef uint32_t total = 0
- *             for tid from 0 <= tid < self.samfile.header.n_targets:
- *                 total += pysam_get_unmapped( self.index, tid )             # <<<<<<<<<<<<<<
- *             # get unmapped reads without coordinates
- *             total += pysam_get_unmapped( self.index, -1 )
- */
-    __pyx_v_total = (__pyx_v_total + pysam_get_unmapped(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index, __pyx_v_tid));
-  }
-
-  /* "csamtools.pyx":1078
- *                 total += pysam_get_unmapped( self.index, tid )
- *             # get unmapped reads without coordinates
- *             total += pysam_get_unmapped( self.index, -1 )             # <<<<<<<<<<<<<<
- *             return total
- * 
- */
-  __pyx_v_total = (__pyx_v_total + pysam_get_unmapped(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index, -1));
-
-  /* "csamtools.pyx":1079
- *             # get unmapped reads without coordinates
- *             total += pysam_get_unmapped( self.index, -1 )
- *             return total             # <<<<<<<<<<<<<<
- * 
- *     property text:
- */
-  __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_total); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __pyx_r = __pyx_t_2;
-  __pyx_t_2 = 0;
-  goto __pyx_L0;
-
-  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_XDECREF(__pyx_t_1);
-  __Pyx_XDECREF(__pyx_t_2);
-  __Pyx_AddTraceback("csamtools.Samfile.unmapped.__get__");
-  __pyx_r = NULL;
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_TraceReturn(__pyx_r);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "csamtools.pyx":1083
- *     property text:
- *         '''full contents of the :term:`sam file` header as a string.'''
- *         def __get__(self):             # <<<<<<<<<<<<<<
- *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
- *             return PyString_FromStringAndSize(self.samfile.header.text, self.samfile.header.l_text)
- */
-
-static PyObject *__pyx_pf_9csamtools_7Samfile_4text___get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_9csamtools_7Samfile_4text___get__(PyObject *__pyx_v_self) {
-  PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
-  PyObject *__pyx_t_2 = NULL;
-  int __pyx_t_3;
-  int __pyx_t_4;
-  __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 1083);
-
-  /* "csamtools.pyx":1084
- *         '''full contents of the :term:`sam file` header as a string.'''
- *         def __get__(self):
- *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
- *             return PyString_FromStringAndSize(self.samfile.header.text, self.samfile.header.l_text)
- * 
- */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyString_FromStringAndSize(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->text, ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->l_text); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1028; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_4 = (!__pyx_t_3);
-  if (__pyx_t_4) {
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_86), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_Raise(__pyx_t_2, 0, 0);
-    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    goto __pyx_L5;
-  }
-  __pyx_L5:;
-
-  /* "csamtools.pyx":1085
- *         def __get__(self):
- *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
- *             return PyString_FromStringAndSize(self.samfile.header.text, self.samfile.header.l_text)             # <<<<<<<<<<<<<<
- * 
- *     property header:
- */
-  __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = PyString_FromStringAndSize(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->text, ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->l_text); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __pyx_r = __pyx_t_2;
-  __pyx_t_2 = 0;
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
   goto __pyx_L0;
 
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
@@ -11046,7 +10977,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_4text___get__(PyObject *__pyx_v_se
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1091
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1034
  *         a two-level dictionary.
  *         '''
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -11078,56 +11009,62 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6header___get__(PyObject *__pyx_v_
   PyObject *__pyx_t_10 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 1091);
-  __pyx_v_result = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 1034);
+  __pyx_v_result = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
   __pyx_v_t = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_line = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_fields = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_record = Py_None; __Pyx_INCREF(Py_None);
-  __pyx_v_x = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
+  __pyx_v_x = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
   __pyx_v_field = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_key = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_value = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "csamtools.pyx":1092
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1035
  *         '''
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  * 
  *             result = {}
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_87), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_Raise(__pyx_t_2, 0, 0);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_Raise(__pyx_t_1, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":1094
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1037
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  * 
  *             result = {}             # <<<<<<<<<<<<<<
  * 
  *             if self.samfile.header.text != NULL:
  */
-  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1094; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1037; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
   __Pyx_DECREF(((PyObject *)__pyx_v_result));
-  __pyx_v_result = __pyx_t_2;
-  __pyx_t_2 = 0;
+  __pyx_v_result = __pyx_t_1;
+  __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":1096
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1039
  *             result = {}
  * 
  *             if self.samfile.header.text != NULL:             # <<<<<<<<<<<<<<
@@ -11137,71 +11074,77 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6header___get__(PyObject *__pyx_v_
   __pyx_t_4 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->text != NULL);
   if (__pyx_t_4) {
 
-    /* "csamtools.pyx":1098
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1041
  *             if self.samfile.header.text != NULL:
  *                 # convert to python string (note: call self.text to create 0-terminated string)
  *                 t = self.text             # <<<<<<<<<<<<<<
  *                 for line in t.split("\n"):
  *                     if not line.strip(): continue
  */
-    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__text); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__text); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_v_t);
-    __pyx_v_t = __pyx_t_2;
-    __pyx_t_2 = 0;
+    __pyx_v_t = __pyx_t_1;
+    __pyx_t_1 = 0;
 
-    /* "csamtools.pyx":1099
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1042
  *                 # convert to python string (note: call self.text to create 0-terminated string)
  *                 t = self.text
  *                 for line in t.split("\n"):             # <<<<<<<<<<<<<<
  *                     if not line.strip(): continue
  *                     assert line.startswith("@"), "header line without '@': '%s'" % line
  */
-    __pyx_t_2 = PyObject_GetAttr(__pyx_v_t, __pyx_n_s__split); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1099; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_88), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1099; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_t, __pyx_n_s__split); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_2));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_2));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_2));
+    __pyx_t_6 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
-      __pyx_t_5 = 0; __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2);
+    if (PyList_CheckExact(__pyx_t_6) || PyTuple_CheckExact(__pyx_t_6)) {
+      __pyx_t_5 = 0; __pyx_t_2 = __pyx_t_6; __Pyx_INCREF(__pyx_t_2);
     } else {
-      __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1099; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
     }
-    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
     for (;;) {
       if (likely(PyList_CheckExact(__pyx_t_2))) {
         if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
-        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++;
+        __pyx_t_6 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_6); __pyx_t_5++;
       } else if (likely(PyTuple_CheckExact(__pyx_t_2))) {
         if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
-        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++;
+        __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_6); __pyx_t_5++;
       } else {
-        __pyx_t_1 = PyIter_Next(__pyx_t_2);
-        if (!__pyx_t_1) {
-          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1099; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = PyIter_Next(__pyx_t_2);
+        if (!__pyx_t_6) {
+          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           break;
         }
-        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_GOTREF(__pyx_t_6);
       }
       __Pyx_DECREF(__pyx_v_line);
-      __pyx_v_line = __pyx_t_1;
-      __pyx_t_1 = 0;
+      __pyx_v_line = __pyx_t_6;
+      __pyx_t_6 = 0;
 
-      /* "csamtools.pyx":1100
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1043
  *                 t = self.text
  *                 for line in t.split("\n"):
  *                     if not line.strip(): continue             # <<<<<<<<<<<<<<
  *                     assert line.startswith("@"), "header line without '@': '%s'" % line
  *                     fields = line[1:].split("\t")
  */
-      __pyx_t_1 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__strip); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_1);
-      __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__strip); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1043; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
-      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1043; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1043; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
       __pyx_t_3 = (!__pyx_t_4);
       if (__pyx_t_3) {
         goto __pyx_L7_continue;
@@ -11209,154 +11152,167 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6header___get__(PyObject *__pyx_v_
       }
       __pyx_L9:;
 
-      /* "csamtools.pyx":1101
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1044
  *                 for line in t.split("\n"):
  *                     if not line.strip(): continue
  *                     assert line.startswith("@"), "header line without '@': '%s'" % line             # <<<<<<<<<<<<<<
  *                     fields = line[1:].split("\t")
  *                     record = fields[0]
  */
-      #ifndef CYTHON_WITHOUT_ASSERTIONS
-      __pyx_t_6 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__startswith); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_6);
-      __pyx_t_1 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_k_tuple_90), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      #ifndef PYREX_WITHOUT_ASSERTIONS
+      __pyx_t_1 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__startswith); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_44));
+      PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_44));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_44));
+      __pyx_t_7 = PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_7);
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
       if (unlikely(!__pyx_t_3)) {
-        __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_91), __pyx_v_line); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-        PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_t_1));
-        __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_45), __pyx_v_line); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(((PyObject *)__pyx_t_7));
+        PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_t_7));
+        __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       }
       #endif
 
-      /* "csamtools.pyx":1102
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1045
  *                     if not line.strip(): continue
  *                     assert line.startswith("@"), "header line without '@': '%s'" % line
  *                     fields = line[1:].split("\t")             # <<<<<<<<<<<<<<
  *                     record = fields[0]
  *                     assert record in VALID_HEADER_TYPES, "header line with invalid type '%s': '%s'" % (record, line)
  */
-      __pyx_t_1 = __Pyx_PySequence_GetSlice(__pyx_v_line, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_1);
-      __pyx_t_6 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__split); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PySequence_GetSlice(__pyx_v_line, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1045; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __pyx_t_6 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__split); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1045; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
-      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-      __pyx_t_1 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_k_tuple_92), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1045; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_1));
+      PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_kp_s_1));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_1));
+      __pyx_t_1 = PyObject_Call(__pyx_t_6, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1045; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
       __Pyx_DECREF(__pyx_v_fields);
       __pyx_v_fields = __pyx_t_1;
       __pyx_t_1 = 0;
 
-      /* "csamtools.pyx":1103
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1046
  *                     assert line.startswith("@"), "header line without '@': '%s'" % line
  *                     fields = line[1:].split("\t")
  *                     record = fields[0]             # <<<<<<<<<<<<<<
  *                     assert record in VALID_HEADER_TYPES, "header line with invalid type '%s': '%s'" % (record, line)
  * 
  */
-      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_fields, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_fields, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1046; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
       __Pyx_DECREF(__pyx_v_record);
       __pyx_v_record = __pyx_t_1;
       __pyx_t_1 = 0;
 
-      /* "csamtools.pyx":1104
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1047
  *                     fields = line[1:].split("\t")
  *                     record = fields[0]
  *                     assert record in VALID_HEADER_TYPES, "header line with invalid type '%s': '%s'" % (record, line)             # <<<<<<<<<<<<<<
  * 
  *                     # treat comments
  */
-      #ifndef CYTHON_WITHOUT_ASSERTIONS
-      __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_TYPES); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      #ifndef PYREX_WITHOUT_ASSERTIONS
+      __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_TYPES); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __pyx_t_3 = ((PySequence_Contains(__pyx_t_1, __pyx_v_record))); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = ((PySequence_Contains(__pyx_t_1, __pyx_v_record))); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
       if (unlikely(!__pyx_t_3)) {
-        __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+        __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_1);
         __Pyx_INCREF(__pyx_v_record);
         PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_record);
         __Pyx_GIVEREF(__pyx_v_record);
         __Pyx_INCREF(__pyx_v_line);
         PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_line);
         __Pyx_GIVEREF(__pyx_v_line);
-        __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_93), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(((PyObject *)__pyx_t_6));
-        __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
-        PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_t_6));
-        __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_46), __pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(((PyObject *)__pyx_t_7));
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+        PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_t_7));
+        __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       }
       #endif
 
-      /* "csamtools.pyx":1107
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1050
  * 
  *                     # treat comments
  *                     if record == "CO":             # <<<<<<<<<<<<<<
  *                         if record not in result: result[record] = []
  *                         result[record].append( "\t".join( fields[1:] ) )
  */
-      __pyx_t_6 = PyObject_RichCompare(__pyx_v_record, ((PyObject *)__pyx_n_s__CO), Py_EQ); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_6);
-      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __pyx_t_7 = PyObject_RichCompare(__pyx_v_record, ((PyObject *)__pyx_n_s__CO), Py_EQ); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
       if (__pyx_t_3) {
 
-        /* "csamtools.pyx":1108
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1051
  *                     # treat comments
  *                     if record == "CO":
  *                         if record not in result: result[record] = []             # <<<<<<<<<<<<<<
  *                         result[record].append( "\t".join( fields[1:] ) )
  *                         continue
  */
-        if (unlikely(__pyx_v_result == Py_None)) {
-          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1108; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+        if (unlikely(((PyObject *)__pyx_v_result) == Py_None)) {
+          __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        } else {
+          __pyx_t_3 = (__Pyx_NegateNonNeg(PyDict_Contains(((PyObject *)__pyx_v_result), __pyx_v_record))); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         }
-        __pyx_t_3 = (__Pyx_NegateNonNeg(PyDict_Contains(((PyObject *)__pyx_v_result), __pyx_v_record))); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         if (__pyx_t_3) {
-          __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __Pyx_GOTREF(((PyObject *)__pyx_t_6));
-          if (PyDict_SetItem(((PyObject *)__pyx_v_result), __pyx_v_record, ((PyObject *)__pyx_t_6)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
+          __pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(((PyObject *)__pyx_t_7));
+          if (PyDict_SetItem(((PyObject *)__pyx_v_result), __pyx_v_record, ((PyObject *)__pyx_t_7)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
           goto __pyx_L11;
         }
         __pyx_L11:;
 
-        /* "csamtools.pyx":1109
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1052
  *                     if record == "CO":
  *                         if record not in result: result[record] = []
  *                         result[record].append( "\t".join( fields[1:] ) )             # <<<<<<<<<<<<<<
  *                         continue
  * 
  */
-        __pyx_t_6 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_result), __pyx_v_record); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_6);
-        __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_1), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_1);
-        __pyx_t_7 = __Pyx_PySequence_GetSlice(__pyx_v_fields, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_7);
-        __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(((PyObject *)__pyx_t_8));
-        PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7);
-        __Pyx_GIVEREF(__pyx_t_7);
-        __pyx_t_7 = 0;
-        __pyx_t_7 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_result), __pyx_v_record); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
+        __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_1), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_1);
+        __pyx_t_6 = PySequence_GetSlice(__pyx_v_fields, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_6);
+        __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_8);
+        PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6);
+        __Pyx_GIVEREF(__pyx_t_6);
+        __pyx_t_6 = 0;
+        __pyx_t_6 = PyObject_Call(__pyx_t_1, __pyx_t_8, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_6);
         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-        __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
-        __pyx_t_8 = __Pyx_PyObject_Append(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+        __pyx_t_8 = __Pyx_PyObject_Append(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
-        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
 
-        /* "csamtools.pyx":1110
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1053
  *                         if record not in result: result[record] = []
  *                         result[record].append( "\t".join( fields[1:] ) )
  *                         continue             # <<<<<<<<<<<<<<
@@ -11368,46 +11324,46 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6header___get__(PyObject *__pyx_v_
       }
       __pyx_L10:;
 
-      /* "csamtools.pyx":1113
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1056
  * 
  *                     # the following is clumsy as generators do not work?
  *                     x = {}             # <<<<<<<<<<<<<<
  *                     for field in fields[1:]:
  *                         key, value = field.split(":",1)
  */
-      __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_8));
       __Pyx_DECREF(((PyObject *)__pyx_v_x));
       __pyx_v_x = __pyx_t_8;
       __pyx_t_8 = 0;
 
-      /* "csamtools.pyx":1114
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1057
  *                     # the following is clumsy as generators do not work?
  *                     x = {}
  *                     for field in fields[1:]:             # <<<<<<<<<<<<<<
  *                         key, value = field.split(":",1)
  *                         # uppercase keys must be valid
  */
-      __pyx_t_8 = __Pyx_PySequence_GetSlice(__pyx_v_fields, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = PySequence_GetSlice(__pyx_v_fields, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_8);
       if (PyList_CheckExact(__pyx_t_8) || PyTuple_CheckExact(__pyx_t_8)) {
-        __pyx_t_9 = 0; __pyx_t_7 = __pyx_t_8; __Pyx_INCREF(__pyx_t_7);
+        __pyx_t_9 = 0; __pyx_t_6 = __pyx_t_8; __Pyx_INCREF(__pyx_t_6);
       } else {
-        __pyx_t_9 = -1; __pyx_t_7 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_7);
+        __pyx_t_9 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_6);
       }
       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
       for (;;) {
-        if (likely(PyList_CheckExact(__pyx_t_7))) {
-          if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_7)) break;
-          __pyx_t_8 = PyList_GET_ITEM(__pyx_t_7, __pyx_t_9); __Pyx_INCREF(__pyx_t_8); __pyx_t_9++;
-        } else if (likely(PyTuple_CheckExact(__pyx_t_7))) {
-          if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_7)) break;
-          __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_7, __pyx_t_9); __Pyx_INCREF(__pyx_t_8); __pyx_t_9++;
+        if (likely(PyList_CheckExact(__pyx_t_6))) {
+          if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_6)) break;
+          __pyx_t_8 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_9); __Pyx_INCREF(__pyx_t_8); __pyx_t_9++;
+        } else if (likely(PyTuple_CheckExact(__pyx_t_6))) {
+          if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
+          __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_9); __Pyx_INCREF(__pyx_t_8); __pyx_t_9++;
         } else {
-          __pyx_t_8 = PyIter_Next(__pyx_t_7);
+          __pyx_t_8 = PyIter_Next(__pyx_t_6);
           if (!__pyx_t_8) {
-            if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             break;
           }
           __Pyx_GOTREF(__pyx_t_8);
@@ -11416,274 +11372,285 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6header___get__(PyObject *__pyx_v_
         __pyx_v_field = __pyx_t_8;
         __pyx_t_8 = 0;
 
-        /* "csamtools.pyx":1115
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1058
  *                     x = {}
  *                     for field in fields[1:]:
  *                         key, value = field.split(":",1)             # <<<<<<<<<<<<<<
  *                         # uppercase keys must be valid
  *                         # lowercase are permitted for user fields
  */
-        __pyx_t_8 = PyObject_GetAttr(__pyx_v_field, __pyx_n_s__split); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = PyObject_GetAttr(__pyx_v_field, __pyx_n_s__split); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
-        __pyx_t_6 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_k_tuple_95), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_6);
+        __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_7);
+        __Pyx_INCREF(((PyObject *)__pyx_kp_s_47));
+        PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_kp_s_47));
+        __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_47));
+        __Pyx_INCREF(__pyx_int_1);
+        PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_int_1);
+        __Pyx_GIVEREF(__pyx_int_1);
+        __pyx_t_1 = PyObject_Call(__pyx_t_8, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_1);
         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-        if (PyTuple_CheckExact(__pyx_t_6) && likely(PyTuple_GET_SIZE(__pyx_t_6) == 2)) {
-          PyObject* tuple = __pyx_t_6;
-          __pyx_t_8 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_8);
-          __pyx_t_1 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_1);
-          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+        if (PyTuple_CheckExact(__pyx_t_1) && likely(PyTuple_GET_SIZE(__pyx_t_1) == 2)) {
+          PyObject* tuple = __pyx_t_1;
+          __pyx_t_7 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_7);
+          __pyx_t_8 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_8);
+          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
           __Pyx_DECREF(__pyx_v_key);
-          __pyx_v_key = __pyx_t_8;
-          __pyx_t_8 = 0;
+          __pyx_v_key = __pyx_t_7;
+          __pyx_t_7 = 0;
           __Pyx_DECREF(__pyx_v_value);
-          __pyx_v_value = __pyx_t_1;
-          __pyx_t_1 = 0;
+          __pyx_v_value = __pyx_t_8;
+          __pyx_t_8 = 0;
         } else {
-          __pyx_t_10 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_10 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_10);
-          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-          __pyx_t_8 = __Pyx_UnpackItem(__pyx_t_10, 0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+          __pyx_t_7 = __Pyx_UnpackItem(__pyx_t_10, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_7);
+          __pyx_t_8 = __Pyx_UnpackItem(__pyx_t_10, 1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_8);
-          __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_10, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __Pyx_GOTREF(__pyx_t_1);
-          if (__Pyx_EndUnpack(__pyx_t_10, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          if (__Pyx_EndUnpack(__pyx_t_10, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
           __Pyx_DECREF(__pyx_v_key);
-          __pyx_v_key = __pyx_t_8;
-          __pyx_t_8 = 0;
+          __pyx_v_key = __pyx_t_7;
+          __pyx_t_7 = 0;
           __Pyx_DECREF(__pyx_v_value);
-          __pyx_v_value = __pyx_t_1;
-          __pyx_t_1 = 0;
+          __pyx_v_value = __pyx_t_8;
+          __pyx_t_8 = 0;
         }
 
-        /* "csamtools.pyx":1118
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1061
  *                         # uppercase keys must be valid
  *                         # lowercase are permitted for user fields
  *                         if key in VALID_HEADER_FIELDS[record]:             # <<<<<<<<<<<<<<
  *                             x[key] = VALID_HEADER_FIELDS[record][key](value)
  *                         elif not key.isupper():
  */
-        __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_FIELDS); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_6);
-        __pyx_t_1 = PyObject_GetItem(__pyx_t_6, __pyx_v_record); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_FIELDS); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_1);
-        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-        __pyx_t_3 = ((PySequence_Contains(__pyx_t_1, __pyx_v_key))); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = PyObject_GetItem(__pyx_t_1, __pyx_v_record); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_8);
         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+        __pyx_t_3 = ((PySequence_Contains(__pyx_t_8, __pyx_v_key))); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
         if (__pyx_t_3) {
 
-          /* "csamtools.pyx":1119
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1062
  *                         # lowercase are permitted for user fields
  *                         if key in VALID_HEADER_FIELDS[record]:
  *                             x[key] = VALID_HEADER_FIELDS[record][key](value)             # <<<<<<<<<<<<<<
  *                         elif not key.isupper():
  *                             x[key] = value
  */
-          __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_FIELDS); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_FIELDS); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_8);
+          __pyx_t_1 = PyObject_GetItem(__pyx_t_8, __pyx_v_record); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_1);
-          __pyx_t_6 = PyObject_GetItem(__pyx_t_1, __pyx_v_record); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __Pyx_GOTREF(__pyx_t_6);
+          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+          __pyx_t_8 = PyObject_GetItem(__pyx_t_1, __pyx_v_key); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_8);
           __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-          __pyx_t_1 = PyObject_GetItem(__pyx_t_6, __pyx_v_key); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_1);
-          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-          __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __Pyx_GOTREF(((PyObject *)__pyx_t_6));
           __Pyx_INCREF(__pyx_v_value);
-          PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_value);
+          PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_value);
           __Pyx_GIVEREF(__pyx_v_value);
-          __pyx_t_8 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __Pyx_GOTREF(__pyx_t_8);
-          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-          __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
-          if (PyDict_SetItem(((PyObject *)__pyx_v_x), __pyx_v_key, __pyx_t_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_7 = PyObject_Call(__pyx_t_8, __pyx_t_1, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_7);
           __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+          if (PyDict_SetItem(((PyObject *)__pyx_v_x), __pyx_v_key, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
           goto __pyx_L14;
         }
 
-        /* "csamtools.pyx":1120
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1063
  *                         if key in VALID_HEADER_FIELDS[record]:
  *                             x[key] = VALID_HEADER_FIELDS[record][key](value)
  *                         elif not key.isupper():             # <<<<<<<<<<<<<<
  *                             x[key] = value
  *                         else:
  */
-        __pyx_t_8 = PyObject_GetAttr(__pyx_v_key, __pyx_n_s__isupper); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_8);
-        __pyx_t_6 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_6);
-        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-        __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __pyx_t_7 = PyObject_GetAttr(__pyx_v_key, __pyx_n_s__isupper); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_7);
+        __pyx_t_1 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+        __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
         __pyx_t_4 = (!__pyx_t_3);
         if (__pyx_t_4) {
 
-          /* "csamtools.pyx":1121
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1064
  *                             x[key] = VALID_HEADER_FIELDS[record][key](value)
  *                         elif not key.isupper():
  *                             x[key] = value             # <<<<<<<<<<<<<<
  *                         else:
  *                             raise ValueError( "unknown field code '%s' in record '%s'" % (key, record) )
  */
-          if (PyDict_SetItem(((PyObject *)__pyx_v_x), __pyx_v_key, __pyx_v_value) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          if (PyDict_SetItem(((PyObject *)__pyx_v_x), __pyx_v_key, __pyx_v_value) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           goto __pyx_L14;
         }
         /*else*/ {
 
-          /* "csamtools.pyx":1123
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1066
  *                             x[key] = value
  *                         else:
  *                             raise ValueError( "unknown field code '%s' in record '%s'" % (key, record) )             # <<<<<<<<<<<<<<
  * 
  *                     if VALID_HEADER_TYPES[record] == dict:
  */
-          __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __Pyx_GOTREF(((PyObject *)__pyx_t_6));
+          __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_1);
           __Pyx_INCREF(__pyx_v_key);
-          PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_key);
+          PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_key);
           __Pyx_GIVEREF(__pyx_v_key);
           __Pyx_INCREF(__pyx_v_record);
-          PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_record);
+          PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_record);
           __Pyx_GIVEREF(__pyx_v_record);
-          __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_96), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __Pyx_GOTREF(((PyObject *)__pyx_t_8));
-          __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
-          __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __Pyx_GOTREF(((PyObject *)__pyx_t_6));
-          PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_8));
-          __Pyx_GIVEREF(((PyObject *)__pyx_t_8));
-          __pyx_t_8 = 0;
-          __pyx_t_8 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __Pyx_GOTREF(__pyx_t_8);
-          __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
-          __Pyx_Raise(__pyx_t_8, 0, 0);
-          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_48), __pyx_t_1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(((PyObject *)__pyx_t_7));
+          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+          __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_1);
+          PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_7));
+          __Pyx_GIVEREF(((PyObject *)__pyx_t_7));
+          __pyx_t_7 = 0;
+          __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_7);
+          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+          __Pyx_Raise(__pyx_t_7, 0, 0);
+          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         }
         __pyx_L14:;
       }
-      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 
-      /* "csamtools.pyx":1125
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1068
  *                             raise ValueError( "unknown field code '%s' in record '%s'" % (key, record) )
  * 
  *                     if VALID_HEADER_TYPES[record] == dict:             # <<<<<<<<<<<<<<
  *                         if record in result:
  *                             raise ValueError( "multiple '%s' lines are not permitted" % record )
  */
-      __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_TYPES); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_7);
-      __pyx_t_8 = PyObject_GetItem(__pyx_t_7, __pyx_v_record); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_8);
-      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-      __pyx_t_7 = PyObject_RichCompare(__pyx_t_8, ((PyObject *)((PyObject*)(&PyDict_Type))), Py_EQ); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_TYPES); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
+      __pyx_t_7 = PyObject_GetItem(__pyx_t_6, __pyx_v_record); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
-      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __pyx_t_6 = PyObject_RichCompare(__pyx_t_7, ((PyObject *)((PyObject*)&PyDict_Type)), Py_EQ); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
       if (__pyx_t_4) {
 
-        /* "csamtools.pyx":1126
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1069
  * 
  *                     if VALID_HEADER_TYPES[record] == dict:
  *                         if record in result:             # <<<<<<<<<<<<<<
  *                             raise ValueError( "multiple '%s' lines are not permitted" % record )
  *                         result[record] = x
  */
-        if (unlikely(__pyx_v_result == Py_None)) {
-          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+        if (unlikely(((PyObject *)__pyx_v_result) == Py_None)) {
+          __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        } else {
+          __pyx_t_4 = ((PyDict_Contains(((PyObject *)__pyx_v_result), __pyx_v_record))); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         }
-        __pyx_t_4 = ((PyDict_Contains(((PyObject *)__pyx_v_result), __pyx_v_record))); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         if (__pyx_t_4) {
 
-          /* "csamtools.pyx":1127
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1070
  *                     if VALID_HEADER_TYPES[record] == dict:
  *                         if record in result:
  *                             raise ValueError( "multiple '%s' lines are not permitted" % record )             # <<<<<<<<<<<<<<
  *                         result[record] = x
  *                     elif VALID_HEADER_TYPES[record] == list:
  */
-          __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_97), __pyx_v_record); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __Pyx_GOTREF(((PyObject *)__pyx_t_7));
-          __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __Pyx_GOTREF(((PyObject *)__pyx_t_8));
-          PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_t_7));
-          __Pyx_GIVEREF(((PyObject *)__pyx_t_7));
-          __pyx_t_7 = 0;
-          __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_49), __pyx_v_record); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(((PyObject *)__pyx_t_6));
+          __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_7);
-          __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
-          __Pyx_Raise(__pyx_t_7, 0, 0);
+          PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_t_6));
+          __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
+          __pyx_t_6 = 0;
+          __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_7, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_6);
           __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_Raise(__pyx_t_6, 0, 0);
+          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           goto __pyx_L16;
         }
         __pyx_L16:;
 
-        /* "csamtools.pyx":1128
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1071
  *                         if record in result:
  *                             raise ValueError( "multiple '%s' lines are not permitted" % record )
  *                         result[record] = x             # <<<<<<<<<<<<<<
  *                     elif VALID_HEADER_TYPES[record] == list:
  *                         if record not in result: result[record] = []
  */
-        if (PyDict_SetItem(((PyObject *)__pyx_v_result), __pyx_v_record, ((PyObject *)__pyx_v_x)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        if (PyDict_SetItem(((PyObject *)__pyx_v_result), __pyx_v_record, ((PyObject *)__pyx_v_x)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         goto __pyx_L15;
       }
 
-      /* "csamtools.pyx":1129
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1072
  *                             raise ValueError( "multiple '%s' lines are not permitted" % record )
  *                         result[record] = x
  *                     elif VALID_HEADER_TYPES[record] == list:             # <<<<<<<<<<<<<<
  *                         if record not in result: result[record] = []
  *                         result[record].append( x )
  */
-      __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_TYPES); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_7);
-      __pyx_t_8 = PyObject_GetItem(__pyx_t_7, __pyx_v_record); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_8);
-      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-      __pyx_t_7 = PyObject_RichCompare(__pyx_t_8, ((PyObject *)((PyObject*)(&PyList_Type))), Py_EQ); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_TYPES); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
+      __pyx_t_7 = PyObject_GetItem(__pyx_t_6, __pyx_v_record); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
-      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __pyx_t_6 = PyObject_RichCompare(__pyx_t_7, ((PyObject *)((PyObject*)&PyList_Type)), Py_EQ); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
       if (__pyx_t_4) {
 
-        /* "csamtools.pyx":1130
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1073
  *                         result[record] = x
  *                     elif VALID_HEADER_TYPES[record] == list:
  *                         if record not in result: result[record] = []             # <<<<<<<<<<<<<<
  *                         result[record].append( x )
  * 
  */
-        if (unlikely(__pyx_v_result == Py_None)) {
-          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1130; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+        if (unlikely(((PyObject *)__pyx_v_result) == Py_None)) {
+          __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        } else {
+          __pyx_t_4 = (__Pyx_NegateNonNeg(PyDict_Contains(((PyObject *)__pyx_v_result), __pyx_v_record))); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         }
-        __pyx_t_4 = (__Pyx_NegateNonNeg(PyDict_Contains(((PyObject *)__pyx_v_result), __pyx_v_record))); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         if (__pyx_t_4) {
-          __pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __Pyx_GOTREF(((PyObject *)__pyx_t_7));
-          if (PyDict_SetItem(((PyObject *)__pyx_v_result), __pyx_v_record, ((PyObject *)__pyx_t_7)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
+          __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(((PyObject *)__pyx_t_6));
+          if (PyDict_SetItem(((PyObject *)__pyx_v_result), __pyx_v_record, ((PyObject *)__pyx_t_6)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
           goto __pyx_L17;
         }
         __pyx_L17:;
 
-        /* "csamtools.pyx":1131
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1074
  *                     elif VALID_HEADER_TYPES[record] == list:
  *                         if record not in result: result[record] = []
  *                         result[record].append( x )             # <<<<<<<<<<<<<<
  * 
  *             return result
  */
-        __pyx_t_7 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_result), __pyx_v_record); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_result), __pyx_v_record); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_6);
+        __pyx_t_7 = __Pyx_PyObject_Append(__pyx_t_6, ((PyObject *)__pyx_v_x)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
-        __pyx_t_8 = __Pyx_PyObject_Append(__pyx_t_7, ((PyObject *)__pyx_v_x)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_8);
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-        __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
         goto __pyx_L15;
       }
       __pyx_L15:;
@@ -11694,7 +11661,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6header___get__(PyObject *__pyx_v_
   }
   __pyx_L6:;
 
-  /* "csamtools.pyx":1133
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1076
  *                         result[record].append( x )
  * 
  *             return result             # <<<<<<<<<<<<<<
@@ -11733,7 +11700,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6header___get__(PyObject *__pyx_v_
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1135
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1078
  *             return result
  * 
  *     def _buildLine( self, fields, record ):             # <<<<<<<<<<<<<<
@@ -11741,9 +11708,9 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_6header___get__(PyObject *__pyx_v_
  * 
  */
 
-static PyObject *__pyx_pf_9csamtools_7Samfile_19_buildLine(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_9csamtools_7Samfile_19_buildLine[] = "Samfile._buildLine(self, fields, record)\nbuild a header line from *fields* dictionary for *record*";
-static PyObject *__pyx_pf_9csamtools_7Samfile_19_buildLine(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+static PyObject *__pyx_pf_9csamtools_7Samfile__buildLine(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_9csamtools_7Samfile__buildLine[] = "Samfile._buildLine(self, fields, record)\nbuild a header line from *fields* dictionary for *record*";
+static PyObject *__pyx_pf_9csamtools_7Samfile__buildLine(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   PyObject *__pyx_v_fields = 0;
   PyObject *__pyx_v_record = 0;
   PyObject *__pyx_v_line;
@@ -11759,7 +11726,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_19_buildLine(PyObject *__pyx_v_sel
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__fields,&__pyx_n_s__record,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("_buildLine");
-  __Pyx_TraceCall("_buildLine", __pyx_f[0], 1135);
+  __Pyx_TraceCall("_buildLine", __pyx_f[0], 1078);
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[2] = {0,0};
@@ -11778,11 +11745,11 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_19_buildLine(PyObject *__pyx_v_sel
       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__record);
       if (likely(values[1])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("_buildLine", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1135; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("_buildLine", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1078; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_buildLine") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1135; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_buildLine") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1078; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_fields = values[0];
     __pyx_v_record = values[1];
@@ -11794,25 +11761,25 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_19_buildLine(PyObject *__pyx_v_sel
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("_buildLine", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1135; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("_buildLine", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1078; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("csamtools.Samfile._buildLine");
   __Pyx_RefNannyFinishContext();
   return NULL;
   __pyx_L4_argument_unpacking_done:;
-  __pyx_v_line = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
+  __pyx_v_line = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
   __pyx_v_key = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "csamtools.pyx":1139
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1082
  * 
  *         # TODO: add checking for field and sort order
  *         line = ["@%s" % record ]             # <<<<<<<<<<<<<<
  *         if record == "CO":
  *             line.append( fields )
  */
-  __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_98), __pyx_v_record); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_50), __pyx_v_record); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
   PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
   __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
@@ -11821,20 +11788,20 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_19_buildLine(PyObject *__pyx_v_sel
   __pyx_v_line = __pyx_t_2;
   __pyx_t_2 = 0;
 
-  /* "csamtools.pyx":1140
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1083
  *         # TODO: add checking for field and sort order
  *         line = ["@%s" % record ]
  *         if record == "CO":             # <<<<<<<<<<<<<<
  *             line.append( fields )
  *         else:
  */
-  __pyx_t_2 = PyObject_RichCompare(__pyx_v_record, ((PyObject *)__pyx_n_s__CO), Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_RichCompare(__pyx_v_record, ((PyObject *)__pyx_n_s__CO), Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1083; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1083; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   if (__pyx_t_3) {
 
-    /* "csamtools.pyx":1141
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1084
  *         line = ["@%s" % record ]
  *         if record == "CO":
  *             line.append( fields )             # <<<<<<<<<<<<<<
@@ -11842,29 +11809,29 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_19_buildLine(PyObject *__pyx_v_sel
  *             # write fields of the specification
  */
     if (unlikely(__pyx_v_line == Py_None)) {
-      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1141; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1084; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
     }
-    __pyx_t_4 = PyList_Append(__pyx_v_line, __pyx_v_fields); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyList_Append(((PyObject *)__pyx_v_line), __pyx_v_fields); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   /*else*/ {
 
-    /* "csamtools.pyx":1144
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1087
  *         else:
  *             # write fields of the specification
  *             for key in VALID_HEADER_ORDER[record]:             # <<<<<<<<<<<<<<
  *                 if key in fields:
  *                     line.append( "%s:%s" % (key, str(fields[key])))
  */
-    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_ORDER); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_ORDER); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_1 = PyObject_GetItem(__pyx_t_2, __pyx_v_record); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetItem(__pyx_t_2, __pyx_v_record); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
       __pyx_t_5 = 0; __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2);
     } else {
-      __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
     }
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
@@ -11878,7 +11845,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_19_buildLine(PyObject *__pyx_v_sel
       } else {
         __pyx_t_1 = PyIter_Next(__pyx_t_2);
         if (!__pyx_t_1) {
-          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           break;
         }
         __Pyx_GOTREF(__pyx_t_1);
@@ -11887,17 +11854,17 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_19_buildLine(PyObject *__pyx_v_sel
       __pyx_v_key = __pyx_t_1;
       __pyx_t_1 = 0;
 
-      /* "csamtools.pyx":1145
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1088
  *             # write fields of the specification
  *             for key in VALID_HEADER_ORDER[record]:
  *                 if key in fields:             # <<<<<<<<<<<<<<
  *                     line.append( "%s:%s" % (key, str(fields[key])))
  *             # write user fields
  */
-      __pyx_t_3 = ((PySequence_Contains(__pyx_v_fields, __pyx_v_key))); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = ((PySequence_Contains(__pyx_v_fields, __pyx_v_key))); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       if (__pyx_t_3) {
 
-        /* "csamtools.pyx":1146
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1089
  *             for key in VALID_HEADER_ORDER[record]:
  *                 if key in fields:
  *                     line.append( "%s:%s" % (key, str(fields[key])))             # <<<<<<<<<<<<<<
@@ -11905,30 +11872,30 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_19_buildLine(PyObject *__pyx_v_sel
  *             for key in fields:
  */
         if (unlikely(__pyx_v_line == Py_None)) {
-          PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1146; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+          PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1089; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
         }
-        __pyx_t_1 = PyObject_GetItem(__pyx_v_fields, __pyx_v_key); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_1 = PyObject_GetItem(__pyx_v_fields, __pyx_v_key); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_1);
-        __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(((PyObject *)__pyx_t_6));
+        __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_6);
         PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
         __Pyx_GIVEREF(__pyx_t_1);
         __pyx_t_1 = 0;
-        __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_1);
-        __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
-        __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(((PyObject *)__pyx_t_6));
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_6);
         __Pyx_INCREF(__pyx_v_key);
         PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_key);
         __Pyx_GIVEREF(__pyx_v_key);
         PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
         __Pyx_GIVEREF(__pyx_t_1);
         __pyx_t_1 = 0;
-        __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_99), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_51), __pyx_t_6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-        __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
-        __pyx_t_4 = PyList_Append(__pyx_v_line, ((PyObject *)__pyx_t_1)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __pyx_t_4 = PyList_Append(((PyObject *)__pyx_v_line), ((PyObject *)__pyx_t_1)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
         goto __pyx_L9;
       }
@@ -11936,7 +11903,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_19_buildLine(PyObject *__pyx_v_sel
     }
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-    /* "csamtools.pyx":1148
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1091
  *                     line.append( "%s:%s" % (key, str(fields[key])))
  *             # write user fields
  *             for key in fields:             # <<<<<<<<<<<<<<
@@ -11946,7 +11913,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_19_buildLine(PyObject *__pyx_v_sel
     if (PyList_CheckExact(__pyx_v_fields) || PyTuple_CheckExact(__pyx_v_fields)) {
       __pyx_t_5 = 0; __pyx_t_2 = __pyx_v_fields; __Pyx_INCREF(__pyx_t_2);
     } else {
-      __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_fields); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_v_fields); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
     }
     for (;;) {
@@ -11959,7 +11926,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_19_buildLine(PyObject *__pyx_v_sel
       } else {
         __pyx_t_1 = PyIter_Next(__pyx_t_2);
         if (!__pyx_t_1) {
-          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           break;
         }
         __Pyx_GOTREF(__pyx_t_1);
@@ -11968,24 +11935,24 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_19_buildLine(PyObject *__pyx_v_sel
       __pyx_v_key = __pyx_t_1;
       __pyx_t_1 = 0;
 
-      /* "csamtools.pyx":1149
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1092
  *             # write user fields
  *             for key in fields:
  *                 if not key.isupper():             # <<<<<<<<<<<<<<
  *                     line.append( "%s:%s" % (key, str(fields[key])))
  * 
  */
-      __pyx_t_1 = PyObject_GetAttr(__pyx_v_key, __pyx_n_s__isupper); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyObject_GetAttr(__pyx_v_key, __pyx_n_s__isupper); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
       __pyx_t_7 = (!__pyx_t_3);
       if (__pyx_t_7) {
 
-        /* "csamtools.pyx":1150
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1093
  *             for key in fields:
  *                 if not key.isupper():
  *                     line.append( "%s:%s" % (key, str(fields[key])))             # <<<<<<<<<<<<<<
@@ -11993,30 +11960,30 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_19_buildLine(PyObject *__pyx_v_sel
  *         return "\t".join( line )
  */
         if (unlikely(__pyx_v_line == Py_None)) {
-          PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1150; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+          PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1093; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
         }
-        __pyx_t_6 = PyObject_GetItem(__pyx_v_fields, __pyx_v_key); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = PyObject_GetItem(__pyx_v_fields, __pyx_v_key); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1093; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
-        __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+        __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1093; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_1);
         PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
         __Pyx_GIVEREF(__pyx_t_6);
         __pyx_t_6 = 0;
-        __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1093; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
-        __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
-        __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+        __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1093; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_1);
         __Pyx_INCREF(__pyx_v_key);
         PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_key);
         __Pyx_GIVEREF(__pyx_v_key);
         PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_6);
         __Pyx_GIVEREF(__pyx_t_6);
         __pyx_t_6 = 0;
-        __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_99), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_51), __pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1093; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(((PyObject *)__pyx_t_6));
-        __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
-        __pyx_t_4 = PyList_Append(__pyx_v_line, ((PyObject *)__pyx_t_6)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+        __pyx_t_4 = PyList_Append(((PyObject *)__pyx_v_line), ((PyObject *)__pyx_t_6)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1093; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
         goto __pyx_L12;
       }
@@ -12026,7 +11993,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_19_buildLine(PyObject *__pyx_v_sel
   }
   __pyx_L6:;
 
-  /* "csamtools.pyx":1152
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1095
  *                     line.append( "%s:%s" % (key, str(fields[key])))
  * 
  *         return "\t".join( line )             # <<<<<<<<<<<<<<
@@ -12034,17 +12001,17 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_19_buildLine(PyObject *__pyx_v_sel
  *     cdef bam_header_t * _buildHeader( self, new_header ):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_1), __pyx_n_s__join); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_1), __pyx_n_s__join); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_6));
+  __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_6);
   __Pyx_INCREF(((PyObject *)__pyx_v_line));
   PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_line));
   __Pyx_GIVEREF(((PyObject *)__pyx_v_line));
-  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
+  __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
   goto __pyx_L0;
@@ -12066,7 +12033,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_19_buildLine(PyObject *__pyx_v_sel
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1154
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1097
  *         return "\t".join( line )
  * 
  *     cdef bam_header_t * _buildHeader( self, new_header ):             # <<<<<<<<<<<<<<
@@ -12102,31 +12069,31 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
   uint32_t __pyx_t_13;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("_buildHeader");
-  __Pyx_TraceCall("_buildHeader", __pyx_f[0], 1154);
-  __pyx_v_lines = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
+  __Pyx_TraceCall("_buildHeader", __pyx_f[0], 1097);
+  __pyx_v_lines = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
   __pyx_v_record = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_ttype = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_data = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_fields = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_text = Py_None; __Pyx_INCREF(Py_None);
-  __pyx_v_seqs = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
+  __pyx_v_seqs = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
   __pyx_v_seqname = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_seqlen = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "csamtools.pyx":1160
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1103
  *         '''
  * 
  *         lines = []             # <<<<<<<<<<<<<<
  * 
  *         # check if hash exists
  */
-  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
   __Pyx_DECREF(((PyObject *)__pyx_v_lines));
   __pyx_v_lines = __pyx_t_1;
   __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":1167
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1110
  *         cdef bam_header_t * dest
  * 
  *         dest = bam_header_init()             # <<<<<<<<<<<<<<
@@ -12135,19 +12102,19 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
  */
   __pyx_v_dest = bam_header_init();
 
-  /* "csamtools.pyx":1169
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1112
  *         dest = bam_header_init()
  * 
  *         for record in VALID_HEADERS:             # <<<<<<<<<<<<<<
  *             if record in new_header:
  *                 ttype = VALID_HEADER_TYPES[record]
  */
-  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADERS); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADERS); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
     __pyx_t_2 = 0; __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3);
   } else {
-    __pyx_t_2 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
   }
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
@@ -12161,7 +12128,7 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
     } else {
       __pyx_t_1 = PyIter_Next(__pyx_t_3);
       if (!__pyx_t_1) {
-        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         break;
       }
       __Pyx_GOTREF(__pyx_t_1);
@@ -12170,72 +12137,72 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
     __pyx_v_record = __pyx_t_1;
     __pyx_t_1 = 0;
 
-    /* "csamtools.pyx":1170
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1113
  * 
  *         for record in VALID_HEADERS:
  *             if record in new_header:             # <<<<<<<<<<<<<<
  *                 ttype = VALID_HEADER_TYPES[record]
  *                 data = new_header[record]
  */
-    __pyx_t_4 = ((PySequence_Contains(__pyx_v_new_header, __pyx_v_record))); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = ((PySequence_Contains(__pyx_v_new_header, __pyx_v_record))); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (__pyx_t_4) {
 
-      /* "csamtools.pyx":1171
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1114
  *         for record in VALID_HEADERS:
  *             if record in new_header:
  *                 ttype = VALID_HEADER_TYPES[record]             # <<<<<<<<<<<<<<
  *                 data = new_header[record]
  *                 if type( data ) != type( ttype() ):
  */
-      __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_TYPES); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_TYPES); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __pyx_t_5 = PyObject_GetItem(__pyx_t_1, __pyx_v_record); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_GetItem(__pyx_t_1, __pyx_v_record); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
       __Pyx_DECREF(__pyx_v_ttype);
       __pyx_v_ttype = __pyx_t_5;
       __pyx_t_5 = 0;
 
-      /* "csamtools.pyx":1172
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1115
  *             if record in new_header:
  *                 ttype = VALID_HEADER_TYPES[record]
  *                 data = new_header[record]             # <<<<<<<<<<<<<<
  *                 if type( data ) != type( ttype() ):
  *                     raise ValueError( "invalid type for record %s: %s, expected %s" % (record, type(data), type(ttype()) ) )
  */
-      __pyx_t_5 = PyObject_GetItem(__pyx_v_new_header, __pyx_v_record); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_GetItem(__pyx_v_new_header, __pyx_v_record); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __Pyx_DECREF(__pyx_v_data);
       __pyx_v_data = __pyx_t_5;
       __pyx_t_5 = 0;
 
-      /* "csamtools.pyx":1173
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1116
  *                 ttype = VALID_HEADER_TYPES[record]
  *                 data = new_header[record]
  *                 if type( data ) != type( ttype() ):             # <<<<<<<<<<<<<<
  *                     raise ValueError( "invalid type for record %s: %s, expected %s" % (record, type(data), type(ttype()) ) )
  *                 if type( data ) == types.DictType:
  */
-      __pyx_t_5 = PyObject_Call(__pyx_v_ttype, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_Call(__pyx_v_ttype, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
-      __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_data)), ((PyObject *)Py_TYPE(__pyx_t_5)), Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_data)), ((PyObject *)Py_TYPE(__pyx_t_5)), Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
       if (__pyx_t_4) {
 
-        /* "csamtools.pyx":1174
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1117
  *                 data = new_header[record]
  *                 if type( data ) != type( ttype() ):
  *                     raise ValueError( "invalid type for record %s: %s, expected %s" % (record, type(data), type(ttype()) ) )             # <<<<<<<<<<<<<<
  *                 if type( data ) == types.DictType:
  *                     lines.append( self._buildLine( data, record ) )
  */
-        __pyx_t_1 = PyObject_Call(__pyx_v_ttype, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_1 = PyObject_Call(__pyx_v_ttype, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_1);
-        __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+        __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_5);
         __Pyx_INCREF(__pyx_v_record);
         PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_record);
         __Pyx_GIVEREF(__pyx_v_record);
@@ -12246,44 +12213,44 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
         PyTuple_SET_ITEM(__pyx_t_5, 2, ((PyObject *)Py_TYPE(__pyx_t_1)));
         __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_t_1)));
         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-        __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_100), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_52), __pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-        __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
-        __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_5);
         PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_1));
         __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
         __pyx_t_1 = 0;
-        __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_1);
-        __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
         __Pyx_Raise(__pyx_t_1, 0, 0);
         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         goto __pyx_L6;
       }
       __pyx_L6:;
 
-      /* "csamtools.pyx":1175
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1118
  *                 if type( data ) != type( ttype() ):
  *                     raise ValueError( "invalid type for record %s: %s, expected %s" % (record, type(data), type(ttype()) ) )
  *                 if type( data ) == types.DictType:             # <<<<<<<<<<<<<<
  *                     lines.append( self._buildLine( data, record ) )
  *                 else:
  */
-      __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__types); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__types); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __pyx_t_5 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__DictType); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__DictType); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-      __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_data)), __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_data)), __pyx_t_5, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
       if (__pyx_t_4) {
 
-        /* "csamtools.pyx":1176
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1119
  *                     raise ValueError( "invalid type for record %s: %s, expected %s" % (record, type(data), type(ttype()) ) )
  *                 if type( data ) == types.DictType:
  *                     lines.append( self._buildLine( data, record ) )             # <<<<<<<<<<<<<<
@@ -12291,41 +12258,41 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
  *                     for fields in new_header[record]:
  */
         if (unlikely(__pyx_v_lines == Py_None)) {
-          PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1176; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+          PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1119; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
         }
-        __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___buildLine); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___buildLine); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_1);
-        __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+        __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_5);
         __Pyx_INCREF(__pyx_v_data);
         PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_data);
         __Pyx_GIVEREF(__pyx_v_data);
         __Pyx_INCREF(__pyx_v_record);
         PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_record);
         __Pyx_GIVEREF(__pyx_v_record);
-        __pyx_t_6 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = PyObject_Call(__pyx_t_1, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-        __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
-        __pyx_t_7 = PyList_Append(__pyx_v_lines, __pyx_t_6); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+        __pyx_t_7 = PyList_Append(((PyObject *)__pyx_v_lines), __pyx_t_6); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
         goto __pyx_L7;
       }
       /*else*/ {
 
-        /* "csamtools.pyx":1178
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1121
  *                     lines.append( self._buildLine( data, record ) )
  *                 else:
  *                     for fields in new_header[record]:             # <<<<<<<<<<<<<<
  *                         lines.append( self._buildLine( fields, record ) )
  * 
  */
-        __pyx_t_6 = PyObject_GetItem(__pyx_v_new_header, __pyx_v_record); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = PyObject_GetItem(__pyx_v_new_header, __pyx_v_record); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
         if (PyList_CheckExact(__pyx_t_6) || PyTuple_CheckExact(__pyx_t_6)) {
           __pyx_t_8 = 0; __pyx_t_5 = __pyx_t_6; __Pyx_INCREF(__pyx_t_5);
         } else {
-          __pyx_t_8 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_8 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_5);
         }
         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
@@ -12339,7 +12306,7 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
           } else {
             __pyx_t_6 = PyIter_Next(__pyx_t_5);
             if (!__pyx_t_6) {
-              if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+              if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
               break;
             }
             __Pyx_GOTREF(__pyx_t_6);
@@ -12348,7 +12315,7 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
           __pyx_v_fields = __pyx_t_6;
           __pyx_t_6 = 0;
 
-          /* "csamtools.pyx":1179
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1122
  *                 else:
  *                     for fields in new_header[record]:
  *                         lines.append( self._buildLine( fields, record ) )             # <<<<<<<<<<<<<<
@@ -12356,23 +12323,23 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
  *         text = "\n".join(lines) + "\n"
  */
           if (unlikely(__pyx_v_lines == Py_None)) {
-            PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1179; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+            PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1122; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
           }
-          __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___buildLine); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___buildLine); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_6);
-          __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+          __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_1);
           __Pyx_INCREF(__pyx_v_fields);
           PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_fields);
           __Pyx_GIVEREF(__pyx_v_fields);
           __Pyx_INCREF(__pyx_v_record);
           PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_record);
           __Pyx_GIVEREF(__pyx_v_record);
-          __pyx_t_9 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_9 = PyObject_Call(__pyx_t_6, __pyx_t_1, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_9);
           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-          __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
-          __pyx_t_7 = PyList_Append(__pyx_v_lines, __pyx_t_9); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+          __pyx_t_7 = PyList_Append(((PyObject *)__pyx_v_lines), __pyx_t_9); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
         }
         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
@@ -12384,32 +12351,32 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
   }
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
-  /* "csamtools.pyx":1181
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1124
  *                         lines.append( self._buildLine( fields, record ) )
  * 
  *         text = "\n".join(lines) + "\n"             # <<<<<<<<<<<<<<
  *         if dest.text != NULL: free( dest.text )
  *         dest.text = <char*>calloc( len(text), sizeof(char))
  */
-  __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_2), __pyx_n_s__join); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_2), __pyx_n_s__join); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+  __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
   __Pyx_INCREF(((PyObject *)__pyx_v_lines));
   PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_lines));
   __Pyx_GIVEREF(((PyObject *)__pyx_v_lines));
-  __pyx_t_9 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_9 = PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_9);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
-  __pyx_t_5 = PyNumber_Add(__pyx_t_9, ((PyObject *)__pyx_kp_s_2)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __pyx_t_5 = PyNumber_Add(__pyx_t_9, ((PyObject *)__pyx_kp_s_2)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
   __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
   __Pyx_DECREF(__pyx_v_text);
   __pyx_v_text = __pyx_t_5;
   __pyx_t_5 = 0;
 
-  /* "csamtools.pyx":1182
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1125
  * 
  *         text = "\n".join(lines) + "\n"
  *         if dest.text != NULL: free( dest.text )             # <<<<<<<<<<<<<<
@@ -12423,72 +12390,72 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
   }
   __pyx_L10:;
 
-  /* "csamtools.pyx":1183
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1126
  *         text = "\n".join(lines) + "\n"
  *         if dest.text != NULL: free( dest.text )
  *         dest.text = <char*>calloc( len(text), sizeof(char))             # <<<<<<<<<<<<<<
  *         dest.l_text = len(text)
  *         strncpy( dest.text, text, dest.l_text )
  */
-  __pyx_t_2 = PyObject_Length(__pyx_v_text); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Length(__pyx_v_text); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_dest->text = ((char *)calloc(__pyx_t_2, (sizeof(char))));
 
-  /* "csamtools.pyx":1184
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1127
  *         if dest.text != NULL: free( dest.text )
  *         dest.text = <char*>calloc( len(text), sizeof(char))
  *         dest.l_text = len(text)             # <<<<<<<<<<<<<<
  *         strncpy( dest.text, text, dest.l_text )
  * 
  */
-  __pyx_t_2 = PyObject_Length(__pyx_v_text); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Length(__pyx_v_text); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_dest->l_text = __pyx_t_2;
 
-  /* "csamtools.pyx":1185
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1128
  *         dest.text = <char*>calloc( len(text), sizeof(char))
  *         dest.l_text = len(text)
  *         strncpy( dest.text, text, dest.l_text )             # <<<<<<<<<<<<<<
  * 
  *         # collect targets
  */
-  __pyx_t_10 = PyBytes_AsString(__pyx_v_text); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_10 = PyBytes_AsString(__pyx_v_text); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   strncpy(__pyx_v_dest->text, __pyx_t_10, __pyx_v_dest->l_text);
 
-  /* "csamtools.pyx":1188
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1131
  * 
  *         # collect targets
  *         if "SQ" in new_header:             # <<<<<<<<<<<<<<
  *             seqs = []
  *             for fields in new_header["SQ"]:
  */
-  __pyx_t_4 = ((PySequence_Contains(__pyx_v_new_header, ((PyObject *)__pyx_n_s__SQ)))); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = ((PySequence_Contains(__pyx_v_new_header, ((PyObject *)__pyx_n_s__SQ)))); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_4) {
 
-    /* "csamtools.pyx":1189
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1132
  *         # collect targets
  *         if "SQ" in new_header:
  *             seqs = []             # <<<<<<<<<<<<<<
  *             for fields in new_header["SQ"]:
  *                 try:
  */
-    __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_5));
     __Pyx_DECREF(((PyObject *)__pyx_v_seqs));
     __pyx_v_seqs = __pyx_t_5;
     __pyx_t_5 = 0;
 
-    /* "csamtools.pyx":1190
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1133
  *         if "SQ" in new_header:
  *             seqs = []
  *             for fields in new_header["SQ"]:             # <<<<<<<<<<<<<<
  *                 try:
  *                     seqs.append( (fields["SN"], fields["LN"] ) )
  */
-    __pyx_t_5 = PyObject_GetItem(__pyx_v_new_header, ((PyObject *)__pyx_n_s__SQ)); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyObject_GetItem(__pyx_v_new_header, ((PyObject *)__pyx_n_s__SQ)); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
     if (PyList_CheckExact(__pyx_t_5) || PyTuple_CheckExact(__pyx_t_5)) {
       __pyx_t_2 = 0; __pyx_t_9 = __pyx_t_5; __Pyx_INCREF(__pyx_t_9);
     } else {
-      __pyx_t_2 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_9);
     }
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
@@ -12502,7 +12469,7 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
       } else {
         __pyx_t_5 = PyIter_Next(__pyx_t_9);
         if (!__pyx_t_5) {
-          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           break;
         }
         __Pyx_GOTREF(__pyx_t_5);
@@ -12511,7 +12478,7 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
       __pyx_v_fields = __pyx_t_5;
       __pyx_t_5 = 0;
 
-      /* "csamtools.pyx":1191
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1134
  *             seqs = []
  *             for fields in new_header["SQ"]:
  *                 try:             # <<<<<<<<<<<<<<
@@ -12526,7 +12493,7 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
         __Pyx_XGOTREF(__pyx_save_exc_tb);
         /*try:*/ {
 
-          /* "csamtools.pyx":1192
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1135
  *             for fields in new_header["SQ"]:
  *                 try:
  *                     seqs.append( (fields["SN"], fields["LN"] ) )             # <<<<<<<<<<<<<<
@@ -12534,22 +12501,22 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
  *                     raise KeyError( "incomplete sequence information in '%s'" % str(fields))
  */
           if (unlikely(__pyx_v_seqs == Py_None)) {
-            PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1192; __pyx_clineno = __LINE__; goto __pyx_L14_error;} 
+            PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1135; __pyx_clineno = __LINE__; goto __pyx_L14_error;} 
           }
-          __pyx_t_5 = PyObject_GetItem(__pyx_v_fields, ((PyObject *)__pyx_n_s__SN)); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1192; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
+          __pyx_t_5 = PyObject_GetItem(__pyx_v_fields, ((PyObject *)__pyx_n_s__SN)); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1135; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
           __Pyx_GOTREF(__pyx_t_5);
-          __pyx_t_3 = PyObject_GetItem(__pyx_v_fields, ((PyObject *)__pyx_n_s__LN)); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1192; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
+          __pyx_t_3 = PyObject_GetItem(__pyx_v_fields, ((PyObject *)__pyx_n_s__LN)); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1135; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
           __Pyx_GOTREF(__pyx_t_3);
-          __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1192; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
-          __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+          __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1135; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
+          __Pyx_GOTREF(__pyx_t_1);
           PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
           __Pyx_GIVEREF(__pyx_t_5);
           PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
           __Pyx_GIVEREF(__pyx_t_3);
           __pyx_t_5 = 0;
           __pyx_t_3 = 0;
-          __pyx_t_7 = PyList_Append(__pyx_v_seqs, ((PyObject *)__pyx_t_1)); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1192; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
-          __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+          __pyx_t_7 = PyList_Append(((PyObject *)__pyx_v_seqs), __pyx_t_1); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1135; __pyx_clineno = __LINE__; goto __pyx_L14_error;}
+          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
         }
         __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
         __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
@@ -12561,7 +12528,7 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
         __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
         __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-        /* "csamtools.pyx":1193
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1136
  *                 try:
  *                     seqs.append( (fields["SN"], fields["LN"] ) )
  *                 except KeyError:             # <<<<<<<<<<<<<<
@@ -12571,40 +12538,40 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
         __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_KeyError);
         if (__pyx_t_7) {
           __Pyx_AddTraceback("csamtools.Samfile._buildHeader");
-          if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_3, &__pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1193; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
+          if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_3, &__pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1136; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
           __Pyx_GOTREF(__pyx_t_1);
           __Pyx_GOTREF(__pyx_t_3);
           __Pyx_GOTREF(__pyx_t_5);
 
-          /* "csamtools.pyx":1194
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1137
  *                     seqs.append( (fields["SN"], fields["LN"] ) )
  *                 except KeyError:
  *                     raise KeyError( "incomplete sequence information in '%s'" % str(fields))             # <<<<<<<<<<<<<<
  * 
  *             dest.n_targets = len(seqs)
  */
-          __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1194; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
-          __Pyx_GOTREF(((PyObject *)__pyx_t_6));
+          __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1137; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
+          __Pyx_GOTREF(__pyx_t_6);
           __Pyx_INCREF(__pyx_v_fields);
           PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_fields);
           __Pyx_GIVEREF(__pyx_v_fields);
-          __pyx_t_11 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1194; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
+          __pyx_t_11 = PyObject_Call(((PyObject *)((PyObject*)&PyString_Type)), __pyx_t_6, NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1137; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
           __Pyx_GOTREF(__pyx_t_11);
-          __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
-          __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_101), __pyx_t_11); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1194; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
+          __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+          __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_53), __pyx_t_11); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1137; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
           __Pyx_GOTREF(((PyObject *)__pyx_t_6));
           __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
-          __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1194; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
-          __Pyx_GOTREF(((PyObject *)__pyx_t_11));
+          __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1137; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
+          __Pyx_GOTREF(__pyx_t_11);
           PyTuple_SET_ITEM(__pyx_t_11, 0, ((PyObject *)__pyx_t_6));
           __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
           __pyx_t_6 = 0;
-          __pyx_t_6 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_11), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1194; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
+          __pyx_t_6 = PyObject_Call(__pyx_builtin_KeyError, __pyx_t_11, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1137; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
           __Pyx_GOTREF(__pyx_t_6);
-          __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;
+          __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
           __Pyx_Raise(__pyx_t_6, 0, 0);
           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1194; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
+          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1137; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
           __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
           __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
           __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
@@ -12626,7 +12593,7 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
     }
     __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
 
-    /* "csamtools.pyx":1196
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1139
  *                     raise KeyError( "incomplete sequence information in '%s'" % str(fields))
  * 
  *             dest.n_targets = len(seqs)             # <<<<<<<<<<<<<<
@@ -12634,12 +12601,12 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
  *             dest.target_len = <uint32_t*>calloc( dest.n_targets, sizeof(uint32_t) )
  */
     if (unlikely(__pyx_v_seqs == Py_None)) {
-      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1196; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+      PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1139; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
     }
     __pyx_t_2 = PyList_GET_SIZE(((PyObject *)__pyx_v_seqs)); 
     __pyx_v_dest->n_targets = __pyx_t_2;
 
-    /* "csamtools.pyx":1197
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1140
  * 
  *             dest.n_targets = len(seqs)
  *             dest.target_name = <char**>calloc( dest.n_targets, sizeof(char*) )             # <<<<<<<<<<<<<<
@@ -12648,7 +12615,7 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
  */
     __pyx_v_dest->target_name = ((char **)calloc(__pyx_v_dest->n_targets, (sizeof(char *))));
 
-    /* "csamtools.pyx":1198
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1141
  *             dest.n_targets = len(seqs)
  *             dest.target_name = <char**>calloc( dest.n_targets, sizeof(char*) )
  *             dest.target_len = <uint32_t*>calloc( dest.n_targets, sizeof(uint32_t) )             # <<<<<<<<<<<<<<
@@ -12657,7 +12624,7 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
  */
     __pyx_v_dest->target_len = ((uint32_t *)calloc(__pyx_v_dest->n_targets, (sizeof(uint32_t))));
 
-    /* "csamtools.pyx":1200
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1143
  *             dest.target_len = <uint32_t*>calloc( dest.n_targets, sizeof(uint32_t) )
  * 
  *             for x from 0 <= x < dest.n_targets:             # <<<<<<<<<<<<<<
@@ -12667,14 +12634,14 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
     __pyx_t_12 = __pyx_v_dest->n_targets;
     for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_12; __pyx_v_x++) {
 
-      /* "csamtools.pyx":1201
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1144
  * 
  *             for x from 0 <= x < dest.n_targets:
  *                 seqname, seqlen = seqs[x]             # <<<<<<<<<<<<<<
  *                 dest.target_name[x] = <char*>calloc( len( seqname ) + 1, sizeof(char) )
  *                 strncpy( dest.target_name[x], seqname, len(seqname) + 1 )
  */
-      __pyx_t_9 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_seqs), __pyx_v_x, sizeof(long), PyInt_FromLong); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_9 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_seqs), __pyx_v_x, sizeof(long), PyInt_FromLong); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_9);
       if (PyTuple_CheckExact(__pyx_t_9) && likely(PyTuple_GET_SIZE(__pyx_t_9) == 2)) {
         PyObject* tuple = __pyx_t_9;
@@ -12688,14 +12655,14 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
         __pyx_v_seqlen = __pyx_t_3;
         __pyx_t_3 = 0;
       } else {
-        __pyx_t_1 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_1 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_1);
         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-        __pyx_t_5 = __Pyx_UnpackItem(__pyx_t_1, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_5 = __Pyx_UnpackItem(__pyx_t_1, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_5);
-        __pyx_t_3 = __Pyx_UnpackItem(__pyx_t_1, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_3 = __Pyx_UnpackItem(__pyx_t_1, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_3);
-        if (__Pyx_EndUnpack(__pyx_t_1, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        if (__Pyx_EndUnpack(__pyx_t_1, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
         __Pyx_DECREF(__pyx_v_seqname);
         __pyx_v_seqname = __pyx_t_5;
@@ -12705,42 +12672,42 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
         __pyx_t_3 = 0;
       }
 
-      /* "csamtools.pyx":1202
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1145
  *             for x from 0 <= x < dest.n_targets:
  *                 seqname, seqlen = seqs[x]
  *                 dest.target_name[x] = <char*>calloc( len( seqname ) + 1, sizeof(char) )             # <<<<<<<<<<<<<<
  *                 strncpy( dest.target_name[x], seqname, len(seqname) + 1 )
  *                 dest.target_len[x] = seqlen
  */
-      __pyx_t_2 = PyObject_Length(__pyx_v_seqname); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyObject_Length(__pyx_v_seqname); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       (__pyx_v_dest->target_name[__pyx_v_x]) = ((char *)calloc((__pyx_t_2 + 1), (sizeof(char))));
 
-      /* "csamtools.pyx":1203
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1146
  *                 seqname, seqlen = seqs[x]
  *                 dest.target_name[x] = <char*>calloc( len( seqname ) + 1, sizeof(char) )
  *                 strncpy( dest.target_name[x], seqname, len(seqname) + 1 )             # <<<<<<<<<<<<<<
  *                 dest.target_len[x] = seqlen
  * 
  */
-      __pyx_t_10 = PyBytes_AsString(__pyx_v_seqname); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __pyx_t_2 = PyObject_Length(__pyx_v_seqname); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_10 = PyBytes_AsString(__pyx_v_seqname); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyObject_Length(__pyx_v_seqname); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       strncpy((__pyx_v_dest->target_name[__pyx_v_x]), __pyx_t_10, (__pyx_t_2 + 1));
 
-      /* "csamtools.pyx":1204
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1147
  *                 dest.target_name[x] = <char*>calloc( len( seqname ) + 1, sizeof(char) )
  *                 strncpy( dest.target_name[x], seqname, len(seqname) + 1 )
  *                 dest.target_len[x] = seqlen             # <<<<<<<<<<<<<<
  * 
  *         return dest
  */
-      __pyx_t_13 = __Pyx_PyInt_from_py_uint32_t(__pyx_v_seqlen); if (unlikely((__pyx_t_13 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_13 = __Pyx_PyInt_from_py_uint32_t(__pyx_v_seqlen); if (unlikely((__pyx_t_13 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       (__pyx_v_dest->target_len[__pyx_v_x]) = __pyx_t_13;
     }
     goto __pyx_L11;
   }
   __pyx_L11:;
 
-  /* "csamtools.pyx":1206
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1149
  *                 dest.target_len[x] = seqlen
  * 
  *         return dest             # <<<<<<<<<<<<<<
@@ -12776,86 +12743,59 @@ static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1216
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1159
  *     ## Possible solutions: deprecate or open new file handle
  *     ###############################################################
  *     def __iter__(self):             # <<<<<<<<<<<<<<
  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
- *         if not self.isbam and self.samfile.header.n_targets == 0:
+ *         return self
  */
 
-static PyObject *__pyx_pf_9csamtools_7Samfile_20__iter__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_9csamtools_7Samfile_20__iter__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_7Samfile___iter__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_7Samfile___iter__(PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   PyObject *__pyx_t_2 = NULL;
   int __pyx_t_3;
   int __pyx_t_4;
-  int __pyx_t_5;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__iter__");
-  __Pyx_TraceCall("__iter__", __pyx_f[0], 1216);
+  __Pyx_TraceCall("__iter__", __pyx_f[0], 1159);
 
-  /* "csamtools.pyx":1217
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1160
  *     ###############################################################
  *     def __iter__(self):
  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
- *         if not self.isbam and self.samfile.header.n_targets == 0:
- *                 raise NotImplementedError( "can not iterate over samfile without header")
+ *         return self
+ * 
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_102), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_Raise(__pyx_t_2, 0, 0);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_Raise(__pyx_t_1, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":1218
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1161
  *     def __iter__(self):
  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
- *         if not self.isbam and self.samfile.header.n_targets == 0:             # <<<<<<<<<<<<<<
- *                 raise NotImplementedError( "can not iterate over samfile without header")
- *         return self
- */
-  __pyx_t_4 = (!((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam);
-  if (__pyx_t_4) {
-    __pyx_t_3 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->n_targets == 0);
-    __pyx_t_5 = __pyx_t_3;
-  } else {
-    __pyx_t_5 = __pyx_t_4;
-  }
-  if (__pyx_t_5) {
-
-    /* "csamtools.pyx":1219
- *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
- *         if not self.isbam and self.samfile.header.n_targets == 0:
- *                 raise NotImplementedError( "can not iterate over samfile without header")             # <<<<<<<<<<<<<<
- *         return self
- * 
- */
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_NotImplementedError, ((PyObject *)__pyx_k_tuple_104), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_Raise(__pyx_t_2, 0, 0);
-    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    goto __pyx_L6;
-  }
-  __pyx_L6:;
-
-  /* "csamtools.pyx":1220
- *         if not self.isbam and self.samfile.header.n_targets == 0:
- *                 raise NotImplementedError( "can not iterate over samfile without header")
  *         return self             # <<<<<<<<<<<<<<
  * 
  *     cdef bam1_t * getCurrent( self ):
@@ -12879,7 +12819,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_20__iter__(PyObject *__pyx_v_self)
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1222
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1163
  *         return self
  * 
  *     cdef bam1_t * getCurrent( self ):             # <<<<<<<<<<<<<<
@@ -12891,9 +12831,9 @@ static  bam1_t *__pyx_f_9csamtools_7Samfile_getCurrent(struct __pyx_obj_9csamtoo
   bam1_t *__pyx_r;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("getCurrent");
-  __Pyx_TraceCall("getCurrent", __pyx_f[0], 1222);
+  __Pyx_TraceCall("getCurrent", __pyx_f[0], 1163);
 
-  /* "csamtools.pyx":1223
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1164
  * 
  *     cdef bam1_t * getCurrent( self ):
  *         return self.b             # <<<<<<<<<<<<<<
@@ -12910,7 +12850,7 @@ static  bam1_t *__pyx_f_9csamtools_7Samfile_getCurrent(struct __pyx_obj_9csamtoo
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1225
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1166
  *         return self.b
  * 
  *     cdef int cnext(self):             # <<<<<<<<<<<<<<
@@ -12922,9 +12862,9 @@ static  int __pyx_f_9csamtools_7Samfile_cnext(struct __pyx_obj_9csamtools_Samfil
   int __pyx_r;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("cnext");
-  __Pyx_TraceCall("cnext", __pyx_f[0], 1225);
+  __Pyx_TraceCall("cnext", __pyx_f[0], 1166);
 
-  /* "csamtools.pyx":1230
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1171
  *         '''
  *         cdef int ret
  *         return samread(self.samfile, self.b)             # <<<<<<<<<<<<<<
@@ -12941,7 +12881,7 @@ static  int __pyx_f_9csamtools_7Samfile_cnext(struct __pyx_obj_9csamtools_Samfil
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1232
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1173
  *         return samread(self.samfile, self.b)
  * 
  *     def __next__(self):             # <<<<<<<<<<<<<<
@@ -12949,19 +12889,19 @@ static  int __pyx_f_9csamtools_7Samfile_cnext(struct __pyx_obj_9csamtools_Samfil
  *         python version of next().
  */
 
-static PyObject *__pyx_pf_9csamtools_7Samfile_21__next__(PyObject *__pyx_v_self); /*proto*/
-static char __pyx_doc_9csamtools_7Samfile_21__next__[] = "\n        python version of next().\n        ";
-struct wrapperbase __pyx_wrapperbase_9csamtools_7Samfile_21__next__;
-static PyObject *__pyx_pf_9csamtools_7Samfile_21__next__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_7Samfile___next__(PyObject *__pyx_v_self); /*proto*/
+static char __pyx_doc_9csamtools_7Samfile___next__[] = "\n        python version of next().\n        ";
+struct wrapperbase __pyx_wrapperbase_9csamtools_7Samfile___next__;
+static PyObject *__pyx_pf_9csamtools_7Samfile___next__(PyObject *__pyx_v_self) {
   int __pyx_v_ret;
   PyObject *__pyx_r = NULL;
   int __pyx_t_1;
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__next__");
-  __Pyx_TraceCall("__next__", __pyx_f[0], 1232);
+  __Pyx_TraceCall("__next__", __pyx_f[0], 1173);
 
-  /* "csamtools.pyx":1237
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1178
  *         """
  *         cdef int ret
  *         ret = samread(self.samfile, self.b)             # <<<<<<<<<<<<<<
@@ -12970,7 +12910,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_21__next__(PyObject *__pyx_v_self)
  */
   __pyx_v_ret = samread(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile, ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->b);
 
-  /* "csamtools.pyx":1238
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1179
  *         cdef int ret
  *         ret = samread(self.samfile, self.b)
  *         if (ret > 0):             # <<<<<<<<<<<<<<
@@ -12980,7 +12920,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_21__next__(PyObject *__pyx_v_self)
   __pyx_t_1 = (__pyx_v_ret > 0);
   if (__pyx_t_1) {
 
-    /* "csamtools.pyx":1239
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1180
  *         ret = samread(self.samfile, self.b)
  *         if (ret > 0):
  *             return makeAlignedRead( self.b )             # <<<<<<<<<<<<<<
@@ -12988,7 +12928,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_21__next__(PyObject *__pyx_v_self)
  *             raise StopIteration
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_2 = __pyx_f_9csamtools_makeAlignedRead(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->b); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = __pyx_f_9csamtools_makeAlignedRead(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->b); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __pyx_r = __pyx_t_2;
     __pyx_t_2 = 0;
@@ -12997,7 +12937,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_21__next__(PyObject *__pyx_v_self)
   }
   /*else*/ {
 
-    /* "csamtools.pyx":1241
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1182
  *             return makeAlignedRead( self.b )
  *         else:
  *             raise StopIteration             # <<<<<<<<<<<<<<
@@ -13005,7 +12945,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_21__next__(PyObject *__pyx_v_self)
  * ##-------------------------------------------------------------------
  */
     __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   __pyx_L5:;
 
@@ -13022,7 +12962,7 @@ static PyObject *__pyx_pf_9csamtools_7Samfile_21__next__(PyObject *__pyx_v_self)
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1293
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1234
  *     cdef int owns_samfile
  * 
  *     def __cinit__(self, Samfile samfile, int tid, int beg, int end, int reopen = True ):             # <<<<<<<<<<<<<<
@@ -13048,7 +12988,7 @@ static int __pyx_pf_9csamtools_17IteratorRowRegion___cinit__(PyObject *__pyx_v_s
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__samfile,&__pyx_n_s__tid,&__pyx_n_s__beg,&__pyx_n_s__end,&__pyx_n_s__reopen,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__cinit__");
-  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1293);
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1234);
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[5] = {0,0,0,0,0};
@@ -13070,19 +13010,19 @@ static int __pyx_pf_9csamtools_17IteratorRowRegion___cinit__(PyObject *__pyx_v_s
       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__tid);
       if (likely(values[1])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 4, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1293; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 4, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
       case  2:
       values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__beg);
       if (likely(values[2])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 4, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1293; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 4, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
       case  3:
       values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end);
       if (likely(values[3])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 4, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1293; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 4, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
       case  4:
       if (kw_args > 0) {
@@ -13091,14 +13031,14 @@ static int __pyx_pf_9csamtools_17IteratorRowRegion___cinit__(PyObject *__pyx_v_s
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1293; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)values[0]);
-    __pyx_v_tid = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_tid == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1293; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-    __pyx_v_beg = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_beg == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1293; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-    __pyx_v_end = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_end == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1293; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_tid = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_tid == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_beg = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_beg == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_end = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_end == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     if (values[4]) {
-      __pyx_v_reopen = __Pyx_PyInt_AsInt(values[4]); if (unlikely((__pyx_v_reopen == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1293; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      __pyx_v_reopen = __Pyx_PyInt_AsInt(values[4]); if (unlikely((__pyx_v_reopen == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     } else {
       __pyx_v_reopen = ((int)1);
     }
@@ -13106,11 +13046,11 @@ static int __pyx_pf_9csamtools_17IteratorRowRegion___cinit__(PyObject *__pyx_v_s
     __pyx_v_reopen = ((int)1);
     switch (PyTuple_GET_SIZE(__pyx_args)) {
       case  5:
-      __pyx_v_reopen = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 4)); if (unlikely((__pyx_v_reopen == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1293; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      __pyx_v_reopen = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 4)); if (unlikely((__pyx_v_reopen == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       case  4:
-      __pyx_v_end = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 3)); if (unlikely((__pyx_v_end == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1293; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-      __pyx_v_beg = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_beg == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1293; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-      __pyx_v_tid = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_tid == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1293; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      __pyx_v_end = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 3)); if (unlikely((__pyx_v_end == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      __pyx_v_beg = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_beg == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      __pyx_v_tid = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_tid == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)PyTuple_GET_ITEM(__pyx_args, 0));
       break;
       default: goto __pyx_L5_argtuple_error;
@@ -13118,7 +13058,7 @@ static int __pyx_pf_9csamtools_17IteratorRowRegion___cinit__(PyObject *__pyx_v_s
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 4, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1293; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 4, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("csamtools.IteratorRowRegion.__cinit__");
   __Pyx_RefNannyFinishContext();
@@ -13126,75 +13066,87 @@ static int __pyx_pf_9csamtools_17IteratorRowRegion___cinit__(PyObject *__pyx_v_s
   __pyx_L4_argument_unpacking_done:;
   __pyx_v_mode = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_store = Py_None; __Pyx_INCREF(Py_None);
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "csamtools.pyx":1295
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1236
  *     def __cinit__(self, Samfile samfile, int tid, int beg, int end, int reopen = True ):
  * 
  *         if not samfile._isOpen():             # <<<<<<<<<<<<<<
  *             raise ValueError( "I/O operation on closed file" )
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_samfile), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_samfile), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
 
-    /* "csamtools.pyx":1296
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1237
  * 
  *         if not samfile._isOpen():
  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  * 
  *         if not samfile._hasIndex():
  */
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_105), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_Raise(__pyx_t_2, 0, 0);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_Raise(__pyx_t_1, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   __pyx_L6:;
 
-  /* "csamtools.pyx":1298
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1239
  *             raise ValueError( "I/O operation on closed file" )
  * 
  *         if not samfile._hasIndex():             # <<<<<<<<<<<<<<
  *             raise ValueError( "no index available for iteration" )
  * 
  */
-  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_samfile), __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_samfile), __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_3 = (!__pyx_t_4);
   if (__pyx_t_3) {
 
-    /* "csamtools.pyx":1299
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1240
  * 
  *         if not samfile._hasIndex():
  *             raise ValueError( "no index available for iteration" )             # <<<<<<<<<<<<<<
  * 
  *         # makes sure that samfile stays alive as long as the
  */
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_107), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_54));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_54));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_54));
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_Raise(__pyx_t_1, 0, 0);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L7;
   }
   __pyx_L7:;
 
-  /* "csamtools.pyx":1303
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1244
  *         # makes sure that samfile stays alive as long as the
  *         # iterator is alive
  *         self.samfile = samfile             # <<<<<<<<<<<<<<
@@ -13207,7 +13159,7 @@ static int __pyx_pf_9csamtools_17IteratorRowRegion___cinit__(PyObject *__pyx_v_s
   __Pyx_DECREF(((PyObject *)((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->samfile));
   ((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->samfile = __pyx_v_samfile;
 
-  /* "csamtools.pyx":1305
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1246
  *         self.samfile = samfile
  * 
  *         if samfile.isbam: mode = "rb"             # <<<<<<<<<<<<<<
@@ -13222,7 +13174,7 @@ static int __pyx_pf_9csamtools_17IteratorRowRegion___cinit__(PyObject *__pyx_v_s
   }
   /*else*/ {
 
-    /* "csamtools.pyx":1306
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1247
  * 
  *         if samfile.isbam: mode = "rb"
  *         else: mode = "r"             # <<<<<<<<<<<<<<
@@ -13235,7 +13187,7 @@ static int __pyx_pf_9csamtools_17IteratorRowRegion___cinit__(PyObject *__pyx_v_s
   }
   __pyx_L8:;
 
-  /* "csamtools.pyx":1310
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1251
  *         # reopen the file - note that this makes the iterator
  *         # slow and causes pileup to slow down significantly.
  *         if reopen:             # <<<<<<<<<<<<<<
@@ -13244,61 +13196,61 @@ static int __pyx_pf_9csamtools_17IteratorRowRegion___cinit__(PyObject *__pyx_v_s
  */
   if (__pyx_v_reopen) {
 
-    /* "csamtools.pyx":1311
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1252
  *         # slow and causes pileup to slow down significantly.
  *         if reopen:
  *             store = StderrStore()             # <<<<<<<<<<<<<<
  *             self.fp = samopen( samfile._filename, mode, NULL )
  *             store.release()
  */
-    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__StderrStore); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__StderrStore); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __Pyx_DECREF(__pyx_v_store);
     __pyx_v_store = __pyx_t_2;
     __pyx_t_2 = 0;
 
-    /* "csamtools.pyx":1312
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1253
  *         if reopen:
  *             store = StderrStore()
  *             self.fp = samopen( samfile._filename, mode, NULL )             # <<<<<<<<<<<<<<
  *             store.release()
  *             assert self.fp != NULL
  */
-    __pyx_t_5 = PyBytes_AsString(__pyx_v_mode); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyBytes_AsString(__pyx_v_mode); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     ((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->fp = samopen(__pyx_v_samfile->_filename, __pyx_t_5, NULL);
 
-    /* "csamtools.pyx":1313
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1254
  *             store = StderrStore()
  *             self.fp = samopen( samfile._filename, mode, NULL )
  *             store.release()             # <<<<<<<<<<<<<<
  *             assert self.fp != NULL
  *             self.owns_samfile = True
  */
-    __pyx_t_2 = PyObject_GetAttr(__pyx_v_store, __pyx_n_s__release); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_store, __pyx_n_s__release); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-    /* "csamtools.pyx":1314
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1255
  *             self.fp = samopen( samfile._filename, mode, NULL )
  *             store.release()
  *             assert self.fp != NULL             # <<<<<<<<<<<<<<
  *             self.owns_samfile = True
  *         else:
  */
-    #ifndef CYTHON_WITHOUT_ASSERTIONS
+    #ifndef PYREX_WITHOUT_ASSERTIONS
     if (unlikely(!(((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->fp != NULL))) {
       PyErr_SetNone(PyExc_AssertionError);
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     }
     #endif
 
-    /* "csamtools.pyx":1315
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1256
  *             store.release()
  *             assert self.fp != NULL
  *             self.owns_samfile = True             # <<<<<<<<<<<<<<
@@ -13310,7 +13262,7 @@ static int __pyx_pf_9csamtools_17IteratorRowRegion___cinit__(PyObject *__pyx_v_s
   }
   /*else*/ {
 
-    /* "csamtools.pyx":1317
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1258
  *             self.owns_samfile = True
  *         else:
  *             self.fp = self.samfile.samfile             # <<<<<<<<<<<<<<
@@ -13319,7 +13271,7 @@ static int __pyx_pf_9csamtools_17IteratorRowRegion___cinit__(PyObject *__pyx_v_s
  */
     ((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->fp = ((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->samfile->samfile;
 
-    /* "csamtools.pyx":1318
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1259
  *         else:
  *             self.fp = self.samfile.samfile
  *             self.owns_samfile = False             # <<<<<<<<<<<<<<
@@ -13330,7 +13282,7 @@ static int __pyx_pf_9csamtools_17IteratorRowRegion___cinit__(PyObject *__pyx_v_s
   }
   __pyx_L9:;
 
-  /* "csamtools.pyx":1320
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1261
  *             self.owns_samfile = False
  * 
  *         self.retval = 0             # <<<<<<<<<<<<<<
@@ -13339,7 +13291,7 @@ static int __pyx_pf_9csamtools_17IteratorRowRegion___cinit__(PyObject *__pyx_v_s
  */
   ((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->retval = 0;
 
-  /* "csamtools.pyx":1322
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1263
  *         self.retval = 0
  * 
  *         self.iter = bam_iter_query(self.samfile.index,             # <<<<<<<<<<<<<<
@@ -13348,7 +13300,7 @@ static int __pyx_pf_9csamtools_17IteratorRowRegion___cinit__(PyObject *__pyx_v_s
  */
   ((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->iter = bam_iter_query(((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->samfile->index, __pyx_v_tid, __pyx_v_beg, __pyx_v_end);
 
-  /* "csamtools.pyx":1326
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1267
  *                                    beg,
  *                                    end)
  *         self.b = bam_init1()             # <<<<<<<<<<<<<<
@@ -13372,7 +13324,7 @@ static int __pyx_pf_9csamtools_17IteratorRowRegion___cinit__(PyObject *__pyx_v_s
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1328
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1269
  *         self.b = bam_init1()
  * 
  *     def __iter__(self):             # <<<<<<<<<<<<<<
@@ -13380,14 +13332,14 @@ static int __pyx_pf_9csamtools_17IteratorRowRegion___cinit__(PyObject *__pyx_v_s
  * 
  */
 
-static PyObject *__pyx_pf_9csamtools_17IteratorRowRegion_1__iter__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_9csamtools_17IteratorRowRegion_1__iter__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_17IteratorRowRegion___iter__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_17IteratorRowRegion___iter__(PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__iter__");
-  __Pyx_TraceCall("__iter__", __pyx_f[0], 1328);
+  __Pyx_TraceCall("__iter__", __pyx_f[0], 1269);
 
-  /* "csamtools.pyx":1329
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1270
  * 
  *     def __iter__(self):
  *         return self             # <<<<<<<<<<<<<<
@@ -13407,7 +13359,7 @@ static PyObject *__pyx_pf_9csamtools_17IteratorRowRegion_1__iter__(PyObject *__p
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1331
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1272
  *         return self
  * 
  *     cdef bam1_t * getCurrent( self ):             # <<<<<<<<<<<<<<
@@ -13419,9 +13371,9 @@ static  bam1_t *__pyx_f_9csamtools_17IteratorRowRegion_getCurrent(struct __pyx_o
   bam1_t *__pyx_r;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("getCurrent");
-  __Pyx_TraceCall("getCurrent", __pyx_f[0], 1331);
+  __Pyx_TraceCall("getCurrent", __pyx_f[0], 1272);
 
-  /* "csamtools.pyx":1332
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1273
  * 
  *     cdef bam1_t * getCurrent( self ):
  *         return self.b             # <<<<<<<<<<<<<<
@@ -13438,7 +13390,7 @@ static  bam1_t *__pyx_f_9csamtools_17IteratorRowRegion_getCurrent(struct __pyx_o
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1334
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1275
  *         return self.b
  * 
  *     cdef int cnext(self):             # <<<<<<<<<<<<<<
@@ -13450,9 +13402,9 @@ static  int __pyx_f_9csamtools_17IteratorRowRegion_cnext(struct __pyx_obj_9csamt
   int __pyx_r;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("cnext");
-  __Pyx_TraceCall("cnext", __pyx_f[0], 1334);
+  __Pyx_TraceCall("cnext", __pyx_f[0], 1275);
 
-  /* "csamtools.pyx":1336
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1277
  *     cdef int cnext(self):
  *         '''cversion of iterator. Used by IteratorColumn'''
  *         self.retval = bam_iter_read( self.fp.x.bam,             # <<<<<<<<<<<<<<
@@ -13467,7 +13419,7 @@ static  int __pyx_f_9csamtools_17IteratorRowRegion_cnext(struct __pyx_obj_9csamt
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1340
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1281
  *                                      self.b)
  * 
  *     def __next__(self):             # <<<<<<<<<<<<<<
@@ -13475,18 +13427,18 @@ static  int __pyx_f_9csamtools_17IteratorRowRegion_cnext(struct __pyx_obj_9csamt
  *         """
  */
 
-static PyObject *__pyx_pf_9csamtools_17IteratorRowRegion_2__next__(PyObject *__pyx_v_self); /*proto*/
-static char __pyx_doc_9csamtools_17IteratorRowRegion_2__next__[] = "python version of next().\n        ";
-struct wrapperbase __pyx_wrapperbase_9csamtools_17IteratorRowRegion_2__next__;
-static PyObject *__pyx_pf_9csamtools_17IteratorRowRegion_2__next__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_17IteratorRowRegion___next__(PyObject *__pyx_v_self); /*proto*/
+static char __pyx_doc_9csamtools_17IteratorRowRegion___next__[] = "python version of next().\n        ";
+struct wrapperbase __pyx_wrapperbase_9csamtools_17IteratorRowRegion___next__;
+static PyObject *__pyx_pf_9csamtools_17IteratorRowRegion___next__(PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
   int __pyx_t_1;
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__next__");
-  __Pyx_TraceCall("__next__", __pyx_f[0], 1340);
+  __Pyx_TraceCall("__next__", __pyx_f[0], 1281);
 
-  /* "csamtools.pyx":1343
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1284
  *         """python version of next().
  *         """
  *         self.cnext()             # <<<<<<<<<<<<<<
@@ -13495,7 +13447,7 @@ static PyObject *__pyx_pf_9csamtools_17IteratorRowRegion_2__next__(PyObject *__p
  */
   ((struct __pyx_vtabstruct_9csamtools_IteratorRowRegion *)((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->__pyx_vtab)->cnext(((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self));
 
-  /* "csamtools.pyx":1344
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1285
  *         """
  *         self.cnext()
  *         if self.retval < 0: raise StopIteration             # <<<<<<<<<<<<<<
@@ -13505,12 +13457,12 @@ static PyObject *__pyx_pf_9csamtools_17IteratorRowRegion_2__next__(PyObject *__p
   __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->retval < 0);
   if (__pyx_t_1) {
     __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":1345
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1286
  *         self.cnext()
  *         if self.retval < 0: raise StopIteration
  *         return makeAlignedRead( self.b )             # <<<<<<<<<<<<<<
@@ -13518,7 +13470,7 @@ static PyObject *__pyx_pf_9csamtools_17IteratorRowRegion_2__next__(PyObject *__p
  *     def __dealloc__(self):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = __pyx_f_9csamtools_makeAlignedRead(((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->b); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __pyx_f_9csamtools_makeAlignedRead(((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->b); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
@@ -13537,7 +13489,7 @@ static PyObject *__pyx_pf_9csamtools_17IteratorRowRegion_2__next__(PyObject *__p
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1347
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1288
  *         return makeAlignedRead( self.b )
  * 
  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
@@ -13545,13 +13497,13 @@ static PyObject *__pyx_pf_9csamtools_17IteratorRowRegion_2__next__(PyObject *__p
  *         if self.owns_samfile: samclose( self.fp )
  */
 
-static void __pyx_pf_9csamtools_17IteratorRowRegion_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
-static void __pyx_pf_9csamtools_17IteratorRowRegion_3__dealloc__(PyObject *__pyx_v_self) {
+static void __pyx_pf_9csamtools_17IteratorRowRegion___dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_pf_9csamtools_17IteratorRowRegion___dealloc__(PyObject *__pyx_v_self) {
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__dealloc__");
-  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1347);
+  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1288);
 
-  /* "csamtools.pyx":1348
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1289
  * 
  *     def __dealloc__(self):
  *         bam_destroy1(self.b)             # <<<<<<<<<<<<<<
@@ -13560,7 +13512,7 @@ static void __pyx_pf_9csamtools_17IteratorRowRegion_3__dealloc__(PyObject *__pyx
  */
   bam_destroy1(((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->b);
 
-  /* "csamtools.pyx":1349
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1290
  *     def __dealloc__(self):
  *         bam_destroy1(self.b)
  *         if self.owns_samfile: samclose( self.fp )             # <<<<<<<<<<<<<<
@@ -13577,8 +13529,8 @@ static void __pyx_pf_9csamtools_17IteratorRowRegion_3__dealloc__(PyObject *__pyx
   __Pyx_RefNannyFinishContext();
 }
 
-/* "csamtools.pyx":1366
- *     cdef int owns_samfile
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1307
+ *     cdef int owns_samfile
  * 
  *     def __cinit__(self, Samfile samfile, int reopen = True ):             # <<<<<<<<<<<<<<
  * 
@@ -13600,7 +13552,7 @@ static int __pyx_pf_9csamtools_14IteratorRowAll___cinit__(PyObject *__pyx_v_self
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__samfile,&__pyx_n_s__reopen,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__cinit__");
-  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1366);
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1307);
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[2] = {0,0};
@@ -13622,18 +13574,18 @@ static int __pyx_pf_9csamtools_14IteratorRowAll___cinit__(PyObject *__pyx_v_self
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1366; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1307; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)values[0]);
     if (values[1]) {
-      __pyx_v_reopen = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_reopen == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1366; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      __pyx_v_reopen = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_reopen == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1307; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     } else {
       __pyx_v_reopen = ((int)1);
     }
   } else {
     __pyx_v_reopen = ((int)1);
     switch (PyTuple_GET_SIZE(__pyx_args)) {
-      case  2: __pyx_v_reopen = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_reopen == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1366; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      case  2: __pyx_v_reopen = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_reopen == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1307; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       case  1: __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)PyTuple_GET_ITEM(__pyx_args, 0));
       break;
       default: goto __pyx_L5_argtuple_error;
@@ -13641,7 +13593,7 @@ static int __pyx_pf_9csamtools_14IteratorRowAll___cinit__(PyObject *__pyx_v_self
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1366; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1307; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("csamtools.IteratorRowAll.__cinit__");
   __Pyx_RefNannyFinishContext();
@@ -13649,42 +13601,48 @@ static int __pyx_pf_9csamtools_14IteratorRowAll___cinit__(PyObject *__pyx_v_self
   __pyx_L4_argument_unpacking_done:;
   __pyx_v_mode = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_store = Py_None; __Pyx_INCREF(Py_None);
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "csamtools.pyx":1368
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1309
  *     def __cinit__(self, Samfile samfile, int reopen = True ):
  * 
  *         if not samfile._isOpen():             # <<<<<<<<<<<<<<
  *             raise ValueError( "I/O operation on closed file" )
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_samfile), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_samfile), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
 
-    /* "csamtools.pyx":1369
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1310
  * 
  *         if not samfile._isOpen():
  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  * 
  *         if samfile.isbam: mode = "rb"
  */
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_108), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_Raise(__pyx_t_2, 0, 0);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_Raise(__pyx_t_1, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   __pyx_L6:;
 
-  /* "csamtools.pyx":1371
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1312
  *             raise ValueError( "I/O operation on closed file" )
  * 
  *         if samfile.isbam: mode = "rb"             # <<<<<<<<<<<<<<
@@ -13699,7 +13657,7 @@ static int __pyx_pf_9csamtools_14IteratorRowAll___cinit__(PyObject *__pyx_v_self
   }
   /*else*/ {
 
-    /* "csamtools.pyx":1372
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1313
  * 
  *         if samfile.isbam: mode = "rb"
  *         else: mode = "r"             # <<<<<<<<<<<<<<
@@ -13712,7 +13670,7 @@ static int __pyx_pf_9csamtools_14IteratorRowAll___cinit__(PyObject *__pyx_v_self
   }
   __pyx_L7:;
 
-  /* "csamtools.pyx":1375
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1316
  * 
  *         # reopen the file to avoid iterator conflict
  *         if reopen:             # <<<<<<<<<<<<<<
@@ -13721,61 +13679,61 @@ static int __pyx_pf_9csamtools_14IteratorRowAll___cinit__(PyObject *__pyx_v_self
  */
   if (__pyx_v_reopen) {
 
-    /* "csamtools.pyx":1376
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1317
  *         # reopen the file to avoid iterator conflict
  *         if reopen:
  *             store = StderrStore()             # <<<<<<<<<<<<<<
  *             self.fp = samopen( samfile._filename, mode, NULL )
  *             store.release()
  */
-    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__StderrStore); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__StderrStore); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __Pyx_DECREF(__pyx_v_store);
-    __pyx_v_store = __pyx_t_1;
-    __pyx_t_1 = 0;
+    __pyx_v_store = __pyx_t_2;
+    __pyx_t_2 = 0;
 
-    /* "csamtools.pyx":1377
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1318
  *         if reopen:
  *             store = StderrStore()
  *             self.fp = samopen( samfile._filename, mode, NULL )             # <<<<<<<<<<<<<<
  *             store.release()
  *             assert self.fp != NULL
  */
-    __pyx_t_5 = PyBytes_AsString(__pyx_v_mode); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1377; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyBytes_AsString(__pyx_v_mode); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     ((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->fp = samopen(__pyx_v_samfile->_filename, __pyx_t_5, NULL);
 
-    /* "csamtools.pyx":1378
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1319
  *             store = StderrStore()
  *             self.fp = samopen( samfile._filename, mode, NULL )
  *             store.release()             # <<<<<<<<<<<<<<
  *             assert self.fp != NULL
  *             self.owns_samfile = True
  */
-    __pyx_t_1 = PyObject_GetAttr(__pyx_v_store, __pyx_n_s__release); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_store, __pyx_n_s__release); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-    /* "csamtools.pyx":1379
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1320
  *             self.fp = samopen( samfile._filename, mode, NULL )
  *             store.release()
  *             assert self.fp != NULL             # <<<<<<<<<<<<<<
  *             self.owns_samfile = True
  *         else:
  */
-    #ifndef CYTHON_WITHOUT_ASSERTIONS
+    #ifndef PYREX_WITHOUT_ASSERTIONS
     if (unlikely(!(((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->fp != NULL))) {
       PyErr_SetNone(PyExc_AssertionError);
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     }
     #endif
 
-    /* "csamtools.pyx":1380
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1321
  *             store.release()
  *             assert self.fp != NULL
  *             self.owns_samfile = True             # <<<<<<<<<<<<<<
@@ -13787,7 +13745,7 @@ static int __pyx_pf_9csamtools_14IteratorRowAll___cinit__(PyObject *__pyx_v_self
   }
   /*else*/ {
 
-    /* "csamtools.pyx":1382
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1323
  *             self.owns_samfile = True
  *         else:
  *             self.fp = samfile.samfile             # <<<<<<<<<<<<<<
@@ -13796,7 +13754,7 @@ static int __pyx_pf_9csamtools_14IteratorRowAll___cinit__(PyObject *__pyx_v_self
  */
     ((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->fp = __pyx_v_samfile->samfile;
 
-    /* "csamtools.pyx":1383
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1324
  *         else:
  *             self.fp = samfile.samfile
  *             self.owns_samfile = False             # <<<<<<<<<<<<<<
@@ -13807,7 +13765,7 @@ static int __pyx_pf_9csamtools_14IteratorRowAll___cinit__(PyObject *__pyx_v_self
   }
   __pyx_L8:;
 
-  /* "csamtools.pyx":1386
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1327
  * 
  *         # allocate memory for alignment
  *         self.b = <bam1_t*>calloc(1, sizeof(bam1_t))             # <<<<<<<<<<<<<<
@@ -13831,7 +13789,7 @@ static int __pyx_pf_9csamtools_14IteratorRowAll___cinit__(PyObject *__pyx_v_self
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1388
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1329
  *         self.b = <bam1_t*>calloc(1, sizeof(bam1_t))
  * 
  *     def __iter__(self):             # <<<<<<<<<<<<<<
@@ -13839,14 +13797,14 @@ static int __pyx_pf_9csamtools_14IteratorRowAll___cinit__(PyObject *__pyx_v_self
  * 
  */
 
-static PyObject *__pyx_pf_9csamtools_14IteratorRowAll_1__iter__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_9csamtools_14IteratorRowAll_1__iter__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_14IteratorRowAll___iter__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_14IteratorRowAll___iter__(PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__iter__");
-  __Pyx_TraceCall("__iter__", __pyx_f[0], 1388);
+  __Pyx_TraceCall("__iter__", __pyx_f[0], 1329);
 
-  /* "csamtools.pyx":1389
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1330
  * 
  *     def __iter__(self):
  *         return self             # <<<<<<<<<<<<<<
@@ -13866,7 +13824,7 @@ static PyObject *__pyx_pf_9csamtools_14IteratorRowAll_1__iter__(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1391
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1332
  *         return self
  * 
  *     cdef bam1_t * getCurrent( self ):             # <<<<<<<<<<<<<<
@@ -13878,9 +13836,9 @@ static  bam1_t *__pyx_f_9csamtools_14IteratorRowAll_getCurrent(struct __pyx_obj_
   bam1_t *__pyx_r;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("getCurrent");
-  __Pyx_TraceCall("getCurrent", __pyx_f[0], 1391);
+  __Pyx_TraceCall("getCurrent", __pyx_f[0], 1332);
 
-  /* "csamtools.pyx":1392
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1333
  * 
  *     cdef bam1_t * getCurrent( self ):
  *         return self.b             # <<<<<<<<<<<<<<
@@ -13897,7 +13855,7 @@ static  bam1_t *__pyx_f_9csamtools_14IteratorRowAll_getCurrent(struct __pyx_obj_
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1394
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1335
  *         return self.b
  * 
  *     cdef int cnext(self):             # <<<<<<<<<<<<<<
@@ -13909,9 +13867,9 @@ static  int __pyx_f_9csamtools_14IteratorRowAll_cnext(struct __pyx_obj_9csamtool
   int __pyx_r;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("cnext");
-  __Pyx_TraceCall("cnext", __pyx_f[0], 1394);
+  __Pyx_TraceCall("cnext", __pyx_f[0], 1335);
 
-  /* "csamtools.pyx":1397
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1338
  *         '''cversion of iterator. Used by IteratorColumn'''
  *         cdef int ret
  *         return samread(self.fp, self.b)             # <<<<<<<<<<<<<<
@@ -13928,7 +13886,7 @@ static  int __pyx_f_9csamtools_14IteratorRowAll_cnext(struct __pyx_obj_9csamtool
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1399
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1340
  *         return samread(self.fp, self.b)
  * 
  *     def __next__(self):             # <<<<<<<<<<<<<<
@@ -13936,19 +13894,19 @@ static  int __pyx_f_9csamtools_14IteratorRowAll_cnext(struct __pyx_obj_9csamtool
  * 
  */
 
-static PyObject *__pyx_pf_9csamtools_14IteratorRowAll_2__next__(PyObject *__pyx_v_self); /*proto*/
-static char __pyx_doc_9csamtools_14IteratorRowAll_2__next__[] = "python version of next().\n\n        pyrex uses this non-standard name instead of next()\n        ";
-struct wrapperbase __pyx_wrapperbase_9csamtools_14IteratorRowAll_2__next__;
-static PyObject *__pyx_pf_9csamtools_14IteratorRowAll_2__next__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_14IteratorRowAll___next__(PyObject *__pyx_v_self); /*proto*/
+static char __pyx_doc_9csamtools_14IteratorRowAll___next__[] = "python version of next().\n\n        pyrex uses this non-standard name instead of next()\n        ";
+struct wrapperbase __pyx_wrapperbase_9csamtools_14IteratorRowAll___next__;
+static PyObject *__pyx_pf_9csamtools_14IteratorRowAll___next__(PyObject *__pyx_v_self) {
   int __pyx_v_ret;
   PyObject *__pyx_r = NULL;
   int __pyx_t_1;
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__next__");
-  __Pyx_TraceCall("__next__", __pyx_f[0], 1399);
+  __Pyx_TraceCall("__next__", __pyx_f[0], 1340);
 
-  /* "csamtools.pyx":1405
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1346
  *         """
  *         cdef int ret
  *         ret = samread(self.fp, self.b)             # <<<<<<<<<<<<<<
@@ -13957,7 +13915,7 @@ static PyObject *__pyx_pf_9csamtools_14IteratorRowAll_2__next__(PyObject *__pyx_
  */
   __pyx_v_ret = samread(((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->fp, ((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->b);
 
-  /* "csamtools.pyx":1406
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1347
  *         cdef int ret
  *         ret = samread(self.fp, self.b)
  *         if (ret > 0):             # <<<<<<<<<<<<<<
@@ -13967,7 +13925,7 @@ static PyObject *__pyx_pf_9csamtools_14IteratorRowAll_2__next__(PyObject *__pyx_
   __pyx_t_1 = (__pyx_v_ret > 0);
   if (__pyx_t_1) {
 
-    /* "csamtools.pyx":1407
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1348
  *         ret = samread(self.fp, self.b)
  *         if (ret > 0):
  *             return makeAlignedRead( self.b )             # <<<<<<<<<<<<<<
@@ -13975,7 +13933,7 @@ static PyObject *__pyx_pf_9csamtools_14IteratorRowAll_2__next__(PyObject *__pyx_
  *             raise StopIteration
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_2 = __pyx_f_9csamtools_makeAlignedRead(((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->b); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = __pyx_f_9csamtools_makeAlignedRead(((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->b); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __pyx_r = __pyx_t_2;
     __pyx_t_2 = 0;
@@ -13984,7 +13942,7 @@ static PyObject *__pyx_pf_9csamtools_14IteratorRowAll_2__next__(PyObject *__pyx_
   }
   /*else*/ {
 
-    /* "csamtools.pyx":1409
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1350
  *             return makeAlignedRead( self.b )
  *         else:
  *             raise StopIteration             # <<<<<<<<<<<<<<
@@ -13992,7 +13950,7 @@ static PyObject *__pyx_pf_9csamtools_14IteratorRowAll_2__next__(PyObject *__pyx_
  *     def __dealloc__(self):
  */
     __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   __pyx_L5:;
 
@@ -14009,7 +13967,7 @@ static PyObject *__pyx_pf_9csamtools_14IteratorRowAll_2__next__(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1411
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1352
  *             raise StopIteration
  * 
  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
@@ -14017,13 +13975,13 @@ static PyObject *__pyx_pf_9csamtools_14IteratorRowAll_2__next__(PyObject *__pyx_
  *         if self.owns_samfile: samclose( self.fp )
  */
 
-static void __pyx_pf_9csamtools_14IteratorRowAll_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
-static void __pyx_pf_9csamtools_14IteratorRowAll_3__dealloc__(PyObject *__pyx_v_self) {
+static void __pyx_pf_9csamtools_14IteratorRowAll___dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_pf_9csamtools_14IteratorRowAll___dealloc__(PyObject *__pyx_v_self) {
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__dealloc__");
-  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1411);
+  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1352);
 
-  /* "csamtools.pyx":1412
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1353
  * 
  *     def __dealloc__(self):
  *         bam_destroy1(self.b)             # <<<<<<<<<<<<<<
@@ -14032,7 +13990,7 @@ static void __pyx_pf_9csamtools_14IteratorRowAll_3__dealloc__(PyObject *__pyx_v_
  */
   bam_destroy1(((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->b);
 
-  /* "csamtools.pyx":1413
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1354
  *     def __dealloc__(self):
  *         bam_destroy1(self.b)
  *         if self.owns_samfile: samclose( self.fp )             # <<<<<<<<<<<<<<
@@ -14049,7 +14007,7 @@ static void __pyx_pf_9csamtools_14IteratorRowAll_3__dealloc__(PyObject *__pyx_v_
   __Pyx_RefNannyFinishContext();
 }
 
-/* "csamtools.pyx":1422
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1363
  *     cdef IteratorRowRegion rowiter
  * 
  *     def __cinit__(self, Samfile samfile):             # <<<<<<<<<<<<<<
@@ -14068,7 +14026,7 @@ static int __pyx_pf_9csamtools_18IteratorRowAllRefs___cinit__(PyObject *__pyx_v_
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__samfile,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__cinit__");
-  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1422);
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1363);
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[1] = {0};
@@ -14084,7 +14042,7 @@ static int __pyx_pf_9csamtools_18IteratorRowAllRefs___cinit__(PyObject *__pyx_v_
       else goto __pyx_L5_argtuple_error;
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1422; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1363; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)values[0]);
   } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
@@ -14094,61 +14052,67 @@ static int __pyx_pf_9csamtools_18IteratorRowAllRefs___cinit__(PyObject *__pyx_v_
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1422; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1363; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("csamtools.IteratorRowAllRefs.__cinit__");
   __Pyx_RefNannyFinishContext();
   return -1;
   __pyx_L4_argument_unpacking_done:;
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "csamtools.pyx":1423
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1364
  * 
  *     def __cinit__(self, Samfile samfile):
  *         assert samfile._isOpen()             # <<<<<<<<<<<<<<
  *         if not samfile._hasIndex(): raise ValueError("no index available for fetch")
  *         self.samfile = samfile
  */
-  #ifndef CYTHON_WITHOUT_ASSERTIONS
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_samfile), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #ifndef PYREX_WITHOUT_ASSERTIONS
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_samfile), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   if (unlikely(!__pyx_t_3)) {
     PyErr_SetNone(PyExc_AssertionError);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   #endif
 
-  /* "csamtools.pyx":1424
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1365
  *     def __cinit__(self, Samfile samfile):
  *         assert samfile._isOpen()
  *         if not samfile._hasIndex(): raise ValueError("no index available for fetch")             # <<<<<<<<<<<<<<
  *         self.samfile = samfile
  *         self.tid = -1
  */
-  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_samfile), __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_samfile), __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_109), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __Pyx_Raise(__pyx_t_1, 0, 0);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_32));
+    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_32));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_32));
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_Raise(__pyx_t_2, 0, 0);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   __pyx_L6:;
 
-  /* "csamtools.pyx":1425
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1366
  *         assert samfile._isOpen()
  *         if not samfile._hasIndex(): raise ValueError("no index available for fetch")
  *         self.samfile = samfile             # <<<<<<<<<<<<<<
@@ -14161,7 +14125,7 @@ static int __pyx_pf_9csamtools_18IteratorRowAllRefs___cinit__(PyObject *__pyx_v_
   __Pyx_DECREF(((PyObject *)((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->samfile));
   ((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->samfile = __pyx_v_samfile;
 
-  /* "csamtools.pyx":1426
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1367
  *         if not samfile._hasIndex(): raise ValueError("no index available for fetch")
  *         self.samfile = samfile
  *         self.tid = -1             # <<<<<<<<<<<<<<
@@ -14183,7 +14147,7 @@ static int __pyx_pf_9csamtools_18IteratorRowAllRefs___cinit__(PyObject *__pyx_v_
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1428
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1369
  *         self.tid = -1
  * 
  *     def nextiter(self):             # <<<<<<<<<<<<<<
@@ -14191,27 +14155,27 @@ static int __pyx_pf_9csamtools_18IteratorRowAllRefs___cinit__(PyObject *__pyx_v_
  * 
  */
 
-static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs_1nextiter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_9csamtools_18IteratorRowAllRefs_1nextiter[] = "IteratorRowAllRefs.nextiter(self)";
-static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs_1nextiter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs_nextiter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static char __pyx_doc_9csamtools_18IteratorRowAllRefs_nextiter[] = "IteratorRowAllRefs.nextiter(self)";
+static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs_nextiter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("nextiter");
-  __Pyx_TraceCall("nextiter", __pyx_f[0], 1428);
+  __Pyx_TraceCall("nextiter", __pyx_f[0], 1369);
 
-  /* "csamtools.pyx":1429
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1370
  * 
  *     def nextiter(self):
  *         self.rowiter = IteratorRowRegion(self.samfile, self.tid, 0, 1<<29)             # <<<<<<<<<<<<<<
  * 
  *     def __iter__(self):
  */
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+  __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
   __Pyx_INCREF(((PyObject *)((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->samfile));
   PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->samfile));
   __Pyx_GIVEREF(((PyObject *)((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->samfile));
@@ -14224,9 +14188,9 @@ static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs_1nextiter(PyObject *__
   PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_int_536870912);
   __Pyx_GIVEREF(__pyx_int_536870912);
   __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorRowRegion)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorRowRegion)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __Pyx_GIVEREF(__pyx_t_1);
   __Pyx_GOTREF(((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->rowiter);
   __Pyx_DECREF(((PyObject *)((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->rowiter));
@@ -14247,7 +14211,7 @@ static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs_1nextiter(PyObject *__
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1431
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1372
  *         self.rowiter = IteratorRowRegion(self.samfile, self.tid, 0, 1<<29)
  * 
  *     def __iter__(self):             # <<<<<<<<<<<<<<
@@ -14255,14 +14219,14 @@ static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs_1nextiter(PyObject *__
  * 
  */
 
-static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs_2__iter__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs_2__iter__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs___iter__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs___iter__(PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__iter__");
-  __Pyx_TraceCall("__iter__", __pyx_f[0], 1431);
+  __Pyx_TraceCall("__iter__", __pyx_f[0], 1372);
 
-  /* "csamtools.pyx":1432
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1373
  * 
  *     def __iter__(self):
  *         return self             # <<<<<<<<<<<<<<
@@ -14282,7 +14246,7 @@ static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs_2__iter__(PyObject *__
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1434
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1375
  *         return self
  * 
  *     def __next__(self):             # <<<<<<<<<<<<<<
@@ -14290,10 +14254,10 @@ static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs_2__iter__(PyObject *__
  * 
  */
 
-static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs_3__next__(PyObject *__pyx_v_self); /*proto*/
-static char __pyx_doc_9csamtools_18IteratorRowAllRefs_3__next__[] = "python version of next().\n\n        pyrex uses this non-standard name instead of next()\n        ";
-struct wrapperbase __pyx_wrapperbase_9csamtools_18IteratorRowAllRefs_3__next__;
-static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs_3__next__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs___next__(PyObject *__pyx_v_self); /*proto*/
+static char __pyx_doc_9csamtools_18IteratorRowAllRefs___next__[] = "python version of next().\n\n        pyrex uses this non-standard name instead of next()\n        ";
+struct wrapperbase __pyx_wrapperbase_9csamtools_18IteratorRowAllRefs___next__;
+static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs___next__(PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
   int __pyx_t_1;
   PyObject *__pyx_t_2 = NULL;
@@ -14302,9 +14266,9 @@ static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs_3__next__(PyObject *__
   PyObject *__pyx_t_5 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__next__");
-  __Pyx_TraceCall("__next__", __pyx_f[0], 1434);
+  __Pyx_TraceCall("__next__", __pyx_f[0], 1375);
 
-  /* "csamtools.pyx":1440
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1381
  *         """
  *         # Create an initial iterator
  *         if self.tid==-1:             # <<<<<<<<<<<<<<
@@ -14314,21 +14278,21 @@ static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs_3__next__(PyObject *__
   __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->tid == -1);
   if (__pyx_t_1) {
 
-    /* "csamtools.pyx":1441
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1382
  *         # Create an initial iterator
  *         if self.tid==-1:
  *             if not self.samfile.nreferences:             # <<<<<<<<<<<<<<
  *                 raise StopIteration
  *             self.tid = 0
  */
-    __pyx_t_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->samfile), __pyx_n_s__nreferences); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->samfile), __pyx_n_s__nreferences); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __pyx_t_3 = (!__pyx_t_1);
     if (__pyx_t_3) {
 
-      /* "csamtools.pyx":1442
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1383
  *         if self.tid==-1:
  *             if not self.samfile.nreferences:
  *                 raise StopIteration             # <<<<<<<<<<<<<<
@@ -14336,12 +14300,12 @@ static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs_3__next__(PyObject *__
  *             self.nextiter()
  */
       __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L6;
     }
     __pyx_L6:;
 
-    /* "csamtools.pyx":1443
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1384
  *             if not self.samfile.nreferences:
  *                 raise StopIteration
  *             self.tid = 0             # <<<<<<<<<<<<<<
@@ -14350,16 +14314,16 @@ static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs_3__next__(PyObject *__
  */
     ((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->tid = 0;
 
-    /* "csamtools.pyx":1444
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1385
  *                 raise StopIteration
  *             self.tid = 0
  *             self.nextiter()             # <<<<<<<<<<<<<<
  * 
  *         while 1:
  */
-    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__nextiter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__nextiter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1385; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1385; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
@@ -14367,7 +14331,7 @@ static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs_3__next__(PyObject *__
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":1446
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1387
  *             self.nextiter()
  * 
  *         while 1:             # <<<<<<<<<<<<<<
@@ -14377,7 +14341,7 @@ static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs_3__next__(PyObject *__
   while (1) {
     if (!1) break;
 
-    /* "csamtools.pyx":1447
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1388
  * 
  *         while 1:
  *             self.rowiter.cnext()             # <<<<<<<<<<<<<<
@@ -14386,7 +14350,7 @@ static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs_3__next__(PyObject *__
  */
     ((struct __pyx_vtabstruct_9csamtools_IteratorRowRegion *)((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->rowiter->__pyx_vtab)->cnext(((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->rowiter);
 
-    /* "csamtools.pyx":1450
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1391
  * 
  *             # If current iterator is not exhausted, return aligned read
  *             if self.rowiter.retval>0:             # <<<<<<<<<<<<<<
@@ -14396,7 +14360,7 @@ static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs_3__next__(PyObject *__
     __pyx_t_3 = (((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->rowiter->retval > 0);
     if (__pyx_t_3) {
 
-      /* "csamtools.pyx":1451
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1392
  *             # If current iterator is not exhausted, return aligned read
  *             if self.rowiter.retval>0:
  *                 return makeAlignedRead(self.rowiter.b)             # <<<<<<<<<<<<<<
@@ -14404,7 +14368,7 @@ static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs_3__next__(PyObject *__
  *             self.tid += 1
  */
       __Pyx_XDECREF(__pyx_r);
-      __pyx_t_4 = __pyx_f_9csamtools_makeAlignedRead(((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->rowiter->b); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = __pyx_f_9csamtools_makeAlignedRead(((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->rowiter->b); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_4);
       __pyx_r = __pyx_t_4;
       __pyx_t_4 = 0;
@@ -14413,44 +14377,44 @@ static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs_3__next__(PyObject *__
     }
     __pyx_L9:;
 
-    /* "csamtools.pyx":1453
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1394
  *                 return makeAlignedRead(self.rowiter.b)
  * 
  *             self.tid += 1             # <<<<<<<<<<<<<<
  * 
  *             # Otherwise, proceed to next reference or stop
  */
-    ((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->tid = (((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->tid + 1);
+    ((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->tid += 1;
 
-    /* "csamtools.pyx":1456
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1397
  * 
  *             # Otherwise, proceed to next reference or stop
  *             if self.tid<self.samfile.nreferences:             # <<<<<<<<<<<<<<
  *                 self.nextiter()
  *             else:
  */
-    __pyx_t_4 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->tid); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->tid); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
-    __pyx_t_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->samfile), __pyx_n_s__nreferences); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->samfile), __pyx_n_s__nreferences); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_5 = PyObject_RichCompare(__pyx_t_4, __pyx_t_2, Py_LT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyObject_RichCompare(__pyx_t_4, __pyx_t_2, Py_LT); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
     if (__pyx_t_3) {
 
-      /* "csamtools.pyx":1457
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1398
  *             # Otherwise, proceed to next reference or stop
  *             if self.tid<self.samfile.nreferences:
  *                 self.nextiter()             # <<<<<<<<<<<<<<
  *             else:
  *                 raise StopIteration
  */
-      __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__nextiter); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__nextiter); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
-      __pyx_t_2 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
@@ -14458,7 +14422,7 @@ static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs_3__next__(PyObject *__
     }
     /*else*/ {
 
-      /* "csamtools.pyx":1459
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1400
  *                 self.nextiter()
  *             else:
  *                 raise StopIteration             # <<<<<<<<<<<<<<
@@ -14466,7 +14430,7 @@ static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs_3__next__(PyObject *__
  * cdef class IteratorRowSelection(IteratorRow):
  */
       __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     }
     __pyx_L10:;
   }
@@ -14486,7 +14450,7 @@ static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs_3__next__(PyObject *__
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1474
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1415
  *     cdef int owns_samfile
  * 
  *     def __cinit__(self, Samfile samfile, positions, int reopen = True ):             # <<<<<<<<<<<<<<
@@ -14510,7 +14474,7 @@ static int __pyx_pf_9csamtools_20IteratorRowSelection___cinit__(PyObject *__pyx_
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__samfile,&__pyx_n_s__positions,&__pyx_n_s__reopen,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__cinit__");
-  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1474);
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1415);
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[3] = {0,0,0};
@@ -14530,7 +14494,7 @@ static int __pyx_pf_9csamtools_20IteratorRowSelection___cinit__(PyObject *__pyx_
       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__positions);
       if (likely(values[1])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1474; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
       case  2:
       if (kw_args > 0) {
@@ -14539,12 +14503,12 @@ static int __pyx_pf_9csamtools_20IteratorRowSelection___cinit__(PyObject *__pyx_
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1474; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)values[0]);
     __pyx_v_positions = values[1];
     if (values[2]) {
-      __pyx_v_reopen = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_reopen == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1474; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      __pyx_v_reopen = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_reopen == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     } else {
       __pyx_v_reopen = ((int)1);
     }
@@ -14552,7 +14516,7 @@ static int __pyx_pf_9csamtools_20IteratorRowSelection___cinit__(PyObject *__pyx_
     __pyx_v_reopen = ((int)1);
     switch (PyTuple_GET_SIZE(__pyx_args)) {
       case  3:
-      __pyx_v_reopen = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_reopen == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1474; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      __pyx_v_reopen = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_reopen == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       case  2:
       __pyx_v_positions = PyTuple_GET_ITEM(__pyx_args, 1);
       __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)PyTuple_GET_ITEM(__pyx_args, 0));
@@ -14562,7 +14526,7 @@ static int __pyx_pf_9csamtools_20IteratorRowSelection___cinit__(PyObject *__pyx_
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1474; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("csamtools.IteratorRowSelection.__cinit__");
   __Pyx_RefNannyFinishContext();
@@ -14570,89 +14534,101 @@ static int __pyx_pf_9csamtools_20IteratorRowSelection___cinit__(PyObject *__pyx_
   __pyx_L4_argument_unpacking_done:;
   __pyx_v_mode = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_store = Py_None; __Pyx_INCREF(Py_None);
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "csamtools.pyx":1476
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1417
  *     def __cinit__(self, Samfile samfile, positions, int reopen = True ):
  * 
  *         if not samfile._isOpen():             # <<<<<<<<<<<<<<
  *             raise ValueError( "I/O operation on closed file" )
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_samfile), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_samfile), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
 
-    /* "csamtools.pyx":1477
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1418
  * 
  *         if not samfile._isOpen():
  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  * 
  *         if not samfile._isOpen():
  */
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_110), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_Raise(__pyx_t_2, 0, 0);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_Raise(__pyx_t_1, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   __pyx_L6:;
 
-  /* "csamtools.pyx":1479
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1420
  *             raise ValueError( "I/O operation on closed file" )
  * 
  *         if not samfile._isOpen():             # <<<<<<<<<<<<<<
  *             raise ValueError( "I/O operation on closed file" )
  * 
  */
-  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_samfile), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1479; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1479; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_samfile), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1479; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_3 = (!__pyx_t_4);
   if (__pyx_t_3) {
 
-    /* "csamtools.pyx":1480
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1421
  * 
  *         if not samfile._isOpen():
  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  * 
  *         assert samfile.isbam, "can only use this iterator on bam files"
  */
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_111), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_Raise(__pyx_t_1, 0, 0);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L7;
   }
   __pyx_L7:;
 
-  /* "csamtools.pyx":1482
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1423
  *             raise ValueError( "I/O operation on closed file" )
  * 
  *         assert samfile.isbam, "can only use this iterator on bam files"             # <<<<<<<<<<<<<<
  *         mode = "rb"
  * 
  */
-  #ifndef CYTHON_WITHOUT_ASSERTIONS
+  #ifndef PYREX_WITHOUT_ASSERTIONS
   if (unlikely(!__pyx_v_samfile->isbam)) {
-    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_112));
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_55));
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   #endif
 
-  /* "csamtools.pyx":1483
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1424
  * 
  *         assert samfile.isbam, "can only use this iterator on bam files"
  *         mode = "rb"             # <<<<<<<<<<<<<<
@@ -14663,7 +14639,7 @@ static int __pyx_pf_9csamtools_20IteratorRowSelection___cinit__(PyObject *__pyx_
   __Pyx_DECREF(__pyx_v_mode);
   __pyx_v_mode = ((PyObject *)__pyx_n_s__rb);
 
-  /* "csamtools.pyx":1486
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1427
  * 
  *         # reopen the file to avoid iterator conflict
  *         if reopen:             # <<<<<<<<<<<<<<
@@ -14672,61 +14648,61 @@ static int __pyx_pf_9csamtools_20IteratorRowSelection___cinit__(PyObject *__pyx_
  */
   if (__pyx_v_reopen) {
 
-    /* "csamtools.pyx":1487
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1428
  *         # reopen the file to avoid iterator conflict
  *         if reopen:
  *             store = StderrStore()             # <<<<<<<<<<<<<<
  *             self.fp = samopen( samfile._filename, mode, NULL )
  *             store.release()
  */
-    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__StderrStore); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__StderrStore); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __Pyx_DECREF(__pyx_v_store);
     __pyx_v_store = __pyx_t_2;
     __pyx_t_2 = 0;
 
-    /* "csamtools.pyx":1488
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1429
  *         if reopen:
  *             store = StderrStore()
  *             self.fp = samopen( samfile._filename, mode, NULL )             # <<<<<<<<<<<<<<
  *             store.release()
  *             assert self.fp != NULL
  */
-    __pyx_t_5 = PyBytes_AsString(__pyx_v_mode); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyBytes_AsString(__pyx_v_mode); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     ((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->fp = samopen(__pyx_v_samfile->_filename, __pyx_t_5, NULL);
 
-    /* "csamtools.pyx":1489
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1430
  *             store = StderrStore()
  *             self.fp = samopen( samfile._filename, mode, NULL )
  *             store.release()             # <<<<<<<<<<<<<<
  *             assert self.fp != NULL
  *             self.owns_samfile = True
  */
-    __pyx_t_2 = PyObject_GetAttr(__pyx_v_store, __pyx_n_s__release); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_store, __pyx_n_s__release); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-    /* "csamtools.pyx":1490
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1431
  *             self.fp = samopen( samfile._filename, mode, NULL )
  *             store.release()
  *             assert self.fp != NULL             # <<<<<<<<<<<<<<
  *             self.owns_samfile = True
  *         else:
  */
-    #ifndef CYTHON_WITHOUT_ASSERTIONS
+    #ifndef PYREX_WITHOUT_ASSERTIONS
     if (unlikely(!(((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->fp != NULL))) {
       PyErr_SetNone(PyExc_AssertionError);
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     }
     #endif
 
-    /* "csamtools.pyx":1491
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1432
  *             store.release()
  *             assert self.fp != NULL
  *             self.owns_samfile = True             # <<<<<<<<<<<<<<
@@ -14738,7 +14714,7 @@ static int __pyx_pf_9csamtools_20IteratorRowSelection___cinit__(PyObject *__pyx_
   }
   /*else*/ {
 
-    /* "csamtools.pyx":1493
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1434
  *             self.owns_samfile = True
  *         else:
  *             self.fp = samfile.samfile             # <<<<<<<<<<<<<<
@@ -14747,7 +14723,7 @@ static int __pyx_pf_9csamtools_20IteratorRowSelection___cinit__(PyObject *__pyx_
  */
     ((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->fp = __pyx_v_samfile->samfile;
 
-    /* "csamtools.pyx":1494
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1435
  *         else:
  *             self.fp = samfile.samfile
  *             self.owns_samfile = False             # <<<<<<<<<<<<<<
@@ -14758,7 +14734,7 @@ static int __pyx_pf_9csamtools_20IteratorRowSelection___cinit__(PyObject *__pyx_
   }
   __pyx_L8:;
 
-  /* "csamtools.pyx":1497
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1438
  * 
  *         # allocate memory for alignment
  *         self.b = <bam1_t*>calloc(1, sizeof(bam1_t))             # <<<<<<<<<<<<<<
@@ -14767,7 +14743,7 @@ static int __pyx_pf_9csamtools_20IteratorRowSelection___cinit__(PyObject *__pyx_
  */
   ((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->b = ((bam1_t *)calloc(1, (sizeof(bam1_t))));
 
-  /* "csamtools.pyx":1499
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1440
  *         self.b = <bam1_t*>calloc(1, sizeof(bam1_t))
  * 
  *         self.positions = positions             # <<<<<<<<<<<<<<
@@ -14780,7 +14756,7 @@ static int __pyx_pf_9csamtools_20IteratorRowSelection___cinit__(PyObject *__pyx_
   __Pyx_DECREF(((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->positions);
   ((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->positions = __pyx_v_positions;
 
-  /* "csamtools.pyx":1500
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1441
  * 
  *         self.positions = positions
  *         self.current_pos = 0             # <<<<<<<<<<<<<<
@@ -14804,7 +14780,7 @@ static int __pyx_pf_9csamtools_20IteratorRowSelection___cinit__(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1502
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1443
  *         self.current_pos = 0
  * 
  *     def __iter__(self):             # <<<<<<<<<<<<<<
@@ -14812,14 +14788,14 @@ static int __pyx_pf_9csamtools_20IteratorRowSelection___cinit__(PyObject *__pyx_
  * 
  */
 
-static PyObject *__pyx_pf_9csamtools_20IteratorRowSelection_1__iter__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_9csamtools_20IteratorRowSelection_1__iter__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_20IteratorRowSelection___iter__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_20IteratorRowSelection___iter__(PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__iter__");
-  __Pyx_TraceCall("__iter__", __pyx_f[0], 1502);
+  __Pyx_TraceCall("__iter__", __pyx_f[0], 1443);
 
-  /* "csamtools.pyx":1503
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1444
  * 
  *     def __iter__(self):
  *         return self             # <<<<<<<<<<<<<<
@@ -14839,7 +14815,7 @@ static PyObject *__pyx_pf_9csamtools_20IteratorRowSelection_1__iter__(PyObject *
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1505
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1446
  *         return self
  * 
  *     cdef bam1_t * getCurrent( self ):             # <<<<<<<<<<<<<<
@@ -14851,9 +14827,9 @@ static  bam1_t *__pyx_f_9csamtools_20IteratorRowSelection_getCurrent(struct __py
   bam1_t *__pyx_r;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("getCurrent");
-  __Pyx_TraceCall("getCurrent", __pyx_f[0], 1505);
+  __Pyx_TraceCall("getCurrent", __pyx_f[0], 1446);
 
-  /* "csamtools.pyx":1506
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1447
  * 
  *     cdef bam1_t * getCurrent( self ):
  *         return self.b             # <<<<<<<<<<<<<<
@@ -14870,7 +14846,7 @@ static  bam1_t *__pyx_f_9csamtools_20IteratorRowSelection_getCurrent(struct __py
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1508
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1449
  *         return self.b
  * 
  *     cdef int cnext(self):             # <<<<<<<<<<<<<<
@@ -14880,56 +14856,53 @@ static  bam1_t *__pyx_f_9csamtools_20IteratorRowSelection_getCurrent(struct __py
 
 static  int __pyx_f_9csamtools_20IteratorRowSelection_cnext(struct __pyx_obj_9csamtools_IteratorRowSelection *__pyx_v_self) {
   int __pyx_r;
-  PyObject *__pyx_t_1 = NULL;
-  Py_ssize_t __pyx_t_2;
-  int __pyx_t_3;
+  Py_ssize_t __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
   uint64_t __pyx_t_4;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("cnext");
-  __Pyx_TraceCall("cnext", __pyx_f[0], 1508);
+  __Pyx_TraceCall("cnext", __pyx_f[0], 1449);
 
-  /* "csamtools.pyx":1512
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1453
  * 
  *         # end iteration if out of positions
  *         if self.current_pos >= len(self.positions): return -1             # <<<<<<<<<<<<<<
  * 
  *         bam_seek( self.fp.x.bam, self.positions[self.current_pos], 0 )
  */
-  __pyx_t_1 = __pyx_v_self->positions;
-  __Pyx_INCREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = (__pyx_v_self->current_pos >= __pyx_t_2);
-  if (__pyx_t_3) {
+  __pyx_t_1 = PyObject_Length(__pyx_v_self->positions); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = (__pyx_v_self->current_pos >= __pyx_t_1);
+  if (__pyx_t_2) {
     __pyx_r = -1;
     goto __pyx_L0;
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "csamtools.pyx":1514
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1455
  *         if self.current_pos >= len(self.positions): return -1
  * 
  *         bam_seek( self.fp.x.bam, self.positions[self.current_pos], 0 )             # <<<<<<<<<<<<<<
  *         self.current_pos += 1
  *         return samread(self.fp, self.b)
  */
-  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->positions, __pyx_v_self->current_pos, sizeof(int), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_4 = __Pyx_PyInt_from_py_uint64_t(__pyx_t_1); if (unlikely((__pyx_t_4 == (uint64_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_self->positions, __pyx_v_self->current_pos, sizeof(int), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = __Pyx_PyInt_from_py_uint64_t(__pyx_t_3); if (unlikely((__pyx_t_4 == (uint64_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   bam_seek(__pyx_v_self->fp->x.bam, __pyx_t_4, 0);
 
-  /* "csamtools.pyx":1515
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1456
  * 
  *         bam_seek( self.fp.x.bam, self.positions[self.current_pos], 0 )
  *         self.current_pos += 1             # <<<<<<<<<<<<<<
  *         return samread(self.fp, self.b)
  * 
  */
-  __pyx_v_self->current_pos = (__pyx_v_self->current_pos + 1);
+  __pyx_v_self->current_pos += 1;
 
-  /* "csamtools.pyx":1516
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1457
  *         bam_seek( self.fp.x.bam, self.positions[self.current_pos], 0 )
  *         self.current_pos += 1
  *         return samread(self.fp, self.b)             # <<<<<<<<<<<<<<
@@ -14942,7 +14915,7 @@ static  int __pyx_f_9csamtools_20IteratorRowSelection_cnext(struct __pyx_obj_9cs
   __pyx_r = 0;
   goto __pyx_L0;
   __pyx_L1_error:;
-  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_3);
   __Pyx_WriteUnraisable("csamtools.IteratorRowSelection.cnext");
   __pyx_r = 0;
   __pyx_L0:;
@@ -14951,7 +14924,7 @@ static  int __pyx_f_9csamtools_20IteratorRowSelection_cnext(struct __pyx_obj_9cs
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1518
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1459
  *         return samread(self.fp, self.b)
  * 
  *     def __next__(self):             # <<<<<<<<<<<<<<
@@ -14959,19 +14932,19 @@ static  int __pyx_f_9csamtools_20IteratorRowSelection_cnext(struct __pyx_obj_9cs
  * 
  */
 
-static PyObject *__pyx_pf_9csamtools_20IteratorRowSelection_2__next__(PyObject *__pyx_v_self); /*proto*/
-static char __pyx_doc_9csamtools_20IteratorRowSelection_2__next__[] = "python version of next().\n\n        pyrex uses this non-standard name instead of next()\n        ";
-struct wrapperbase __pyx_wrapperbase_9csamtools_20IteratorRowSelection_2__next__;
-static PyObject *__pyx_pf_9csamtools_20IteratorRowSelection_2__next__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_20IteratorRowSelection___next__(PyObject *__pyx_v_self); /*proto*/
+static char __pyx_doc_9csamtools_20IteratorRowSelection___next__[] = "python version of next().\n\n        pyrex uses this non-standard name instead of next()\n        ";
+struct wrapperbase __pyx_wrapperbase_9csamtools_20IteratorRowSelection___next__;
+static PyObject *__pyx_pf_9csamtools_20IteratorRowSelection___next__(PyObject *__pyx_v_self) {
   int __pyx_v_ret;
   PyObject *__pyx_r = NULL;
   int __pyx_t_1;
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__next__");
-  __Pyx_TraceCall("__next__", __pyx_f[0], 1518);
+  __Pyx_TraceCall("__next__", __pyx_f[0], 1459);
 
-  /* "csamtools.pyx":1524
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1465
  *         """
  * 
  *         cdef int ret = self.cnext()             # <<<<<<<<<<<<<<
@@ -14980,7 +14953,7 @@ static PyObject *__pyx_pf_9csamtools_20IteratorRowSelection_2__next__(PyObject *
  */
   __pyx_v_ret = ((struct __pyx_vtabstruct_9csamtools_IteratorRowSelection *)((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->__pyx_vtab)->cnext(((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self));
 
-  /* "csamtools.pyx":1525
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1466
  * 
  *         cdef int ret = self.cnext()
  *         if (ret > 0):             # <<<<<<<<<<<<<<
@@ -14990,7 +14963,7 @@ static PyObject *__pyx_pf_9csamtools_20IteratorRowSelection_2__next__(PyObject *
   __pyx_t_1 = (__pyx_v_ret > 0);
   if (__pyx_t_1) {
 
-    /* "csamtools.pyx":1526
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1467
  *         cdef int ret = self.cnext()
  *         if (ret > 0):
  *             return makeAlignedRead( self.b )             # <<<<<<<<<<<<<<
@@ -14998,7 +14971,7 @@ static PyObject *__pyx_pf_9csamtools_20IteratorRowSelection_2__next__(PyObject *
  *             raise StopIteration
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_2 = __pyx_f_9csamtools_makeAlignedRead(((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->b); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = __pyx_f_9csamtools_makeAlignedRead(((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->b); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __pyx_r = __pyx_t_2;
     __pyx_t_2 = 0;
@@ -15007,7 +14980,7 @@ static PyObject *__pyx_pf_9csamtools_20IteratorRowSelection_2__next__(PyObject *
   }
   /*else*/ {
 
-    /* "csamtools.pyx":1528
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1469
  *             return makeAlignedRead( self.b )
  *         else:
  *             raise StopIteration             # <<<<<<<<<<<<<<
@@ -15015,7 +14988,7 @@ static PyObject *__pyx_pf_9csamtools_20IteratorRowSelection_2__next__(PyObject *
  *     def __dealloc__(self):
  */
     __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   __pyx_L5:;
 
@@ -15032,7 +15005,7 @@ static PyObject *__pyx_pf_9csamtools_20IteratorRowSelection_2__next__(PyObject *
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1530
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1471
  *             raise StopIteration
  * 
  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
@@ -15040,13 +15013,13 @@ static PyObject *__pyx_pf_9csamtools_20IteratorRowSelection_2__next__(PyObject *
  *         if self.owns_samfile: samclose( self.fp )
  */
 
-static void __pyx_pf_9csamtools_20IteratorRowSelection_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
-static void __pyx_pf_9csamtools_20IteratorRowSelection_3__dealloc__(PyObject *__pyx_v_self) {
+static void __pyx_pf_9csamtools_20IteratorRowSelection___dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_pf_9csamtools_20IteratorRowSelection___dealloc__(PyObject *__pyx_v_self) {
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__dealloc__");
-  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1530);
+  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1471);
 
-  /* "csamtools.pyx":1531
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1472
  * 
  *     def __dealloc__(self):
  *         bam_destroy1(self.b)             # <<<<<<<<<<<<<<
@@ -15055,7 +15028,7 @@ static void __pyx_pf_9csamtools_20IteratorRowSelection_3__dealloc__(PyObject *__
  */
   bam_destroy1(((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->b);
 
-  /* "csamtools.pyx":1532
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1473
  *     def __dealloc__(self):
  *         bam_destroy1(self.b)
  *         if self.owns_samfile: samclose( self.fp )             # <<<<<<<<<<<<<<
@@ -15072,7 +15045,7 @@ static void __pyx_pf_9csamtools_20IteratorRowSelection_3__dealloc__(PyObject *__
   __Pyx_RefNannyFinishContext();
 }
 
-/* "csamtools.pyx":1545
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1486
  *     int seq_len
  * 
  * cdef int __advance_all( void * data, bam1_t * b ):             # <<<<<<<<<<<<<<
@@ -15085,9 +15058,9 @@ static  int __pyx_f_9csamtools___advance_all(void *__pyx_v_data, bam1_t *__pyx_v
   int __pyx_r;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__advance_all");
-  __Pyx_TraceCall("__advance_all", __pyx_f[0], 1545);
+  __Pyx_TraceCall("__advance_all", __pyx_f[0], 1486);
 
-  /* "csamtools.pyx":1549
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1490
  *     '''
  *     cdef __iterdata * d
  *     d = <__iterdata*>data             # <<<<<<<<<<<<<<
@@ -15096,7 +15069,7 @@ static  int __pyx_f_9csamtools___advance_all(void *__pyx_v_data, bam1_t *__pyx_v
  */
   __pyx_v_d = ((__pyx_t_9csamtools___iterdata *)__pyx_v_data);
 
-  /* "csamtools.pyx":1550
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1491
  *     cdef __iterdata * d
  *     d = <__iterdata*>data
  *     return bam_iter_read( d.samfile.x.bam, d.iter, b )             # <<<<<<<<<<<<<<
@@ -15113,7 +15086,7 @@ static  int __pyx_f_9csamtools___advance_all(void *__pyx_v_data, bam1_t *__pyx_v
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1552
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1493
  *     return bam_iter_read( d.samfile.x.bam, d.iter, b )
  * 
  * cdef int __advance_snpcalls( void * data, bam1_t * b ):             # <<<<<<<<<<<<<<
@@ -15139,9 +15112,9 @@ static  int __pyx_f_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1_t *__
   long __pyx_t_7;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__advance_snpcalls");
-  __Pyx_TraceCall("__advance_snpcalls", __pyx_f[0], 1552);
+  __Pyx_TraceCall("__advance_snpcalls", __pyx_f[0], 1493);
 
-  /* "csamtools.pyx":1557
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1498
  *     '''
  *     cdef __iterdata * d
  *     d = <__iterdata*>data             # <<<<<<<<<<<<<<
@@ -15150,7 +15123,7 @@ static  int __pyx_f_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1_t *__
  */
   __pyx_v_d = ((__pyx_t_9csamtools___iterdata *)__pyx_v_data);
 
-  /* "csamtools.pyx":1559
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1500
  *     d = <__iterdata*>data
  * 
  *     cdef int ret = bam_iter_read( d.samfile.x.bam, d.iter, b )             # <<<<<<<<<<<<<<
@@ -15159,7 +15132,7 @@ static  int __pyx_f_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1_t *__
  */
   __pyx_v_ret = bam_iter_read(__pyx_v_d->samfile->x.bam, __pyx_v_d->iter, __pyx_v_b);
 
-  /* "csamtools.pyx":1560
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1501
  * 
  *     cdef int ret = bam_iter_read( d.samfile.x.bam, d.iter, b )
  *     cdef int skip = 0             # <<<<<<<<<<<<<<
@@ -15168,7 +15141,7 @@ static  int __pyx_f_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1_t *__
  */
   __pyx_v_skip = 0;
 
-  /* "csamtools.pyx":1562
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1503
  *     cdef int skip = 0
  *     cdef int q
  *     cdef int is_cns = 1             # <<<<<<<<<<<<<<
@@ -15177,7 +15150,7 @@ static  int __pyx_f_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1_t *__
  */
   __pyx_v_is_cns = 1;
 
-  /* "csamtools.pyx":1563
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1504
  *     cdef int q
  *     cdef int is_cns = 1
  *     cdef int is_nobaq = 0             # <<<<<<<<<<<<<<
@@ -15186,7 +15159,7 @@ static  int __pyx_f_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1_t *__
  */
   __pyx_v_is_nobaq = 0;
 
-  /* "csamtools.pyx":1564
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1505
  *     cdef int is_cns = 1
  *     cdef int is_nobaq = 0
  *     cdef int capQ_thres = 0             # <<<<<<<<<<<<<<
@@ -15195,7 +15168,7 @@ static  int __pyx_f_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1_t *__
  */
   __pyx_v_capQ_thres = 0;
 
-  /* "csamtools.pyx":1567
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1508
  * 
  *     # reload sequence
  *     if d.fastafile != NULL and b.core.tid != d.tid:             # <<<<<<<<<<<<<<
@@ -15211,7 +15184,7 @@ static  int __pyx_f_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1_t *__
   }
   if (__pyx_t_3) {
 
-    /* "csamtools.pyx":1568
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1509
  *     # reload sequence
  *     if d.fastafile != NULL and b.core.tid != d.tid:
  *         if d.seq != NULL: free(d.seq)             # <<<<<<<<<<<<<<
@@ -15225,7 +15198,7 @@ static  int __pyx_f_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1_t *__
     }
     __pyx_L4:;
 
-    /* "csamtools.pyx":1569
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1510
  *     if d.fastafile != NULL and b.core.tid != d.tid:
  *         if d.seq != NULL: free(d.seq)
  *         d.tid = b.core.tid             # <<<<<<<<<<<<<<
@@ -15234,7 +15207,7 @@ static  int __pyx_f_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1_t *__
  */
     __pyx_v_d->tid = __pyx_v_b->core.tid;
 
-    /* "csamtools.pyx":1570
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1511
  *         if d.seq != NULL: free(d.seq)
  *         d.tid = b.core.tid
  *         d.seq = faidx_fetch_seq(d.fastafile,             # <<<<<<<<<<<<<<
@@ -15243,7 +15216,7 @@ static  int __pyx_f_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1_t *__
  */
     __pyx_v_d->seq = faidx_fetch_seq(__pyx_v_d->fastafile, (__pyx_v_d->samfile->header->target_name[__pyx_v_d->tid]), 0, __pyx_v_9csamtools_max_pos, (&__pyx_v_d->seq_len));
 
-    /* "csamtools.pyx":1574
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1515
  *                                 0, max_pos,
  *                                 &d.seq_len)
  *         if d.seq == NULL:             # <<<<<<<<<<<<<<
@@ -15253,47 +15226,47 @@ static  int __pyx_f_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1_t *__
     __pyx_t_3 = (__pyx_v_d->seq == NULL);
     if (__pyx_t_3) {
 
-      /* "csamtools.pyx":1576
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1517
  *         if d.seq == NULL:
  *             raise ValueError( "reference sequence for '%s' (tid=%i) not found" % \
  *                                   (d.samfile.header.target_name[d.tid],             # <<<<<<<<<<<<<<
  *                                    d.tid))
  * 
  */
-      __pyx_t_4 = PyBytes_FromString((__pyx_v_d->samfile->header->target_name[__pyx_v_d->tid])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = PyBytes_FromString((__pyx_v_d->samfile->header->target_name[__pyx_v_d->tid])); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_4));
 
-      /* "csamtools.pyx":1577
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1518
  *             raise ValueError( "reference sequence for '%s' (tid=%i) not found" % \
  *                                   (d.samfile.header.target_name[d.tid],
  *                                    d.tid))             # <<<<<<<<<<<<<<
  * 
  * 
  */
-      __pyx_t_5 = PyInt_FromLong(__pyx_v_d->tid); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyInt_FromLong(__pyx_v_d->tid); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
-      __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(((PyObject *)__pyx_t_6));
+      __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
       PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_4));
       __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
       PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5);
       __Pyx_GIVEREF(__pyx_t_5);
       __pyx_t_4 = 0;
       __pyx_t_5 = 0;
-      __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_113), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_56), __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_5));
-      __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
-      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(((PyObject *)__pyx_t_6));
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
       PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_5));
       __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
       __pyx_t_5 = 0;
-      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
-      __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
       __Pyx_Raise(__pyx_t_5, 0, 0);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L5;
     }
     __pyx_L5:;
@@ -15301,7 +15274,7 @@ static  int __pyx_f_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1_t *__
   }
   __pyx_L3:;
 
-  /* "csamtools.pyx":1580
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1521
  * 
  * 
  *     while ret >= 0:             # <<<<<<<<<<<<<<
@@ -15312,7 +15285,7 @@ static  int __pyx_f_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1_t *__
     __pyx_t_3 = (__pyx_v_ret >= 0);
     if (!__pyx_t_3) break;
 
-    /* "csamtools.pyx":1582
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1523
  *     while ret >= 0:
  * 
  *         skip = 0             # <<<<<<<<<<<<<<
@@ -15321,7 +15294,7 @@ static  int __pyx_f_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1_t *__
  */
     __pyx_v_skip = 0;
 
-    /* "csamtools.pyx":1585
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1526
  * 
  *         # realign read - changes base qualities
  *         if d.seq != NULL and is_cns and not is_nobaq: bam_prob_realn( b, d.seq )             # <<<<<<<<<<<<<<
@@ -15346,7 +15319,7 @@ static  int __pyx_f_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1_t *__
     }
     __pyx_L8:;
 
-    /* "csamtools.pyx":1587
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1528
  *         if d.seq != NULL and is_cns and not is_nobaq: bam_prob_realn( b, d.seq )
  * 
  *         if d.seq != NULL and capQ_thres > 10:             # <<<<<<<<<<<<<<
@@ -15362,7 +15335,7 @@ static  int __pyx_f_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1_t *__
     }
     if (__pyx_t_2) {
 
-      /* "csamtools.pyx":1588
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1529
  * 
  *         if d.seq != NULL and capQ_thres > 10:
  *             q = bam_cap_mapQ(b, d.seq, capQ_thres)             # <<<<<<<<<<<<<<
@@ -15371,7 +15344,7 @@ static  int __pyx_f_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1_t *__
  */
       __pyx_v_q = bam_cap_mapQ(__pyx_v_b, __pyx_v_d->seq, __pyx_v_capQ_thres);
 
-      /* "csamtools.pyx":1589
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1530
  *         if d.seq != NULL and capQ_thres > 10:
  *             q = bam_cap_mapQ(b, d.seq, capQ_thres)
  *             if q < 0: skip = 1             # <<<<<<<<<<<<<<
@@ -15384,7 +15357,7 @@ static  int __pyx_f_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1_t *__
         goto __pyx_L10;
       }
 
-      /* "csamtools.pyx":1590
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1531
  *             q = bam_cap_mapQ(b, d.seq, capQ_thres)
  *             if q < 0: skip = 1
  *             elif b.core.qual > q: b.core.qual = q             # <<<<<<<<<<<<<<
@@ -15401,7 +15374,7 @@ static  int __pyx_f_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1_t *__
     }
     __pyx_L9:;
 
-    /* "csamtools.pyx":1591
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1532
  *             if q < 0: skip = 1
  *             elif b.core.qual > q: b.core.qual = q
  *         if b.core.flag & BAM_FUNMAP: skip = 1             # <<<<<<<<<<<<<<
@@ -15414,7 +15387,7 @@ static  int __pyx_f_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1_t *__
       goto __pyx_L11;
     }
 
-    /* "csamtools.pyx":1592
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1533
  *             elif b.core.qual > q: b.core.qual = q
  *         if b.core.flag & BAM_FUNMAP: skip = 1
  *         elif b.core.flag & 1 and not b.core.flag & 2: skip = 1             # <<<<<<<<<<<<<<
@@ -15433,7 +15406,7 @@ static  int __pyx_f_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1_t *__
     }
     __pyx_L11:;
 
-    /* "csamtools.pyx":1594
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1535
  *         elif b.core.flag & 1 and not b.core.flag & 2: skip = 1
  * 
  *         if not skip: break             # <<<<<<<<<<<<<<
@@ -15447,7 +15420,7 @@ static  int __pyx_f_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1_t *__
     }
     __pyx_L12:;
 
-    /* "csamtools.pyx":1597
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1538
  *         # additional filters
  * 
  *         ret = bam_iter_read( d.samfile.x.bam, d.iter, b )             # <<<<<<<<<<<<<<
@@ -15458,7 +15431,7 @@ static  int __pyx_f_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1_t *__
   }
   __pyx_L7_break:;
 
-  /* "csamtools.pyx":1599
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1540
  *         ret = bam_iter_read( d.samfile.x.bam, d.iter, b )
  * 
  *     return ret             # <<<<<<<<<<<<<<
@@ -15482,8 +15455,8 @@ static  int __pyx_f_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1_t *__
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1659
- *     cdef int max_depth
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1599
+ *     cdef stepper
  * 
  *     def __cinit__( self, Samfile samfile, **kwargs ):             # <<<<<<<<<<<<<<
  *         self.samfile = samfile
@@ -15501,7 +15474,7 @@ static int __pyx_pf_9csamtools_14IteratorColumn___cinit__(PyObject *__pyx_v_self
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__samfile,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__cinit__");
-  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1659);
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1599);
   __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
   __Pyx_GOTREF(__pyx_v_kwargs);
   if (unlikely(__pyx_kwds)) {
@@ -15519,7 +15492,7 @@ static int __pyx_pf_9csamtools_14IteratorColumn___cinit__(PyObject *__pyx_v_self
       else goto __pyx_L5_argtuple_error;
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1659; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1599; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)values[0]);
   } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
@@ -15529,16 +15502,16 @@ static int __pyx_pf_9csamtools_14IteratorColumn___cinit__(PyObject *__pyx_v_self
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1659; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1599; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_DECREF(__pyx_v_kwargs);
   __Pyx_AddTraceback("csamtools.IteratorColumn.__cinit__");
   __Pyx_RefNannyFinishContext();
   return -1;
   __pyx_L4_argument_unpacking_done:;
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1659; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1599; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "csamtools.pyx":1660
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1600
  * 
  *     def __cinit__( self, Samfile samfile, **kwargs ):
  *         self.samfile = samfile             # <<<<<<<<<<<<<<
@@ -15551,7 +15524,7 @@ static int __pyx_pf_9csamtools_14IteratorColumn___cinit__(PyObject *__pyx_v_self
   __Pyx_DECREF(((PyObject *)((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->samfile));
   ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->samfile = __pyx_v_samfile;
 
-  /* "csamtools.pyx":1661
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1601
  *     def __cinit__( self, Samfile samfile, **kwargs ):
  *         self.samfile = samfile
  *         self.mask = kwargs.get("mask", BAM_DEF_MASK )             # <<<<<<<<<<<<<<
@@ -15559,47 +15532,47 @@ static int __pyx_pf_9csamtools_14IteratorColumn___cinit__(PyObject *__pyx_v_self
  *         self.stepper = kwargs.get( "stepper", None )
  */
   if (unlikely(__pyx_v_kwargs == Py_None)) {
-    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1661; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1601; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
   }
-  __pyx_t_1 = PyInt_FromLong(BAM_DEF_MASK); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(BAM_DEF_MASK); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__mask), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__mask), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->mask = __pyx_t_3;
 
-  /* "csamtools.pyx":1662
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1602
  *         self.samfile = samfile
  *         self.mask = kwargs.get("mask", BAM_DEF_MASK )
  *         self.fastafile = kwargs.get( "fastafile", None )             # <<<<<<<<<<<<<<
  *         self.stepper = kwargs.get( "stepper", None )
- *         self.max_depth = kwargs.get( "max_depth", 8000 )
+ *         self.iterdata.seq = NULL
  */
   if (unlikely(__pyx_v_kwargs == Py_None)) {
-    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1662; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1602; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
   }
-  __pyx_t_2 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__fastafile), Py_None); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__fastafile), Py_None); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_9csamtools_Fastafile))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_9csamtools_Fastafile))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GIVEREF(__pyx_t_2);
   __Pyx_GOTREF(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->fastafile);
   __Pyx_DECREF(((PyObject *)((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->fastafile));
   ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->fastafile = ((struct __pyx_obj_9csamtools_Fastafile *)__pyx_t_2);
   __pyx_t_2 = 0;
 
-  /* "csamtools.pyx":1663
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1603
  *         self.mask = kwargs.get("mask", BAM_DEF_MASK )
  *         self.fastafile = kwargs.get( "fastafile", None )
  *         self.stepper = kwargs.get( "stepper", None )             # <<<<<<<<<<<<<<
- *         self.max_depth = kwargs.get( "max_depth", 8000 )
  *         self.iterdata.seq = NULL
+ *         self.tid = 0
  */
   if (unlikely(__pyx_v_kwargs == Py_None)) {
-    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1663; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1603; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
   }
-  __pyx_t_2 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__stepper), Py_None); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__stepper), Py_None); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_GIVEREF(__pyx_t_2);
   __Pyx_GOTREF(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->stepper);
@@ -15607,33 +15580,17 @@ static int __pyx_pf_9csamtools_14IteratorColumn___cinit__(PyObject *__pyx_v_self
   ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->stepper = __pyx_t_2;
   __pyx_t_2 = 0;
 
-  /* "csamtools.pyx":1664
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1604
  *         self.fastafile = kwargs.get( "fastafile", None )
  *         self.stepper = kwargs.get( "stepper", None )
- *         self.max_depth = kwargs.get( "max_depth", 8000 )             # <<<<<<<<<<<<<<
- *         self.iterdata.seq = NULL
- *         self.tid = 0
- */
-  if (unlikely(__pyx_v_kwargs == Py_None)) {
-    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1664; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
-  }
-  __pyx_t_2 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__max_depth), __pyx_int_8000); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1664; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1664; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->max_depth = __pyx_t_3;
-
-  /* "csamtools.pyx":1665
- *         self.stepper = kwargs.get( "stepper", None )
- *         self.max_depth = kwargs.get( "max_depth", 8000 )
  *         self.iterdata.seq = NULL             # <<<<<<<<<<<<<<
  *         self.tid = 0
  *         self.pos = 0
  */
   ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->iterdata.seq = NULL;
 
-  /* "csamtools.pyx":1666
- *         self.max_depth = kwargs.get( "max_depth", 8000 )
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1605
+ *         self.stepper = kwargs.get( "stepper", None )
  *         self.iterdata.seq = NULL
  *         self.tid = 0             # <<<<<<<<<<<<<<
  *         self.pos = 0
@@ -15641,7 +15598,7 @@ static int __pyx_pf_9csamtools_14IteratorColumn___cinit__(PyObject *__pyx_v_self
  */
   ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->tid = 0;
 
-  /* "csamtools.pyx":1667
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1606
  *         self.iterdata.seq = NULL
  *         self.tid = 0
  *         self.pos = 0             # <<<<<<<<<<<<<<
@@ -15650,7 +15607,7 @@ static int __pyx_pf_9csamtools_14IteratorColumn___cinit__(PyObject *__pyx_v_self
  */
   ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->pos = 0;
 
-  /* "csamtools.pyx":1668
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1607
  *         self.tid = 0
  *         self.pos = 0
  *         self.n_plp = 0             # <<<<<<<<<<<<<<
@@ -15659,7 +15616,7 @@ static int __pyx_pf_9csamtools_14IteratorColumn___cinit__(PyObject *__pyx_v_self
  */
   ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->n_plp = 0;
 
-  /* "csamtools.pyx":1669
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1608
  *         self.pos = 0
  *         self.n_plp = 0
  *         self.plp = NULL             # <<<<<<<<<<<<<<
@@ -15668,12 +15625,12 @@ static int __pyx_pf_9csamtools_14IteratorColumn___cinit__(PyObject *__pyx_v_self
  */
   ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->plp = NULL;
 
-  /* "csamtools.pyx":1670
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1609
  *         self.n_plp = 0
  *         self.plp = NULL
  *         self.pileup_iter = <bam_plp_t>NULL             # <<<<<<<<<<<<<<
  * 
- * 
+ *     def __iter__(self):
  */
   ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->pileup_iter = ((bam_plp_t)NULL);
 
@@ -15691,22 +15648,22 @@ static int __pyx_pf_9csamtools_14IteratorColumn___cinit__(PyObject *__pyx_v_self
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1673
- * 
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1611
+ *         self.pileup_iter = <bam_plp_t>NULL
  * 
  *     def __iter__(self):             # <<<<<<<<<<<<<<
  *         return self
  * 
  */
 
-static PyObject *__pyx_pf_9csamtools_14IteratorColumn_1__iter__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_9csamtools_14IteratorColumn_1__iter__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_14IteratorColumn___iter__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_14IteratorColumn___iter__(PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__iter__");
-  __Pyx_TraceCall("__iter__", __pyx_f[0], 1673);
+  __Pyx_TraceCall("__iter__", __pyx_f[0], 1611);
 
-  /* "csamtools.pyx":1674
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1612
  * 
  *     def __iter__(self):
  *         return self             # <<<<<<<<<<<<<<
@@ -15726,7 +15683,7 @@ static PyObject *__pyx_pf_9csamtools_14IteratorColumn_1__iter__(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1676
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1614
  *         return self
  * 
  *     cdef int cnext(self):             # <<<<<<<<<<<<<<
@@ -15738,9 +15695,9 @@ static  int __pyx_f_9csamtools_14IteratorColumn_cnext(struct __pyx_obj_9csamtool
   int __pyx_r;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("cnext");
-  __Pyx_TraceCall("cnext", __pyx_f[0], 1676);
+  __Pyx_TraceCall("cnext", __pyx_f[0], 1614);
 
-  /* "csamtools.pyx":1682
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1620
  *         It has been re-implemented to permit for filtering.
  *         '''
  *         self.plp = bam_plp_auto( self.pileup_iter,             # <<<<<<<<<<<<<<
@@ -15755,7 +15712,7 @@ static  int __pyx_f_9csamtools_14IteratorColumn_cnext(struct __pyx_obj_9csamtool
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1687
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1625
  *                                  &self.n_plp )
  * 
  *     cdef char * getSequence( self ):             # <<<<<<<<<<<<<<
@@ -15767,9 +15724,9 @@ static  char *__pyx_f_9csamtools_14IteratorColumn_getSequence(struct __pyx_obj_9
   char *__pyx_r;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("getSequence");
-  __Pyx_TraceCall("getSequence", __pyx_f[0], 1687);
+  __Pyx_TraceCall("getSequence", __pyx_f[0], 1625);
 
-  /* "csamtools.pyx":1690
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1628
  *         '''return current reference sequence underlying the iterator.
  *         '''
  *         return self.iterdata.seq             # <<<<<<<<<<<<<<
@@ -15786,7 +15743,7 @@ static  char *__pyx_f_9csamtools_14IteratorColumn_getSequence(struct __pyx_obj_9
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1694
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1632
  *     property seq_len:
  *         '''current sequence length.'''
  *         def __get__(self): return self.iterdata.seq_len             # <<<<<<<<<<<<<<
@@ -15800,9 +15757,9 @@ static PyObject *__pyx_pf_9csamtools_14IteratorColumn_7seq_len___get__(PyObject
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 1694);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 1632);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->iterdata.seq_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->iterdata.seq_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -15821,7 +15778,7 @@ static PyObject *__pyx_pf_9csamtools_14IteratorColumn_7seq_len___get__(PyObject
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1696
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1634
  *         def __get__(self): return self.iterdata.seq_len
  * 
  *     def addReference( self, Fastafile fastafile ):             # <<<<<<<<<<<<<<
@@ -15829,17 +15786,17 @@ static PyObject *__pyx_pf_9csamtools_14IteratorColumn_7seq_len___get__(PyObject
  *        add reference sequences in *fastafile* to iterator.'''
  */
 
-static PyObject *__pyx_pf_9csamtools_14IteratorColumn_2addReference(PyObject *__pyx_v_self, PyObject *__pyx_v_fastafile); /*proto*/
-static char __pyx_doc_9csamtools_14IteratorColumn_2addReference[] = "IteratorColumn.addReference(self, Fastafile fastafile)\n\n       add reference sequences in *fastafile* to iterator.";
-static PyObject *__pyx_pf_9csamtools_14IteratorColumn_2addReference(PyObject *__pyx_v_self, PyObject *__pyx_v_fastafile) {
+static PyObject *__pyx_pf_9csamtools_14IteratorColumn_addReference(PyObject *__pyx_v_self, PyObject *__pyx_v_fastafile); /*proto*/
+static char __pyx_doc_9csamtools_14IteratorColumn_addReference[] = "IteratorColumn.addReference(self, Fastafile fastafile)\n\n       add reference sequences in *fastafile* to iterator.";
+static PyObject *__pyx_pf_9csamtools_14IteratorColumn_addReference(PyObject *__pyx_v_self, PyObject *__pyx_v_fastafile) {
   PyObject *__pyx_r = NULL;
   int __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("addReference");
-  __Pyx_TraceCall("addReference", __pyx_f[0], 1696);
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_fastafile), __pyx_ptype_9csamtools_Fastafile, 1, "fastafile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("addReference", __pyx_f[0], 1634);
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_fastafile), __pyx_ptype_9csamtools_Fastafile, 1, "fastafile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "csamtools.pyx":1699
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1637
  *        '''
  *        add reference sequences in *fastafile* to iterator.'''
  *        self.fastafile = fastafile             # <<<<<<<<<<<<<<
@@ -15852,7 +15809,7 @@ static PyObject *__pyx_pf_9csamtools_14IteratorColumn_2addReference(PyObject *__
   __Pyx_DECREF(((PyObject *)((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->fastafile));
   ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->fastafile = ((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_fastafile);
 
-  /* "csamtools.pyx":1700
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1638
  *        add reference sequences in *fastafile* to iterator.'''
  *        self.fastafile = fastafile
  *        if self.iterdata.seq != NULL: free(self.iterdata.seq)             # <<<<<<<<<<<<<<
@@ -15866,7 +15823,7 @@ static PyObject *__pyx_pf_9csamtools_14IteratorColumn_2addReference(PyObject *__
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":1701
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1639
  *        self.fastafile = fastafile
  *        if self.iterdata.seq != NULL: free(self.iterdata.seq)
  *        self.iterdata.tid = -1             # <<<<<<<<<<<<<<
@@ -15875,7 +15832,7 @@ static PyObject *__pyx_pf_9csamtools_14IteratorColumn_2addReference(PyObject *__
  */
   ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->iterdata.tid = -1;
 
-  /* "csamtools.pyx":1702
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1640
  *        if self.iterdata.seq != NULL: free(self.iterdata.seq)
  *        self.iterdata.tid = -1
  *        self.iterdata.fastafile = self.fastafile.fastafile             # <<<<<<<<<<<<<<
@@ -15896,7 +15853,7 @@ static PyObject *__pyx_pf_9csamtools_14IteratorColumn_2addReference(PyObject *__
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1704
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1642
  *        self.iterdata.fastafile = self.fastafile.fastafile
  * 
  *     def hasReference( self ):             # <<<<<<<<<<<<<<
@@ -15904,15 +15861,15 @@ static PyObject *__pyx_pf_9csamtools_14IteratorColumn_2addReference(PyObject *__
  *         return true if iterator is associated with a reference'''
  */
 
-static PyObject *__pyx_pf_9csamtools_14IteratorColumn_3hasReference(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_9csamtools_14IteratorColumn_3hasReference[] = "IteratorColumn.hasReference(self)\n\n        return true if iterator is associated with a reference";
-static PyObject *__pyx_pf_9csamtools_14IteratorColumn_3hasReference(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+static PyObject *__pyx_pf_9csamtools_14IteratorColumn_hasReference(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static char __pyx_doc_9csamtools_14IteratorColumn_hasReference[] = "IteratorColumn.hasReference(self)\n\n        return true if iterator is associated with a reference";
+static PyObject *__pyx_pf_9csamtools_14IteratorColumn_hasReference(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
   PyObject *__pyx_r = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("hasReference");
-  __Pyx_TraceCall("hasReference", __pyx_f[0], 1704);
+  __Pyx_TraceCall("hasReference", __pyx_f[0], 1642);
 
-  /* "csamtools.pyx":1707
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1645
  *         '''
  *         return true if iterator is associated with a reference'''
  *         return self.fastafile             # <<<<<<<<<<<<<<
@@ -15932,7 +15889,7 @@ static PyObject *__pyx_pf_9csamtools_14IteratorColumn_3hasReference(PyObject *__
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1709
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1647
  *         return self.fastafile
  * 
  *     cdef setMask( self, mask ):             # <<<<<<<<<<<<<<
@@ -15945,19 +15902,19 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_setMask(struct __pyx_obj_9
   int __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("setMask");
-  __Pyx_TraceCall("setMask", __pyx_f[0], 1709);
+  __Pyx_TraceCall("setMask", __pyx_f[0], 1647);
 
-  /* "csamtools.pyx":1714
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1652
  *         reads with bits set in *mask* will be skipped.
  *         '''
  *         self.mask = mask             # <<<<<<<<<<<<<<
  *         bam_plp_set_mask( self.pileup_iter, self.mask )
  * 
  */
-  __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_mask); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1714; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_mask); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_self->mask = __pyx_t_1;
 
-  /* "csamtools.pyx":1715
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1653
  *         '''
  *         self.mask = mask
  *         bam_plp_set_mask( self.pileup_iter, self.mask )             # <<<<<<<<<<<<<<
@@ -15978,7 +15935,7 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_setMask(struct __pyx_obj_9
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1717
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1655
  *         bam_plp_set_mask( self.pileup_iter, self.mask )
  * 
  *     cdef setupIteratorData( self,             # <<<<<<<<<<<<<<
@@ -15999,30 +15956,30 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_setupIteratorData(struct _
   int __pyx_t_8;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("setupIteratorData");
-  __Pyx_TraceCall("setupIteratorData", __pyx_f[0], 1717);
+  __Pyx_TraceCall("setupIteratorData", __pyx_f[0], 1655);
   if (__pyx_optional_args) {
     if (__pyx_optional_args->__pyx_n > 0) {
       __pyx_v_reopen = __pyx_optional_args->reopen;
     }
   }
 
-  /* "csamtools.pyx":1724
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1662
  *         '''setup the iterator structure'''
  * 
  *         self.iter = IteratorRowRegion( self.samfile, tid, start, end, reopen )             # <<<<<<<<<<<<<<
  *         self.iterdata.samfile = self.samfile.samfile
  *         self.iterdata.iter = self.iter.iter
  */
-  __pyx_t_1 = PyInt_FromLong(__pyx_v_tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(__pyx_v_tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyInt_FromLong(__pyx_v_start); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyInt_FromLong(__pyx_v_start); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = PyInt_FromLong(__pyx_v_end); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyInt_FromLong(__pyx_v_end); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_4 = PyInt_FromLong(__pyx_v_reopen); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyInt_FromLong(__pyx_v_reopen); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_5 = PyTuple_New(5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+  __pyx_t_5 = PyTuple_New(5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
   __Pyx_INCREF(((PyObject *)__pyx_v_self->samfile));
   PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_self->samfile));
   __Pyx_GIVEREF(((PyObject *)__pyx_v_self->samfile));
@@ -16038,16 +15995,16 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_setupIteratorData(struct _
   __pyx_t_2 = 0;
   __pyx_t_3 = 0;
   __pyx_t_4 = 0;
-  __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorRowRegion)), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorRowRegion)), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
   __Pyx_GIVEREF(__pyx_t_4);
   __Pyx_GOTREF(__pyx_v_self->iter);
   __Pyx_DECREF(((PyObject *)__pyx_v_self->iter));
   __pyx_v_self->iter = ((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_t_4);
   __pyx_t_4 = 0;
 
-  /* "csamtools.pyx":1725
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1663
  * 
  *         self.iter = IteratorRowRegion( self.samfile, tid, start, end, reopen )
  *         self.iterdata.samfile = self.samfile.samfile             # <<<<<<<<<<<<<<
@@ -16056,7 +16013,7 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_setupIteratorData(struct _
  */
   __pyx_v_self->iterdata.samfile = __pyx_v_self->samfile->samfile;
 
-  /* "csamtools.pyx":1726
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1664
  *         self.iter = IteratorRowRegion( self.samfile, tid, start, end, reopen )
  *         self.iterdata.samfile = self.samfile.samfile
  *         self.iterdata.iter = self.iter.iter             # <<<<<<<<<<<<<<
@@ -16065,7 +16022,7 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_setupIteratorData(struct _
  */
   __pyx_v_self->iterdata.iter = __pyx_v_self->iter->iter;
 
-  /* "csamtools.pyx":1727
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1665
  *         self.iterdata.samfile = self.samfile.samfile
  *         self.iterdata.iter = self.iter.iter
  *         self.iterdata.seq = NULL             # <<<<<<<<<<<<<<
@@ -16074,7 +16031,7 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_setupIteratorData(struct _
  */
   __pyx_v_self->iterdata.seq = NULL;
 
-  /* "csamtools.pyx":1728
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1666
  *         self.iterdata.iter = self.iter.iter
  *         self.iterdata.seq = NULL
  *         self.iterdata.tid = -1             # <<<<<<<<<<<<<<
@@ -16083,20 +16040,20 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_setupIteratorData(struct _
  */
   __pyx_v_self->iterdata.tid = -1;
 
-  /* "csamtools.pyx":1730
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1668
  *         self.iterdata.tid = -1
  * 
  *         if self.fastafile != None:             # <<<<<<<<<<<<<<
  *             self.iterdata.fastafile = self.fastafile.fastafile
  *         else:
  */
-  __pyx_t_4 = PyObject_RichCompare(((PyObject *)__pyx_v_self->fastafile), Py_None, Py_NE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_RichCompare(((PyObject *)__pyx_v_self->fastafile), Py_None, Py_NE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   if (__pyx_t_6) {
 
-    /* "csamtools.pyx":1731
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1669
  * 
  *         if self.fastafile != None:
  *             self.iterdata.fastafile = self.fastafile.fastafile             # <<<<<<<<<<<<<<
@@ -16108,7 +16065,7 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_setupIteratorData(struct _
   }
   /*else*/ {
 
-    /* "csamtools.pyx":1733
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1671
  *             self.iterdata.fastafile = self.fastafile.fastafile
  *         else:
  *             self.iterdata.fastafile = NULL             # <<<<<<<<<<<<<<
@@ -16119,21 +16076,21 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_setupIteratorData(struct _
   }
   __pyx_L3:;
 
-  /* "csamtools.pyx":1735
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1673
  *             self.iterdata.fastafile = NULL
  * 
  *         if self.stepper == None or self.stepper == "all":             # <<<<<<<<<<<<<<
  *             self.pileup_iter = bam_plp_init( &__advance_all, &self.iterdata )
  *         elif self.stepper == "samtools":
  */
-  __pyx_t_4 = PyObject_RichCompare(__pyx_v_self->stepper, Py_None, Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_RichCompare(__pyx_v_self->stepper, Py_None, Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   if (!__pyx_t_6) {
-    __pyx_t_4 = PyObject_RichCompare(__pyx_v_self->stepper, ((PyObject *)__pyx_n_s__all), Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_RichCompare(__pyx_v_self->stepper, ((PyObject *)__pyx_n_s__all), Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
-    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     __pyx_t_8 = __pyx_t_7;
   } else {
@@ -16141,7 +16098,7 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_setupIteratorData(struct _
   }
   if (__pyx_t_8) {
 
-    /* "csamtools.pyx":1736
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1674
  * 
  *         if self.stepper == None or self.stepper == "all":
  *             self.pileup_iter = bam_plp_init( &__advance_all, &self.iterdata )             # <<<<<<<<<<<<<<
@@ -16152,20 +16109,20 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_setupIteratorData(struct _
     goto __pyx_L4;
   }
 
-  /* "csamtools.pyx":1737
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1675
  *         if self.stepper == None or self.stepper == "all":
  *             self.pileup_iter = bam_plp_init( &__advance_all, &self.iterdata )
  *         elif self.stepper == "samtools":             # <<<<<<<<<<<<<<
  *             self.pileup_iter = bam_plp_init( &__advance_snpcalls, &self.iterdata )
  *         else:
  */
-  __pyx_t_4 = PyObject_RichCompare(__pyx_v_self->stepper, ((PyObject *)__pyx_n_s__samtools), Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1737; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_RichCompare(__pyx_v_self->stepper, ((PyObject *)__pyx_n_s__samtools), Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1737; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1675; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   if (__pyx_t_8) {
 
-    /* "csamtools.pyx":1738
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1676
  *             self.pileup_iter = bam_plp_init( &__advance_all, &self.iterdata )
  *         elif self.stepper == "samtools":
  *             self.pileup_iter = bam_plp_init( &__advance_snpcalls, &self.iterdata )             # <<<<<<<<<<<<<<
@@ -16177,53 +16134,32 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_setupIteratorData(struct _
   }
   /*else*/ {
 
-    /* "csamtools.pyx":1740
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1678
  *             self.pileup_iter = bam_plp_init( &__advance_snpcalls, &self.iterdata )
  *         else:
  *             raise ValueError( "unknown stepper option `%s` in IteratorColumn" % self.stepper)             # <<<<<<<<<<<<<<
  * 
- *         if self.max_depth:
+ *         bam_plp_set_mask( self.pileup_iter, self.mask )
  */
-    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_114), __pyx_v_self->stepper); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_57), __pyx_v_self->stepper); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_4));
-    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
     PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_4));
     __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
     __pyx_t_4 = 0;
-    __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
-    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
     __Pyx_Raise(__pyx_t_4, 0, 0);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   __pyx_L4:;
 
-  /* "csamtools.pyx":1742
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1680
  *             raise ValueError( "unknown stepper option `%s` in IteratorColumn" % self.stepper)
  * 
- *         if self.max_depth:             # <<<<<<<<<<<<<<
- *             bam_plp_set_maxcnt( self.pileup_iter, self.max_depth )
- * 
- */
-  if (__pyx_v_self->max_depth) {
-
-    /* "csamtools.pyx":1743
- * 
- *         if self.max_depth:
- *             bam_plp_set_maxcnt( self.pileup_iter, self.max_depth )             # <<<<<<<<<<<<<<
- * 
- *         bam_plp_set_mask( self.pileup_iter, self.mask )
- */
-    bam_plp_set_maxcnt(__pyx_v_self->pileup_iter, __pyx_v_self->max_depth);
-    goto __pyx_L5;
-  }
-  __pyx_L5:;
-
-  /* "csamtools.pyx":1745
- *             bam_plp_set_maxcnt( self.pileup_iter, self.max_depth )
- * 
  *         bam_plp_set_mask( self.pileup_iter, self.mask )             # <<<<<<<<<<<<<<
  * 
  *     cdef reset( self, tid, start, end ):
@@ -16247,7 +16183,7 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_setupIteratorData(struct _
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1747
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1682
  *         bam_plp_set_mask( self.pileup_iter, self.mask )
  * 
  *     cdef reset( self, tid, start, end ):             # <<<<<<<<<<<<<<
@@ -16263,17 +16199,17 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_reset(struct __pyx_obj_9cs
   int __pyx_t_4;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("reset");
-  __Pyx_TraceCall("reset", __pyx_f[0], 1747);
+  __Pyx_TraceCall("reset", __pyx_f[0], 1682);
 
-  /* "csamtools.pyx":1753
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1688
  *         having to incur the full set-up costs.
  *         '''
  *         self.iter = IteratorRowRegion( self.samfile, tid, start, end, reopen = 0 )             # <<<<<<<<<<<<<<
  *         self.iterdata.iter = self.iter.iter
  * 
  */
-  __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
   __Pyx_INCREF(((PyObject *)__pyx_v_self->samfile));
   PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self->samfile));
   __Pyx_GIVEREF(((PyObject *)__pyx_v_self->samfile));
@@ -16286,12 +16222,12 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_reset(struct __pyx_obj_9cs
   __Pyx_INCREF(__pyx_v_end);
   PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_v_end);
   __Pyx_GIVEREF(__pyx_v_end);
-  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__reopen), __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_3 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorRowRegion)), ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__reopen), __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorRowRegion)), __pyx_t_1, ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
   __Pyx_GIVEREF(__pyx_t_3);
   __Pyx_GOTREF(__pyx_v_self->iter);
@@ -16299,7 +16235,7 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_reset(struct __pyx_obj_9cs
   __pyx_v_self->iter = ((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_t_3);
   __pyx_t_3 = 0;
 
-  /* "csamtools.pyx":1754
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1689
  *         '''
  *         self.iter = IteratorRowRegion( self.samfile, tid, start, end, reopen = 0 )
  *         self.iterdata.iter = self.iter.iter             # <<<<<<<<<<<<<<
@@ -16308,23 +16244,23 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_reset(struct __pyx_obj_9cs
  */
   __pyx_v_self->iterdata.iter = __pyx_v_self->iter->iter;
 
-  /* "csamtools.pyx":1757
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1692
  * 
  *         # invalidate sequence if different tid
  *         if self.tid != tid:             # <<<<<<<<<<<<<<
  *             if self.iterdata.seq != NULL: free( self.iterdata.seq )
  *             self.iterdata.seq = NULL
  */
-  __pyx_t_3 = PyInt_FromLong(__pyx_v_self->tid); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyInt_FromLong(__pyx_v_self->tid); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, __pyx_v_tid, Py_NE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, __pyx_v_tid, Py_NE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   if (__pyx_t_4) {
 
-    /* "csamtools.pyx":1758
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1693
  *         # invalidate sequence if different tid
  *         if self.tid != tid:
  *             if self.iterdata.seq != NULL: free( self.iterdata.seq )             # <<<<<<<<<<<<<<
@@ -16338,7 +16274,7 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_reset(struct __pyx_obj_9cs
     }
     __pyx_L4:;
 
-    /* "csamtools.pyx":1759
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1694
  *         if self.tid != tid:
  *             if self.iterdata.seq != NULL: free( self.iterdata.seq )
  *             self.iterdata.seq = NULL             # <<<<<<<<<<<<<<
@@ -16347,7 +16283,7 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_reset(struct __pyx_obj_9cs
  */
     __pyx_v_self->iterdata.seq = NULL;
 
-    /* "csamtools.pyx":1760
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1695
  *             if self.iterdata.seq != NULL: free( self.iterdata.seq )
  *             self.iterdata.seq = NULL
  *             self.iterdata.tid = -1             # <<<<<<<<<<<<<<
@@ -16359,7 +16295,7 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_reset(struct __pyx_obj_9cs
   }
   __pyx_L3:;
 
-  /* "csamtools.pyx":1763
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1698
  * 
  *         # self.pileup_iter = bam_plp_init( &__advancepileup, &self.iterdata )
  *         bam_plp_reset(self.pileup_iter)             # <<<<<<<<<<<<<<
@@ -16383,7 +16319,7 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_reset(struct __pyx_obj_9cs
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1765
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1700
  *         bam_plp_reset(self.pileup_iter)
  * 
  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
@@ -16391,14 +16327,14 @@ static  PyObject *__pyx_f_9csamtools_14IteratorColumn_reset(struct __pyx_obj_9cs
  *         # not been fully consumed
  */
 
-static void __pyx_pf_9csamtools_14IteratorColumn_4__dealloc__(PyObject *__pyx_v_self); /*proto*/
-static void __pyx_pf_9csamtools_14IteratorColumn_4__dealloc__(PyObject *__pyx_v_self) {
+static void __pyx_pf_9csamtools_14IteratorColumn___dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_pf_9csamtools_14IteratorColumn___dealloc__(PyObject *__pyx_v_self) {
   int __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__dealloc__");
-  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1765);
+  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1700);
 
-  /* "csamtools.pyx":1768
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1703
  *         # reset in order to avoid memory leak messages for iterators that have
  *         # not been fully consumed
  *         if self.pileup_iter != <bam_plp_t>NULL:             # <<<<<<<<<<<<<<
@@ -16408,7 +16344,7 @@ static void __pyx_pf_9csamtools_14IteratorColumn_4__dealloc__(PyObject *__pyx_v_
   __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->pileup_iter != ((bam_plp_t)NULL));
   if (__pyx_t_1) {
 
-    /* "csamtools.pyx":1769
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1704
  *         # not been fully consumed
  *         if self.pileup_iter != <bam_plp_t>NULL:
  *             bam_plp_reset(self.pileup_iter)             # <<<<<<<<<<<<<<
@@ -16417,7 +16353,7 @@ static void __pyx_pf_9csamtools_14IteratorColumn_4__dealloc__(PyObject *__pyx_v_
  */
     bam_plp_reset(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->pileup_iter);
 
-    /* "csamtools.pyx":1770
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1705
  *         if self.pileup_iter != <bam_plp_t>NULL:
  *             bam_plp_reset(self.pileup_iter)
  *             bam_plp_destroy(self.pileup_iter)             # <<<<<<<<<<<<<<
@@ -16426,7 +16362,7 @@ static void __pyx_pf_9csamtools_14IteratorColumn_4__dealloc__(PyObject *__pyx_v_
  */
     bam_plp_destroy(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->pileup_iter);
 
-    /* "csamtools.pyx":1771
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1706
  *             bam_plp_reset(self.pileup_iter)
  *             bam_plp_destroy(self.pileup_iter)
  *             self.pileup_iter = <bam_plp_t>NULL             # <<<<<<<<<<<<<<
@@ -16438,7 +16374,7 @@ static void __pyx_pf_9csamtools_14IteratorColumn_4__dealloc__(PyObject *__pyx_v_
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":1773
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1708
  *             self.pileup_iter = <bam_plp_t>NULL
  * 
  *         if self.iterdata.seq != NULL:             # <<<<<<<<<<<<<<
@@ -16448,7 +16384,7 @@ static void __pyx_pf_9csamtools_14IteratorColumn_4__dealloc__(PyObject *__pyx_v_
   __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->iterdata.seq != NULL);
   if (__pyx_t_1) {
 
-    /* "csamtools.pyx":1774
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1709
  * 
  *         if self.iterdata.seq != NULL:
  *             free(self.iterdata.seq)             # <<<<<<<<<<<<<<
@@ -16457,7 +16393,7 @@ static void __pyx_pf_9csamtools_14IteratorColumn_4__dealloc__(PyObject *__pyx_v_
  */
     free(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->iterdata.seq);
 
-    /* "csamtools.pyx":1775
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1710
  *         if self.iterdata.seq != NULL:
  *             free(self.iterdata.seq)
  *             self.iterdata.seq = NULL             # <<<<<<<<<<<<<<
@@ -16473,7 +16409,7 @@ static void __pyx_pf_9csamtools_14IteratorColumn_4__dealloc__(PyObject *__pyx_v_
   __Pyx_RefNannyFinishContext();
 }
 
-/* "csamtools.pyx":1780
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1715
  *     '''iterates over a region only.
  *     '''
  *     def __cinit__(self, Samfile samfile,             # <<<<<<<<<<<<<<
@@ -16494,7 +16430,7 @@ static int __pyx_pf_9csamtools_20IteratorColumnRegion___cinit__(PyObject *__pyx_
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__samfile,&__pyx_n_s__tid,&__pyx_n_s__start,&__pyx_n_s__end,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__cinit__");
-  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1780);
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1715);
   __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
   __Pyx_GOTREF(__pyx_v_kwargs);
   if (unlikely(__pyx_kwds)) {
@@ -16530,32 +16466,32 @@ static int __pyx_pf_9csamtools_20IteratorColumnRegion___cinit__(PyObject *__pyx_
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1780; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1715; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)values[0]);
     if (values[1]) {
-      __pyx_v_tid = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_tid == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1781; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      __pyx_v_tid = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_tid == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1716; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     } else {
       __pyx_v_tid = ((int)0);
     }
     if (values[2]) {
-      __pyx_v_start = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_start == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1782; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      __pyx_v_start = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_start == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1717; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     } else {
       __pyx_v_start = ((int)0);
     }
     if (values[3]) {
-      __pyx_v_end = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_end == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1783; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      __pyx_v_end = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_end == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1718; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     } else {
-      __pyx_v_end = __pyx_k_115;
+      __pyx_v_end = __pyx_k_58;
     }
   } else {
     __pyx_v_tid = ((int)0);
     __pyx_v_start = ((int)0);
-    __pyx_v_end = __pyx_k_115;
+    __pyx_v_end = __pyx_k_58;
     switch (PyTuple_GET_SIZE(__pyx_args)) {
-      case  4: __pyx_v_end = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 3)); if (unlikely((__pyx_v_end == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1783; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-      case  3: __pyx_v_start = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_start == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1782; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-      case  2: __pyx_v_tid = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_tid == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1781; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      case  4: __pyx_v_end = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 3)); if (unlikely((__pyx_v_end == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1718; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      case  3: __pyx_v_start = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_start == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1717; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      case  2: __pyx_v_tid = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_tid == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1716; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       case  1: __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)PyTuple_GET_ITEM(__pyx_args, 0));
       break;
       default: goto __pyx_L5_argtuple_error;
@@ -16563,16 +16499,16 @@ static int __pyx_pf_9csamtools_20IteratorColumnRegion___cinit__(PyObject *__pyx_
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1780; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1715; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_DECREF(__pyx_v_kwargs);
   __Pyx_AddTraceback("csamtools.IteratorColumnRegion.__cinit__");
   __Pyx_RefNannyFinishContext();
   return -1;
   __pyx_L4_argument_unpacking_done:;
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "csamtools.pyx":1787
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1722
  * 
  *         # initialize iterator
  *         self.setupIteratorData( tid, start, end, 1 )             # <<<<<<<<<<<<<<
@@ -16581,7 +16517,7 @@ static int __pyx_pf_9csamtools_20IteratorColumnRegion___cinit__(PyObject *__pyx_
  */
   __pyx_t_2.__pyx_n = 1;
   __pyx_t_2.reopen = 1;
-  __pyx_t_1 = ((struct __pyx_vtabstruct_9csamtools_IteratorColumnRegion *)((struct __pyx_obj_9csamtools_IteratorColumnRegion *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.setupIteratorData(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self), __pyx_v_tid, __pyx_v_start, __pyx_v_end, &__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = ((struct __pyx_vtabstruct_9csamtools_IteratorColumnRegion *)((struct __pyx_obj_9csamtools_IteratorColumnRegion *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.setupIteratorData(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self), __pyx_v_tid, __pyx_v_start, __pyx_v_end, &__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
@@ -16598,7 +16534,7 @@ static int __pyx_pf_9csamtools_20IteratorColumnRegion___cinit__(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1789
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1724
  *         self.setupIteratorData( tid, start, end, 1 )
  * 
  *     def __next__(self):             # <<<<<<<<<<<<<<
@@ -16606,18 +16542,19 @@ static int __pyx_pf_9csamtools_20IteratorColumnRegion___cinit__(PyObject *__pyx_
  *         """
  */
 
-static PyObject *__pyx_pf_9csamtools_20IteratorColumnRegion_1__next__(PyObject *__pyx_v_self); /*proto*/
-static char __pyx_doc_9csamtools_20IteratorColumnRegion_1__next__[] = "python version of next().\n        ";
-struct wrapperbase __pyx_wrapperbase_9csamtools_20IteratorColumnRegion_1__next__;
-static PyObject *__pyx_pf_9csamtools_20IteratorColumnRegion_1__next__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_20IteratorColumnRegion___next__(PyObject *__pyx_v_self); /*proto*/
+static char __pyx_doc_9csamtools_20IteratorColumnRegion___next__[] = "python version of next().\n        ";
+struct wrapperbase __pyx_wrapperbase_9csamtools_20IteratorColumnRegion___next__;
+static PyObject *__pyx_pf_9csamtools_20IteratorColumnRegion___next__(PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
   int __pyx_t_1;
   PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__next__");
-  __Pyx_TraceCall("__next__", __pyx_f[0], 1789);
+  __Pyx_TraceCall("__next__", __pyx_f[0], 1724);
 
-  /* "csamtools.pyx":1793
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1728
  *         """
  * 
  *         while 1:             # <<<<<<<<<<<<<<
@@ -16627,7 +16564,7 @@ static PyObject *__pyx_pf_9csamtools_20IteratorColumnRegion_1__next__(PyObject *
   while (1) {
     if (!1) break;
 
-    /* "csamtools.pyx":1794
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1729
  * 
  *         while 1:
  *             self.cnext()             # <<<<<<<<<<<<<<
@@ -16636,7 +16573,7 @@ static PyObject *__pyx_pf_9csamtools_20IteratorColumnRegion_1__next__(PyObject *
  */
     ((struct __pyx_vtabstruct_9csamtools_IteratorColumnRegion *)((struct __pyx_obj_9csamtools_IteratorColumnRegion *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.cnext(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self));
 
-    /* "csamtools.pyx":1795
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1730
  *         while 1:
  *             self.cnext()
  *             if self.n_plp < 0:             # <<<<<<<<<<<<<<
@@ -16646,23 +16583,29 @@ static PyObject *__pyx_pf_9csamtools_20IteratorColumnRegion_1__next__(PyObject *
     __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorColumnRegion *)__pyx_v_self)->__pyx_base.n_plp < 0);
     if (__pyx_t_1) {
 
-      /* "csamtools.pyx":1796
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1731
  *             self.cnext()
  *             if self.n_plp < 0:
  *                 raise ValueError("error during iteration" )             # <<<<<<<<<<<<<<
  * 
  *             if self.plp == NULL:
  */
-      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_117), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
-      __Pyx_Raise(__pyx_t_2, 0, 0);
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_59));
+      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_59));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_59));
+      __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_Raise(__pyx_t_3, 0, 0);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L7;
     }
     __pyx_L7:;
 
-    /* "csamtools.pyx":1798
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1733
  *                 raise ValueError("error during iteration" )
  * 
  *             if self.plp == NULL:             # <<<<<<<<<<<<<<
@@ -16672,7 +16615,7 @@ static PyObject *__pyx_pf_9csamtools_20IteratorColumnRegion_1__next__(PyObject *
     __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorColumnRegion *)__pyx_v_self)->__pyx_base.plp == NULL);
     if (__pyx_t_1) {
 
-      /* "csamtools.pyx":1799
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1734
  * 
  *             if self.plp == NULL:
  *                 raise StopIteration             # <<<<<<<<<<<<<<
@@ -16680,12 +16623,12 @@ static PyObject *__pyx_pf_9csamtools_20IteratorColumnRegion_1__next__(PyObject *
  *             return makePileupProxy( <bam_pileup1_t*>self.plp,
  */
       __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1734; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L8;
     }
     __pyx_L8:;
 
-    /* "csamtools.pyx":1801
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1736
  *                 raise StopIteration
  * 
  *             return makePileupProxy( <bam_pileup1_t*>self.plp,             # <<<<<<<<<<<<<<
@@ -16694,24 +16637,25 @@ static PyObject *__pyx_pf_9csamtools_20IteratorColumnRegion_1__next__(PyObject *
  */
     __Pyx_XDECREF(__pyx_r);
 
-    /* "csamtools.pyx":1804
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1739
  *                                      self.tid,
  *                                      self.pos,
  *                                      self.n_plp )             # <<<<<<<<<<<<<<
  * 
  * cdef class IteratorColumnAllRefs(IteratorColumn):
  */
-    __pyx_t_2 = __pyx_f_9csamtools_makePileupProxy(((bam_pileup1_t *)((struct __pyx_obj_9csamtools_IteratorColumnRegion *)__pyx_v_self)->__pyx_base.plp), ((struct __pyx_obj_9csamtools_IteratorColumnRegion *)__pyx_v_self)->__pyx_base.tid, ((struct __pyx_obj_9csamtools_IteratorColumnRegion *)__pyx_v_self)->__pyx_base.pos, ((struct __pyx_obj_9csamtools_IteratorColumnRegion *)__pyx_v_self)->__pyx_base.n_plp); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1801; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_2);
-    __pyx_r = __pyx_t_2;
-    __pyx_t_2 = 0;
-    goto __pyx_L0;
+    __pyx_t_3 = __pyx_f_9csamtools_makePileupProxy(((bam_pileup1_t *)((struct __pyx_obj_9csamtools_IteratorColumnRegion *)__pyx_v_self)->__pyx_base.plp), ((struct __pyx_obj_9csamtools_IteratorColumnRegion *)__pyx_v_self)->__pyx_base.tid, ((struct __pyx_obj_9csamtools_IteratorColumnRegion *)__pyx_v_self)->__pyx_base.pos, ((struct __pyx_obj_9csamtools_IteratorColumnRegion *)__pyx_v_self)->__pyx_base.n_plp); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_r = __pyx_t_3;
+    __pyx_t_3 = 0;
+    goto __pyx_L0;
   }
 
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   goto __pyx_L0;
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
   __Pyx_AddTraceback("csamtools.IteratorColumnRegion.__next__");
   __pyx_r = NULL;
   __pyx_L0:;
@@ -16721,7 +16665,7 @@ static PyObject *__pyx_pf_9csamtools_20IteratorColumnRegion_1__next__(PyObject *
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1810
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1745
  *     """
  * 
  *     def __cinit__(self,             # <<<<<<<<<<<<<<
@@ -16741,7 +16685,7 @@ static int __pyx_pf_9csamtools_21IteratorColumnAllRefs___cinit__(PyObject *__pyx
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__samfile,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__cinit__");
-  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1810);
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1745);
   __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
   __Pyx_GOTREF(__pyx_v_kwargs);
   if (unlikely(__pyx_kwds)) {
@@ -16759,7 +16703,7 @@ static int __pyx_pf_9csamtools_21IteratorColumnAllRefs___cinit__(PyObject *__pyx
       else goto __pyx_L5_argtuple_error;
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1810; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1745; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)values[0]);
   } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
@@ -16769,35 +16713,35 @@ static int __pyx_pf_9csamtools_21IteratorColumnAllRefs___cinit__(PyObject *__pyx
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1810; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1745; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_DECREF(__pyx_v_kwargs);
   __Pyx_AddTraceback("csamtools.IteratorColumnAllRefs.__cinit__");
   __Pyx_RefNannyFinishContext();
   return -1;
   __pyx_L4_argument_unpacking_done:;
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "csamtools.pyx":1815
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1750
  * 
  *         # no iteration over empty files
  *         if not samfile.nreferences: raise StopIteration             # <<<<<<<<<<<<<<
  * 
  *         # initialize iterator
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_samfile), __pyx_n_s__nreferences); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_samfile), __pyx_n_s__nreferences); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __pyx_t_3 = (!__pyx_t_2);
   if (__pyx_t_3) {
     __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   __pyx_L6:;
 
-  /* "csamtools.pyx":1818
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1753
  * 
  *         # initialize iterator
  *         self.setupIteratorData( self.tid, 0, max_pos, 1 )             # <<<<<<<<<<<<<<
@@ -16806,7 +16750,7 @@ static int __pyx_pf_9csamtools_21IteratorColumnAllRefs___cinit__(PyObject *__pyx
  */
   __pyx_t_4.__pyx_n = 1;
   __pyx_t_4.reopen = 1;
-  __pyx_t_1 = ((struct __pyx_vtabstruct_9csamtools_IteratorColumnAllRefs *)((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.setupIteratorData(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self), ((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.tid, 0, __pyx_v_9csamtools_max_pos, &__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = ((struct __pyx_vtabstruct_9csamtools_IteratorColumnAllRefs *)((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.setupIteratorData(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self), ((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.tid, 0, __pyx_v_9csamtools_max_pos, &__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
@@ -16823,7 +16767,7 @@ static int __pyx_pf_9csamtools_21IteratorColumnAllRefs___cinit__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1820
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1755
  *         self.setupIteratorData( self.tid, 0, max_pos, 1 )
  * 
  *     def __next__(self):             # <<<<<<<<<<<<<<
@@ -16831,10 +16775,10 @@ static int __pyx_pf_9csamtools_21IteratorColumnAllRefs___cinit__(PyObject *__pyx
  *         """
  */
 
-static PyObject *__pyx_pf_9csamtools_21IteratorColumnAllRefs_1__next__(PyObject *__pyx_v_self); /*proto*/
-static char __pyx_doc_9csamtools_21IteratorColumnAllRefs_1__next__[] = "python version of next().\n        ";
-struct wrapperbase __pyx_wrapperbase_9csamtools_21IteratorColumnAllRefs_1__next__;
-static PyObject *__pyx_pf_9csamtools_21IteratorColumnAllRefs_1__next__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_21IteratorColumnAllRefs___next__(PyObject *__pyx_v_self); /*proto*/
+static char __pyx_doc_9csamtools_21IteratorColumnAllRefs___next__[] = "python version of next().\n        ";
+struct wrapperbase __pyx_wrapperbase_9csamtools_21IteratorColumnAllRefs___next__;
+static PyObject *__pyx_pf_9csamtools_21IteratorColumnAllRefs___next__(PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
   int __pyx_t_1;
   PyObject *__pyx_t_2 = NULL;
@@ -16843,9 +16787,9 @@ static PyObject *__pyx_pf_9csamtools_21IteratorColumnAllRefs_1__next__(PyObject
   struct __pyx_opt_args_9csamtools_14IteratorColumn_setupIteratorData __pyx_t_5;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__next__");
-  __Pyx_TraceCall("__next__", __pyx_f[0], 1820);
+  __Pyx_TraceCall("__next__", __pyx_f[0], 1755);
 
-  /* "csamtools.pyx":1824
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1759
  *         """
  * 
  *         while 1:             # <<<<<<<<<<<<<<
@@ -16855,7 +16799,7 @@ static PyObject *__pyx_pf_9csamtools_21IteratorColumnAllRefs_1__next__(PyObject
   while (1) {
     if (!1) break;
 
-    /* "csamtools.pyx":1825
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1760
  * 
  *         while 1:
  *             self.cnext()             # <<<<<<<<<<<<<<
@@ -16864,7 +16808,7 @@ static PyObject *__pyx_pf_9csamtools_21IteratorColumnAllRefs_1__next__(PyObject
  */
     ((struct __pyx_vtabstruct_9csamtools_IteratorColumnAllRefs *)((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.cnext(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self));
 
-    /* "csamtools.pyx":1827
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1762
  *             self.cnext()
  * 
  *             if self.n_plp < 0:             # <<<<<<<<<<<<<<
@@ -16874,23 +16818,29 @@ static PyObject *__pyx_pf_9csamtools_21IteratorColumnAllRefs_1__next__(PyObject
     __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.n_plp < 0);
     if (__pyx_t_1) {
 
-      /* "csamtools.pyx":1828
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1763
  * 
  *             if self.n_plp < 0:
  *                 raise ValueError("error during iteration" )             # <<<<<<<<<<<<<<
  * 
  *             # return result, if within same reference
  */
-      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_118), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
-      __Pyx_Raise(__pyx_t_2, 0, 0);
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_59));
+      PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_59));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_59));
+      __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_Raise(__pyx_t_3, 0, 0);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L7;
     }
     __pyx_L7:;
 
-    /* "csamtools.pyx":1831
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1766
  * 
  *             # return result, if within same reference
  *             if self.plp != NULL:             # <<<<<<<<<<<<<<
@@ -16900,7 +16850,7 @@ static PyObject *__pyx_pf_9csamtools_21IteratorColumnAllRefs_1__next__(PyObject
     __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.plp != NULL);
     if (__pyx_t_1) {
 
-      /* "csamtools.pyx":1832
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1767
  *             # return result, if within same reference
  *             if self.plp != NULL:
  *                 return makePileupProxy( <bam_pileup1_t*>self.plp,             # <<<<<<<<<<<<<<
@@ -16909,51 +16859,51 @@ static PyObject *__pyx_pf_9csamtools_21IteratorColumnAllRefs_1__next__(PyObject
  */
       __Pyx_XDECREF(__pyx_r);
 
-      /* "csamtools.pyx":1835
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1770
  *                                          self.tid,
  *                                          self.pos,
  *                                          self.n_plp )             # <<<<<<<<<<<<<<
  * 
  *             # otherwise, proceed to next reference or stop
  */
-      __pyx_t_2 = __pyx_f_9csamtools_makePileupProxy(((bam_pileup1_t *)((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.plp), ((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.tid, ((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.pos, ((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.n_plp); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_2);
-      __pyx_r = __pyx_t_2;
-      __pyx_t_2 = 0;
+      __pyx_t_3 = __pyx_f_9csamtools_makePileupProxy(((bam_pileup1_t *)((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.plp), ((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.tid, ((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.pos, ((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.n_plp); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_r = __pyx_t_3;
+      __pyx_t_3 = 0;
       goto __pyx_L0;
       goto __pyx_L8;
     }
     __pyx_L8:;
 
-    /* "csamtools.pyx":1838
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1773
  * 
  *             # otherwise, proceed to next reference or stop
  *             self.tid += 1             # <<<<<<<<<<<<<<
  *             if self.tid < self.samfile.nreferences:
  *                 self.setupIteratorData( self.tid, 0, max_pos, 0 )
  */
-    ((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.tid = (((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.tid + 1);
+    ((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.tid += 1;
 
-    /* "csamtools.pyx":1839
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1774
  *             # otherwise, proceed to next reference or stop
  *             self.tid += 1
  *             if self.tid < self.samfile.nreferences:             # <<<<<<<<<<<<<<
  *                 self.setupIteratorData( self.tid, 0, max_pos, 0 )
  *             else:
  */
-    __pyx_t_2 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.tid); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_3 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.samfile), __pyx_n_s__nreferences); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.tid); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_LT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.samfile), __pyx_n_s__nreferences); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_4 = PyObject_RichCompare(__pyx_t_3, __pyx_t_2, Py_LT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
-    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     if (__pyx_t_1) {
 
-      /* "csamtools.pyx":1840
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1775
  *             self.tid += 1
  *             if self.tid < self.samfile.nreferences:
  *                 self.setupIteratorData( self.tid, 0, max_pos, 0 )             # <<<<<<<<<<<<<<
@@ -16962,14 +16912,14 @@ static PyObject *__pyx_pf_9csamtools_21IteratorColumnAllRefs_1__next__(PyObject
  */
       __pyx_t_5.__pyx_n = 1;
       __pyx_t_5.reopen = 0;
-      __pyx_t_4 = ((struct __pyx_vtabstruct_9csamtools_IteratorColumnAllRefs *)((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.setupIteratorData(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self), ((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.tid, 0, __pyx_v_9csamtools_max_pos, &__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = ((struct __pyx_vtabstruct_9csamtools_IteratorColumnAllRefs *)((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.__pyx_vtab)->__pyx_base.setupIteratorData(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self), ((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.tid, 0, __pyx_v_9csamtools_max_pos, &__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_4);
       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
       goto __pyx_L9;
     }
     /*else*/ {
 
-      /* "csamtools.pyx":1842
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1777
  *                 self.setupIteratorData( self.tid, 0, max_pos, 0 )
  *             else:
  *                 raise StopIteration             # <<<<<<<<<<<<<<
@@ -16977,7 +16927,7 @@ static PyObject *__pyx_pf_9csamtools_21IteratorColumnAllRefs_1__next__(PyObject
  * ##-------------------------------------------------------------------
  */
       __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     }
     __pyx_L9:;
   }
@@ -16997,7 +16947,7 @@ static PyObject *__pyx_pf_9csamtools_21IteratorColumnAllRefs_1__next__(PyObject
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1847
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1782
  * ##-------------------------------------------------------------------
  * ##-------------------------------------------------------------------
  * cdef inline int32_t query_start(bam1_t *src) except -1:             # <<<<<<<<<<<<<<
@@ -17017,9 +16967,9 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_start(bam1_t *__pyx_v_src)
   int __pyx_t_4;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("query_start");
-  __Pyx_TraceCall("query_start", __pyx_f[0], 1847);
+  __Pyx_TraceCall("query_start", __pyx_f[0], 1782);
 
-  /* "csamtools.pyx":1850
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1785
  *     cdef uint32_t * cigar_p, op
  *     cdef uint32_t k
  *     cdef uint32_t start_offset = 0             # <<<<<<<<<<<<<<
@@ -17028,7 +16978,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_start(bam1_t *__pyx_v_src)
  */
   __pyx_v_start_offset = 0;
 
-  /* "csamtools.pyx":1852
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1787
  *     cdef uint32_t start_offset = 0
  * 
  *     if src.core.n_cigar:             # <<<<<<<<<<<<<<
@@ -17037,7 +16987,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_start(bam1_t *__pyx_v_src)
  */
   if (__pyx_v_src->core.n_cigar) {
 
-    /* "csamtools.pyx":1853
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1788
  * 
  *     if src.core.n_cigar:
  *         cigar_p = bam1_cigar(src);             # <<<<<<<<<<<<<<
@@ -17046,7 +16996,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_start(bam1_t *__pyx_v_src)
  */
     __pyx_v_cigar_p = bam1_cigar(__pyx_v_src);
 
-    /* "csamtools.pyx":1854
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1789
  *     if src.core.n_cigar:
  *         cigar_p = bam1_cigar(src);
  *         for k from 0 <= k < src.core.n_cigar:             # <<<<<<<<<<<<<<
@@ -17056,7 +17006,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_start(bam1_t *__pyx_v_src)
     __pyx_t_1 = __pyx_v_src->core.n_cigar;
     for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_1; __pyx_v_k++) {
 
-      /* "csamtools.pyx":1855
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1790
  *         cigar_p = bam1_cigar(src);
  *         for k from 0 <= k < src.core.n_cigar:
  *             op = cigar_p[k] & BAM_CIGAR_MASK             # <<<<<<<<<<<<<<
@@ -17065,25 +17015,17 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_start(bam1_t *__pyx_v_src)
  */
       __pyx_v_op = ((__pyx_v_cigar_p[__pyx_v_k]) & 15);
 
-      /* "csamtools.pyx":1860
- *                     PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string')
- *                     return -1
- *             elif op==BAM_CSOFT_CLIP:             # <<<<<<<<<<<<<<
- *                 start_offset += cigar_p[k] >> BAM_CIGAR_SHIFT
- *             else:
- */
-      switch (__pyx_v_op) {
-
-        /* "csamtools.pyx":1856
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1791
  *         for k from 0 <= k < src.core.n_cigar:
  *             op = cigar_p[k] & BAM_CIGAR_MASK
  *             if op==BAM_CHARD_CLIP:             # <<<<<<<<<<<<<<
  *                 if start_offset!=0 and start_offset!=src.core.l_qseq:
  *                     PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string')
  */
+      switch (__pyx_v_op) {
         case 5:
 
-        /* "csamtools.pyx":1857
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1792
  *             op = cigar_p[k] & BAM_CIGAR_MASK
  *             if op==BAM_CHARD_CLIP:
  *                 if start_offset!=0 and start_offset!=src.core.l_qseq:             # <<<<<<<<<<<<<<
@@ -17099,16 +17041,16 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_start(bam1_t *__pyx_v_src)
         }
         if (__pyx_t_4) {
 
-          /* "csamtools.pyx":1858
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1793
  *             if op==BAM_CHARD_CLIP:
  *                 if start_offset!=0 and start_offset!=src.core.l_qseq:
  *                     PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string')             # <<<<<<<<<<<<<<
  *                     return -1
  *             elif op==BAM_CSOFT_CLIP:
  */
-          PyErr_SetString(__pyx_builtin_ValueError, __pyx_k_119);
+          PyErr_SetString(__pyx_builtin_ValueError, __pyx_k_60);
 
-          /* "csamtools.pyx":1859
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1794
  *                 if start_offset!=0 and start_offset!=src.core.l_qseq:
  *                     PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string')
  *                     return -1             # <<<<<<<<<<<<<<
@@ -17122,7 +17064,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_start(bam1_t *__pyx_v_src)
         __pyx_L6:;
         break;
 
-        /* "csamtools.pyx":1860
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1795
  *                     PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string')
  *                     return -1
  *             elif op==BAM_CSOFT_CLIP:             # <<<<<<<<<<<<<<
@@ -17131,18 +17073,18 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_start(bam1_t *__pyx_v_src)
  */
         case 4:
 
-        /* "csamtools.pyx":1861
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1796
  *                     return -1
  *             elif op==BAM_CSOFT_CLIP:
  *                 start_offset += cigar_p[k] >> BAM_CIGAR_SHIFT             # <<<<<<<<<<<<<<
  *             else:
  *                 break
  */
-        __pyx_v_start_offset = (__pyx_v_start_offset + ((__pyx_v_cigar_p[__pyx_v_k]) >> 4));
+        __pyx_v_start_offset += ((__pyx_v_cigar_p[__pyx_v_k]) >> 4);
         break;
         default:
 
-        /* "csamtools.pyx":1863
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1798
  *                 start_offset += cigar_p[k] >> BAM_CIGAR_SHIFT
  *             else:
  *                 break             # <<<<<<<<<<<<<<
@@ -17158,7 +17100,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_start(bam1_t *__pyx_v_src)
   }
   __pyx_L3:;
 
-  /* "csamtools.pyx":1865
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1800
  *                 break
  * 
  *     return start_offset             # <<<<<<<<<<<<<<
@@ -17175,7 +17117,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_start(bam1_t *__pyx_v_src)
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1870
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1805
  * ##-------------------------------------------------------------------
  * ##-------------------------------------------------------------------
  * cdef inline int32_t query_end(bam1_t *src) except -1:             # <<<<<<<<<<<<<<
@@ -17194,9 +17136,9 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_end(bam1_t *__pyx_v_src) {
   int __pyx_t_3;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("query_end");
-  __Pyx_TraceCall("query_end", __pyx_f[0], 1870);
+  __Pyx_TraceCall("query_end", __pyx_f[0], 1805);
 
-  /* "csamtools.pyx":1873
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1808
  *     cdef uint32_t * cigar_p, op
  *     cdef uint32_t k
  *     cdef uint32_t end_offset = src.core.l_qseq             # <<<<<<<<<<<<<<
@@ -17205,7 +17147,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_end(bam1_t *__pyx_v_src) {
  */
   __pyx_v_end_offset = __pyx_v_src->core.l_qseq;
 
-  /* "csamtools.pyx":1875
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1810
  *     cdef uint32_t end_offset = src.core.l_qseq
  * 
  *     if src.core.n_cigar>1:             # <<<<<<<<<<<<<<
@@ -17215,7 +17157,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_end(bam1_t *__pyx_v_src) {
   __pyx_t_1 = (__pyx_v_src->core.n_cigar > 1);
   if (__pyx_t_1) {
 
-    /* "csamtools.pyx":1876
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1811
  * 
  *     if src.core.n_cigar>1:
  *         cigar_p = bam1_cigar(src);             # <<<<<<<<<<<<<<
@@ -17224,7 +17166,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_end(bam1_t *__pyx_v_src) {
  */
     __pyx_v_cigar_p = bam1_cigar(__pyx_v_src);
 
-    /* "csamtools.pyx":1877
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1812
  *     if src.core.n_cigar>1:
  *         cigar_p = bam1_cigar(src);
  *         for k from src.core.n_cigar > k >= 1:             # <<<<<<<<<<<<<<
@@ -17233,7 +17175,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_end(bam1_t *__pyx_v_src) {
  */
     for (__pyx_v_k = __pyx_v_src->core.n_cigar-1; __pyx_v_k >= 1; __pyx_v_k--) {
 
-      /* "csamtools.pyx":1878
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1813
  *         cigar_p = bam1_cigar(src);
  *         for k from src.core.n_cigar > k >= 1:
  *             op = cigar_p[k] & BAM_CIGAR_MASK             # <<<<<<<<<<<<<<
@@ -17242,25 +17184,17 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_end(bam1_t *__pyx_v_src) {
  */
       __pyx_v_op = ((__pyx_v_cigar_p[__pyx_v_k]) & 15);
 
-      /* "csamtools.pyx":1883
- *                     PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string')
- *                     return -1
- *             elif op==BAM_CSOFT_CLIP:             # <<<<<<<<<<<<<<
- *                 end_offset -= cigar_p[k] >> BAM_CIGAR_SHIFT
- *             else:
- */
-      switch (__pyx_v_op) {
-
-        /* "csamtools.pyx":1879
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1814
  *         for k from src.core.n_cigar > k >= 1:
  *             op = cigar_p[k] & BAM_CIGAR_MASK
  *             if op==BAM_CHARD_CLIP:             # <<<<<<<<<<<<<<
  *                 if end_offset!=0 and end_offset!=src.core.l_qseq:
  *                     PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string')
  */
+      switch (__pyx_v_op) {
         case 5:
 
-        /* "csamtools.pyx":1880
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1815
  *             op = cigar_p[k] & BAM_CIGAR_MASK
  *             if op==BAM_CHARD_CLIP:
  *                 if end_offset!=0 and end_offset!=src.core.l_qseq:             # <<<<<<<<<<<<<<
@@ -17276,16 +17210,16 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_end(bam1_t *__pyx_v_src) {
         }
         if (__pyx_t_3) {
 
-          /* "csamtools.pyx":1881
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1816
  *             if op==BAM_CHARD_CLIP:
  *                 if end_offset!=0 and end_offset!=src.core.l_qseq:
  *                     PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string')             # <<<<<<<<<<<<<<
  *                     return -1
  *             elif op==BAM_CSOFT_CLIP:
  */
-          PyErr_SetString(__pyx_builtin_ValueError, __pyx_k_119);
+          PyErr_SetString(__pyx_builtin_ValueError, __pyx_k_60);
 
-          /* "csamtools.pyx":1882
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1817
  *                 if end_offset!=0 and end_offset!=src.core.l_qseq:
  *                     PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string')
  *                     return -1             # <<<<<<<<<<<<<<
@@ -17299,7 +17233,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_end(bam1_t *__pyx_v_src) {
         __pyx_L6:;
         break;
 
-        /* "csamtools.pyx":1883
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1818
  *                     PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string')
  *                     return -1
  *             elif op==BAM_CSOFT_CLIP:             # <<<<<<<<<<<<<<
@@ -17308,18 +17242,18 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_end(bam1_t *__pyx_v_src) {
  */
         case 4:
 
-        /* "csamtools.pyx":1884
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1819
  *                     return -1
  *             elif op==BAM_CSOFT_CLIP:
  *                 end_offset -= cigar_p[k] >> BAM_CIGAR_SHIFT             # <<<<<<<<<<<<<<
  *             else:
  *                 break
  */
-        __pyx_v_end_offset = (__pyx_v_end_offset - ((__pyx_v_cigar_p[__pyx_v_k]) >> 4));
+        __pyx_v_end_offset -= ((__pyx_v_cigar_p[__pyx_v_k]) >> 4);
         break;
         default:
 
-        /* "csamtools.pyx":1886
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1821
  *                 end_offset -= cigar_p[k] >> BAM_CIGAR_SHIFT
  *             else:
  *                 break             # <<<<<<<<<<<<<<
@@ -17335,7 +17269,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_end(bam1_t *__pyx_v_src) {
   }
   __pyx_L3:;
 
-  /* "csamtools.pyx":1888
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1823
  *                 break
  * 
  *     if end_offset==0:             # <<<<<<<<<<<<<<
@@ -17345,7 +17279,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_end(bam1_t *__pyx_v_src) {
   __pyx_t_3 = (__pyx_v_end_offset == 0);
   if (__pyx_t_3) {
 
-    /* "csamtools.pyx":1889
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1824
  * 
  *     if end_offset==0:
  *         end_offset = src.core.l_qseq             # <<<<<<<<<<<<<<
@@ -17357,7 +17291,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_end(bam1_t *__pyx_v_src) {
   }
   __pyx_L7:;
 
-  /* "csamtools.pyx":1891
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1826
  *         end_offset = src.core.l_qseq
  * 
  *     return end_offset             # <<<<<<<<<<<<<<
@@ -17374,7 +17308,7 @@ static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_end(bam1_t *__pyx_v_src) {
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1894
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1829
  * 
  * 
  * cdef inline object get_seq_range(bam1_t *src, uint32_t start, uint32_t end):             # <<<<<<<<<<<<<<
@@ -17393,10 +17327,10 @@ static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_seq_range(bam1_t *__pyx_v_
   uint32_t __pyx_t_3;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("get_seq_range");
-  __Pyx_TraceCall("get_seq_range", __pyx_f[0], 1894);
+  __Pyx_TraceCall("get_seq_range", __pyx_f[0], 1829);
   __pyx_v_seq = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "csamtools.pyx":1899
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1834
  *     cdef char * s
  * 
  *     if not src.core.l_qseq:             # <<<<<<<<<<<<<<
@@ -17406,7 +17340,7 @@ static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_seq_range(bam1_t *__pyx_v_
   __pyx_t_1 = (!__pyx_v_src->core.l_qseq);
   if (__pyx_t_1) {
 
-    /* "csamtools.pyx":1900
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1835
  * 
  *     if not src.core.l_qseq:
  *         return None             # <<<<<<<<<<<<<<
@@ -17421,20 +17355,20 @@ static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_seq_range(bam1_t *__pyx_v_
   }
   __pyx_L3:;
 
-  /* "csamtools.pyx":1902
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1837
  *         return None
  * 
  *     seq = PyString_FromStringAndSize(NULL, end-start)             # <<<<<<<<<<<<<<
  *     s   = PyString_AS_STRING(seq)
  *     p   = bam1_seq(src)
  */
-  __pyx_t_2 = PyString_FromStringAndSize(NULL, (__pyx_v_end - __pyx_v_start)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyString_FromStringAndSize(NULL, (__pyx_v_end - __pyx_v_start)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_v_seq);
   __pyx_v_seq = __pyx_t_2;
   __pyx_t_2 = 0;
 
-  /* "csamtools.pyx":1903
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1838
  * 
  *     seq = PyString_FromStringAndSize(NULL, end-start)
  *     s   = PyString_AS_STRING(seq)             # <<<<<<<<<<<<<<
@@ -17443,7 +17377,7 @@ static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_seq_range(bam1_t *__pyx_v_
  */
   __pyx_v_s = PyString_AS_STRING(__pyx_v_seq);
 
-  /* "csamtools.pyx":1904
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1839
  *     seq = PyString_FromStringAndSize(NULL, end-start)
  *     s   = PyString_AS_STRING(seq)
  *     p   = bam1_seq(src)             # <<<<<<<<<<<<<<
@@ -17452,7 +17386,7 @@ static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_seq_range(bam1_t *__pyx_v_
  */
   __pyx_v_p = bam1_seq(__pyx_v_src);
 
-  /* "csamtools.pyx":1906
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1841
  *     p   = bam1_seq(src)
  * 
  *     for k from start <= k < end:             # <<<<<<<<<<<<<<
@@ -17462,7 +17396,7 @@ static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_seq_range(bam1_t *__pyx_v_
   __pyx_t_3 = __pyx_v_end;
   for (__pyx_v_k = __pyx_v_start; __pyx_v_k < __pyx_t_3; __pyx_v_k++) {
 
-    /* "csamtools.pyx":1909
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1844
  *         # equivalent to bam_nt16_rev_table[bam1_seqi(s, i)] (see bam.c)
  *         # note: do not use string literal as it will be a python string
  *         s[k-start] = bam_nt16_rev_table[p[k/2] >> 4 * (1 - k%2) & 0xf]             # <<<<<<<<<<<<<<
@@ -17472,7 +17406,7 @@ static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_seq_range(bam1_t *__pyx_v_
     (__pyx_v_s[(__pyx_v_k - __pyx_v_start)]) = (__pyx_v_9csamtools_bam_nt16_rev_table[(((__pyx_v_p[__Pyx_div_long(__pyx_v_k, 2)]) >> (4 * (1 - __Pyx_mod_long(__pyx_v_k, 2)))) & 0xf)]);
   }
 
-  /* "csamtools.pyx":1911
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1846
  *         s[k-start] = bam_nt16_rev_table[p[k/2] >> 4 * (1 - k%2) & 0xf]
  * 
  *     return seq             # <<<<<<<<<<<<<<
@@ -17498,7 +17432,7 @@ static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_seq_range(bam1_t *__pyx_v_
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1914
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1849
  * 
  * 
  * cdef inline object get_qual_range(bam1_t *src, uint32_t start, uint32_t end):             # <<<<<<<<<<<<<<
@@ -17517,10 +17451,10 @@ static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_qual_range(bam1_t *__pyx_v
   uint32_t __pyx_t_3;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("get_qual_range");
-  __Pyx_TraceCall("get_qual_range", __pyx_f[0], 1914);
+  __Pyx_TraceCall("get_qual_range", __pyx_f[0], 1849);
   __pyx_v_qual = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "csamtools.pyx":1919
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1854
  *     cdef char * q
  * 
  *     p = bam1_qual(src)             # <<<<<<<<<<<<<<
@@ -17529,7 +17463,7 @@ static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_qual_range(bam1_t *__pyx_v
  */
   __pyx_v_p = bam1_qual(__pyx_v_src);
 
-  /* "csamtools.pyx":1920
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1855
  * 
  *     p = bam1_qual(src)
  *     if p[0] == 0xff:             # <<<<<<<<<<<<<<
@@ -17539,7 +17473,7 @@ static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_qual_range(bam1_t *__pyx_v
   __pyx_t_1 = ((__pyx_v_p[0]) == 0xff);
   if (__pyx_t_1) {
 
-    /* "csamtools.pyx":1921
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1856
  *     p = bam1_qual(src)
  *     if p[0] == 0xff:
  *         return None             # <<<<<<<<<<<<<<
@@ -17554,20 +17488,20 @@ static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_qual_range(bam1_t *__pyx_v
   }
   __pyx_L3:;
 
-  /* "csamtools.pyx":1923
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1858
  *         return None
  * 
  *     qual = PyString_FromStringAndSize(NULL, end-start)             # <<<<<<<<<<<<<<
  *     q    = PyString_AS_STRING(qual)
  * 
  */
-  __pyx_t_2 = PyString_FromStringAndSize(NULL, (__pyx_v_end - __pyx_v_start)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1923; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyString_FromStringAndSize(NULL, (__pyx_v_end - __pyx_v_start)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_v_qual);
   __pyx_v_qual = __pyx_t_2;
   __pyx_t_2 = 0;
 
-  /* "csamtools.pyx":1924
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1859
  * 
  *     qual = PyString_FromStringAndSize(NULL, end-start)
  *     q    = PyString_AS_STRING(qual)             # <<<<<<<<<<<<<<
@@ -17576,7 +17510,7 @@ static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_qual_range(bam1_t *__pyx_v
  */
   __pyx_v_q = PyString_AS_STRING(__pyx_v_qual);
 
-  /* "csamtools.pyx":1926
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1861
  *     q    = PyString_AS_STRING(qual)
  * 
  *     for k from start <= k < end:             # <<<<<<<<<<<<<<
@@ -17586,7 +17520,7 @@ static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_qual_range(bam1_t *__pyx_v
   __pyx_t_3 = __pyx_v_end;
   for (__pyx_v_k = __pyx_v_start; __pyx_v_k < __pyx_t_3; __pyx_v_k++) {
 
-    /* "csamtools.pyx":1928
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1863
  *     for k from start <= k < end:
  *         ## equivalent to t[i] + 33 (see bam.c)
  *         q[k-start] = p[k] + 33             # <<<<<<<<<<<<<<
@@ -17596,7 +17530,7 @@ static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_qual_range(bam1_t *__pyx_v
     (__pyx_v_q[(__pyx_v_k - __pyx_v_start)]) = ((__pyx_v_p[__pyx_v_k]) + 33);
   }
 
-  /* "csamtools.pyx":1930
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1865
  *         q[k-start] = p[k] + 33
  * 
  *     return qual             # <<<<<<<<<<<<<<
@@ -17622,7 +17556,7 @@ static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_qual_range(bam1_t *__pyx_v
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1955
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1890
  * 
  *     # Now only called when instances are created from Python
  *     def __init__(self):             # <<<<<<<<<<<<<<
@@ -17635,12 +17569,12 @@ static int __pyx_pf_9csamtools_11AlignedRead___init__(PyObject *__pyx_v_self, Py
   int __pyx_r;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__init__");
-  __Pyx_TraceCall("__init__", __pyx_f[0], 1955);
+  __Pyx_TraceCall("__init__", __pyx_f[0], 1890);
   if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
     __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
   if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
 
-  /* "csamtools.pyx":1957
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1892
  *     def __init__(self):
  *         # see bam_init1
  *         self._delegate = <bam1_t*>calloc( 1, sizeof( bam1_t) )             # <<<<<<<<<<<<<<
@@ -17649,7 +17583,7 @@ static int __pyx_pf_9csamtools_11AlignedRead___init__(PyObject *__pyx_v_self, Py
  */
   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate = ((bam1_t *)calloc(1, (sizeof(bam1_t))));
 
-  /* "csamtools.pyx":1961
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1896
  *         # If size is 0, calloc does not return a pointer that can be passed to free()
  *         # so allocate 40 bytes for a new read
  *         self._delegate.m_data = 40             # <<<<<<<<<<<<<<
@@ -17658,7 +17592,7 @@ static int __pyx_pf_9csamtools_11AlignedRead___init__(PyObject *__pyx_v_self, Py
  */
   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->m_data = 40;
 
-  /* "csamtools.pyx":1962
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1897
  *         # so allocate 40 bytes for a new read
  *         self._delegate.m_data = 40
  *         self._delegate.data = <uint8_t *>calloc( self._delegate.m_data, 1 )             # <<<<<<<<<<<<<<
@@ -17667,7 +17601,7 @@ static int __pyx_pf_9csamtools_11AlignedRead___init__(PyObject *__pyx_v_self, Py
  */
   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->data = ((uint8_t *)calloc(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->m_data, 1));
 
-  /* "csamtools.pyx":1963
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1898
  *         self._delegate.m_data = 40
  *         self._delegate.data = <uint8_t *>calloc( self._delegate.m_data, 1 )
  *         self._delegate.data_len = 0             # <<<<<<<<<<<<<<
@@ -17682,7 +17616,7 @@ static int __pyx_pf_9csamtools_11AlignedRead___init__(PyObject *__pyx_v_self, Py
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1965
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1900
  *         self._delegate.data_len = 0
  * 
  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
@@ -17690,13 +17624,13 @@ static int __pyx_pf_9csamtools_11AlignedRead___init__(PyObject *__pyx_v_self, Py
  * 
  */
 
-static void __pyx_pf_9csamtools_11AlignedRead_1__dealloc__(PyObject *__pyx_v_self); /*proto*/
-static void __pyx_pf_9csamtools_11AlignedRead_1__dealloc__(PyObject *__pyx_v_self) {
+static void __pyx_pf_9csamtools_11AlignedRead___dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_pf_9csamtools_11AlignedRead___dealloc__(PyObject *__pyx_v_self) {
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__dealloc__");
-  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1965);
+  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1900);
 
-  /* "csamtools.pyx":1966
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1901
  * 
  *     def __dealloc__(self):
  *         bam_destroy1(self._delegate)             # <<<<<<<<<<<<<<
@@ -17709,7 +17643,7 @@ static void __pyx_pf_9csamtools_11AlignedRead_1__dealloc__(PyObject *__pyx_v_sel
   __Pyx_RefNannyFinishContext();
 }
 
-/* "csamtools.pyx":1968
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1903
  *         bam_destroy1(self._delegate)
  * 
  *     def __str__(self):             # <<<<<<<<<<<<<<
@@ -17717,10 +17651,10 @@ static void __pyx_pf_9csamtools_11AlignedRead_1__dealloc__(PyObject *__pyx_v_sel
  * 
  */
 
-static PyObject *__pyx_pf_9csamtools_11AlignedRead_2__str__(PyObject *__pyx_v_self); /*proto*/
-static char __pyx_doc_9csamtools_11AlignedRead_2__str__[] = "return string representation of alignment.\n\n        The representation is an approximate :term:`sam` format.\n\n        An aligned read might not be associated with a :term:`Samfile`.\n        As a result :term:`tid` is shown instead of the reference name.\n\n        Similarly, the tags field is returned in its parsed state.\n        ";
-struct wrapperbase __pyx_wrapperbase_9csamtools_11AlignedRead_2__str__;
-static PyObject *__pyx_pf_9csamtools_11AlignedRead_2__str__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_11AlignedRead___str__(PyObject *__pyx_v_self); /*proto*/
+static char __pyx_doc_9csamtools_11AlignedRead___str__[] = "return string representation of alignment.\n\n        The representation is an approximate :term:`sam` format.\n\n        An aligned read might not be associated with a :term:`Samfile`.\n        As a result :term:`tid` is shown instead of the reference name.\n\n        Similarly, the tags field is returned in its parsed state.\n        ";
+struct wrapperbase __pyx_wrapperbase_9csamtools_11AlignedRead___str__;
+static PyObject *__pyx_pf_9csamtools_11AlignedRead___str__(PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   PyObject *__pyx_t_2 = NULL;
@@ -17738,9 +17672,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_2__str__(PyObject *__pyx_v_se
   PyObject *__pyx_t_14 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__str__");
-  __Pyx_TraceCall("__str__", __pyx_f[0], 1968);
+  __Pyx_TraceCall("__str__", __pyx_f[0], 1903);
 
-  /* "csamtools.pyx":1980
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1915
  *         # sam-parsing is done in sam.c/bam_format1_core which
  *         # requires a valid header.
  *         return "\t".join(map(str, (self.qname,             # <<<<<<<<<<<<<<
@@ -17748,122 +17682,122 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_2__str__(PyObject *__pyx_v_se
  *                                    self.rname,
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_1), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_1), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__qname); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__qname); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
 
-  /* "csamtools.pyx":1981
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1916
  *         # requires a valid header.
  *         return "\t".join(map(str, (self.qname,
  *                                    self.flag,             # <<<<<<<<<<<<<<
  *                                    self.rname,
  *                                    self.pos,
  */
-  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1981; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
 
-  /* "csamtools.pyx":1982
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1917
  *         return "\t".join(map(str, (self.qname,
  *                                    self.flag,
  *                                    self.rname,             # <<<<<<<<<<<<<<
  *                                    self.pos,
  *                                    self.mapq,
  */
-  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__rname); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1982; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__rname); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
 
-  /* "csamtools.pyx":1983
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1918
  *                                    self.flag,
  *                                    self.rname,
  *                                    self.pos,             # <<<<<<<<<<<<<<
  *                                    self.mapq,
  *                                    self.cigar,
  */
-  __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__pos); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1983; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__pos); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1918; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
 
-  /* "csamtools.pyx":1984
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1919
  *                                    self.rname,
  *                                    self.pos,
  *                                    self.mapq,             # <<<<<<<<<<<<<<
  *                                    self.cigar,
  *                                    self.mrnm,
  */
-  __pyx_t_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__mapq); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__mapq); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1919; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_6);
 
-  /* "csamtools.pyx":1985
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1920
  *                                    self.pos,
  *                                    self.mapq,
  *                                    self.cigar,             # <<<<<<<<<<<<<<
  *                                    self.mrnm,
  *                                    self.mpos,
  */
-  __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__cigar); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__cigar); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_7);
 
-  /* "csamtools.pyx":1986
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1921
  *                                    self.mapq,
  *                                    self.cigar,
  *                                    self.mrnm,             # <<<<<<<<<<<<<<
  *                                    self.mpos,
  *                                    self.rlen,
  */
-  __pyx_t_8 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__mrnm); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__mrnm); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1921; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_8);
 
-  /* "csamtools.pyx":1987
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1922
  *                                    self.cigar,
  *                                    self.mrnm,
  *                                    self.mpos,             # <<<<<<<<<<<<<<
  *                                    self.rlen,
  *                                    self.seq,
  */
-  __pyx_t_9 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__mpos); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1987; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_9 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__mpos); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_9);
 
-  /* "csamtools.pyx":1988
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1923
  *                                    self.mrnm,
  *                                    self.mpos,
  *                                    self.rlen,             # <<<<<<<<<<<<<<
  *                                    self.seq,
  *                                    self.qual,
  */
-  __pyx_t_10 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__rlen); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1988; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_10 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__rlen); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1923; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_10);
 
-  /* "csamtools.pyx":1989
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1924
  *                                    self.mpos,
  *                                    self.rlen,
  *                                    self.seq,             # <<<<<<<<<<<<<<
  *                                    self.qual,
  *                                    self.tags )))
  */
-  __pyx_t_11 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__seq); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_11 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__seq); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_11);
 
-  /* "csamtools.pyx":1990
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1925
  *                                    self.rlen,
  *                                    self.seq,
  *                                    self.qual,             # <<<<<<<<<<<<<<
  *                                    self.tags )))
  * 
  */
-  __pyx_t_12 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__qual); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_12 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__qual); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_12);
 
-  /* "csamtools.pyx":1991
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1926
  *                                    self.seq,
  *                                    self.qual,
  *                                    self.tags )))             # <<<<<<<<<<<<<<
  * 
  *     def compare(self, AlignedRead other):
  */
-  __pyx_t_13 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__tags); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1991; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_13 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__tags); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1926; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_13);
-  __pyx_t_14 = PyTuple_New(12); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_14));
+  __pyx_t_14 = PyTuple_New(12); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_14);
   PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_2);
   __Pyx_GIVEREF(__pyx_t_2);
   PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_3);
@@ -17900,26 +17834,26 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_2__str__(PyObject *__pyx_v_se
   __pyx_t_11 = 0;
   __pyx_t_12 = 0;
   __pyx_t_13 = 0;
-  __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_13));
-  __Pyx_INCREF(((PyObject *)((PyObject*)(&PyString_Type))));
-  PyTuple_SET_ITEM(__pyx_t_13, 0, ((PyObject *)((PyObject*)(&PyString_Type))));
-  __Pyx_GIVEREF(((PyObject *)((PyObject*)(&PyString_Type))));
-  PyTuple_SET_ITEM(__pyx_t_13, 1, ((PyObject *)__pyx_t_14));
-  __Pyx_GIVEREF(((PyObject *)__pyx_t_14));
+  __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_13);
+  __Pyx_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
+  PyTuple_SET_ITEM(__pyx_t_13, 0, ((PyObject *)((PyObject*)&PyString_Type)));
+  __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
+  PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_14);
+  __Pyx_GIVEREF(__pyx_t_14);
   __pyx_t_14 = 0;
-  __pyx_t_14 = PyObject_Call(__pyx_builtin_map, ((PyObject *)__pyx_t_13), NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_14 = PyObject_Call(__pyx_builtin_map, __pyx_t_13, NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_14);
-  __Pyx_DECREF(((PyObject *)__pyx_t_13)); __pyx_t_13 = 0;
-  __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_13));
+  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+  __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_13);
   PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_14);
   __Pyx_GIVEREF(__pyx_t_14);
   __pyx_t_14 = 0;
-  __pyx_t_14 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_13), NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_14 = PyObject_Call(__pyx_t_1, __pyx_t_13, NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1915; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_14);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __Pyx_DECREF(((PyObject *)__pyx_t_13)); __pyx_t_13 = 0;
+  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
   __pyx_r = __pyx_t_14;
   __pyx_t_14 = 0;
   goto __pyx_L0;
@@ -17950,7 +17884,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_2__str__(PyObject *__pyx_v_se
   return __pyx_r;
 }
 
-/* "csamtools.pyx":1993
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1928
  *                                    self.tags )))
  * 
  *     def compare(self, AlignedRead other):             # <<<<<<<<<<<<<<
@@ -17958,9 +17892,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_2__str__(PyObject *__pyx_v_se
  * 
  */
 
-static PyObject *__pyx_pf_9csamtools_11AlignedRead_3compare(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
-static char __pyx_doc_9csamtools_11AlignedRead_3compare[] = "AlignedRead.compare(self, AlignedRead other)\nreturn -1,0,1, if contents in this are binary <,=,> to *other*";
-static PyObject *__pyx_pf_9csamtools_11AlignedRead_3compare(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
+static PyObject *__pyx_pf_9csamtools_11AlignedRead_compare(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
+static char __pyx_doc_9csamtools_11AlignedRead_compare[] = "AlignedRead.compare(self, AlignedRead other)\nreturn -1,0,1, if contents in this are binary <,=,> to *other*";
+static PyObject *__pyx_pf_9csamtools_11AlignedRead_compare(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
   int __pyx_v_retval;
   bam1_t *__pyx_v_t;
   bam1_t *__pyx_v_o;
@@ -17972,10 +17906,10 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3compare(PyObject *__pyx_v_se
   int __pyx_t_5;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("compare");
-  __Pyx_TraceCall("compare", __pyx_f[0], 1993);
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_9csamtools_AlignedRead, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("compare", __pyx_f[0], 1928);
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_9csamtools_AlignedRead, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "csamtools.pyx":1999
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1934
  *         cdef bam1_t *t, *o
  * 
  *         t = self._delegate             # <<<<<<<<<<<<<<
@@ -17984,7 +17918,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3compare(PyObject *__pyx_v_se
  */
   __pyx_v_t = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "csamtools.pyx":2000
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1935
  * 
  *         t = self._delegate
  *         o = other._delegate             # <<<<<<<<<<<<<<
@@ -17993,7 +17927,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3compare(PyObject *__pyx_v_se
  */
   __pyx_v_o = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_other)->_delegate;
 
-  /* "csamtools.pyx":2012
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1947
  * 
  *         # Fast-path test for object identity
  *         if t==o:             # <<<<<<<<<<<<<<
@@ -18003,7 +17937,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3compare(PyObject *__pyx_v_se
   __pyx_t_1 = (__pyx_v_t == __pyx_v_o);
   if (__pyx_t_1) {
 
-    /* "csamtools.pyx":2013
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1948
  *         # Fast-path test for object identity
  *         if t==o:
  *             return 0             # <<<<<<<<<<<<<<
@@ -18018,7 +17952,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3compare(PyObject *__pyx_v_se
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":2015
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1950
  *             return 0
  * 
  *         retval = memcmp(&t.core, &o.core, sizeof(bam1_core_t))             # <<<<<<<<<<<<<<
@@ -18027,7 +17961,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3compare(PyObject *__pyx_v_se
  */
   __pyx_v_retval = memcmp((&__pyx_v_t->core), (&__pyx_v_o->core), (sizeof(bam1_core_t)));
 
-  /* "csamtools.pyx":2017
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1952
  *         retval = memcmp(&t.core, &o.core, sizeof(bam1_core_t))
  * 
  *         if retval: return retval             # <<<<<<<<<<<<<<
@@ -18036,7 +17970,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3compare(PyObject *__pyx_v_se
  */
   if (__pyx_v_retval) {
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_2 = PyInt_FromLong(__pyx_v_retval); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyInt_FromLong(__pyx_v_retval); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1952; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __pyx_r = __pyx_t_2;
     __pyx_t_2 = 0;
@@ -18045,33 +17979,33 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3compare(PyObject *__pyx_v_se
   }
   __pyx_L6:;
 
-  /* "csamtools.pyx":2018
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1953
  * 
  *         if retval: return retval
  *         retval = cmp(t.data_len, o.data_len)             # <<<<<<<<<<<<<<
  *         if retval: return retval
  *         return memcmp(t.data, o.data, t.data_len)
  */
-  __pyx_t_2 = PyInt_FromLong(__pyx_v_t->data_len); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyInt_FromLong(__pyx_v_t->data_len); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = PyInt_FromLong(__pyx_v_o->data_len); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyInt_FromLong(__pyx_v_o->data_len); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
+  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
   __Pyx_GIVEREF(__pyx_t_2);
   PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
   __Pyx_GIVEREF(__pyx_t_3);
   __pyx_t_2 = 0;
   __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_Call(__pyx_builtin_cmp, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Call(__pyx_builtin_cmp, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
-  __pyx_t_5 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_5 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   __pyx_v_retval = __pyx_t_5;
 
-  /* "csamtools.pyx":2019
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1954
  *         if retval: return retval
  *         retval = cmp(t.data_len, o.data_len)
  *         if retval: return retval             # <<<<<<<<<<<<<<
@@ -18080,7 +18014,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3compare(PyObject *__pyx_v_se
  */
   if (__pyx_v_retval) {
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_3 = PyInt_FromLong(__pyx_v_retval); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2019; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyInt_FromLong(__pyx_v_retval); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __pyx_r = __pyx_t_3;
     __pyx_t_3 = 0;
@@ -18089,7 +18023,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3compare(PyObject *__pyx_v_se
   }
   __pyx_L7:;
 
-  /* "csamtools.pyx":2020
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1955
  *         retval = cmp(t.data_len, o.data_len)
  *         if retval: return retval
  *         return memcmp(t.data, o.data, t.data_len)             # <<<<<<<<<<<<<<
@@ -18097,7 +18031,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3compare(PyObject *__pyx_v_se
  *     # Disabled so long as __cmp__ is a special method
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_3 = PyInt_FromLong(memcmp(__pyx_v_t->data, __pyx_v_o->data, __pyx_v_t->data_len)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2020; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyInt_FromLong(memcmp(__pyx_v_t->data, __pyx_v_o->data, __pyx_v_t->data_len)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1955; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __pyx_r = __pyx_t_3;
   __pyx_t_3 = 0;
@@ -18118,7 +18052,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3compare(PyObject *__pyx_v_se
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2023
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1958
  * 
  *     # Disabled so long as __cmp__ is a special method
  *     def __hash__(self):             # <<<<<<<<<<<<<<
@@ -18126,14 +18060,14 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3compare(PyObject *__pyx_v_se
  * 
  */
 
-static long __pyx_pf_9csamtools_11AlignedRead_4__hash__(PyObject *__pyx_v_self); /*proto*/
-static long __pyx_pf_9csamtools_11AlignedRead_4__hash__(PyObject *__pyx_v_self) {
+static long __pyx_pf_9csamtools_11AlignedRead___hash__(PyObject *__pyx_v_self); /*proto*/
+static long __pyx_pf_9csamtools_11AlignedRead___hash__(PyObject *__pyx_v_self) {
   long __pyx_r;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__hash__");
-  __Pyx_TraceCall("__hash__", __pyx_f[0], 2023);
+  __Pyx_TraceCall("__hash__", __pyx_f[0], 1958);
 
-  /* "csamtools.pyx":2024
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1959
  *     # Disabled so long as __cmp__ is a special method
  *     def __hash__(self):
  *         return _Py_HashPointer(<void *>self)             # <<<<<<<<<<<<<<
@@ -18151,7 +18085,7 @@ static long __pyx_pf_9csamtools_11AlignedRead_4__hash__(PyObject *__pyx_v_self)
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2028
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1963
  *     property qname:
  *         """the query name (None if not present)"""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -18167,9 +18101,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5qname___get__(PyObject *__py
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2028);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 1963);
 
-  /* "csamtools.pyx":2030
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1965
  *         def __get__(self):
  *             cdef bam1_t * src
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -18178,7 +18112,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5qname___get__(PyObject *__py
  */
   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "csamtools.pyx":2031
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1966
  *             cdef bam1_t * src
  *             src = self._delegate
  *             if src.core.l_qname == 0: return None             # <<<<<<<<<<<<<<
@@ -18195,7 +18129,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5qname___get__(PyObject *__py
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":2032
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1967
  *             src = self._delegate
  *             if src.core.l_qname == 0: return None
  *             return <char *>bam1_qname( src )             # <<<<<<<<<<<<<<
@@ -18203,7 +18137,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5qname___get__(PyObject *__py
  *         def __set__(self, qname ):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = PyBytes_FromString(bam1_qname(__pyx_v_src)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2032; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyBytes_FromString(bam1_qname(__pyx_v_src)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1967; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
   __pyx_r = ((PyObject *)__pyx_t_2);
   __pyx_t_2 = 0;
@@ -18222,7 +18156,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5qname___get__(PyObject *__py
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2034
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1969
  *             return <char *>bam1_qname( src )
  * 
  *         def __set__(self, qname ):             # <<<<<<<<<<<<<<
@@ -18230,8 +18164,8 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5qname___get__(PyObject *__py
  *             cdef bam1_t * src
  */
 
-static int __pyx_pf_9csamtools_11AlignedRead_5qname_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_qname); /*proto*/
-static int __pyx_pf_9csamtools_11AlignedRead_5qname_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_qname) {
+static int __pyx_pf_9csamtools_11AlignedRead_5qname___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_qname); /*proto*/
+static int __pyx_pf_9csamtools_11AlignedRead_5qname___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_qname) {
   bam1_t *__pyx_v_src;
   int __pyx_v_l;
   char *__pyx_v_p;
@@ -18244,21 +18178,21 @@ static int __pyx_pf_9csamtools_11AlignedRead_5qname_1__set__(PyObject *__pyx_v_s
   char *__pyx_t_6;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2034);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 1969);
 
-  /* "csamtools.pyx":2035
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1970
  * 
  *         def __set__(self, qname ):
  *             if qname == None or len(qname) == 0: return             # <<<<<<<<<<<<<<
  *             cdef bam1_t * src
  *             cdef int l
  */
-  __pyx_t_1 = PyObject_RichCompare(__pyx_v_qname, Py_None, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_qname, Py_None, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   if (!__pyx_t_2) {
-    __pyx_t_3 = PyObject_Length(__pyx_v_qname); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Length(__pyx_v_qname); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_t_4 = (__pyx_t_3 == 0);
     __pyx_t_5 = __pyx_t_4;
   } else {
@@ -18271,7 +18205,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_5qname_1__set__(PyObject *__pyx_v_s
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":2040
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1975
  *             cdef char * p
  * 
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -18280,7 +18214,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_5qname_1__set__(PyObject *__pyx_v_s
  */
   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "csamtools.pyx":2041
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1976
  * 
  *             src = self._delegate
  *             p = bam1_qname( src )             # <<<<<<<<<<<<<<
@@ -18289,17 +18223,17 @@ static int __pyx_pf_9csamtools_11AlignedRead_5qname_1__set__(PyObject *__pyx_v_s
  */
   __pyx_v_p = bam1_qname(__pyx_v_src);
 
-  /* "csamtools.pyx":2044
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1979
  * 
  *             # the qname is \0 terminated
  *             l = len(qname) + 1             # <<<<<<<<<<<<<<
  *             pysam_bam_update( src,
  *                               src.core.l_qname,
  */
-  __pyx_t_3 = PyObject_Length(__pyx_v_qname); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Length(__pyx_v_qname); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_l = (__pyx_t_3 + 1);
 
-  /* "csamtools.pyx":2048
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1983
  *                               src.core.l_qname,
  *                               l,
  *                               <uint8_t*>p )             # <<<<<<<<<<<<<<
@@ -18308,7 +18242,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_5qname_1__set__(PyObject *__pyx_v_s
  */
   pysam_bam_update(__pyx_v_src, __pyx_v_src->core.l_qname, __pyx_v_l, ((uint8_t *)__pyx_v_p));
 
-  /* "csamtools.pyx":2050
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1985
  *                               <uint8_t*>p )
  * 
  *             src.core.l_qname = l             # <<<<<<<<<<<<<<
@@ -18317,7 +18251,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_5qname_1__set__(PyObject *__pyx_v_s
  */
   __pyx_v_src->core.l_qname = __pyx_v_l;
 
-  /* "csamtools.pyx":2054
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1989
  *             # re-acquire pointer to location in memory
  *             # as it might have moved
  *             p = bam1_qname(src)             # <<<<<<<<<<<<<<
@@ -18326,14 +18260,14 @@ static int __pyx_pf_9csamtools_11AlignedRead_5qname_1__set__(PyObject *__pyx_v_s
  */
   __pyx_v_p = bam1_qname(__pyx_v_src);
 
-  /* "csamtools.pyx":2056
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1991
  *             p = bam1_qname(src)
  * 
  *             strncpy( p, qname, l )             # <<<<<<<<<<<<<<
  * 
  *     property cigar:
  */
-  __pyx_t_6 = PyBytes_AsString(__pyx_v_qname); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = PyBytes_AsString(__pyx_v_qname); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1991; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   strncpy(__pyx_v_p, __pyx_t_6, __pyx_v_l);
 
   __pyx_r = 0;
@@ -18348,7 +18282,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_5qname_1__set__(PyObject *__pyx_v_s
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2061
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1996
  *         """the :term:`cigar` alignment (None if not present).
  *         """
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -18371,12 +18305,12 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5cigar___get__(PyObject *__py
   PyObject *__pyx_t_4 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2061);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 1996);
   __pyx_v_op = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_l = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_cigar = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "csamtools.pyx":2067
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2002
  *             cdef int k
  * 
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -18385,7 +18319,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5cigar___get__(PyObject *__py
  */
   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "csamtools.pyx":2068
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2003
  * 
  *             src = self._delegate
  *             if src.core.n_cigar == 0: return None             # <<<<<<<<<<<<<<
@@ -18402,20 +18336,20 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5cigar___get__(PyObject *__py
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":2070
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2005
  *             if src.core.n_cigar == 0: return None
  * 
  *             cigar = []             # <<<<<<<<<<<<<<
  *             cigar_p = bam1_cigar(src);
  *             for k from 0 <= k < src.core.n_cigar:
  */
-  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
   __Pyx_DECREF(__pyx_v_cigar);
   __pyx_v_cigar = ((PyObject *)__pyx_t_2);
   __pyx_t_2 = 0;
 
-  /* "csamtools.pyx":2071
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2006
  * 
  *             cigar = []
  *             cigar_p = bam1_cigar(src);             # <<<<<<<<<<<<<<
@@ -18424,7 +18358,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5cigar___get__(PyObject *__py
  */
   __pyx_v_cigar_p = bam1_cigar(__pyx_v_src);
 
-  /* "csamtools.pyx":2072
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2007
  *             cigar = []
  *             cigar_p = bam1_cigar(src);
  *             for k from 0 <= k < src.core.n_cigar:             # <<<<<<<<<<<<<<
@@ -18434,54 +18368,54 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5cigar___get__(PyObject *__py
   __pyx_t_3 = __pyx_v_src->core.n_cigar;
   for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_3; __pyx_v_k++) {
 
-    /* "csamtools.pyx":2073
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2008
  *             cigar_p = bam1_cigar(src);
  *             for k from 0 <= k < src.core.n_cigar:
  *                 op = cigar_p[k] & BAM_CIGAR_MASK             # <<<<<<<<<<<<<<
  *                 l = cigar_p[k] >> BAM_CIGAR_SHIFT
  *                 cigar.append((op, l))
  */
-    __pyx_t_2 = PyInt_FromLong(((__pyx_v_cigar_p[__pyx_v_k]) & 15)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyInt_FromLong(((__pyx_v_cigar_p[__pyx_v_k]) & 15)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2008; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_DECREF(__pyx_v_op);
     __pyx_v_op = __pyx_t_2;
     __pyx_t_2 = 0;
 
-    /* "csamtools.pyx":2074
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2009
  *             for k from 0 <= k < src.core.n_cigar:
  *                 op = cigar_p[k] & BAM_CIGAR_MASK
  *                 l = cigar_p[k] >> BAM_CIGAR_SHIFT             # <<<<<<<<<<<<<<
  *                 cigar.append((op, l))
  *             return cigar
  */
-    __pyx_t_2 = PyInt_FromLong(((__pyx_v_cigar_p[__pyx_v_k]) >> 4)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyInt_FromLong(((__pyx_v_cigar_p[__pyx_v_k]) >> 4)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_DECREF(__pyx_v_l);
     __pyx_v_l = __pyx_t_2;
     __pyx_t_2 = 0;
 
-    /* "csamtools.pyx":2075
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2010
  *                 op = cigar_p[k] & BAM_CIGAR_MASK
  *                 l = cigar_p[k] >> BAM_CIGAR_SHIFT
  *                 cigar.append((op, l))             # <<<<<<<<<<<<<<
  *             return cigar
  * 
  */
-    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
     __Pyx_INCREF(__pyx_v_op);
     PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_op);
     __Pyx_GIVEREF(__pyx_v_op);
     __Pyx_INCREF(__pyx_v_l);
     PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_l);
     __Pyx_GIVEREF(__pyx_v_l);
-    __pyx_t_4 = __Pyx_PyObject_Append(__pyx_v_cigar, ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = __Pyx_PyObject_Append(__pyx_v_cigar, __pyx_t_2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2010; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
-    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   }
 
-  /* "csamtools.pyx":2076
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2011
  *                 l = cigar_p[k] >> BAM_CIGAR_SHIFT
  *                 cigar.append((op, l))
  *             return cigar             # <<<<<<<<<<<<<<
@@ -18510,7 +18444,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5cigar___get__(PyObject *__py
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2078
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2013
  *             return cigar
  * 
  *         def __set__(self, values ):             # <<<<<<<<<<<<<<
@@ -18518,8 +18452,8 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5cigar___get__(PyObject *__py
  *             cdef uint32_t * p
  */
 
-static int __pyx_pf_9csamtools_11AlignedRead_5cigar_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_values); /*proto*/
-static int __pyx_pf_9csamtools_11AlignedRead_5cigar_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_values) {
+static int __pyx_pf_9csamtools_11AlignedRead_5cigar___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_values); /*proto*/
+static int __pyx_pf_9csamtools_11AlignedRead_5cigar___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_values) {
   uint32_t *__pyx_v_p;
   bam1_t *__pyx_v_src;
   PyObject *__pyx_v_op;
@@ -18538,23 +18472,23 @@ static int __pyx_pf_9csamtools_11AlignedRead_5cigar_1__set__(PyObject *__pyx_v_s
   uint32_t __pyx_t_10;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2078);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2013);
   __pyx_v_op = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_l = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "csamtools.pyx":2079
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2014
  * 
  *         def __set__(self, values ):
  *             if values == None or len(values) == 0: return             # <<<<<<<<<<<<<<
  *             cdef uint32_t * p
  *             cdef bam1_t * src
  */
-  __pyx_t_1 = PyObject_RichCompare(__pyx_v_values, Py_None, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_values, Py_None, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2014; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2014; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   if (!__pyx_t_2) {
-    __pyx_t_3 = PyObject_Length(__pyx_v_values); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Length(__pyx_v_values); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2014; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_t_4 = (__pyx_t_3 == 0);
     __pyx_t_5 = __pyx_t_4;
   } else {
@@ -18567,7 +18501,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_5cigar_1__set__(PyObject *__pyx_v_s
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":2085
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2020
  *             cdef int k
  * 
  *             k = 0             # <<<<<<<<<<<<<<
@@ -18576,7 +18510,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_5cigar_1__set__(PyObject *__pyx_v_s
  */
   __pyx_v_k = 0;
 
-  /* "csamtools.pyx":2087
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2022
  *             k = 0
  * 
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -18585,7 +18519,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_5cigar_1__set__(PyObject *__pyx_v_s
  */
   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "csamtools.pyx":2090
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2025
  * 
  *             # get location of cigar string
  *             p = bam1_cigar(src)             # <<<<<<<<<<<<<<
@@ -18594,16 +18528,16 @@ static int __pyx_pf_9csamtools_11AlignedRead_5cigar_1__set__(PyObject *__pyx_v_s
  */
   __pyx_v_p = bam1_cigar(__pyx_v_src);
 
-  /* "csamtools.pyx":2095
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2030
  *             pysam_bam_update( src,
  *                               src.core.n_cigar * 4,
  *                               len(values) * 4,             # <<<<<<<<<<<<<<
  *                               <uint8_t*>p )
  * 
  */
-  __pyx_t_3 = PyObject_Length(__pyx_v_values); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2095; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Length(__pyx_v_values); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2030; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "csamtools.pyx":2096
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2031
  *                               src.core.n_cigar * 4,
  *                               len(values) * 4,
  *                               <uint8_t*>p )             # <<<<<<<<<<<<<<
@@ -18612,17 +18546,17 @@ static int __pyx_pf_9csamtools_11AlignedRead_5cigar_1__set__(PyObject *__pyx_v_s
  */
   pysam_bam_update(__pyx_v_src, (__pyx_v_src->core.n_cigar * 4), (__pyx_t_3 * 4), ((uint8_t *)__pyx_v_p));
 
-  /* "csamtools.pyx":2099
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2034
  * 
  *             # length is number of cigar operations, not bytes
  *             src.core.n_cigar = len(values)             # <<<<<<<<<<<<<<
  * 
  *             # re-acquire pointer to location in memory
  */
-  __pyx_t_3 = PyObject_Length(__pyx_v_values); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2099; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Length(__pyx_v_values); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2034; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_src->core.n_cigar = __pyx_t_3;
 
-  /* "csamtools.pyx":2103
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2038
  *             # re-acquire pointer to location in memory
  *             # as it might have moved
  *             p = bam1_cigar(src)             # <<<<<<<<<<<<<<
@@ -18631,7 +18565,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_5cigar_1__set__(PyObject *__pyx_v_s
  */
   __pyx_v_p = bam1_cigar(__pyx_v_src);
 
-  /* "csamtools.pyx":2106
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2041
  * 
  *             # insert cigar operations
  *             for op, l in values:             # <<<<<<<<<<<<<<
@@ -18641,7 +18575,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_5cigar_1__set__(PyObject *__pyx_v_s
   if (PyList_CheckExact(__pyx_v_values) || PyTuple_CheckExact(__pyx_v_values)) {
     __pyx_t_3 = 0; __pyx_t_1 = __pyx_v_values; __Pyx_INCREF(__pyx_t_1);
   } else {
-    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_values); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_values); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
   }
   for (;;) {
@@ -18654,7 +18588,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_5cigar_1__set__(PyObject *__pyx_v_s
     } else {
       __pyx_t_6 = PyIter_Next(__pyx_t_1);
       if (!__pyx_t_6) {
-        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         break;
       }
       __Pyx_GOTREF(__pyx_t_6);
@@ -18671,14 +18605,14 @@ static int __pyx_pf_9csamtools_11AlignedRead_5cigar_1__set__(PyObject *__pyx_v_s
       __pyx_v_l = __pyx_t_8;
       __pyx_t_8 = 0;
     } else {
-      __pyx_t_9 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_9 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_9);
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-      __pyx_t_7 = __Pyx_UnpackItem(__pyx_t_9, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = __Pyx_UnpackItem(__pyx_t_9, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
-      __pyx_t_8 = __Pyx_UnpackItem(__pyx_t_9, 1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = __Pyx_UnpackItem(__pyx_t_9, 1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_8);
-      if (__Pyx_EndUnpack(__pyx_t_9, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      if (__Pyx_EndUnpack(__pyx_t_9, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
       __Pyx_DECREF(__pyx_v_op);
       __pyx_v_op = __pyx_t_7;
@@ -18688,34 +18622,34 @@ static int __pyx_pf_9csamtools_11AlignedRead_5cigar_1__set__(PyObject *__pyx_v_s
       __pyx_t_8 = 0;
     }
 
-    /* "csamtools.pyx":2107
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2042
  *             # insert cigar operations
  *             for op, l in values:
  *                 p[k] = l << BAM_CIGAR_SHIFT | op             # <<<<<<<<<<<<<<
  *                 k += 1
  * 
  */
-    __pyx_t_6 = PyNumber_Lshift(__pyx_v_l, __pyx_int_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyNumber_Lshift(__pyx_v_l, __pyx_int_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
-    __pyx_t_8 = PyNumber_Or(__pyx_t_6, __pyx_v_op); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = PyNumber_Or(__pyx_t_6, __pyx_v_op); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_8);
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-    __pyx_t_10 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_8); if (unlikely((__pyx_t_10 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_10 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_8); if (unlikely((__pyx_t_10 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
     (__pyx_v_p[__pyx_v_k]) = __pyx_t_10;
 
-    /* "csamtools.pyx":2108
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2043
  *             for op, l in values:
  *                 p[k] = l << BAM_CIGAR_SHIFT | op
  *                 k += 1             # <<<<<<<<<<<<<<
  * 
  *             ## setting the cigar string also updates the "bin" attribute
  */
-    __pyx_v_k = (__pyx_v_k + 1);
+    __pyx_v_k += 1;
   }
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":2111
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2046
  * 
  *             ## setting the cigar string also updates the "bin" attribute
  *             src.core.bin = bam_reg2bin( src.core.pos, bam_calend( &src.core, p))             # <<<<<<<<<<<<<<
@@ -18742,7 +18676,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_5cigar_1__set__(PyObject *__pyx_v_s
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2115
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2050
  *     property seq:
  *         """read sequence bases, including :term:`soft clipped` bases (None if not present)"""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -18758,9 +18692,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3seq___get__(PyObject *__pyx_
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2115);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2050);
 
-  /* "csamtools.pyx":2118
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2053
  *             cdef bam1_t * src
  *             cdef char * s
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -18769,7 +18703,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3seq___get__(PyObject *__pyx_
  */
   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "csamtools.pyx":2120
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2055
  *             src = self._delegate
  * 
  *             if src.core.l_qseq == 0: return None             # <<<<<<<<<<<<<<
@@ -18786,7 +18720,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3seq___get__(PyObject *__pyx_
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":2122
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2057
  *             if src.core.l_qseq == 0: return None
  * 
  *             return get_seq_range(src, 0, src.core.l_qseq)             # <<<<<<<<<<<<<<
@@ -18794,7 +18728,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3seq___get__(PyObject *__pyx_
  *         def __set__(self,seq):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = __pyx_f_9csamtools_get_seq_range(__pyx_v_src, 0, __pyx_v_src->core.l_qseq); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __pyx_f_9csamtools_get_seq_range(__pyx_v_src, 0, __pyx_v_src->core.l_qseq); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
@@ -18813,7 +18747,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3seq___get__(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2124
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2059
  *             return get_seq_range(src, 0, src.core.l_qseq)
  * 
  *         def __set__(self,seq):             # <<<<<<<<<<<<<<
@@ -18821,8 +18755,8 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3seq___get__(PyObject *__pyx_
  *             # if no quality information is present, the first byte says 0xff.
  */
 
-static int __pyx_pf_9csamtools_11AlignedRead_3seq_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_seq); /*proto*/
-static int __pyx_pf_9csamtools_11AlignedRead_3seq_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_seq) {
+static int __pyx_pf_9csamtools_11AlignedRead_3seq___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_seq); /*proto*/
+static int __pyx_pf_9csamtools_11AlignedRead_3seq___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_seq) {
   bam1_t *__pyx_v_src;
   uint8_t *__pyx_v_p;
   char *__pyx_v_s;
@@ -18838,24 +18772,23 @@ static int __pyx_pf_9csamtools_11AlignedRead_3seq_1__set__(PyObject *__pyx_v_sel
   int __pyx_t_5;
   int __pyx_t_6;
   char *__pyx_t_7;
-  long __pyx_t_8;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2124);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2059);
 
-  /* "csamtools.pyx":2128
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2063
  *             # if no quality information is present, the first byte says 0xff.
  * 
  *             if seq == None or len(seq) == 0: return             # <<<<<<<<<<<<<<
  *             cdef bam1_t * src
  *             cdef uint8_t * p
  */
-  __pyx_t_1 = PyObject_RichCompare(__pyx_v_seq, Py_None, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_seq, Py_None, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   if (!__pyx_t_2) {
-    __pyx_t_3 = PyObject_Length(__pyx_v_seq); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Length(__pyx_v_seq); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_t_4 = (__pyx_t_3 == 0);
     __pyx_t_5 = __pyx_t_4;
   } else {
@@ -18868,7 +18801,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_3seq_1__set__(PyObject *__pyx_v_sel
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":2134
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2069
  *             cdef int l, k, nbytes_new, nbytes_old
  * 
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -18877,17 +18810,17 @@ static int __pyx_pf_9csamtools_11AlignedRead_3seq_1__set__(PyObject *__pyx_v_sel
  */
   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "csamtools.pyx":2136
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2071
  *             src = self._delegate
  * 
  *             l = len(seq)             # <<<<<<<<<<<<<<
  * 
  *             # as the sequence is stored in half-bytes, the total length (sequence
  */
-  __pyx_t_3 = PyObject_Length(__pyx_v_seq); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Length(__pyx_v_seq); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_l = __pyx_t_3;
 
-  /* "csamtools.pyx":2140
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2075
  *             # as the sequence is stored in half-bytes, the total length (sequence
  *             # plus quality scores) is (l+1)/2 + l
  *             nbytes_new = (l+1)/2 + l             # <<<<<<<<<<<<<<
@@ -18896,7 +18829,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_3seq_1__set__(PyObject *__pyx_v_sel
  */
   __pyx_v_nbytes_new = (__Pyx_div_long((__pyx_v_l + 1), 2) + __pyx_v_l);
 
-  /* "csamtools.pyx":2141
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2076
  *             # plus quality scores) is (l+1)/2 + l
  *             nbytes_new = (l+1)/2 + l
  *             nbytes_old = (src.core.l_qseq+1)/2 + src.core.l_qseq             # <<<<<<<<<<<<<<
@@ -18905,7 +18838,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_3seq_1__set__(PyObject *__pyx_v_sel
  */
   __pyx_v_nbytes_old = (__Pyx_div_long((__pyx_v_src->core.l_qseq + 1), 2) + __pyx_v_src->core.l_qseq);
 
-  /* "csamtools.pyx":2143
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2078
  *             nbytes_old = (src.core.l_qseq+1)/2 + src.core.l_qseq
  *             # acquire pointer to location in memory
  *             p = bam1_seq( src )             # <<<<<<<<<<<<<<
@@ -18914,7 +18847,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_3seq_1__set__(PyObject *__pyx_v_sel
  */
   __pyx_v_p = bam1_seq(__pyx_v_src);
 
-  /* "csamtools.pyx":2144
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2079
  *             # acquire pointer to location in memory
  *             p = bam1_seq( src )
  *             src.core.l_qseq = l             # <<<<<<<<<<<<<<
@@ -18923,7 +18856,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_3seq_1__set__(PyObject *__pyx_v_sel
  */
   __pyx_v_src->core.l_qseq = __pyx_v_l;
 
-  /* "csamtools.pyx":2149
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2084
  *                               nbytes_old,
  *                               nbytes_new,
  *                               p)             # <<<<<<<<<<<<<<
@@ -18932,7 +18865,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_3seq_1__set__(PyObject *__pyx_v_sel
  */
   pysam_bam_update(__pyx_v_src, __pyx_v_nbytes_old, __pyx_v_nbytes_new, __pyx_v_p);
 
-  /* "csamtools.pyx":2152
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2087
  *             # re-acquire pointer to location in memory
  *             # as it might have moved
  *             p = bam1_seq( src )             # <<<<<<<<<<<<<<
@@ -18941,7 +18874,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_3seq_1__set__(PyObject *__pyx_v_sel
  */
   __pyx_v_p = bam1_seq(__pyx_v_src);
 
-  /* "csamtools.pyx":2153
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2088
  *             # as it might have moved
  *             p = bam1_seq( src )
  *             for k from 0 <= k < nbytes_new: p[k] = 0             # <<<<<<<<<<<<<<
@@ -18953,17 +18886,17 @@ static int __pyx_pf_9csamtools_11AlignedRead_3seq_1__set__(PyObject *__pyx_v_sel
     (__pyx_v_p[__pyx_v_k]) = 0;
   }
 
-  /* "csamtools.pyx":2155
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2090
  *             for k from 0 <= k < nbytes_new: p[k] = 0
  *             # convert to C string
  *             s = seq             # <<<<<<<<<<<<<<
  *             for k from 0 <= k < l:
  *                 p[k/2] |= pysam_translate_sequence(s[k]) << 4 * (1 - k % 2)
  */
-  __pyx_t_7 = PyBytes_AsString(__pyx_v_seq); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_7 = PyBytes_AsString(__pyx_v_seq); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2090; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_s = __pyx_t_7;
 
-  /* "csamtools.pyx":2156
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2091
  *             # convert to C string
  *             s = seq
  *             for k from 0 <= k < l:             # <<<<<<<<<<<<<<
@@ -18973,18 +18906,17 @@ static int __pyx_pf_9csamtools_11AlignedRead_3seq_1__set__(PyObject *__pyx_v_sel
   __pyx_t_6 = __pyx_v_l;
   for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_6; __pyx_v_k++) {
 
-    /* "csamtools.pyx":2157
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2092
  *             s = seq
  *             for k from 0 <= k < l:
  *                 p[k/2] |= pysam_translate_sequence(s[k]) << 4 * (1 - k % 2)             # <<<<<<<<<<<<<<
  * 
  *             # erase qualities
  */
-    __pyx_t_8 = __Pyx_div_long(__pyx_v_k, 2);
-    (__pyx_v_p[__pyx_t_8]) = ((__pyx_v_p[__pyx_t_8]) | (pysam_translate_sequence((__pyx_v_s[__pyx_v_k])) << (4 * (1 - __Pyx_mod_long(__pyx_v_k, 2)))));
+    (__pyx_v_p[__Pyx_div_long(__pyx_v_k, 2)]) |= (pysam_translate_sequence((__pyx_v_s[__pyx_v_k])) << (4 * (1 - __Pyx_mod_long(__pyx_v_k, 2))));
   }
 
-  /* "csamtools.pyx":2160
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2095
  * 
  *             # erase qualities
  *             p = bam1_qual( src )             # <<<<<<<<<<<<<<
@@ -18993,7 +18925,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_3seq_1__set__(PyObject *__pyx_v_sel
  */
   __pyx_v_p = bam1_qual(__pyx_v_src);
 
-  /* "csamtools.pyx":2161
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2096
  *             # erase qualities
  *             p = bam1_qual( src )
  *             p[0] = 0xff             # <<<<<<<<<<<<<<
@@ -19014,7 +18946,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_3seq_1__set__(PyObject *__pyx_v_sel
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2166
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2101
  *     property qual:
  *         """read sequence base qualities, including :term:`soft clipped` bases (None if not present)"""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -19030,9 +18962,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qual___get__(PyObject *__pyx
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2166);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2101);
 
-  /* "csamtools.pyx":2171
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2106
  *             cdef char * q
  * 
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -19041,7 +18973,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qual___get__(PyObject *__pyx
  */
   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "csamtools.pyx":2173
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2108
  *             src = self._delegate
  * 
  *             if src.core.l_qseq == 0: return None             # <<<<<<<<<<<<<<
@@ -19058,7 +18990,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qual___get__(PyObject *__pyx
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":2175
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2110
  *             if src.core.l_qseq == 0: return None
  * 
  *             return get_qual_range(src, 0, src.core.l_qseq)             # <<<<<<<<<<<<<<
@@ -19066,7 +18998,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qual___get__(PyObject *__pyx
  *         def __set__(self,qual):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = __pyx_f_9csamtools_get_qual_range(__pyx_v_src, 0, __pyx_v_src->core.l_qseq); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __pyx_f_9csamtools_get_qual_range(__pyx_v_src, 0, __pyx_v_src->core.l_qseq); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2110; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
@@ -19085,7 +19017,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qual___get__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2177
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2112
  *             return get_qual_range(src, 0, src.core.l_qseq)
  * 
  *         def __set__(self,qual):             # <<<<<<<<<<<<<<
@@ -19093,8 +19025,8 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qual___get__(PyObject *__pyx
  *             cdef bam1_t * src
  */
 
-static int __pyx_pf_9csamtools_11AlignedRead_4qual_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_qual); /*proto*/
-static int __pyx_pf_9csamtools_11AlignedRead_4qual_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_qual) {
+static int __pyx_pf_9csamtools_11AlignedRead_4qual___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_qual); /*proto*/
+static int __pyx_pf_9csamtools_11AlignedRead_4qual___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_qual) {
   bam1_t *__pyx_v_src;
   uint8_t *__pyx_v_p;
   char *__pyx_v_q;
@@ -19112,9 +19044,9 @@ static int __pyx_pf_9csamtools_11AlignedRead_4qual_1__set__(PyObject *__pyx_v_se
   int __pyx_t_9;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2177);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2112);
 
-  /* "csamtools.pyx":2184
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2119
  *             cdef int k
  * 
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -19123,7 +19055,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4qual_1__set__(PyObject *__pyx_v_se
  */
   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "csamtools.pyx":2185
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2120
  * 
  *             src = self._delegate
  *             p = bam1_qual( src )             # <<<<<<<<<<<<<<
@@ -19132,19 +19064,19 @@ static int __pyx_pf_9csamtools_11AlignedRead_4qual_1__set__(PyObject *__pyx_v_se
  */
   __pyx_v_p = bam1_qual(__pyx_v_src);
 
-  /* "csamtools.pyx":2186
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2121
  *             src = self._delegate
  *             p = bam1_qual( src )
  *             if qual == None or len(qual) == 0:             # <<<<<<<<<<<<<<
  *                 # if absent - set to 0xff
  *                 p[0] = 0xff
  */
-  __pyx_t_1 = PyObject_RichCompare(__pyx_v_qual, Py_None, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_qual, Py_None, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   if (!__pyx_t_2) {
-    __pyx_t_3 = PyObject_Length(__pyx_v_qual); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Length(__pyx_v_qual); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_t_4 = (__pyx_t_3 == 0);
     __pyx_t_5 = __pyx_t_4;
   } else {
@@ -19152,7 +19084,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4qual_1__set__(PyObject *__pyx_v_se
   }
   if (__pyx_t_5) {
 
-    /* "csamtools.pyx":2188
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2123
  *             if qual == None or len(qual) == 0:
  *                 # if absent - set to 0xff
  *                 p[0] = 0xff             # <<<<<<<<<<<<<<
@@ -19161,7 +19093,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4qual_1__set__(PyObject *__pyx_v_se
  */
     (__pyx_v_p[0]) = 0xff;
 
-    /* "csamtools.pyx":2189
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2124
  *                 # if absent - set to 0xff
  *                 p[0] = 0xff
  *                 return             # <<<<<<<<<<<<<<
@@ -19174,27 +19106,27 @@ static int __pyx_pf_9csamtools_11AlignedRead_4qual_1__set__(PyObject *__pyx_v_se
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":2192
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2127
  *             cdef int l
  *             # convert to C string
  *             q = qual             # <<<<<<<<<<<<<<
  *             l = len(qual)
  *             if src.core.l_qseq != l:
  */
-  __pyx_t_6 = PyBytes_AsString(__pyx_v_qual); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = PyBytes_AsString(__pyx_v_qual); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_q = __pyx_t_6;
 
-  /* "csamtools.pyx":2193
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2128
  *             # convert to C string
  *             q = qual
  *             l = len(qual)             # <<<<<<<<<<<<<<
  *             if src.core.l_qseq != l:
  *                 raise ValueError("quality and sequence mismatch: %i != %i" % (l, src.core.l_qseq))
  */
-  __pyx_t_3 = PyObject_Length(__pyx_v_qual); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Length(__pyx_v_qual); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_l = __pyx_t_3;
 
-  /* "csamtools.pyx":2194
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2129
  *             q = qual
  *             l = len(qual)
  *             if src.core.l_qseq != l:             # <<<<<<<<<<<<<<
@@ -19204,58 +19136,58 @@ static int __pyx_pf_9csamtools_11AlignedRead_4qual_1__set__(PyObject *__pyx_v_se
   __pyx_t_5 = (__pyx_v_src->core.l_qseq != __pyx_v_l);
   if (__pyx_t_5) {
 
-    /* "csamtools.pyx":2195
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2130
  *             l = len(qual)
  *             if src.core.l_qseq != l:
  *                 raise ValueError("quality and sequence mismatch: %i != %i" % (l, src.core.l_qseq))             # <<<<<<<<<<<<<<
  *             assert src.core.l_qseq == l
  *             for k from 0 <= k < l:
  */
-    __pyx_t_1 = PyInt_FromLong(__pyx_v_l); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyInt_FromLong(__pyx_v_l); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_7 = __Pyx_PyInt_to_py_int32_t(__pyx_v_src->core.l_qseq); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = __Pyx_PyInt_to_py_int32_t(__pyx_v_src->core.l_qseq); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_7);
-    __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_8));
+    __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_8);
     PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1);
     __Pyx_GIVEREF(__pyx_t_1);
     PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7);
     __Pyx_GIVEREF(__pyx_t_7);
     __pyx_t_1 = 0;
     __pyx_t_7 = 0;
-    __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_120), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_61), __pyx_t_8); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_7));
-    __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
-    __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_8));
+    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+    __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_8);
     PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_t_7));
     __Pyx_GIVEREF(((PyObject *)__pyx_t_7));
     __pyx_t_7 = 0;
-    __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_7);
-    __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
+    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
     __Pyx_Raise(__pyx_t_7, 0, 0);
     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L6;
   }
   __pyx_L6:;
 
-  /* "csamtools.pyx":2196
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2131
  *             if src.core.l_qseq != l:
  *                 raise ValueError("quality and sequence mismatch: %i != %i" % (l, src.core.l_qseq))
  *             assert src.core.l_qseq == l             # <<<<<<<<<<<<<<
  *             for k from 0 <= k < l:
  *                 p[k] = <uint8_t>q[k] - 33
  */
-  #ifndef CYTHON_WITHOUT_ASSERTIONS
+  #ifndef PYREX_WITHOUT_ASSERTIONS
   if (unlikely(!(__pyx_v_src->core.l_qseq == __pyx_v_l))) {
     PyErr_SetNone(PyExc_AssertionError);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   #endif
 
-  /* "csamtools.pyx":2197
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2132
  *                 raise ValueError("quality and sequence mismatch: %i != %i" % (l, src.core.l_qseq))
  *             assert src.core.l_qseq == l
  *             for k from 0 <= k < l:             # <<<<<<<<<<<<<<
@@ -19265,7 +19197,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4qual_1__set__(PyObject *__pyx_v_se
   __pyx_t_9 = __pyx_v_l;
   for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_9; __pyx_v_k++) {
 
-    /* "csamtools.pyx":2198
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2133
  *             assert src.core.l_qseq == l
  *             for k from 0 <= k < l:
  *                 p[k] = <uint8_t>q[k] - 33             # <<<<<<<<<<<<<<
@@ -19289,7 +19221,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4qual_1__set__(PyObject *__pyx_v_se
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2210
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2145
  *         were not considered for alignment may have been retained."""
  * 
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -19308,9 +19240,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5query___get__(PyObject *__py
   PyObject *__pyx_t_3 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2210);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2145);
 
-  /* "csamtools.pyx":2215
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2150
  *             cdef char * s
  * 
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -19319,7 +19251,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5query___get__(PyObject *__py
  */
   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "csamtools.pyx":2217
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2152
  *             src = self._delegate
  * 
  *             if src.core.l_qseq == 0: return None             # <<<<<<<<<<<<<<
@@ -19336,27 +19268,27 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5query___get__(PyObject *__py
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":2219
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2154
  *             if src.core.l_qseq == 0: return None
  * 
  *             start = query_start(src)             # <<<<<<<<<<<<<<
  *             end   = query_end(src)
  * 
  */
-  __pyx_t_2 = __pyx_f_9csamtools_query_start(__pyx_v_src); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __pyx_f_9csamtools_query_start(__pyx_v_src); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_start = __pyx_t_2;
 
-  /* "csamtools.pyx":2220
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2155
  * 
  *             start = query_start(src)
  *             end   = query_end(src)             # <<<<<<<<<<<<<<
  * 
  *             return get_seq_range(src, start, end)
  */
-  __pyx_t_2 = __pyx_f_9csamtools_query_end(__pyx_v_src); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __pyx_f_9csamtools_query_end(__pyx_v_src); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_end = __pyx_t_2;
 
-  /* "csamtools.pyx":2222
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2157
  *             end   = query_end(src)
  * 
  *             return get_seq_range(src, start, end)             # <<<<<<<<<<<<<<
@@ -19364,7 +19296,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5query___get__(PyObject *__py
  *     property qqual:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_3 = __pyx_f_9csamtools_get_seq_range(__pyx_v_src, __pyx_v_start, __pyx_v_end); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __pyx_f_9csamtools_get_seq_range(__pyx_v_src, __pyx_v_start, __pyx_v_end); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2157; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __pyx_r = __pyx_t_3;
   __pyx_t_3 = 0;
@@ -19383,7 +19315,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5query___get__(PyObject *__py
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2226
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2161
  *     property qqual:
  *         """aligned query sequence quality values (None if not present)"""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -19402,9 +19334,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5qqual___get__(PyObject *__py
   PyObject *__pyx_t_3 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2226);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2161);
 
-  /* "csamtools.pyx":2231
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2166
  *             cdef char * q
  * 
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -19413,7 +19345,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5qqual___get__(PyObject *__py
  */
   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "csamtools.pyx":2233
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2168
  *             src = self._delegate
  * 
  *             if src.core.l_qseq == 0: return None             # <<<<<<<<<<<<<<
@@ -19430,27 +19362,27 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5qqual___get__(PyObject *__py
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":2235
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2170
  *             if src.core.l_qseq == 0: return None
  * 
  *             start = query_start(src)             # <<<<<<<<<<<<<<
  *             end   = query_end(src)
  * 
  */
-  __pyx_t_2 = __pyx_f_9csamtools_query_start(__pyx_v_src); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __pyx_f_9csamtools_query_start(__pyx_v_src); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_start = __pyx_t_2;
 
-  /* "csamtools.pyx":2236
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2171
  * 
  *             start = query_start(src)
  *             end   = query_end(src)             # <<<<<<<<<<<<<<
  * 
  *             return get_qual_range(src, start, end)
  */
-  __pyx_t_2 = __pyx_f_9csamtools_query_end(__pyx_v_src); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __pyx_f_9csamtools_query_end(__pyx_v_src); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_end = __pyx_t_2;
 
-  /* "csamtools.pyx":2238
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2173
  *             end   = query_end(src)
  * 
  *             return get_qual_range(src, start, end)             # <<<<<<<<<<<<<<
@@ -19458,7 +19390,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5qqual___get__(PyObject *__py
  *     property qstart:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_3 = __pyx_f_9csamtools_get_qual_range(__pyx_v_src, __pyx_v_start, __pyx_v_end); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __pyx_f_9csamtools_get_qual_range(__pyx_v_src, __pyx_v_start, __pyx_v_end); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __pyx_r = __pyx_t_3;
   __pyx_t_3 = 0;
@@ -19477,7 +19409,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5qqual___get__(PyObject *__py
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2242
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2177
  *     property qstart:
  *         """start index of the aligned query portion of the sequence (0-based, inclusive)"""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -19492,9 +19424,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_6qstart___get__(PyObject *__p
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2242);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2177);
 
-  /* "csamtools.pyx":2243
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2178
  *         """start index of the aligned query portion of the sequence (0-based, inclusive)"""
  *         def __get__(self):
  *             return query_start(self._delegate)             # <<<<<<<<<<<<<<
@@ -19502,8 +19434,8 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_6qstart___get__(PyObject *__p
  *     property qend:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __pyx_f_9csamtools_query_start(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_2 = __Pyx_PyInt_to_py_int32_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __pyx_f_9csamtools_query_start(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyInt_to_py_int32_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
@@ -19522,7 +19454,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_6qstart___get__(PyObject *__p
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2247
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2182
  *     property qend:
  *         """end index of the aligned query portion of the sequence (0-based, exclusive)"""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -19537,9 +19469,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qend___get__(PyObject *__pyx
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2247);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2182);
 
-  /* "csamtools.pyx":2248
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2183
  *         """end index of the aligned query portion of the sequence (0-based, exclusive)"""
  *         def __get__(self):
  *             return query_end(self._delegate)             # <<<<<<<<<<<<<<
@@ -19547,8 +19479,8 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qend___get__(PyObject *__pyx
  *     property qlen:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __pyx_f_9csamtools_query_end(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_2 = __Pyx_PyInt_to_py_int32_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __pyx_f_9csamtools_query_end(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyInt_to_py_int32_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
@@ -19567,7 +19499,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qend___get__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2252
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2187
  *     property qlen:
  *         """Length of the aligned query sequence"""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -19584,9 +19516,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qlen___get__(PyObject *__pyx
   PyObject *__pyx_t_3 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2252);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2187);
 
-  /* "csamtools.pyx":2254
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2189
  *         def __get__(self):
  *             cdef bam1_t * src
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -19595,7 +19527,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qlen___get__(PyObject *__pyx
  */
   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "csamtools.pyx":2255
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2190
  *             cdef bam1_t * src
  *             src = self._delegate
  *             return query_end(src)-query_start(src)             # <<<<<<<<<<<<<<
@@ -19603,9 +19535,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qlen___get__(PyObject *__pyx
  *     property tags:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __pyx_f_9csamtools_query_end(__pyx_v_src); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_2 = __pyx_f_9csamtools_query_start(__pyx_v_src); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_3 = __Pyx_PyInt_to_py_int32_t((__pyx_t_1 - __pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __pyx_f_9csamtools_query_end(__pyx_v_src); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __pyx_f_9csamtools_query_start(__pyx_v_src); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyInt_to_py_int32_t((__pyx_t_1 - __pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __pyx_r = __pyx_t_3;
   __pyx_t_3 = 0;
@@ -19624,8 +19556,8 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qlen___get__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2272
- *         multiple times.
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2204
+ * 
  *         """
  *         def __get__(self):             # <<<<<<<<<<<<<<
  *             cdef char * ctag
@@ -19651,40 +19583,38 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
   int __pyx_t_8;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2272);
-  __pyx_v_result = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2204);
+  __pyx_v_result = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
   __pyx_v_value = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "csamtools.pyx":2279
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2211
  *             cdef char auxtype
  * 
  *             src = self._delegate             # <<<<<<<<<<<<<<
- *             if src.l_aux == 0: return []
+ *             if src.l_aux == 0: return None
  * 
  */
   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "csamtools.pyx":2280
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2212
  * 
  *             src = self._delegate
- *             if src.l_aux == 0: return []             # <<<<<<<<<<<<<<
+ *             if src.l_aux == 0: return None             # <<<<<<<<<<<<<<
  * 
  *             s = bam1_aux( src )
  */
   __pyx_t_1 = (__pyx_v_src->l_aux == 0);
   if (__pyx_t_1) {
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-    __pyx_r = ((PyObject *)__pyx_t_2);
-    __pyx_t_2 = 0;
+    __Pyx_INCREF(Py_None);
+    __pyx_r = Py_None;
     goto __pyx_L0;
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":2282
- *             if src.l_aux == 0: return []
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2214
+ *             if src.l_aux == 0: return None
  * 
  *             s = bam1_aux( src )             # <<<<<<<<<<<<<<
  *             result = []
@@ -19692,20 +19622,20 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
  */
   __pyx_v_s = bam1_aux(__pyx_v_src);
 
-  /* "csamtools.pyx":2283
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2215
  * 
  *             s = bam1_aux( src )
  *             result = []             # <<<<<<<<<<<<<<
  *             auxtag[2] = 0
  *             while s < (src.data + src.data_len):
  */
-  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
   __Pyx_DECREF(((PyObject *)__pyx_v_result));
   __pyx_v_result = __pyx_t_2;
   __pyx_t_2 = 0;
 
-  /* "csamtools.pyx":2284
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2216
  *             s = bam1_aux( src )
  *             result = []
  *             auxtag[2] = 0             # <<<<<<<<<<<<<<
@@ -19714,7 +19644,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
  */
   (__pyx_v_auxtag[2]) = 0;
 
-  /* "csamtools.pyx":2285
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2217
  *             result = []
  *             auxtag[2] = 0
  *             while s < (src.data + src.data_len):             # <<<<<<<<<<<<<<
@@ -19725,7 +19655,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
     __pyx_t_1 = (__pyx_v_s < (__pyx_v_src->data + __pyx_v_src->data_len));
     if (!__pyx_t_1) break;
 
-    /* "csamtools.pyx":2287
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2219
  *             while s < (src.data + src.data_len):
  *                 # get tag
  *                 auxtag[0] = s[0]             # <<<<<<<<<<<<<<
@@ -19734,7 +19664,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
  */
     (__pyx_v_auxtag[0]) = (__pyx_v_s[0]);
 
-    /* "csamtools.pyx":2288
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2220
  *                 # get tag
  *                 auxtag[0] = s[0]
  *                 auxtag[1] = s[1]             # <<<<<<<<<<<<<<
@@ -19743,16 +19673,16 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
  */
     (__pyx_v_auxtag[1]) = (__pyx_v_s[1]);
 
-    /* "csamtools.pyx":2289
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2221
  *                 auxtag[0] = s[0]
  *                 auxtag[1] = s[1]
  *                 s += 2             # <<<<<<<<<<<<<<
  *                 auxtype = s[0]
  * 
  */
-    __pyx_v_s = (__pyx_v_s + 2);
+    __pyx_v_s += 2;
 
-    /* "csamtools.pyx":2290
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2222
  *                 auxtag[1] = s[1]
  *                 s += 2
  *                 auxtype = s[0]             # <<<<<<<<<<<<<<
@@ -19761,7 +19691,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
  */
     __pyx_v_auxtype = (__pyx_v_s[0]);
 
-    /* "csamtools.pyx":2292
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2224
  *                 auxtype = s[0]
  * 
  *                 if auxtype in ('c', 'C'):             # <<<<<<<<<<<<<<
@@ -19779,31 +19709,31 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
     __pyx_t_1 = __pyx_t_5;
     if (__pyx_t_1) {
 
-      /* "csamtools.pyx":2293
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2225
  * 
  *                 if auxtype in ('c', 'C'):
  *                     value = <int>bam_aux2i(s)             # <<<<<<<<<<<<<<
  *                     s += 1
  *                 elif auxtype in ('s', 'S'):
  */
-      __pyx_t_2 = PyInt_FromLong(((int)bam_aux2i(__pyx_v_s))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyInt_FromLong(((int)bam_aux2i(__pyx_v_s))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
       __Pyx_DECREF(__pyx_v_value);
       __pyx_v_value = __pyx_t_2;
       __pyx_t_2 = 0;
 
-      /* "csamtools.pyx":2294
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2226
  *                 if auxtype in ('c', 'C'):
  *                     value = <int>bam_aux2i(s)
  *                     s += 1             # <<<<<<<<<<<<<<
  *                 elif auxtype in ('s', 'S'):
  *                     value = <int>bam_aux2i(s)
  */
-      __pyx_v_s = (__pyx_v_s + 1);
+      __pyx_v_s += 1;
       goto __pyx_L8;
     }
 
-    /* "csamtools.pyx":2295
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2227
  *                     value = <int>bam_aux2i(s)
  *                     s += 1
  *                 elif auxtype in ('s', 'S'):             # <<<<<<<<<<<<<<
@@ -19821,31 +19751,31 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
     __pyx_t_1 = __pyx_t_4;
     if (__pyx_t_1) {
 
-      /* "csamtools.pyx":2296
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2228
  *                     s += 1
  *                 elif auxtype in ('s', 'S'):
  *                     value = <int>bam_aux2i(s)             # <<<<<<<<<<<<<<
  *                     s += 2
  *                 elif auxtype in ('i', 'I'):
  */
-      __pyx_t_2 = PyInt_FromLong(((int)bam_aux2i(__pyx_v_s))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyInt_FromLong(((int)bam_aux2i(__pyx_v_s))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
       __Pyx_DECREF(__pyx_v_value);
       __pyx_v_value = __pyx_t_2;
       __pyx_t_2 = 0;
 
-      /* "csamtools.pyx":2297
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2229
  *                 elif auxtype in ('s', 'S'):
  *                     value = <int>bam_aux2i(s)
  *                     s += 2             # <<<<<<<<<<<<<<
  *                 elif auxtype in ('i', 'I'):
  *                     value = <float>bam_aux2i(s)
  */
-      __pyx_v_s = (__pyx_v_s + 2);
+      __pyx_v_s += 2;
       goto __pyx_L8;
     }
 
-    /* "csamtools.pyx":2298
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2230
  *                     value = <int>bam_aux2i(s)
  *                     s += 2
  *                 elif auxtype in ('i', 'I'):             # <<<<<<<<<<<<<<
@@ -19863,31 +19793,31 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
     __pyx_t_1 = __pyx_t_5;
     if (__pyx_t_1) {
 
-      /* "csamtools.pyx":2299
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2231
  *                     s += 2
  *                 elif auxtype in ('i', 'I'):
  *                     value = <float>bam_aux2i(s)             # <<<<<<<<<<<<<<
  *                     s += 4
  *                 elif auxtype == 'f':
  */
-      __pyx_t_2 = PyFloat_FromDouble(((float)bam_aux2i(__pyx_v_s))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyFloat_FromDouble(((float)bam_aux2i(__pyx_v_s))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2231; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
       __Pyx_DECREF(__pyx_v_value);
       __pyx_v_value = __pyx_t_2;
       __pyx_t_2 = 0;
 
-      /* "csamtools.pyx":2300
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2232
  *                 elif auxtype in ('i', 'I'):
  *                     value = <float>bam_aux2i(s)
  *                     s += 4             # <<<<<<<<<<<<<<
  *                 elif auxtype == 'f':
  *                     value = <float>bam_aux2f(s)
  */
-      __pyx_v_s = (__pyx_v_s + 4);
+      __pyx_v_s += 4;
       goto __pyx_L8;
     }
 
-    /* "csamtools.pyx":2301
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2233
  *                     value = <float>bam_aux2i(s)
  *                     s += 4
  *                 elif auxtype == 'f':             # <<<<<<<<<<<<<<
@@ -19897,31 +19827,31 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
     __pyx_t_1 = (__pyx_v_auxtype == 'f');
     if (__pyx_t_1) {
 
-      /* "csamtools.pyx":2302
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2234
  *                     s += 4
  *                 elif auxtype == 'f':
  *                     value = <float>bam_aux2f(s)             # <<<<<<<<<<<<<<
  *                     s += 4
  *                 elif auxtype == 'd':
  */
-      __pyx_t_2 = PyFloat_FromDouble(bam_aux2f(__pyx_v_s)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyFloat_FromDouble(bam_aux2f(__pyx_v_s)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
       __Pyx_DECREF(__pyx_v_value);
       __pyx_v_value = __pyx_t_2;
       __pyx_t_2 = 0;
 
-      /* "csamtools.pyx":2303
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2235
  *                 elif auxtype == 'f':
  *                     value = <float>bam_aux2f(s)
  *                     s += 4             # <<<<<<<<<<<<<<
  *                 elif auxtype == 'd':
  *                     value = <double>bam_aux2d(s)
  */
-      __pyx_v_s = (__pyx_v_s + 4);
+      __pyx_v_s += 4;
       goto __pyx_L8;
     }
 
-    /* "csamtools.pyx":2304
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2236
  *                     value = <float>bam_aux2f(s)
  *                     s += 4
  *                 elif auxtype == 'd':             # <<<<<<<<<<<<<<
@@ -19931,31 +19861,31 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
     __pyx_t_1 = (__pyx_v_auxtype == 'd');
     if (__pyx_t_1) {
 
-      /* "csamtools.pyx":2305
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2237
  *                     s += 4
  *                 elif auxtype == 'd':
  *                     value = <double>bam_aux2d(s)             # <<<<<<<<<<<<<<
  *                     s += 8
  *                 elif auxtype == 'A':
  */
-      __pyx_t_2 = PyFloat_FromDouble(bam_aux2d(__pyx_v_s)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyFloat_FromDouble(bam_aux2d(__pyx_v_s)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
       __Pyx_DECREF(__pyx_v_value);
       __pyx_v_value = __pyx_t_2;
       __pyx_t_2 = 0;
 
-      /* "csamtools.pyx":2306
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2238
  *                 elif auxtype == 'd':
  *                     value = <double>bam_aux2d(s)
  *                     s += 8             # <<<<<<<<<<<<<<
  *                 elif auxtype == 'A':
  *                     value = "%c" % <char>bam_aux2A(s)
  */
-      __pyx_v_s = (__pyx_v_s + 8);
+      __pyx_v_s += 8;
       goto __pyx_L8;
     }
 
-    /* "csamtools.pyx":2307
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2239
  *                     value = <double>bam_aux2d(s)
  *                     s += 8
  *                 elif auxtype == 'A':             # <<<<<<<<<<<<<<
@@ -19965,34 +19895,34 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
     __pyx_t_1 = (__pyx_v_auxtype == 'A');
     if (__pyx_t_1) {
 
-      /* "csamtools.pyx":2308
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2240
  *                     s += 8
  *                 elif auxtype == 'A':
  *                     value = "%c" % <char>bam_aux2A(s)             # <<<<<<<<<<<<<<
  *                     s += 1
  *                 elif auxtype in ('Z', 'H'):
  */
-      __pyx_t_2 = PyInt_FromLong(bam_aux2A(__pyx_v_s)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyInt_FromLong(bam_aux2A(__pyx_v_s)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
-      __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_121), __pyx_t_2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_62), __pyx_t_2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_6));
       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
       __Pyx_DECREF(__pyx_v_value);
       __pyx_v_value = ((PyObject *)__pyx_t_6);
       __pyx_t_6 = 0;
 
-      /* "csamtools.pyx":2309
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2241
  *                 elif auxtype == 'A':
  *                     value = "%c" % <char>bam_aux2A(s)
  *                     s += 1             # <<<<<<<<<<<<<<
  *                 elif auxtype in ('Z', 'H'):
  *                     value = <char*>bam_aux2Z(s)
  */
-      __pyx_v_s = (__pyx_v_s + 1);
+      __pyx_v_s += 1;
       goto __pyx_L8;
     }
 
-    /* "csamtools.pyx":2310
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2242
  *                     value = "%c" % <char>bam_aux2A(s)
  *                     s += 1
  *                 elif auxtype in ('Z', 'H'):             # <<<<<<<<<<<<<<
@@ -20010,42 +19940,42 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
     __pyx_t_1 = __pyx_t_4;
     if (__pyx_t_1) {
 
-      /* "csamtools.pyx":2311
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2243
  *                     s += 1
  *                 elif auxtype in ('Z', 'H'):
  *                     value = <char*>bam_aux2Z(s)             # <<<<<<<<<<<<<<
  *                     # +1 for NULL terminated string
  *                     s += len(value) + 1
  */
-      __pyx_t_6 = PyBytes_FromString(bam_aux2Z(__pyx_v_s)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyBytes_FromString(bam_aux2Z(__pyx_v_s)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_6));
       __Pyx_DECREF(__pyx_v_value);
       __pyx_v_value = ((PyObject *)__pyx_t_6);
       __pyx_t_6 = 0;
 
-      /* "csamtools.pyx":2313
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2245
  *                     value = <char*>bam_aux2Z(s)
  *                     # +1 for NULL terminated string
  *                     s += len(value) + 1             # <<<<<<<<<<<<<<
  *                  #
  *                 s += 1
  */
-      __pyx_t_7 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __pyx_v_s = (__pyx_v_s + (__pyx_t_7 + 1));
+      __pyx_t_7 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_v_s += (__pyx_t_7 + 1);
       goto __pyx_L8;
     }
     __pyx_L8:;
 
-    /* "csamtools.pyx":2315
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2247
  *                     s += len(value) + 1
  *                  #
  *                 s += 1             # <<<<<<<<<<<<<<
  * 
  *                 result.append( (auxtag, value) )
  */
-    __pyx_v_s = (__pyx_v_s + 1);
+    __pyx_v_s += 1;
 
-    /* "csamtools.pyx":2317
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2249
  *                 s += 1
  * 
  *                 result.append( (auxtag, value) )             # <<<<<<<<<<<<<<
@@ -20053,23 +19983,23 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
  *             return result
  */
     if (unlikely(__pyx_v_result == Py_None)) {
-      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2317; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2249; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
     }
-    __pyx_t_6 = PyBytes_FromString(__pyx_v_auxtag); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyBytes_FromString(__pyx_v_auxtag); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_6));
-    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_6));
     __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
     __Pyx_INCREF(__pyx_v_value);
     PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_value);
     __Pyx_GIVEREF(__pyx_v_value);
     __pyx_t_6 = 0;
-    __pyx_t_8 = PyList_Append(__pyx_v_result, ((PyObject *)__pyx_t_2)); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+    __pyx_t_8 = PyList_Append(((PyObject *)__pyx_v_result), __pyx_t_2); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   }
 
-  /* "csamtools.pyx":2319
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2251
  *                 result.append( (auxtag, value) )
  * 
  *             return result             # <<<<<<<<<<<<<<
@@ -20097,7 +20027,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2321
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2253
  *             return result
  * 
  *         def __set__(self, tags):             # <<<<<<<<<<<<<<
@@ -20105,8 +20035,8 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx
  *             cdef bam1_t * src
  */
 
-static int __pyx_pf_9csamtools_11AlignedRead_4tags_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_tags); /*proto*/
-static int __pyx_pf_9csamtools_11AlignedRead_4tags_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_tags) {
+static int __pyx_pf_9csamtools_11AlignedRead_4tags___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_tags); /*proto*/
+static int __pyx_pf_9csamtools_11AlignedRead_4tags___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_tags) {
   bam1_t *__pyx_v_src;
   uint8_t *__pyx_v_s;
   char *__pyx_v_temp;
@@ -20133,15 +20063,15 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags_1__set__(PyObject *__pyx_v_se
   char *__pyx_t_11;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2321);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2253);
   __pyx_v_buffer = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_pytag = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_value = Py_None; __Pyx_INCREF(Py_None);
-  __pyx_v_t = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
+  __pyx_v_t = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
   __pyx_v_fmt = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_pytype = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "csamtools.pyx":2330
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2262
  *             cdef int max_size, size, offset
  * 
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -20150,7 +20080,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags_1__set__(PyObject *__pyx_v_se
  */
   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "csamtools.pyx":2331
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2263
  * 
  *             src = self._delegate
  *             max_size = 4000             # <<<<<<<<<<<<<<
@@ -20159,7 +20089,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags_1__set__(PyObject *__pyx_v_se
  */
   __pyx_v_max_size = 4000;
 
-  /* "csamtools.pyx":2332
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2264
  *             src = self._delegate
  *             max_size = 4000
  *             offset = 0             # <<<<<<<<<<<<<<
@@ -20168,47 +20098,47 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags_1__set__(PyObject *__pyx_v_se
  */
   __pyx_v_offset = 0;
 
-  /* "csamtools.pyx":2334
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2266
  *             offset = 0
  * 
  *             if tags != None:             # <<<<<<<<<<<<<<
  * 
  *                 # map samtools code to python.struct code and byte size
  */
-  __pyx_t_1 = PyObject_RichCompare(__pyx_v_tags, Py_None, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_tags, Py_None, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   if (__pyx_t_2) {
 
-    /* "csamtools.pyx":2337
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2269
  * 
  *                 # map samtools code to python.struct code and byte size
  *                 buffer = ctypes.create_string_buffer(max_size)             # <<<<<<<<<<<<<<
  * 
  *                 for pytag, value in tags:
  */
-    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__ctypes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__ctypes); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s_122); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s_63); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_1 = PyInt_FromLong(__pyx_v_max_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyInt_FromLong(__pyx_v_max_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
+    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
     PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
     __Pyx_GIVEREF(__pyx_t_1);
     __pyx_t_1 = 0;
-    __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     __Pyx_DECREF(__pyx_v_buffer);
     __pyx_v_buffer = __pyx_t_1;
     __pyx_t_1 = 0;
 
-    /* "csamtools.pyx":2339
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2271
  *                 buffer = ctypes.create_string_buffer(max_size)
  * 
  *                 for pytag, value in tags:             # <<<<<<<<<<<<<<
@@ -20218,7 +20148,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags_1__set__(PyObject *__pyx_v_se
     if (PyList_CheckExact(__pyx_v_tags) || PyTuple_CheckExact(__pyx_v_tags)) {
       __pyx_t_5 = 0; __pyx_t_1 = __pyx_v_tags; __Pyx_INCREF(__pyx_t_1);
     } else {
-      __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_tags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_tags); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
     }
     for (;;) {
@@ -20231,7 +20161,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags_1__set__(PyObject *__pyx_v_se
       } else {
         __pyx_t_4 = PyIter_Next(__pyx_t_1);
         if (!__pyx_t_4) {
-          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           break;
         }
         __Pyx_GOTREF(__pyx_t_4);
@@ -20248,14 +20178,14 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags_1__set__(PyObject *__pyx_v_se
         __pyx_v_value = __pyx_t_6;
         __pyx_t_6 = 0;
       } else {
-        __pyx_t_7 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-        __pyx_t_3 = __Pyx_UnpackItem(__pyx_t_7, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_3 = __Pyx_UnpackItem(__pyx_t_7, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_3);
-        __pyx_t_6 = __Pyx_UnpackItem(__pyx_t_7, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = __Pyx_UnpackItem(__pyx_t_7, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
-        if (__Pyx_EndUnpack(__pyx_t_7, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        if (__Pyx_EndUnpack(__pyx_t_7, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
         __Pyx_DECREF(__pyx_v_pytag);
         __pyx_v_pytag = __pyx_t_3;
@@ -20265,7 +20195,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags_1__set__(PyObject *__pyx_v_se
         __pyx_t_6 = 0;
       }
 
-      /* "csamtools.pyx":2340
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2272
  * 
  *                 for pytag, value in tags:
  *                     t = type(value)             # <<<<<<<<<<<<<<
@@ -20274,35 +20204,35 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags_1__set__(PyObject *__pyx_v_se
  */
       __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_value)));
       __Pyx_DECREF(((PyObject *)__pyx_v_t));
-      __pyx_v_t = ((PyObject*)((PyObject *)Py_TYPE(__pyx_v_value)));
+      __pyx_v_t = ((PyObject *)((PyObject *)Py_TYPE(__pyx_v_value)));
 
-      /* "csamtools.pyx":2341
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2273
  *                 for pytag, value in tags:
  *                     t = type(value)
  *                     if t == types.FloatType:             # <<<<<<<<<<<<<<
  *                         fmt, pytype = "<cccf", 'f'
  *                     elif t == types.IntType:
  */
-      __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__types); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__types); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_4);
-      __pyx_t_6 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__FloatType); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__FloatType); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-      __pyx_t_4 = PyObject_RichCompare(((PyObject *)__pyx_v_t), __pyx_t_6, Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = PyObject_RichCompare(((PyObject *)__pyx_v_t), __pyx_t_6, Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_4);
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
       if (__pyx_t_2) {
 
-        /* "csamtools.pyx":2342
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2274
  *                     t = type(value)
  *                     if t == types.FloatType:
  *                         fmt, pytype = "<cccf", 'f'             # <<<<<<<<<<<<<<
  *                     elif t == types.IntType:
  *                         if value < 0:
  */
-        __pyx_t_4 = ((PyObject *)__pyx_kp_s_123);
+        __pyx_t_4 = ((PyObject *)__pyx_kp_s_64);
         __Pyx_INCREF(__pyx_t_4);
         __pyx_t_6 = ((PyObject *)__pyx_n_s__f);
         __Pyx_INCREF(__pyx_t_6);
@@ -20315,51 +20245,51 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags_1__set__(PyObject *__pyx_v_se
         goto __pyx_L8;
       }
 
-      /* "csamtools.pyx":2343
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2275
  *                     if t == types.FloatType:
  *                         fmt, pytype = "<cccf", 'f'
  *                     elif t == types.IntType:             # <<<<<<<<<<<<<<
  *                         if value < 0:
  *                             if value >= -127: fmt, pytype = "<cccb", 'c'
  */
-      __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__types); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__types); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
-      __pyx_t_4 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__IntType); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__IntType); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_4);
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-      __pyx_t_6 = PyObject_RichCompare(((PyObject *)__pyx_v_t), __pyx_t_4, Py_EQ); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyObject_RichCompare(((PyObject *)__pyx_v_t), __pyx_t_4, Py_EQ); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
       if (__pyx_t_2) {
 
-        /* "csamtools.pyx":2344
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2276
  *                         fmt, pytype = "<cccf", 'f'
  *                     elif t == types.IntType:
  *                         if value < 0:             # <<<<<<<<<<<<<<
  *                             if value >= -127: fmt, pytype = "<cccb", 'c'
  *                             elif value >= -32767: fmt, pytype = "<ccch", 's'
  */
-        __pyx_t_6 = PyObject_RichCompare(__pyx_v_value, __pyx_int_0, Py_LT); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = PyObject_RichCompare(__pyx_v_value, __pyx_int_0, Py_LT); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
-        __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
         if (__pyx_t_2) {
 
-          /* "csamtools.pyx":2345
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2277
  *                     elif t == types.IntType:
  *                         if value < 0:
  *                             if value >= -127: fmt, pytype = "<cccb", 'c'             # <<<<<<<<<<<<<<
  *                             elif value >= -32767: fmt, pytype = "<ccch", 's'
  *                             elif value < -2147483648: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )
  */
-          __pyx_t_6 = PyObject_RichCompare(__pyx_v_value, __pyx_int_neg_127, Py_GE); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_6 = PyObject_RichCompare(__pyx_v_value, __pyx_int_neg_127, Py_GE); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_6);
-          __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
           if (__pyx_t_2) {
-            __pyx_t_6 = ((PyObject *)__pyx_kp_s_124);
+            __pyx_t_6 = ((PyObject *)__pyx_kp_s_65);
             __Pyx_INCREF(__pyx_t_6);
             __pyx_t_4 = ((PyObject *)__pyx_n_s__c);
             __Pyx_INCREF(__pyx_t_4);
@@ -20372,19 +20302,19 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags_1__set__(PyObject *__pyx_v_se
             goto __pyx_L10;
           }
 
-          /* "csamtools.pyx":2346
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2278
  *                         if value < 0:
  *                             if value >= -127: fmt, pytype = "<cccb", 'c'
  *                             elif value >= -32767: fmt, pytype = "<ccch", 's'             # <<<<<<<<<<<<<<
  *                             elif value < -2147483648: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )
  *                             else: fmt, pytype = "<ccci", 'i'[0]
  */
-          __pyx_t_4 = PyObject_RichCompare(__pyx_v_value, __pyx_int_neg_32767, Py_GE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_4 = PyObject_RichCompare(__pyx_v_value, __pyx_int_neg_32767, Py_GE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_4);
-          __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
           if (__pyx_t_2) {
-            __pyx_t_4 = ((PyObject *)__pyx_kp_s_125);
+            __pyx_t_4 = ((PyObject *)__pyx_kp_s_66);
             __Pyx_INCREF(__pyx_t_4);
             __pyx_t_6 = ((PyObject *)__pyx_n_s__s);
             __Pyx_INCREF(__pyx_t_6);
@@ -20397,45 +20327,45 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags_1__set__(PyObject *__pyx_v_se
             goto __pyx_L10;
           }
 
-          /* "csamtools.pyx":2347
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2279
  *                             if value >= -127: fmt, pytype = "<cccb", 'c'
  *                             elif value >= -32767: fmt, pytype = "<ccch", 's'
  *                             elif value < -2147483648: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )             # <<<<<<<<<<<<<<
  *                             else: fmt, pytype = "<ccci", 'i'[0]
  *                         else:
  */
-          __pyx_t_6 = PyObject_RichCompare(__pyx_v_value, __pyx_int_neg_2147483648, Py_LT); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_6 = PyObject_RichCompare(__pyx_v_value, __pyx_int_neg_2147483648, Py_LT); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_6);
-          __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
           if (__pyx_t_2) {
-            __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_126), __pyx_v_value); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_67), __pyx_v_value); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             __Pyx_GOTREF(((PyObject *)__pyx_t_6));
-            __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-            __Pyx_GOTREF(((PyObject *)__pyx_t_4));
+            __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __Pyx_GOTREF(__pyx_t_4);
             PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_6));
             __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
             __pyx_t_6 = 0;
-            __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             __Pyx_GOTREF(__pyx_t_6);
-            __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
+            __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
             __Pyx_Raise(__pyx_t_6, 0, 0);
             __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             goto __pyx_L10;
           }
           /*else*/ {
 
-            /* "csamtools.pyx":2348
+            /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2280
  *                             elif value >= -32767: fmt, pytype = "<ccch", 's'
  *                             elif value < -2147483648: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )
  *                             else: fmt, pytype = "<ccci", 'i'[0]             # <<<<<<<<<<<<<<
  *                         else:
  *                             if value <= 255: fmt, pytype = "<cccB", 'C'
  */
-            __pyx_t_6 = ((PyObject *)__pyx_kp_s_127);
+            __pyx_t_6 = ((PyObject *)__pyx_kp_s_68);
             __Pyx_INCREF(__pyx_t_6);
-            __pyx_t_4 = __Pyx_GetItemInt(((PyObject *)__pyx_n_s__i), 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __pyx_t_4 = __Pyx_GetItemInt(((PyObject *)__pyx_n_s__i), 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             __Pyx_GOTREF(__pyx_t_4);
             __Pyx_DECREF(__pyx_v_fmt);
             __pyx_v_fmt = __pyx_t_6;
@@ -20449,19 +20379,19 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags_1__set__(PyObject *__pyx_v_se
         }
         /*else*/ {
 
-          /* "csamtools.pyx":2350
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2282
  *                             else: fmt, pytype = "<ccci", 'i'[0]
  *                         else:
  *                             if value <= 255: fmt, pytype = "<cccB", 'C'             # <<<<<<<<<<<<<<
  *                             elif value <= 65535: fmt, pytype = "<cccH", 'S'
  *                             elif value > 4294967295: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )
  */
-          __pyx_t_4 = PyObject_RichCompare(__pyx_v_value, __pyx_int_255, Py_LE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_4 = PyObject_RichCompare(__pyx_v_value, __pyx_int_255, Py_LE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_4);
-          __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
           if (__pyx_t_2) {
-            __pyx_t_4 = ((PyObject *)__pyx_kp_s_128);
+            __pyx_t_4 = ((PyObject *)__pyx_kp_s_69);
             __Pyx_INCREF(__pyx_t_4);
             __pyx_t_6 = ((PyObject *)__pyx_n_s__C);
             __Pyx_INCREF(__pyx_t_6);
@@ -20474,19 +20404,19 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags_1__set__(PyObject *__pyx_v_se
             goto __pyx_L11;
           }
 
-          /* "csamtools.pyx":2351
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2283
  *                         else:
  *                             if value <= 255: fmt, pytype = "<cccB", 'C'
  *                             elif value <= 65535: fmt, pytype = "<cccH", 'S'             # <<<<<<<<<<<<<<
  *                             elif value > 4294967295: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )
  *                             else: fmt, pytype = "<cccI", 'I'
  */
-          __pyx_t_6 = PyObject_RichCompare(__pyx_v_value, __pyx_int_65535, Py_LE); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_6 = PyObject_RichCompare(__pyx_v_value, __pyx_int_65535, Py_LE); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_6);
-          __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
           if (__pyx_t_2) {
-            __pyx_t_6 = ((PyObject *)__pyx_kp_s_129);
+            __pyx_t_6 = ((PyObject *)__pyx_kp_s_70);
             __Pyx_INCREF(__pyx_t_6);
             __pyx_t_4 = ((PyObject *)__pyx_n_s__S);
             __Pyx_INCREF(__pyx_t_4);
@@ -20499,43 +20429,43 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags_1__set__(PyObject *__pyx_v_se
             goto __pyx_L11;
           }
 
-          /* "csamtools.pyx":2352
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2284
  *                             if value <= 255: fmt, pytype = "<cccB", 'C'
  *                             elif value <= 65535: fmt, pytype = "<cccH", 'S'
  *                             elif value > 4294967295: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )             # <<<<<<<<<<<<<<
  *                             else: fmt, pytype = "<cccI", 'I'
  *                     else:
  */
-          __pyx_t_4 = PyObject_RichCompare(__pyx_v_value, __pyx_int_4294967295, Py_GT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_4 = PyObject_RichCompare(__pyx_v_value, __pyx_int_4294967295, Py_GT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_4);
-          __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
           if (__pyx_t_2) {
-            __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_126), __pyx_v_value); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_67), __pyx_v_value); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             __Pyx_GOTREF(((PyObject *)__pyx_t_4));
-            __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-            __Pyx_GOTREF(((PyObject *)__pyx_t_6));
+            __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __Pyx_GOTREF(__pyx_t_6);
             PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_4));
             __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
             __pyx_t_4 = 0;
-            __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             __Pyx_GOTREF(__pyx_t_4);
-            __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
+            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
             __Pyx_Raise(__pyx_t_4, 0, 0);
             __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             goto __pyx_L11;
           }
           /*else*/ {
 
-            /* "csamtools.pyx":2353
+            /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2285
  *                             elif value <= 65535: fmt, pytype = "<cccH", 'S'
  *                             elif value > 4294967295: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )
  *                             else: fmt, pytype = "<cccI", 'I'             # <<<<<<<<<<<<<<
  *                     else:
  *                         # Note: hex strings (H) are not supported yet
  */
-            __pyx_t_4 = ((PyObject *)__pyx_kp_s_130);
+            __pyx_t_4 = ((PyObject *)__pyx_kp_s_71);
             __Pyx_INCREF(__pyx_t_4);
             __pyx_t_6 = ((PyObject *)__pyx_n_s__I);
             __Pyx_INCREF(__pyx_t_6);
@@ -20553,25 +20483,25 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags_1__set__(PyObject *__pyx_v_se
       }
       /*else*/ {
 
-        /* "csamtools.pyx":2356
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2288
  *                     else:
  *                         # Note: hex strings (H) are not supported yet
  *                         if len(value) == 1:             # <<<<<<<<<<<<<<
  *                             fmt, pytype = "<cccc", 'A'
  *                         else:
  */
-        __pyx_t_8 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __pyx_t_2 = (__pyx_t_8 == 1);
         if (__pyx_t_2) {
 
-          /* "csamtools.pyx":2357
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2289
  *                         # Note: hex strings (H) are not supported yet
  *                         if len(value) == 1:
  *                             fmt, pytype = "<cccc", 'A'             # <<<<<<<<<<<<<<
  *                         else:
  *                             fmt, pytype = "<ccc%is" % (len(value)+1), 'Z'
  */
-          __pyx_t_6 = ((PyObject *)__pyx_kp_s_131);
+          __pyx_t_6 = ((PyObject *)__pyx_kp_s_72);
           __Pyx_INCREF(__pyx_t_6);
           __pyx_t_4 = ((PyObject *)__pyx_n_s__A);
           __Pyx_INCREF(__pyx_t_4);
@@ -20585,17 +20515,17 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags_1__set__(PyObject *__pyx_v_se
         }
         /*else*/ {
 
-          /* "csamtools.pyx":2359
+          /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2291
  *                             fmt, pytype = "<cccc", 'A'
  *                         else:
  *                             fmt, pytype = "<ccc%is" % (len(value)+1), 'Z'             # <<<<<<<<<<<<<<
  * 
  *                     size = struct.calcsize(fmt)
  */
-          __pyx_t_8 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __pyx_t_4 = PyInt_FromSsize_t((__pyx_t_8 + 1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_8 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_4 = PyInt_FromSsize_t((__pyx_t_8 + 1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_4);
-          __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_132), __pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_73), __pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(((PyObject *)__pyx_t_6));
           __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
           __pyx_t_4 = ((PyObject *)__pyx_n_s__Z);
@@ -20611,32 +20541,32 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags_1__set__(PyObject *__pyx_v_se
       }
       __pyx_L8:;
 
-      /* "csamtools.pyx":2361
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2293
  *                             fmt, pytype = "<ccc%is" % (len(value)+1), 'Z'
  * 
  *                     size = struct.calcsize(fmt)             # <<<<<<<<<<<<<<
  *                     if offset + size > max_size:
  *                         raise NotImplementedError("tags field too large")
  */
-      __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__struct); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__struct); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_4);
-      __pyx_t_6 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__calcsize); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__calcsize); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(((PyObject *)__pyx_t_4));
+      __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
       __Pyx_INCREF(__pyx_v_fmt);
       PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_fmt);
       __Pyx_GIVEREF(__pyx_v_fmt);
-      __pyx_t_3 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyObject_Call(__pyx_t_6, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-      __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
-      __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
       __pyx_v_size = __pyx_t_9;
 
-      /* "csamtools.pyx":2362
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2294
  * 
  *                     size = struct.calcsize(fmt)
  *                     if offset + size > max_size:             # <<<<<<<<<<<<<<
@@ -20646,82 +20576,88 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags_1__set__(PyObject *__pyx_v_se
       __pyx_t_2 = ((__pyx_v_offset + __pyx_v_size) > __pyx_v_max_size);
       if (__pyx_t_2) {
 
-        /* "csamtools.pyx":2363
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2295
  *                     size = struct.calcsize(fmt)
  *                     if offset + size > max_size:
  *                         raise NotImplementedError("tags field too large")             # <<<<<<<<<<<<<<
  * 
  *                     struct.pack_into( fmt,
  */
-        __pyx_t_3 = PyObject_Call(__pyx_builtin_NotImplementedError, ((PyObject *)__pyx_k_tuple_134), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_3);
-        __Pyx_Raise(__pyx_t_3, 0, 0);
+        __Pyx_INCREF(((PyObject *)__pyx_kp_s_74));
+        PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_74));
+        __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_74));
+        __pyx_t_4 = PyObject_Call(__pyx_builtin_NotImplementedError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_4);
         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_Raise(__pyx_t_4, 0, 0);
+        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         goto __pyx_L13;
       }
       __pyx_L13:;
 
-      /* "csamtools.pyx":2365
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2297
  *                         raise NotImplementedError("tags field too large")
  * 
  *                     struct.pack_into( fmt,             # <<<<<<<<<<<<<<
  *                                       buffer,
  *                                       offset,
  */
-      __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__struct); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_3);
-      __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__pack_into); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__struct); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_4);
-      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__pack_into); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
-      /* "csamtools.pyx":2367
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2299
  *                     struct.pack_into( fmt,
  *                                       buffer,
  *                                       offset,             # <<<<<<<<<<<<<<
  *                                       pytag[0],
  *                                       pytag[1],
  */
-      __pyx_t_3 = PyInt_FromLong(__pyx_v_offset); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_4 = PyInt_FromLong(__pyx_v_offset); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
 
-      /* "csamtools.pyx":2368
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2300
  *                                       buffer,
  *                                       offset,
  *                                       pytag[0],             # <<<<<<<<<<<<<<
  *                                       pytag[1],
  *                                       pytype,
  */
-      __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_pytag, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_pytag, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
 
-      /* "csamtools.pyx":2369
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2301
  *                                       offset,
  *                                       pytag[0],
  *                                       pytag[1],             # <<<<<<<<<<<<<<
  *                                       pytype,
  *                                       value )
  */
-      __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_pytag, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = __Pyx_GetItemInt(__pyx_v_pytag, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
 
-      /* "csamtools.pyx":2371
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2303
  *                                       pytag[1],
  *                                       pytype,
  *                                       value )             # <<<<<<<<<<<<<<
  *                     offset += size
  * 
  */
-      __pyx_t_10 = PyTuple_New(7); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(((PyObject *)__pyx_t_10));
+      __pyx_t_10 = PyTuple_New(7); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_10);
       __Pyx_INCREF(__pyx_v_fmt);
       PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_fmt);
       __Pyx_GIVEREF(__pyx_v_fmt);
       __Pyx_INCREF(__pyx_v_buffer);
       PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_v_buffer);
       __Pyx_GIVEREF(__pyx_v_buffer);
-      PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_3);
-      __Pyx_GIVEREF(__pyx_t_3);
+      PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_4);
+      __Pyx_GIVEREF(__pyx_t_4);
       PyTuple_SET_ITEM(__pyx_t_10, 3, __pyx_t_6);
       __Pyx_GIVEREF(__pyx_t_6);
       PyTuple_SET_ITEM(__pyx_t_10, 4, __pyx_t_7);
@@ -20732,30 +20668,30 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags_1__set__(PyObject *__pyx_v_se
       __Pyx_INCREF(__pyx_v_value);
       PyTuple_SET_ITEM(__pyx_t_10, 6, __pyx_v_value);
       __Pyx_GIVEREF(__pyx_v_value);
-      __pyx_t_3 = 0;
+      __pyx_t_4 = 0;
       __pyx_t_6 = 0;
       __pyx_t_7 = 0;
-      __pyx_t_7 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_10), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyObject_Call(__pyx_t_3, __pyx_t_10, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
-      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-      __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0;
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
 
-      /* "csamtools.pyx":2372
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2304
  *                                       pytype,
  *                                       value )
  *                     offset += size             # <<<<<<<<<<<<<<
  * 
  *             # delete the old data and allocate new
  */
-      __pyx_v_offset = (__pyx_v_offset + __pyx_v_size);
+      __pyx_v_offset += __pyx_v_size;
     }
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":2380
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2312
  *                               src.l_aux,
  *                               offset,
  *                               bam1_aux( src ) )             # <<<<<<<<<<<<<<
@@ -20764,7 +20700,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags_1__set__(PyObject *__pyx_v_se
  */
   pysam_bam_update(__pyx_v_src, __pyx_v_src->l_aux, __pyx_v_offset, bam1_aux(__pyx_v_src));
 
-  /* "csamtools.pyx":2382
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2314
  *                               bam1_aux( src ) )
  * 
  *             src.l_aux = offset             # <<<<<<<<<<<<<<
@@ -20773,7 +20709,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags_1__set__(PyObject *__pyx_v_se
  */
   __pyx_v_src->l_aux = __pyx_v_offset;
 
-  /* "csamtools.pyx":2385
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2317
  * 
  *             # copy data only if there is any
  *             if offset != 0:             # <<<<<<<<<<<<<<
@@ -20783,7 +20719,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags_1__set__(PyObject *__pyx_v_se
   __pyx_t_2 = (__pyx_v_offset != 0);
   if (__pyx_t_2) {
 
-    /* "csamtools.pyx":2388
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2320
  * 
  *                 # get location of new data
  *                 s = bam1_aux( src )             # <<<<<<<<<<<<<<
@@ -20792,20 +20728,20 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags_1__set__(PyObject *__pyx_v_se
  */
     __pyx_v_s = bam1_aux(__pyx_v_src);
 
-    /* "csamtools.pyx":2391
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2323
  * 
  *                 # check if there is direct path from buffer.raw to tmp
  *                 temp = buffer.raw             # <<<<<<<<<<<<<<
  *                 memcpy( s, temp, offset )
  * 
  */
-    __pyx_t_1 = PyObject_GetAttr(__pyx_v_buffer, __pyx_n_s__raw); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_buffer, __pyx_n_s__raw); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_11 = PyBytes_AsString(__pyx_t_1); if (unlikely((!__pyx_t_11) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_11 = PyBytes_AsString(__pyx_t_1); if (unlikely((!__pyx_t_11) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __pyx_v_temp = __pyx_t_11;
 
-    /* "csamtools.pyx":2392
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2324
  *                 # check if there is direct path from buffer.raw to tmp
  *                 temp = buffer.raw
  *                 memcpy( s, temp, offset )             # <<<<<<<<<<<<<<
@@ -20840,7 +20776,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tags_1__set__(PyObject *__pyx_v_se
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2396
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2328
  *     property flag:
  *         """properties flag"""
  *         def __get__(self): return self._delegate.core.flag             # <<<<<<<<<<<<<<
@@ -20854,9 +20790,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4flag___get__(PyObject *__pyx
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2396);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2328);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -20875,7 +20811,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4flag___get__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2397
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2329
  *         """properties flag"""
  *         def __get__(self): return self._delegate.core.flag
  *         def __set__(self, flag): self._delegate.core.flag = flag             # <<<<<<<<<<<<<<
@@ -20883,14 +20819,14 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4flag___get__(PyObject *__pyx
  *     property rname:
  */
 
-static int __pyx_pf_9csamtools_11AlignedRead_4flag_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_flag); /*proto*/
-static int __pyx_pf_9csamtools_11AlignedRead_4flag_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_flag) {
+static int __pyx_pf_9csamtools_11AlignedRead_4flag___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_flag); /*proto*/
+static int __pyx_pf_9csamtools_11AlignedRead_4flag___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_flag) {
   int __pyx_r;
   uint32_t __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2397);
-  __pyx_t_1 = __Pyx_PyInt_from_py_uint32_t(__pyx_v_flag); if (unlikely((__pyx_t_1 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2329);
+  __pyx_t_1 = __Pyx_PyInt_from_py_uint32_t(__pyx_v_flag); if (unlikely((__pyx_t_1 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag = __pyx_t_1;
 
   __pyx_r = 0;
@@ -20904,7 +20840,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4flag_1__set__(PyObject *__pyx_v_se
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2415
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2347
  * 
  *         """
  *         def __get__(self): return self._delegate.core.tid             # <<<<<<<<<<<<<<
@@ -20918,9 +20854,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5rname___get__(PyObject *__py
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2415);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2347);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -20939,7 +20875,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5rname___get__(PyObject *__py
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2416
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2348
  *         """
  *         def __get__(self): return self._delegate.core.tid
  *         def __set__(self, tid): self._delegate.core.tid = tid             # <<<<<<<<<<<<<<
@@ -20947,14 +20883,14 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5rname___get__(PyObject *__py
  *     property tid:
  */
 
-static int __pyx_pf_9csamtools_11AlignedRead_5rname_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_tid); /*proto*/
-static int __pyx_pf_9csamtools_11AlignedRead_5rname_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_tid) {
+static int __pyx_pf_9csamtools_11AlignedRead_5rname___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_tid); /*proto*/
+static int __pyx_pf_9csamtools_11AlignedRead_5rname___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_tid) {
   int __pyx_r;
   int32_t __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2416);
-  __pyx_t_1 = __Pyx_PyInt_from_py_int32_t(__pyx_v_tid); if (unlikely((__pyx_t_1 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2348);
+  __pyx_t_1 = __Pyx_PyInt_from_py_int32_t(__pyx_v_tid); if (unlikely((__pyx_t_1 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.tid = __pyx_t_1;
 
   __pyx_r = 0;
@@ -20968,7 +20904,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_5rname_1__set__(PyObject *__pyx_v_s
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2429
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2361
  * 
  *         """
  *         def __get__(self): return self._delegate.core.tid             # <<<<<<<<<<<<<<
@@ -20982,9 +20918,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3tid___get__(PyObject *__pyx_
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2429);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2361);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -21003,7 +20939,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3tid___get__(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2430
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2362
  *         """
  *         def __get__(self): return self._delegate.core.tid
  *         def __set__(self, tid): self._delegate.core.tid = tid             # <<<<<<<<<<<<<<
@@ -21011,14 +20947,14 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3tid___get__(PyObject *__pyx_
  *     property pos:
  */
 
-static int __pyx_pf_9csamtools_11AlignedRead_3tid_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_tid); /*proto*/
-static int __pyx_pf_9csamtools_11AlignedRead_3tid_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_tid) {
+static int __pyx_pf_9csamtools_11AlignedRead_3tid___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_tid); /*proto*/
+static int __pyx_pf_9csamtools_11AlignedRead_3tid___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_tid) {
   int __pyx_r;
   int32_t __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2430);
-  __pyx_t_1 = __Pyx_PyInt_from_py_int32_t(__pyx_v_tid); if (unlikely((__pyx_t_1 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2362);
+  __pyx_t_1 = __Pyx_PyInt_from_py_int32_t(__pyx_v_tid); if (unlikely((__pyx_t_1 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.tid = __pyx_t_1;
 
   __pyx_r = 0;
@@ -21032,7 +20968,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_3tid_1__set__(PyObject *__pyx_v_sel
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2434
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2366
  *     property pos:
  *         """0-based leftmost coordinate"""
  *         def __get__(self): return self._delegate.core.pos             # <<<<<<<<<<<<<<
@@ -21046,9 +20982,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3pos___get__(PyObject *__pyx_
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2434);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2366);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.pos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.pos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -21067,7 +21003,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3pos___get__(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2435
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2367
  *         """0-based leftmost coordinate"""
  *         def __get__(self): return self._delegate.core.pos
  *         def __set__(self, pos):             # <<<<<<<<<<<<<<
@@ -21075,16 +21011,16 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3pos___get__(PyObject *__pyx_
  *             cdef bam1_t * src
  */
 
-static int __pyx_pf_9csamtools_11AlignedRead_3pos_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_pos); /*proto*/
-static int __pyx_pf_9csamtools_11AlignedRead_3pos_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_pos) {
+static int __pyx_pf_9csamtools_11AlignedRead_3pos___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_pos); /*proto*/
+static int __pyx_pf_9csamtools_11AlignedRead_3pos___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_pos) {
   bam1_t *__pyx_v_src;
   int __pyx_r;
   int32_t __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2435);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2367);
 
-  /* "csamtools.pyx":2438
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2370
  *             ## setting the cigar string also updates the "bin" attribute
  *             cdef bam1_t * src
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -21093,7 +21029,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_3pos_1__set__(PyObject *__pyx_v_sel
  */
   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "csamtools.pyx":2439
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2371
  *             cdef bam1_t * src
  *             src = self._delegate
  *             if src.core.n_cigar:             # <<<<<<<<<<<<<<
@@ -21102,7 +21038,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_3pos_1__set__(PyObject *__pyx_v_sel
  */
   if (__pyx_v_src->core.n_cigar) {
 
-    /* "csamtools.pyx":2440
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2372
  *             src = self._delegate
  *             if src.core.n_cigar:
  *                 src.core.bin = bam_reg2bin( src.core.pos, bam_calend( &src.core, bam1_cigar(src)) )             # <<<<<<<<<<<<<<
@@ -21114,7 +21050,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_3pos_1__set__(PyObject *__pyx_v_sel
   }
   /*else*/ {
 
-    /* "csamtools.pyx":2442
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2374
  *                 src.core.bin = bam_reg2bin( src.core.pos, bam_calend( &src.core, bam1_cigar(src)) )
  *             else:
  *                 src.core.bin = bam_reg2bin( src.core.pos, src.core.pos + 1)             # <<<<<<<<<<<<<<
@@ -21125,14 +21061,14 @@ static int __pyx_pf_9csamtools_11AlignedRead_3pos_1__set__(PyObject *__pyx_v_sel
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":2443
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2375
  *             else:
  *                 src.core.bin = bam_reg2bin( src.core.pos, src.core.pos + 1)
  *             self._delegate.core.pos = pos             # <<<<<<<<<<<<<<
  *     property bin:
  *         """properties bin"""
  */
-  __pyx_t_1 = __Pyx_PyInt_from_py_int32_t(__pyx_v_pos); if (unlikely((__pyx_t_1 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_from_py_int32_t(__pyx_v_pos); if (unlikely((__pyx_t_1 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.pos = __pyx_t_1;
 
   __pyx_r = 0;
@@ -21146,7 +21082,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_3pos_1__set__(PyObject *__pyx_v_sel
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2446
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2378
  *     property bin:
  *         """properties bin"""
  *         def __get__(self): return self._delegate.core.bin             # <<<<<<<<<<<<<<
@@ -21160,9 +21096,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3bin___get__(PyObject *__pyx_
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2446);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2378);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.bin); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.bin); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -21181,7 +21117,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3bin___get__(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2447
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2379
  *         """properties bin"""
  *         def __get__(self): return self._delegate.core.bin
  *         def __set__(self, bin): self._delegate.core.bin = bin             # <<<<<<<<<<<<<<
@@ -21189,14 +21125,14 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_3bin___get__(PyObject *__pyx_
  *         '''length of the read (read only). Returns 0 if not given.'''
  */
 
-static int __pyx_pf_9csamtools_11AlignedRead_3bin_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_bin); /*proto*/
-static int __pyx_pf_9csamtools_11AlignedRead_3bin_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_bin) {
+static int __pyx_pf_9csamtools_11AlignedRead_3bin___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_bin); /*proto*/
+static int __pyx_pf_9csamtools_11AlignedRead_3bin___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_bin) {
   int __pyx_r;
   uint32_t __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2447);
-  __pyx_t_1 = __Pyx_PyInt_from_py_uint32_t(__pyx_v_bin); if (unlikely((__pyx_t_1 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2379);
+  __pyx_t_1 = __Pyx_PyInt_from_py_uint32_t(__pyx_v_bin); if (unlikely((__pyx_t_1 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.bin = __pyx_t_1;
 
   __pyx_r = 0;
@@ -21210,12 +21146,12 @@ static int __pyx_pf_9csamtools_11AlignedRead_3bin_1__set__(PyObject *__pyx_v_sel
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2450
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2382
  *     property rlen:
  *         '''length of the read (read only). Returns 0 if not given.'''
  *         def __get__(self): return self._delegate.core.l_qseq             # <<<<<<<<<<<<<<
  *     property aend:
- *         '''aligned end position of the read on the reference genome.  Returns
+ *         '''aligned end position of the read (read only).  Returns
  */
 
 static PyObject *__pyx_pf_9csamtools_11AlignedRead_4rlen___get__(PyObject *__pyx_v_self); /*proto*/
@@ -21224,9 +21160,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4rlen___get__(PyObject *__pyx
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2450);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2382);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.l_qseq); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2450; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.l_qseq); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -21245,8 +21181,8 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4rlen___get__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2454
- *         '''aligned end position of the read on the reference genome.  Returns
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2386
+ *         '''aligned end position of the read (read only).  Returns
  *         None if not available.'''
  *         def __get__(self):             # <<<<<<<<<<<<<<
  *             cdef bam1_t * src
@@ -21264,9 +21200,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4aend___get__(PyObject *__pyx
   int __pyx_t_5;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2454);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2386);
 
-  /* "csamtools.pyx":2456
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2388
  *         def __get__(self):
  *             cdef bam1_t * src
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -21275,19 +21211,19 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4aend___get__(PyObject *__pyx
  */
   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "csamtools.pyx":2457
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2389
  *             cdef bam1_t * src
  *             src = self._delegate
  *             if (self.flag & BAM_FUNMAP) or src.core.n_cigar == 0:             # <<<<<<<<<<<<<<
  *                 return None
  *             return bam_calend(&src.core, bam1_cigar(src))
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   if (!__pyx_t_3) {
     __pyx_t_4 = (__pyx_v_src->core.n_cigar == 0);
@@ -21297,7 +21233,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4aend___get__(PyObject *__pyx
   }
   if (__pyx_t_5) {
 
-    /* "csamtools.pyx":2458
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2390
  *             src = self._delegate
  *             if (self.flag & BAM_FUNMAP) or src.core.n_cigar == 0:
  *                 return None             # <<<<<<<<<<<<<<
@@ -21312,15 +21248,15 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4aend___get__(PyObject *__pyx
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":2459
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2391
  *             if (self.flag & BAM_FUNMAP) or src.core.n_cigar == 0:
  *                 return None
  *             return bam_calend(&src.core, bam1_cigar(src))             # <<<<<<<<<<<<<<
  *     property alen:
- *         '''aligned length of the read on the reference genome.  Returns None if
+ *         '''aligned length of the read (read only).  Returns None if
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = __Pyx_PyInt_to_py_uint32_t(bam_calend((&__pyx_v_src->core), bam1_cigar(__pyx_v_src))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyInt_to_py_uint32_t(bam_calend((&__pyx_v_src->core), bam1_cigar(__pyx_v_src))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2391; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
@@ -21340,8 +21276,8 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4aend___get__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2463
- *         '''aligned length of the read on the reference genome.  Returns None if
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2395
+ *         '''aligned length of the read (read only).  Returns None if
  *         not available.'''
  *         def __get__(self):             # <<<<<<<<<<<<<<
  *             cdef bam1_t * src
@@ -21359,9 +21295,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4alen___get__(PyObject *__pyx
   int __pyx_t_5;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2463);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2395);
 
-  /* "csamtools.pyx":2465
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2397
  *         def __get__(self):
  *             cdef bam1_t * src
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -21370,19 +21306,19 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4alen___get__(PyObject *__pyx
  */
   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "csamtools.pyx":2466
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2398
  *             cdef bam1_t * src
  *             src = self._delegate
  *             if (self.flag & BAM_FUNMAP) or src.core.n_cigar == 0:             # <<<<<<<<<<<<<<
  *                 return None
  *             return bam_calend(&src.core,
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   if (!__pyx_t_3) {
     __pyx_t_4 = (__pyx_v_src->core.n_cigar == 0);
@@ -21392,7 +21328,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4alen___get__(PyObject *__pyx
   }
   if (__pyx_t_5) {
 
-    /* "csamtools.pyx":2467
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2399
  *             src = self._delegate
  *             if (self.flag & BAM_FUNMAP) or src.core.n_cigar == 0:
  *                 return None             # <<<<<<<<<<<<<<
@@ -21407,7 +21343,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4alen___get__(PyObject *__pyx
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":2468
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2400
  *             if (self.flag & BAM_FUNMAP) or src.core.n_cigar == 0:
  *                 return None
  *             return bam_calend(&src.core,             # <<<<<<<<<<<<<<
@@ -21416,14 +21352,14 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4alen___get__(PyObject *__pyx
  */
   __Pyx_XDECREF(__pyx_r);
 
-  /* "csamtools.pyx":2470
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2402
  *             return bam_calend(&src.core,
  *                                bam1_cigar(src)) - \
  *                                self._delegate.core.pos             # <<<<<<<<<<<<<<
  * 
  *     property mapq:
  */
-  __pyx_t_2 = __Pyx_PyInt_to_py_int32_t((bam_calend((&__pyx_v_src->core), bam1_cigar(__pyx_v_src)) - ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.pos)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyInt_to_py_int32_t((bam_calend((&__pyx_v_src->core), bam1_cigar(__pyx_v_src)) - ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.pos)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
@@ -21443,7 +21379,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4alen___get__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2474
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2406
  *     property mapq:
  *         """mapping quality"""
  *         def __get__(self): return self._delegate.core.qual             # <<<<<<<<<<<<<<
@@ -21457,9 +21393,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4mapq___get__(PyObject *__pyx
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2474);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2406);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.qual); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.qual); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -21478,22 +21414,22 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4mapq___get__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2475
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2407
  *         """mapping quality"""
  *         def __get__(self): return self._delegate.core.qual
  *         def __set__(self, qual): self._delegate.core.qual = qual             # <<<<<<<<<<<<<<
  *     property mrnm:
- *         """the :term:`reference` id of the mate
+ *         """the :term:`reference` id of the mate """
  */
 
-static int __pyx_pf_9csamtools_11AlignedRead_4mapq_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_qual); /*proto*/
-static int __pyx_pf_9csamtools_11AlignedRead_4mapq_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_qual) {
+static int __pyx_pf_9csamtools_11AlignedRead_4mapq___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_qual); /*proto*/
+static int __pyx_pf_9csamtools_11AlignedRead_4mapq___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_qual) {
   int __pyx_r;
   uint32_t __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2475);
-  __pyx_t_1 = __Pyx_PyInt_from_py_uint32_t(__pyx_v_qual); if (unlikely((__pyx_t_1 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2407);
+  __pyx_t_1 = __Pyx_PyInt_from_py_uint32_t(__pyx_v_qual); if (unlikely((__pyx_t_1 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.qual = __pyx_t_1;
 
   __pyx_r = 0;
@@ -21507,12 +21443,12 @@ static int __pyx_pf_9csamtools_11AlignedRead_4mapq_1__set__(PyObject *__pyx_v_se
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2480
- *         deprecated, use RNEXT instead.
- *         """
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2410
+ *     property mrnm:
+ *         """the :term:`reference` id of the mate """
  *         def __get__(self): return self._delegate.core.mtid             # <<<<<<<<<<<<<<
  *         def __set__(self, mtid): self._delegate.core.mtid = mtid
- *     property rnext:
+ *     property mpos:
  */
 
 static PyObject *__pyx_pf_9csamtools_11AlignedRead_4mrnm___get__(PyObject *__pyx_v_self); /*proto*/
@@ -21521,9 +21457,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4mrnm___get__(PyObject *__pyx
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2480);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2410);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.mtid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.mtid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -21542,92 +21478,28 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4mrnm___get__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2481
- *         """
- *         def __get__(self): return self._delegate.core.mtid
- *         def __set__(self, mtid): self._delegate.core.mtid = mtid             # <<<<<<<<<<<<<<
- *     property rnext:
- *         """the :term:`reference` id of the mate """
- */
-
-static int __pyx_pf_9csamtools_11AlignedRead_4mrnm_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_mtid); /*proto*/
-static int __pyx_pf_9csamtools_11AlignedRead_4mrnm_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_mtid) {
-  int __pyx_r;
-  int32_t __pyx_t_1;
-  __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2481);
-  __pyx_t_1 = __Pyx_PyInt_from_py_int32_t(__pyx_v_mtid); if (unlikely((__pyx_t_1 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.mtid = __pyx_t_1;
-
-  __pyx_r = 0;
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_AddTraceback("csamtools.AlignedRead.mrnm.__set__");
-  __pyx_r = -1;
-  __pyx_L0:;
-  __Pyx_TraceReturn(Py_None);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "csamtools.pyx":2484
- *     property rnext:
- *         """the :term:`reference` id of the mate """
- *         def __get__(self): return self._delegate.core.mtid             # <<<<<<<<<<<<<<
- *         def __set__(self, mtid): self._delegate.core.mtid = mtid
- *     property mpos:
- */
-
-static PyObject *__pyx_pf_9csamtools_11AlignedRead_5rnext___get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_9csamtools_11AlignedRead_5rnext___get__(PyObject *__pyx_v_self) {
-  PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
-  __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2484);
-  __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.mtid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __pyx_r = __pyx_t_1;
-  __pyx_t_1 = 0;
-  goto __pyx_L0;
-
-  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_XDECREF(__pyx_t_1);
-  __Pyx_AddTraceback("csamtools.AlignedRead.rnext.__get__");
-  __pyx_r = NULL;
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_TraceReturn(__pyx_r);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "csamtools.pyx":2485
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2411
  *         """the :term:`reference` id of the mate """
  *         def __get__(self): return self._delegate.core.mtid
  *         def __set__(self, mtid): self._delegate.core.mtid = mtid             # <<<<<<<<<<<<<<
  *     property mpos:
- *         """the position of the mate
+ *         """the position of the mate"""
  */
 
-static int __pyx_pf_9csamtools_11AlignedRead_5rnext_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_mtid); /*proto*/
-static int __pyx_pf_9csamtools_11AlignedRead_5rnext_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_mtid) {
+static int __pyx_pf_9csamtools_11AlignedRead_4mrnm___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_mtid); /*proto*/
+static int __pyx_pf_9csamtools_11AlignedRead_4mrnm___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_mtid) {
   int __pyx_r;
   int32_t __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2485);
-  __pyx_t_1 = __Pyx_PyInt_from_py_int32_t(__pyx_v_mtid); if (unlikely((__pyx_t_1 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2411);
+  __pyx_t_1 = __Pyx_PyInt_from_py_int32_t(__pyx_v_mtid); if (unlikely((__pyx_t_1 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2411; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.mtid = __pyx_t_1;
 
   __pyx_r = 0;
   goto __pyx_L0;
   __pyx_L1_error:;
-  __Pyx_AddTraceback("csamtools.AlignedRead.rnext.__set__");
+  __Pyx_AddTraceback("csamtools.AlignedRead.mrnm.__set__");
   __pyx_r = -1;
   __pyx_L0:;
   __Pyx_TraceReturn(Py_None);
@@ -21635,12 +21507,12 @@ static int __pyx_pf_9csamtools_11AlignedRead_5rnext_1__set__(PyObject *__pyx_v_s
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2489
- *         """the position of the mate
- *         deprecated, use PNEXT instead."""
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2414
+ *     property mpos:
+ *         """the position of the mate"""
  *         def __get__(self): return self._delegate.core.mpos             # <<<<<<<<<<<<<<
  *         def __set__(self, mpos): self._delegate.core.mpos = mpos
- *     property pnext:
+ *     property isize:
  */
 
 static PyObject *__pyx_pf_9csamtools_11AlignedRead_4mpos___get__(PyObject *__pyx_v_self); /*proto*/
@@ -21649,9 +21521,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4mpos___get__(PyObject *__pyx
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2489);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2414);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.mpos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.mpos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -21670,92 +21542,28 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4mpos___get__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2490
- *         deprecated, use PNEXT instead."""
- *         def __get__(self): return self._delegate.core.mpos
- *         def __set__(self, mpos): self._delegate.core.mpos = mpos             # <<<<<<<<<<<<<<
- *     property pnext:
- *         """the position of the mate"""
- */
-
-static int __pyx_pf_9csamtools_11AlignedRead_4mpos_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_mpos); /*proto*/
-static int __pyx_pf_9csamtools_11AlignedRead_4mpos_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_mpos) {
-  int __pyx_r;
-  int32_t __pyx_t_1;
-  __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2490);
-  __pyx_t_1 = __Pyx_PyInt_from_py_int32_t(__pyx_v_mpos); if (unlikely((__pyx_t_1 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.mpos = __pyx_t_1;
-
-  __pyx_r = 0;
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_AddTraceback("csamtools.AlignedRead.mpos.__set__");
-  __pyx_r = -1;
-  __pyx_L0:;
-  __Pyx_TraceReturn(Py_None);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "csamtools.pyx":2493
- *     property pnext:
- *         """the position of the mate"""
- *         def __get__(self): return self._delegate.core.mpos             # <<<<<<<<<<<<<<
- *         def __set__(self, mpos): self._delegate.core.mpos = mpos
- *     property isize:
- */
-
-static PyObject *__pyx_pf_9csamtools_11AlignedRead_5pnext___get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_9csamtools_11AlignedRead_5pnext___get__(PyObject *__pyx_v_self) {
-  PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
-  __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2493);
-  __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.mpos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __pyx_r = __pyx_t_1;
-  __pyx_t_1 = 0;
-  goto __pyx_L0;
-
-  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_XDECREF(__pyx_t_1);
-  __Pyx_AddTraceback("csamtools.AlignedRead.pnext.__get__");
-  __pyx_r = NULL;
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_TraceReturn(__pyx_r);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "csamtools.pyx":2494
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2415
  *         """the position of the mate"""
  *         def __get__(self): return self._delegate.core.mpos
  *         def __set__(self, mpos): self._delegate.core.mpos = mpos             # <<<<<<<<<<<<<<
  *     property isize:
- *         """the insert size
+ *         """the insert size"""
  */
 
-static int __pyx_pf_9csamtools_11AlignedRead_5pnext_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_mpos); /*proto*/
-static int __pyx_pf_9csamtools_11AlignedRead_5pnext_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_mpos) {
+static int __pyx_pf_9csamtools_11AlignedRead_4mpos___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_mpos); /*proto*/
+static int __pyx_pf_9csamtools_11AlignedRead_4mpos___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_mpos) {
   int __pyx_r;
   int32_t __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2494);
-  __pyx_t_1 = __Pyx_PyInt_from_py_int32_t(__pyx_v_mpos); if (unlikely((__pyx_t_1 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2415);
+  __pyx_t_1 = __Pyx_PyInt_from_py_int32_t(__pyx_v_mpos); if (unlikely((__pyx_t_1 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.mpos = __pyx_t_1;
 
   __pyx_r = 0;
   goto __pyx_L0;
   __pyx_L1_error:;
-  __Pyx_AddTraceback("csamtools.AlignedRead.pnext.__set__");
+  __Pyx_AddTraceback("csamtools.AlignedRead.mpos.__set__");
   __pyx_r = -1;
   __pyx_L0:;
   __Pyx_TraceReturn(Py_None);
@@ -21763,12 +21571,12 @@ static int __pyx_pf_9csamtools_11AlignedRead_5pnext_1__set__(PyObject *__pyx_v_s
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2498
- *         """the insert size
- *         deprecated: use tlen instead"""
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2418
+ *     property isize:
+ *         """the insert size"""
  *         def __get__(self): return self._delegate.core.isize             # <<<<<<<<<<<<<<
  *         def __set__(self, isize): self._delegate.core.isize = isize
- *     property tlen:
+ *     property is_paired:
  */
 
 static PyObject *__pyx_pf_9csamtools_11AlignedRead_5isize___get__(PyObject *__pyx_v_self); /*proto*/
@@ -21777,9 +21585,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5isize___get__(PyObject *__py
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2498);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2418);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.isize); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2498; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.isize); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -21798,71 +21606,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5isize___get__(PyObject *__py
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2499
- *         deprecated: use tlen instead"""
- *         def __get__(self): return self._delegate.core.isize
- *         def __set__(self, isize): self._delegate.core.isize = isize             # <<<<<<<<<<<<<<
- *     property tlen:
- *         """the insert size"""
- */
-
-static int __pyx_pf_9csamtools_11AlignedRead_5isize_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_isize); /*proto*/
-static int __pyx_pf_9csamtools_11AlignedRead_5isize_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_isize) {
-  int __pyx_r;
-  int32_t __pyx_t_1;
-  __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2499);
-  __pyx_t_1 = __Pyx_PyInt_from_py_int32_t(__pyx_v_isize); if (unlikely((__pyx_t_1 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.isize = __pyx_t_1;
-
-  __pyx_r = 0;
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_AddTraceback("csamtools.AlignedRead.isize.__set__");
-  __pyx_r = -1;
-  __pyx_L0:;
-  __Pyx_TraceReturn(Py_None);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "csamtools.pyx":2502
- *     property tlen:
- *         """the insert size"""
- *         def __get__(self): return self._delegate.core.isize             # <<<<<<<<<<<<<<
- *         def __set__(self, isize): self._delegate.core.isize = isize
- *     property is_paired:
- */
-
-static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tlen___get__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tlen___get__(PyObject *__pyx_v_self) {
-  PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
-  __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2502);
-  __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.isize); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __pyx_r = __pyx_t_1;
-  __pyx_t_1 = 0;
-  goto __pyx_L0;
-
-  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
-  goto __pyx_L0;
-  __pyx_L1_error:;
-  __Pyx_XDECREF(__pyx_t_1);
-  __Pyx_AddTraceback("csamtools.AlignedRead.tlen.__get__");
-  __pyx_r = NULL;
-  __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_TraceReturn(__pyx_r);
-  __Pyx_RefNannyFinishContext();
-  return __pyx_r;
-}
-
-/* "csamtools.pyx":2503
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2419
  *         """the insert size"""
  *         def __get__(self): return self._delegate.core.isize
  *         def __set__(self, isize): self._delegate.core.isize = isize             # <<<<<<<<<<<<<<
@@ -21870,20 +21614,20 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tlen___get__(PyObject *__pyx
  *         """true if read is paired in sequencing"""
  */
 
-static int __pyx_pf_9csamtools_11AlignedRead_4tlen_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_isize); /*proto*/
-static int __pyx_pf_9csamtools_11AlignedRead_4tlen_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_isize) {
+static int __pyx_pf_9csamtools_11AlignedRead_5isize___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_isize); /*proto*/
+static int __pyx_pf_9csamtools_11AlignedRead_5isize___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_isize) {
   int __pyx_r;
   int32_t __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2503);
-  __pyx_t_1 = __Pyx_PyInt_from_py_int32_t(__pyx_v_isize); if (unlikely((__pyx_t_1 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2419);
+  __pyx_t_1 = __Pyx_PyInt_from_py_int32_t(__pyx_v_isize); if (unlikely((__pyx_t_1 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.isize = __pyx_t_1;
 
   __pyx_r = 0;
   goto __pyx_L0;
   __pyx_L1_error:;
-  __Pyx_AddTraceback("csamtools.AlignedRead.tlen.__set__");
+  __Pyx_AddTraceback("csamtools.AlignedRead.isize.__set__");
   __pyx_r = -1;
   __pyx_L0:;
   __Pyx_TraceReturn(Py_None);
@@ -21891,7 +21635,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_4tlen_1__set__(PyObject *__pyx_v_se
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2506
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2422
  *     property is_paired:
  *         """true if read is paired in sequencing"""
  *         def __get__(self): return (self._delegate.core.flag & BAM_FPAIRED) != 0             # <<<<<<<<<<<<<<
@@ -21905,9 +21649,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_9is_paired___get__(PyObject *
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2506);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2422);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyBool_FromLong(((((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag & 1) != 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyBool_FromLong(((((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag & 1) != 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -21926,7 +21670,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_9is_paired___get__(PyObject *
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2507
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2423
  *         """true if read is paired in sequencing"""
  *         def __get__(self): return (self._delegate.core.flag & BAM_FPAIRED) != 0
  *         def __set__(self,val):             # <<<<<<<<<<<<<<
@@ -21934,36 +21678,36 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_9is_paired___get__(PyObject *
  *             else: self._delegate.core.flag &= ~BAM_FPAIRED
  */
 
-static int __pyx_pf_9csamtools_11AlignedRead_9is_paired_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
-static int __pyx_pf_9csamtools_11AlignedRead_9is_paired_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
+static int __pyx_pf_9csamtools_11AlignedRead_9is_paired___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
+static int __pyx_pf_9csamtools_11AlignedRead_9is_paired___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
   int __pyx_r;
   int __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2507);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2423);
 
-  /* "csamtools.pyx":2508
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2424
  *         def __get__(self): return (self._delegate.core.flag & BAM_FPAIRED) != 0
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FPAIRED             # <<<<<<<<<<<<<<
  *             else: self._delegate.core.flag &= ~BAM_FPAIRED
  *     property is_proper_pair:
  */
-  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_1) {
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag = (((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag | 1);
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 1;
     goto __pyx_L5;
   }
   /*else*/ {
 
-    /* "csamtools.pyx":2509
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2425
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FPAIRED
  *             else: self._delegate.core.flag &= ~BAM_FPAIRED             # <<<<<<<<<<<<<<
  *     property is_proper_pair:
  *         """true if read is mapped in a proper pair"""
  */
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag = (((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag & (~1));
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~1);
   }
   __pyx_L5:;
 
@@ -21978,7 +21722,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_9is_paired_1__set__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2512
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2428
  *     property is_proper_pair:
  *         """true if read is mapped in a proper pair"""
  *         def __get__(self): return (self.flag & BAM_FPROPER_PAIR) != 0             # <<<<<<<<<<<<<<
@@ -21993,14 +21737,14 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_14is_proper_pair___get__(PyOb
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2512);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2428);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2512; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_r = __pyx_t_1;
@@ -22021,7 +21765,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_14is_proper_pair___get__(PyOb
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2513
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2429
  *         """true if read is mapped in a proper pair"""
  *         def __get__(self): return (self.flag & BAM_FPROPER_PAIR) != 0
  *         def __set__(self,val):             # <<<<<<<<<<<<<<
@@ -22029,36 +21773,36 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_14is_proper_pair___get__(PyOb
  *             else: self._delegate.core.flag &= ~BAM_FPROPER_PAIR
  */
 
-static int __pyx_pf_9csamtools_11AlignedRead_14is_proper_pair_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
-static int __pyx_pf_9csamtools_11AlignedRead_14is_proper_pair_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
+static int __pyx_pf_9csamtools_11AlignedRead_14is_proper_pair___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
+static int __pyx_pf_9csamtools_11AlignedRead_14is_proper_pair___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
   int __pyx_r;
   int __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2513);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2429);
 
-  /* "csamtools.pyx":2514
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2430
  *         def __get__(self): return (self.flag & BAM_FPROPER_PAIR) != 0
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FPROPER_PAIR             # <<<<<<<<<<<<<<
  *             else: self._delegate.core.flag &= ~BAM_FPROPER_PAIR
  *     property is_unmapped:
  */
-  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_1) {
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag = (((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag | 2);
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 2;
     goto __pyx_L5;
   }
   /*else*/ {
 
-    /* "csamtools.pyx":2515
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2431
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FPROPER_PAIR
  *             else: self._delegate.core.flag &= ~BAM_FPROPER_PAIR             # <<<<<<<<<<<<<<
  *     property is_unmapped:
  *         """true if read itself is unmapped"""
  */
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag = (((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag & (~2));
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~2);
   }
   __pyx_L5:;
 
@@ -22073,7 +21817,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_14is_proper_pair_1__set__(PyObject
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2518
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2434
  *     property is_unmapped:
  *         """true if read itself is unmapped"""
  *         def __get__(self): return (self.flag & BAM_FUNMAP) != 0             # <<<<<<<<<<<<<<
@@ -22088,14 +21832,14 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_11is_unmapped___get__(PyObjec
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2518);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2434);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_r = __pyx_t_1;
@@ -22116,7 +21860,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_11is_unmapped___get__(PyObjec
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2519
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2435
  *         """true if read itself is unmapped"""
  *         def __get__(self): return (self.flag & BAM_FUNMAP) != 0
  *         def __set__(self,val):             # <<<<<<<<<<<<<<
@@ -22124,36 +21868,36 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_11is_unmapped___get__(PyObjec
  *             else: self._delegate.core.flag &= ~BAM_FUNMAP
  */
 
-static int __pyx_pf_9csamtools_11AlignedRead_11is_unmapped_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
-static int __pyx_pf_9csamtools_11AlignedRead_11is_unmapped_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
+static int __pyx_pf_9csamtools_11AlignedRead_11is_unmapped___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
+static int __pyx_pf_9csamtools_11AlignedRead_11is_unmapped___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
   int __pyx_r;
   int __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2519);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2435);
 
-  /* "csamtools.pyx":2520
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2436
  *         def __get__(self): return (self.flag & BAM_FUNMAP) != 0
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FUNMAP             # <<<<<<<<<<<<<<
  *             else: self._delegate.core.flag &= ~BAM_FUNMAP
  *     property mate_is_unmapped:
  */
-  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_1) {
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag = (((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag | 4);
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 4;
     goto __pyx_L5;
   }
   /*else*/ {
 
-    /* "csamtools.pyx":2521
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2437
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FUNMAP
  *             else: self._delegate.core.flag &= ~BAM_FUNMAP             # <<<<<<<<<<<<<<
  *     property mate_is_unmapped:
  *         """true if the mate is unmapped"""
  */
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag = (((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag & (~4));
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~4);
   }
   __pyx_L5:;
 
@@ -22168,7 +21912,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_11is_unmapped_1__set__(PyObject *__
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2524
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2440
  *     property mate_is_unmapped:
  *         """true if the mate is unmapped"""
  *         def __get__(self): return (self.flag & BAM_FMUNMAP) != 0             # <<<<<<<<<<<<<<
@@ -22183,14 +21927,14 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_16mate_is_unmapped___get__(Py
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2524);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2440);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2524; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2524; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2524; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_r = __pyx_t_1;
@@ -22211,7 +21955,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_16mate_is_unmapped___get__(Py
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2525
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2441
  *         """true if the mate is unmapped"""
  *         def __get__(self): return (self.flag & BAM_FMUNMAP) != 0
  *         def __set__(self,val):             # <<<<<<<<<<<<<<
@@ -22219,36 +21963,36 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_16mate_is_unmapped___get__(Py
  *             else: self._delegate.core.flag &= ~BAM_FMUNMAP
  */
 
-static int __pyx_pf_9csamtools_11AlignedRead_16mate_is_unmapped_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
-static int __pyx_pf_9csamtools_11AlignedRead_16mate_is_unmapped_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
+static int __pyx_pf_9csamtools_11AlignedRead_16mate_is_unmapped___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
+static int __pyx_pf_9csamtools_11AlignedRead_16mate_is_unmapped___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
   int __pyx_r;
   int __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2525);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2441);
 
-  /* "csamtools.pyx":2526
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2442
  *         def __get__(self): return (self.flag & BAM_FMUNMAP) != 0
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FMUNMAP             # <<<<<<<<<<<<<<
  *             else: self._delegate.core.flag &= ~BAM_FMUNMAP
  *     property is_reverse:
  */
-  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_1) {
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag = (((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag | 8);
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 8;
     goto __pyx_L5;
   }
   /*else*/ {
 
-    /* "csamtools.pyx":2527
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2443
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FMUNMAP
  *             else: self._delegate.core.flag &= ~BAM_FMUNMAP             # <<<<<<<<<<<<<<
  *     property is_reverse:
  *         """true if read is mapped to reverse strand"""
  */
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag = (((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag & (~8));
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~8);
   }
   __pyx_L5:;
 
@@ -22263,7 +22007,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_16mate_is_unmapped_1__set__(PyObjec
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2530
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2446
  *     property is_reverse:
  *         """true if read is mapped to reverse strand"""
  *         def __get__(self): return (self.flag & BAM_FREVERSE) != 0             # <<<<<<<<<<<<<<
@@ -22278,14 +22022,14 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_10is_reverse___get__(PyObject
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2530);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2446);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_r = __pyx_t_1;
@@ -22306,7 +22050,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_10is_reverse___get__(PyObject
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2531
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2447
  *         """true if read is mapped to reverse strand"""
  *         def __get__(self): return (self.flag & BAM_FREVERSE) != 0
  *         def __set__(self,val):             # <<<<<<<<<<<<<<
@@ -22314,36 +22058,36 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_10is_reverse___get__(PyObject
  *             else: self._delegate.core.flag &= ~BAM_FREVERSE
  */
 
-static int __pyx_pf_9csamtools_11AlignedRead_10is_reverse_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
-static int __pyx_pf_9csamtools_11AlignedRead_10is_reverse_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
+static int __pyx_pf_9csamtools_11AlignedRead_10is_reverse___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
+static int __pyx_pf_9csamtools_11AlignedRead_10is_reverse___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
   int __pyx_r;
   int __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2531);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2447);
 
-  /* "csamtools.pyx":2532
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2448
  *         def __get__(self): return (self.flag & BAM_FREVERSE) != 0
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FREVERSE             # <<<<<<<<<<<<<<
  *             else: self._delegate.core.flag &= ~BAM_FREVERSE
  *     property mate_is_reverse:
  */
-  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_1) {
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag = (((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag | 16);
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 16;
     goto __pyx_L5;
   }
   /*else*/ {
 
-    /* "csamtools.pyx":2533
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2449
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FREVERSE
  *             else: self._delegate.core.flag &= ~BAM_FREVERSE             # <<<<<<<<<<<<<<
  *     property mate_is_reverse:
  *         """true is read is mapped to reverse strand"""
  */
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag = (((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag & (~16));
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~16);
   }
   __pyx_L5:;
 
@@ -22358,7 +22102,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_10is_reverse_1__set__(PyObject *__p
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2536
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2452
  *     property mate_is_reverse:
  *         """true is read is mapped to reverse strand"""
  *         def __get__(self): return (self.flag & BAM_FMREVERSE) != 0             # <<<<<<<<<<<<<<
@@ -22373,14 +22117,14 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_15mate_is_reverse___get__(PyO
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2536);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2452);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2536; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_32); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2536; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_32); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2536; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_r = __pyx_t_1;
@@ -22401,7 +22145,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_15mate_is_reverse___get__(PyO
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2537
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2453
  *         """true is read is mapped to reverse strand"""
  *         def __get__(self): return (self.flag & BAM_FMREVERSE) != 0
  *         def __set__(self,val):             # <<<<<<<<<<<<<<
@@ -22409,36 +22153,36 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_15mate_is_reverse___get__(PyO
  *             else: self._delegate.core.flag &= ~BAM_FMREVERSE
  */
 
-static int __pyx_pf_9csamtools_11AlignedRead_15mate_is_reverse_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
-static int __pyx_pf_9csamtools_11AlignedRead_15mate_is_reverse_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
+static int __pyx_pf_9csamtools_11AlignedRead_15mate_is_reverse___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
+static int __pyx_pf_9csamtools_11AlignedRead_15mate_is_reverse___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
   int __pyx_r;
   int __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2537);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2453);
 
-  /* "csamtools.pyx":2538
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2454
  *         def __get__(self): return (self.flag & BAM_FMREVERSE) != 0
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FMREVERSE             # <<<<<<<<<<<<<<
  *             else: self._delegate.core.flag &= ~BAM_FMREVERSE
  *     property is_read1:
  */
-  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_1) {
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag = (((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag | 32);
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 32;
     goto __pyx_L5;
   }
   /*else*/ {
 
-    /* "csamtools.pyx":2539
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2455
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FMREVERSE
  *             else: self._delegate.core.flag &= ~BAM_FMREVERSE             # <<<<<<<<<<<<<<
  *     property is_read1:
  *         """true if this is read1"""
  */
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag = (((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag & (~32));
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~32);
   }
   __pyx_L5:;
 
@@ -22453,7 +22197,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_15mate_is_reverse_1__set__(PyObject
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2542
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2458
  *     property is_read1:
  *         """true if this is read1"""
  *         def __get__(self): return (self.flag & BAM_FREAD1) != 0             # <<<<<<<<<<<<<<
@@ -22468,14 +22212,14 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_8is_read1___get__(PyObject *_
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2542);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2458);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_64); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_64); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_r = __pyx_t_1;
@@ -22496,7 +22240,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_8is_read1___get__(PyObject *_
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2543
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2459
  *         """true if this is read1"""
  *         def __get__(self): return (self.flag & BAM_FREAD1) != 0
  *         def __set__(self,val):             # <<<<<<<<<<<<<<
@@ -22504,36 +22248,36 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_8is_read1___get__(PyObject *_
  *             else: self._delegate.core.flag &= ~BAM_FREAD1
  */
 
-static int __pyx_pf_9csamtools_11AlignedRead_8is_read1_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
-static int __pyx_pf_9csamtools_11AlignedRead_8is_read1_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
+static int __pyx_pf_9csamtools_11AlignedRead_8is_read1___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
+static int __pyx_pf_9csamtools_11AlignedRead_8is_read1___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
   int __pyx_r;
   int __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2543);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2459);
 
-  /* "csamtools.pyx":2544
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2460
  *         def __get__(self): return (self.flag & BAM_FREAD1) != 0
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FREAD1             # <<<<<<<<<<<<<<
  *             else: self._delegate.core.flag &= ~BAM_FREAD1
  *     property is_read2:
  */
-  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2544; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2460; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_1) {
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag = (((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag | 64);
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 64;
     goto __pyx_L5;
   }
   /*else*/ {
 
-    /* "csamtools.pyx":2545
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2461
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FREAD1
  *             else: self._delegate.core.flag &= ~BAM_FREAD1             # <<<<<<<<<<<<<<
  *     property is_read2:
  *         """true if this is read2"""
  */
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag = (((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag & (~64));
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~64);
   }
   __pyx_L5:;
 
@@ -22548,7 +22292,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_8is_read1_1__set__(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2548
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2464
  *     property is_read2:
  *         """true if this is read2"""
  *         def __get__(self): return (self.flag & BAM_FREAD2) != 0             # <<<<<<<<<<<<<<
@@ -22563,14 +22307,14 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_8is_read2___get__(PyObject *_
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2548);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2464);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_128); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_128); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_r = __pyx_t_1;
@@ -22591,7 +22335,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_8is_read2___get__(PyObject *_
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2549
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2465
  *         """true if this is read2"""
  *         def __get__(self): return (self.flag & BAM_FREAD2) != 0
  *         def __set__(self,val):             # <<<<<<<<<<<<<<
@@ -22599,36 +22343,36 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_8is_read2___get__(PyObject *_
  *             else: self._delegate.core.flag &= ~BAM_FREAD2
  */
 
-static int __pyx_pf_9csamtools_11AlignedRead_8is_read2_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
-static int __pyx_pf_9csamtools_11AlignedRead_8is_read2_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
+static int __pyx_pf_9csamtools_11AlignedRead_8is_read2___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
+static int __pyx_pf_9csamtools_11AlignedRead_8is_read2___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
   int __pyx_r;
   int __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2549);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2465);
 
-  /* "csamtools.pyx":2550
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2466
  *         def __get__(self): return (self.flag & BAM_FREAD2) != 0
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FREAD2             # <<<<<<<<<<<<<<
  *             else: self._delegate.core.flag &= ~BAM_FREAD2
  *     property is_secondary:
  */
-  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_1) {
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag = (((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag | 128);
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 128;
     goto __pyx_L5;
   }
   /*else*/ {
 
-    /* "csamtools.pyx":2551
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2467
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FREAD2
  *             else: self._delegate.core.flag &= ~BAM_FREAD2             # <<<<<<<<<<<<<<
  *     property is_secondary:
  *         """true if not primary alignment"""
  */
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag = (((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag & (~128));
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~128);
   }
   __pyx_L5:;
 
@@ -22643,7 +22387,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_8is_read2_1__set__(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2554
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2470
  *     property is_secondary:
  *         """true if not primary alignment"""
  *         def __get__(self): return (self.flag & BAM_FSECONDARY) != 0             # <<<<<<<<<<<<<<
@@ -22658,14 +22402,14 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_12is_secondary___get__(PyObje
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2554);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2470);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_256); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_256); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_r = __pyx_t_1;
@@ -22686,7 +22430,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_12is_secondary___get__(PyObje
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2555
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2471
  *         """true if not primary alignment"""
  *         def __get__(self): return (self.flag & BAM_FSECONDARY) != 0
  *         def __set__(self,val):             # <<<<<<<<<<<<<<
@@ -22694,36 +22438,36 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_12is_secondary___get__(PyObje
  *             else: self._delegate.core.flag &= ~BAM_FSECONDARY
  */
 
-static int __pyx_pf_9csamtools_11AlignedRead_12is_secondary_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
-static int __pyx_pf_9csamtools_11AlignedRead_12is_secondary_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
+static int __pyx_pf_9csamtools_11AlignedRead_12is_secondary___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
+static int __pyx_pf_9csamtools_11AlignedRead_12is_secondary___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
   int __pyx_r;
   int __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2555);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2471);
 
-  /* "csamtools.pyx":2556
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2472
  *         def __get__(self): return (self.flag & BAM_FSECONDARY) != 0
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FSECONDARY             # <<<<<<<<<<<<<<
  *             else: self._delegate.core.flag &= ~BAM_FSECONDARY
  *     property is_qcfail:
  */
-  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_1) {
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag = (((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag | 256);
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 256;
     goto __pyx_L5;
   }
   /*else*/ {
 
-    /* "csamtools.pyx":2557
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2473
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FSECONDARY
  *             else: self._delegate.core.flag &= ~BAM_FSECONDARY             # <<<<<<<<<<<<<<
  *     property is_qcfail:
  *         """true if QC failure"""
  */
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag = (((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag & (~256));
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~256);
   }
   __pyx_L5:;
 
@@ -22738,7 +22482,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_12is_secondary_1__set__(PyObject *_
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2560
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2476
  *     property is_qcfail:
  *         """true if QC failure"""
  *         def __get__(self): return (self.flag & BAM_FQCFAIL) != 0             # <<<<<<<<<<<<<<
@@ -22753,14 +22497,14 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_9is_qcfail___get__(PyObject *
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2560);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2476);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_512); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_512); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_r = __pyx_t_1;
@@ -22781,7 +22525,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_9is_qcfail___get__(PyObject *
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2561
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2477
  *         """true if QC failure"""
  *         def __get__(self): return (self.flag & BAM_FQCFAIL) != 0
  *         def __set__(self,val):             # <<<<<<<<<<<<<<
@@ -22789,36 +22533,36 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_9is_qcfail___get__(PyObject *
  *             else: self._delegate.core.flag &= ~BAM_FQCFAIL
  */
 
-static int __pyx_pf_9csamtools_11AlignedRead_9is_qcfail_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
-static int __pyx_pf_9csamtools_11AlignedRead_9is_qcfail_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
+static int __pyx_pf_9csamtools_11AlignedRead_9is_qcfail___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
+static int __pyx_pf_9csamtools_11AlignedRead_9is_qcfail___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
   int __pyx_r;
   int __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2561);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2477);
 
-  /* "csamtools.pyx":2562
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2478
  *         def __get__(self): return (self.flag & BAM_FQCFAIL) != 0
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FQCFAIL             # <<<<<<<<<<<<<<
  *             else: self._delegate.core.flag &= ~BAM_FQCFAIL
  *     property is_duplicate:
  */
-  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_1) {
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag = (((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag | 512);
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 512;
     goto __pyx_L5;
   }
   /*else*/ {
 
-    /* "csamtools.pyx":2563
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2479
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FQCFAIL
  *             else: self._delegate.core.flag &= ~BAM_FQCFAIL             # <<<<<<<<<<<<<<
  *     property is_duplicate:
  *         """true if optical or PCR duplicate"""
  */
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag = (((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag & (~512));
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~512);
   }
   __pyx_L5:;
 
@@ -22833,7 +22577,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_9is_qcfail_1__set__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2566
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2482
  *     property is_duplicate:
  *         """true if optical or PCR duplicate"""
  *         def __get__(self): return (self.flag & BAM_FDUP) != 0             # <<<<<<<<<<<<<<
@@ -22848,14 +22592,14 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_12is_duplicate___get__(PyObje
   PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2566);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2482);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_1024); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_1024); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_r = __pyx_t_1;
@@ -22876,7 +22620,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_12is_duplicate___get__(PyObje
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2567
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2483
  *         """true if optical or PCR duplicate"""
  *         def __get__(self): return (self.flag & BAM_FDUP) != 0
  *         def __set__(self,val):             # <<<<<<<<<<<<<<
@@ -22884,36 +22628,36 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_12is_duplicate___get__(PyObje
  *             else: self._delegate.core.flag &= ~BAM_FDUP
  */
 
-static int __pyx_pf_9csamtools_11AlignedRead_12is_duplicate_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
-static int __pyx_pf_9csamtools_11AlignedRead_12is_duplicate_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
+static int __pyx_pf_9csamtools_11AlignedRead_12is_duplicate___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
+static int __pyx_pf_9csamtools_11AlignedRead_12is_duplicate___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
   int __pyx_r;
   int __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2567);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2483);
 
-  /* "csamtools.pyx":2568
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2484
  *         def __get__(self): return (self.flag & BAM_FDUP) != 0
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FDUP             # <<<<<<<<<<<<<<
  *             else: self._delegate.core.flag &= ~BAM_FDUP
  *     property positions:
  */
-  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_1) {
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag = (((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag | 1024);
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 1024;
     goto __pyx_L5;
   }
   /*else*/ {
 
-    /* "csamtools.pyx":2569
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2485
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FDUP
  *             else: self._delegate.core.flag &= ~BAM_FDUP             # <<<<<<<<<<<<<<
  *     property positions:
  *         """a list of reference positions that this read aligns to."""
  */
-    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag = (((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag & (~1024));
+    ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~1024);
   }
   __pyx_L5:;
 
@@ -22928,7 +22672,7 @@ static int __pyx_pf_9csamtools_11AlignedRead_12is_duplicate_1__set__(PyObject *_
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2572
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2488
  *     property positions:
  *         """a list of reference positions that this read aligns to."""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -22955,24 +22699,24 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_9positions___get__(PyObject *
   int __pyx_t_6;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2572);
-  __pyx_v_result = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2488);
+  __pyx_v_result = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
   __pyx_v_l = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "csamtools.pyx":2578
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2494
  *             cdef bam1_t * src
  * 
  *             result = []             # <<<<<<<<<<<<<<
  *             src = self._delegate
  *             if src.core.n_cigar == 0: return []
  */
-  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2578; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
   __Pyx_DECREF(((PyObject *)__pyx_v_result));
   __pyx_v_result = __pyx_t_1;
   __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":2579
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2495
  * 
  *             result = []
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -22981,7 +22725,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_9positions___get__(PyObject *
  */
   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "csamtools.pyx":2580
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2496
  *             result = []
  *             src = self._delegate
  *             if src.core.n_cigar == 0: return []             # <<<<<<<<<<<<<<
@@ -22991,7 +22735,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_9positions___get__(PyObject *
   __pyx_t_2 = (__pyx_v_src->core.n_cigar == 0);
   if (__pyx_t_2) {
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_1));
     __pyx_r = ((PyObject *)__pyx_t_1);
     __pyx_t_1 = 0;
@@ -23000,7 +22744,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_9positions___get__(PyObject *
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":2582
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2498
  *             if src.core.n_cigar == 0: return []
  * 
  *             pos = src.core.pos             # <<<<<<<<<<<<<<
@@ -23009,7 +22753,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_9positions___get__(PyObject *
  */
   __pyx_v_pos = __pyx_v_src->core.pos;
 
-  /* "csamtools.pyx":2584
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2500
  *             pos = src.core.pos
  * 
  *             cigar_p = bam1_cigar(src)             # <<<<<<<<<<<<<<
@@ -23018,7 +22762,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_9positions___get__(PyObject *
  */
   __pyx_v_cigar_p = bam1_cigar(__pyx_v_src);
 
-  /* "csamtools.pyx":2585
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2501
  * 
  *             cigar_p = bam1_cigar(src)
  *             for k from 0 <= k < src.core.n_cigar:             # <<<<<<<<<<<<<<
@@ -23028,7 +22772,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_9positions___get__(PyObject *
   __pyx_t_3 = __pyx_v_src->core.n_cigar;
   for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_3; __pyx_v_k++) {
 
-    /* "csamtools.pyx":2586
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2502
  *             cigar_p = bam1_cigar(src)
  *             for k from 0 <= k < src.core.n_cigar:
  *                 op = cigar_p[k] & BAM_CIGAR_MASK             # <<<<<<<<<<<<<<
@@ -23037,20 +22781,20 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_9positions___get__(PyObject *
  */
     __pyx_v_op = ((__pyx_v_cigar_p[__pyx_v_k]) & 15);
 
-    /* "csamtools.pyx":2587
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2503
  *             for k from 0 <= k < src.core.n_cigar:
  *                 op = cigar_p[k] & BAM_CIGAR_MASK
  *                 l = cigar_p[k] >> BAM_CIGAR_SHIFT             # <<<<<<<<<<<<<<
  *                 if op == BAM_CMATCH:
  *                     for i from pos <= i < pos + l:
  */
-    __pyx_t_1 = PyInt_FromLong(((__pyx_v_cigar_p[__pyx_v_k]) >> 4)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyInt_FromLong(((__pyx_v_cigar_p[__pyx_v_k]) >> 4)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2503; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_v_l);
     __pyx_v_l = __pyx_t_1;
     __pyx_t_1 = 0;
 
-    /* "csamtools.pyx":2588
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2504
  *                 op = cigar_p[k] & BAM_CIGAR_MASK
  *                 l = cigar_p[k] >> BAM_CIGAR_SHIFT
  *                 if op == BAM_CMATCH:             # <<<<<<<<<<<<<<
@@ -23060,23 +22804,23 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_9positions___get__(PyObject *
     __pyx_t_2 = (__pyx_v_op == 0);
     if (__pyx_t_2) {
 
-      /* "csamtools.pyx":2589
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2505
  *                 l = cigar_p[k] >> BAM_CIGAR_SHIFT
  *                 if op == BAM_CMATCH:
  *                     for i from pos <= i < pos + l:             # <<<<<<<<<<<<<<
  *                         result.append( i )
  * 
  */
-      __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_pos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_pos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __pyx_t_4 = PyNumber_Add(__pyx_t_1, __pyx_v_l); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = PyNumber_Add(__pyx_t_1, __pyx_v_l); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_4);
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-      __pyx_t_5 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_4); if (unlikely((__pyx_t_5 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2589; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_4); if (unlikely((__pyx_t_5 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
       for (__pyx_v_i = __pyx_v_pos; __pyx_v_i < __pyx_t_5; __pyx_v_i++) {
 
-        /* "csamtools.pyx":2590
+        /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2506
  *                 if op == BAM_CMATCH:
  *                     for i from pos <= i < pos + l:
  *                         result.append( i )             # <<<<<<<<<<<<<<
@@ -23084,18 +22828,18 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_9positions___get__(PyObject *
  *                 if op == BAM_CMATCH or op == BAM_CDEL or op == BAM_CREF_SKIP:
  */
         if (unlikely(__pyx_v_result == Py_None)) {
-          PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2590; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+          PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2506; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
         }
-        __pyx_t_4 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_4 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_i); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_4);
-        __pyx_t_6 = PyList_Append(__pyx_v_result, __pyx_t_4); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2590; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = PyList_Append(((PyObject *)__pyx_v_result), __pyx_t_4); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
       }
       goto __pyx_L8;
     }
     __pyx_L8:;
 
-    /* "csamtools.pyx":2592
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2508
  *                         result.append( i )
  * 
  *                 if op == BAM_CMATCH or op == BAM_CDEL or op == BAM_CREF_SKIP:             # <<<<<<<<<<<<<<
@@ -23107,31 +22851,25 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_9positions___get__(PyObject *
       case 2:
       case 3:
 
-      /* "csamtools.pyx":2593
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2509
  * 
  *                 if op == BAM_CMATCH or op == BAM_CDEL or op == BAM_CREF_SKIP:
  *                     pos += l             # <<<<<<<<<<<<<<
  * 
  *             return result
  */
-      __pyx_t_4 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_pos); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_4);
-      __pyx_t_1 = PyNumber_InPlaceAdd(__pyx_t_4, __pyx_v_l); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_1);
-      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-      __pyx_t_5 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_1); if (unlikely((__pyx_t_5 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-      __pyx_v_pos = __pyx_t_5;
+      __pyx_t_5 = __Pyx_PyInt_from_py_uint32_t(__pyx_v_l); if (unlikely((__pyx_t_5 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_v_pos += __pyx_t_5;
       break;
     }
   }
 
-  /* "csamtools.pyx":2595
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2511
  *                     pos += l
  * 
  *             return result             # <<<<<<<<<<<<<<
- * 
  *     def overlap( self, uint32_t start, uint32_t end ):
+ *         """return number of bases on reference overlapping *start* and *end*
  */
   __Pyx_XDECREF(__pyx_r);
   __Pyx_INCREF(((PyObject *)__pyx_v_result));
@@ -23154,17 +22892,17 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_9positions___get__(PyObject *
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2597
- *             return result
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2512
  * 
+ *             return result
  *     def overlap( self, uint32_t start, uint32_t end ):             # <<<<<<<<<<<<<<
- *         """return number of aligned bases of read overlapping the interval *start* and *end*
- *         on the reference sequence.
+ *         """return number of bases on reference overlapping *start* and *end*
+ *         """
  */
 
-static PyObject *__pyx_pf_9csamtools_11AlignedRead_5overlap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_9csamtools_11AlignedRead_5overlap[] = "AlignedRead.overlap(self, uint32_t start, uint32_t end)\nreturn number of aligned bases of read overlapping the interval *start* and *end*\n        on the reference sequence.\n        ";
-static PyObject *__pyx_pf_9csamtools_11AlignedRead_5overlap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+static PyObject *__pyx_pf_9csamtools_11AlignedRead_overlap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_9csamtools_11AlignedRead_overlap[] = "AlignedRead.overlap(self, uint32_t start, uint32_t end)\nreturn number of bases on reference overlapping *start* and *end*\n        ";
+static PyObject *__pyx_pf_9csamtools_11AlignedRead_overlap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   uint32_t __pyx_v_start;
   uint32_t __pyx_v_end;
   uint32_t __pyx_v_k;
@@ -23189,7 +22927,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5overlap(PyObject *__pyx_v_se
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__start,&__pyx_n_s__end,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("overlap");
-  __Pyx_TraceCall("overlap", __pyx_f[0], 2597);
+  __Pyx_TraceCall("overlap", __pyx_f[0], 2512);
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[2] = {0,0};
@@ -23208,23 +22946,23 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5overlap(PyObject *__pyx_v_se
       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end);
       if (likely(values[1])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("overlap", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2597; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("overlap", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2512; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "overlap") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2597; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "overlap") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2512; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
-    __pyx_v_start = __Pyx_PyInt_from_py_uint32_t(values[0]); if (unlikely((__pyx_v_start == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2597; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-    __pyx_v_end = __Pyx_PyInt_from_py_uint32_t(values[1]); if (unlikely((__pyx_v_end == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2597; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_start = __Pyx_PyInt_from_py_uint32_t(values[0]); if (unlikely((__pyx_v_start == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2512; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_end = __Pyx_PyInt_from_py_uint32_t(values[1]); if (unlikely((__pyx_v_end == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2512; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
     goto __pyx_L5_argtuple_error;
   } else {
-    __pyx_v_start = __Pyx_PyInt_from_py_uint32_t(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_start == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2597; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-    __pyx_v_end = __Pyx_PyInt_from_py_uint32_t(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_end == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2597; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_start = __Pyx_PyInt_from_py_uint32_t(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_start == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2512; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_end = __Pyx_PyInt_from_py_uint32_t(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_end == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2512; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("overlap", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2597; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("overlap", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2512; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("csamtools.AlignedRead.overlap");
   __Pyx_RefNannyFinishContext();
@@ -23232,7 +22970,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5overlap(PyObject *__pyx_v_se
   __pyx_L4_argument_unpacking_done:;
   __pyx_v_l = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "csamtools.pyx":2606
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2520
  *         cdef bam1_t * src
  * 
  *         overlap = 0             # <<<<<<<<<<<<<<
@@ -23241,7 +22979,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5overlap(PyObject *__pyx_v_se
  */
   __pyx_v_overlap = 0;
 
-  /* "csamtools.pyx":2608
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2522
  *         overlap = 0
  * 
  *         src = self._delegate             # <<<<<<<<<<<<<<
@@ -23250,7 +22988,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5overlap(PyObject *__pyx_v_se
  */
   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
 
-  /* "csamtools.pyx":2609
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2523
  * 
  *         src = self._delegate
  *         if src.core.n_cigar == 0: return 0             # <<<<<<<<<<<<<<
@@ -23267,7 +23005,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5overlap(PyObject *__pyx_v_se
   }
   __pyx_L6:;
 
-  /* "csamtools.pyx":2610
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2524
  *         src = self._delegate
  *         if src.core.n_cigar == 0: return 0
  *         pos = src.core.pos             # <<<<<<<<<<<<<<
@@ -23276,7 +23014,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5overlap(PyObject *__pyx_v_se
  */
   __pyx_v_pos = __pyx_v_src->core.pos;
 
-  /* "csamtools.pyx":2611
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2525
  *         if src.core.n_cigar == 0: return 0
  *         pos = src.core.pos
  *         o = 0             # <<<<<<<<<<<<<<
@@ -23285,7 +23023,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5overlap(PyObject *__pyx_v_se
  */
   __pyx_v_o = 0;
 
-  /* "csamtools.pyx":2613
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2527
  *         o = 0
  * 
  *         cigar_p = bam1_cigar(src)             # <<<<<<<<<<<<<<
@@ -23294,7 +23032,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5overlap(PyObject *__pyx_v_se
  */
   __pyx_v_cigar_p = bam1_cigar(__pyx_v_src);
 
-  /* "csamtools.pyx":2614
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2528
  * 
  *         cigar_p = bam1_cigar(src)
  *         for k from 0 <= k < src.core.n_cigar:             # <<<<<<<<<<<<<<
@@ -23304,7 +23042,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5overlap(PyObject *__pyx_v_se
   __pyx_t_2 = __pyx_v_src->core.n_cigar;
   for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_2; __pyx_v_k++) {
 
-    /* "csamtools.pyx":2615
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2529
  *         cigar_p = bam1_cigar(src)
  *         for k from 0 <= k < src.core.n_cigar:
  *             op = cigar_p[k] & BAM_CIGAR_MASK             # <<<<<<<<<<<<<<
@@ -23313,20 +23051,20 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5overlap(PyObject *__pyx_v_se
  */
     __pyx_v_op = ((__pyx_v_cigar_p[__pyx_v_k]) & 15);
 
-    /* "csamtools.pyx":2616
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2530
  *         for k from 0 <= k < src.core.n_cigar:
  *             op = cigar_p[k] & BAM_CIGAR_MASK
  *             l = cigar_p[k] >> BAM_CIGAR_SHIFT             # <<<<<<<<<<<<<<
  * 
  *             if op == BAM_CMATCH:
  */
-    __pyx_t_3 = PyInt_FromLong(((__pyx_v_cigar_p[__pyx_v_k]) >> 4)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyInt_FromLong(((__pyx_v_cigar_p[__pyx_v_k]) >> 4)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_v_l);
     __pyx_v_l = __pyx_t_3;
     __pyx_t_3 = 0;
 
-    /* "csamtools.pyx":2618
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2532
  *             l = cigar_p[k] >> BAM_CIGAR_SHIFT
  * 
  *             if op == BAM_CMATCH:             # <<<<<<<<<<<<<<
@@ -23336,7 +23074,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5overlap(PyObject *__pyx_v_se
     __pyx_t_1 = (__pyx_v_op == 0);
     if (__pyx_t_1) {
 
-      /* "csamtools.pyx":2619
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2533
  * 
  *             if op == BAM_CMATCH:
  *                 o = min( pos + l, end) - max( pos, start )             # <<<<<<<<<<<<<<
@@ -23344,20 +23082,20 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5overlap(PyObject *__pyx_v_se
  * 
  */
       __pyx_t_4 = __pyx_v_end;
-      __pyx_t_3 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
-      __pyx_t_5 = PyNumber_Add(__pyx_t_3, __pyx_v_l); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyNumber_Add(__pyx_t_3, __pyx_v_l); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-      __pyx_t_6 = __Pyx_PyInt_to_py_uint32_t(__pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_PyInt_to_py_uint32_t(__pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
-      __pyx_t_7 = PyObject_RichCompare(__pyx_t_6, __pyx_t_5, Py_LT); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyObject_RichCompare(__pyx_t_6, __pyx_t_5, Py_LT); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
       if (__pyx_t_1) {
-        __pyx_t_7 = __Pyx_PyInt_to_py_uint32_t(__pyx_t_4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = __Pyx_PyInt_to_py_uint32_t(__pyx_t_4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
         __pyx_t_3 = __pyx_t_7;
         __pyx_t_7 = 0;
@@ -23373,17 +23111,17 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5overlap(PyObject *__pyx_v_se
       } else {
         __pyx_t_9 = __pyx_t_8;
       }
-      __pyx_t_5 = __Pyx_PyInt_to_py_uint32_t(__pyx_t_9); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = __Pyx_PyInt_to_py_uint32_t(__pyx_t_9); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
-      __pyx_t_7 = PyNumber_Subtract(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyNumber_Subtract(__pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2533; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
       __pyx_v_o = __pyx_t_10;
 
-      /* "csamtools.pyx":2620
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2534
  *             if op == BAM_CMATCH:
  *                 o = min( pos + l, end) - max( pos, start )
  *                 if o > 0: overlap += o             # <<<<<<<<<<<<<<
@@ -23392,7 +23130,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5overlap(PyObject *__pyx_v_se
  */
       __pyx_t_1 = (__pyx_v_o > 0);
       if (__pyx_t_1) {
-        __pyx_v_overlap = (__pyx_v_overlap + __pyx_v_o);
+        __pyx_v_overlap += __pyx_v_o;
         goto __pyx_L10;
       }
       __pyx_L10:;
@@ -23400,7 +23138,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5overlap(PyObject *__pyx_v_se
     }
     __pyx_L9:;
 
-    /* "csamtools.pyx":2622
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2536
  *                 if o > 0: overlap += o
  * 
  *             if op == BAM_CMATCH or op == BAM_CDEL or op == BAM_CREF_SKIP:             # <<<<<<<<<<<<<<
@@ -23412,26 +23150,20 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5overlap(PyObject *__pyx_v_se
       case 2:
       case 3:
 
-      /* "csamtools.pyx":2623
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2537
  * 
  *             if op == BAM_CMATCH or op == BAM_CDEL or op == BAM_CREF_SKIP:
  *                 pos += l             # <<<<<<<<<<<<<<
  * 
  *         return overlap
  */
-      __pyx_t_7 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_pos); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_7);
-      __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_t_7, __pyx_v_l); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_5);
-      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-      __pyx_t_9 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_5); if (unlikely((__pyx_t_9 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2623; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      __pyx_v_pos = __pyx_t_9;
+      __pyx_t_9 = __Pyx_PyInt_from_py_uint32_t(__pyx_v_l); if (unlikely((__pyx_t_9 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_v_pos += __pyx_t_9;
       break;
     }
   }
 
-  /* "csamtools.pyx":2625
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2539
  *                 pos += l
  * 
  *         return overlap             # <<<<<<<<<<<<<<
@@ -23439,10 +23171,10 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5overlap(PyObject *__pyx_v_se
  *     def opt(self, tag):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_5 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_overlap); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_5);
-  __pyx_r = __pyx_t_5;
-  __pyx_t_5 = 0;
+  __pyx_t_7 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_overlap); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_7);
+  __pyx_r = __pyx_t_7;
+  __pyx_t_7 = 0;
   goto __pyx_L0;
 
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
@@ -23462,7 +23194,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5overlap(PyObject *__pyx_v_se
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2627
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2541
  *         return overlap
  * 
  *     def opt(self, tag):             # <<<<<<<<<<<<<<
@@ -23470,9 +23202,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_5overlap(PyObject *__pyx_v_se
  *         #see bam_aux.c: bam_aux_get() and bam_aux2i() etc
  */
 
-static PyObject *__pyx_pf_9csamtools_11AlignedRead_6opt(PyObject *__pyx_v_self, PyObject *__pyx_v_tag); /*proto*/
-static char __pyx_doc_9csamtools_11AlignedRead_6opt[] = "AlignedRead.opt(self, tag)\nretrieves optional data given a two-letter *tag*";
-static PyObject *__pyx_pf_9csamtools_11AlignedRead_6opt(PyObject *__pyx_v_self, PyObject *__pyx_v_tag) {
+static PyObject *__pyx_pf_9csamtools_11AlignedRead_opt(PyObject *__pyx_v_self, PyObject *__pyx_v_tag); /*proto*/
+static char __pyx_doc_9csamtools_11AlignedRead_opt[] = "AlignedRead.opt(self, tag)\nretrieves optional data given a two-letter *tag*";
+static PyObject *__pyx_pf_9csamtools_11AlignedRead_opt(PyObject *__pyx_v_self, PyObject *__pyx_v_tag) {
   uint8_t *__pyx_v_v;
   PyObject *__pyx_v_type;
   PyObject *__pyx_r = NULL;
@@ -23486,20 +23218,20 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_6opt(PyObject *__pyx_v_self,
   int __pyx_t_8;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("opt");
-  __Pyx_TraceCall("opt", __pyx_f[0], 2627);
+  __Pyx_TraceCall("opt", __pyx_f[0], 2541);
   __pyx_v_type = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "csamtools.pyx":2631
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2545
  *         #see bam_aux.c: bam_aux_get() and bam_aux2i() etc
  *         cdef uint8_t * v
  *         v = bam_aux_get(self._delegate, tag)             # <<<<<<<<<<<<<<
  *         if v == NULL: raise KeyError( "tag '%s' not present" % tag )
  *         type = chr(v[0])
  */
-  __pyx_t_1 = PyBytes_AsString(__pyx_v_tag); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2631; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyBytes_AsString(__pyx_v_tag); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_v = bam_aux_get(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate, __pyx_t_1);
 
-  /* "csamtools.pyx":2632
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2546
  *         cdef uint8_t * v
  *         v = bam_aux_get(self._delegate, tag)
  *         if v == NULL: raise KeyError( "tag '%s' not present" % tag )             # <<<<<<<<<<<<<<
@@ -23508,69 +23240,69 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_6opt(PyObject *__pyx_v_self,
  */
   __pyx_t_2 = (__pyx_v_v == NULL);
   if (__pyx_t_2) {
-    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_135), __pyx_v_tag); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_75), __pyx_v_tag); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
+    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
     PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3));
     __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
     __pyx_t_3 = 0;
-    __pyx_t_3 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Call(__pyx_builtin_KeyError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     __Pyx_Raise(__pyx_t_3, 0, 0);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "csamtools.pyx":2633
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2547
  *         v = bam_aux_get(self._delegate, tag)
  *         if v == NULL: raise KeyError( "tag '%s' not present" % tag )
  *         type = chr(v[0])             # <<<<<<<<<<<<<<
  *         if type == 'c' or type == 'C' or type == 's' or type == 'S':
  *             return <int>bam_aux2i(v)
  */
-  __pyx_t_3 = __Pyx_PyInt_to_py_uint8_t((__pyx_v_v[0])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyInt_to_py_uint8_t((__pyx_v_v[0])); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
+  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
   __Pyx_GIVEREF(__pyx_t_3);
   __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_Call(__pyx_builtin_chr, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Call(__pyx_builtin_chr, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   __Pyx_DECREF(__pyx_v_type);
   __pyx_v_type = __pyx_t_3;
   __pyx_t_3 = 0;
 
-  /* "csamtools.pyx":2634
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2548
  *         if v == NULL: raise KeyError( "tag '%s' not present" % tag )
  *         type = chr(v[0])
  *         if type == 'c' or type == 'C' or type == 's' or type == 'S':             # <<<<<<<<<<<<<<
  *             return <int>bam_aux2i(v)
  *         elif type == 'i' or type == 'I':
  */
-  __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__c), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__c), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   if (!__pyx_t_2) {
-    __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__C), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__C), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     if (!__pyx_t_5) {
-      __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__s), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__s), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
-      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
       if (!__pyx_t_6) {
-        __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__S), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__S), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_3);
-        __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
         __pyx_t_8 = __pyx_t_7;
       } else {
@@ -23586,7 +23318,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_6opt(PyObject *__pyx_v_self,
   }
   if (__pyx_t_5) {
 
-    /* "csamtools.pyx":2635
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2549
  *         type = chr(v[0])
  *         if type == 'c' or type == 'C' or type == 's' or type == 'S':
  *             return <int>bam_aux2i(v)             # <<<<<<<<<<<<<<
@@ -23594,7 +23326,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_6opt(PyObject *__pyx_v_self,
  *             return <int32_t>bam_aux2i(v)
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_3 = PyInt_FromLong(((int)bam_aux2i(__pyx_v_v))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2635; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyInt_FromLong(((int)bam_aux2i(__pyx_v_v))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2549; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __pyx_r = __pyx_t_3;
     __pyx_t_3 = 0;
@@ -23602,21 +23334,21 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_6opt(PyObject *__pyx_v_self,
     goto __pyx_L6;
   }
 
-  /* "csamtools.pyx":2636
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2550
  *         if type == 'c' or type == 'C' or type == 's' or type == 'S':
  *             return <int>bam_aux2i(v)
  *         elif type == 'i' or type == 'I':             # <<<<<<<<<<<<<<
  *             return <int32_t>bam_aux2i(v)
  *         elif type == 'f' or type == 'F':
  */
-  __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__i), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__i), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   if (!__pyx_t_5) {
-    __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__I), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__I), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2550; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __pyx_t_6 = __pyx_t_2;
   } else {
@@ -23624,7 +23356,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_6opt(PyObject *__pyx_v_self,
   }
   if (__pyx_t_6) {
 
-    /* "csamtools.pyx":2637
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2551
  *             return <int>bam_aux2i(v)
  *         elif type == 'i' or type == 'I':
  *             return <int32_t>bam_aux2i(v)             # <<<<<<<<<<<<<<
@@ -23632,7 +23364,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_6opt(PyObject *__pyx_v_self,
  *             return <float>bam_aux2f(v)
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_3 = __Pyx_PyInt_to_py_int32_t(bam_aux2i(__pyx_v_v)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = __Pyx_PyInt_to_py_int32_t(bam_aux2i(__pyx_v_v)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __pyx_r = __pyx_t_3;
     __pyx_t_3 = 0;
@@ -23640,21 +23372,21 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_6opt(PyObject *__pyx_v_self,
     goto __pyx_L6;
   }
 
-  /* "csamtools.pyx":2638
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2552
  *         elif type == 'i' or type == 'I':
  *             return <int32_t>bam_aux2i(v)
  *         elif type == 'f' or type == 'F':             # <<<<<<<<<<<<<<
  *             return <float>bam_aux2f(v)
  *         elif type == 'd' or type == 'D':
  */
-  __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__f), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__f), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   if (!__pyx_t_6) {
-    __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__F), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__F), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2552; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __pyx_t_2 = __pyx_t_5;
   } else {
@@ -23662,7 +23394,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_6opt(PyObject *__pyx_v_self,
   }
   if (__pyx_t_2) {
 
-    /* "csamtools.pyx":2639
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2553
  *             return <int32_t>bam_aux2i(v)
  *         elif type == 'f' or type == 'F':
  *             return <float>bam_aux2f(v)             # <<<<<<<<<<<<<<
@@ -23670,7 +23402,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_6opt(PyObject *__pyx_v_self,
  *             return <double>bam_aux2d(v)
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_3 = PyFloat_FromDouble(bam_aux2f(__pyx_v_v)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyFloat_FromDouble(bam_aux2f(__pyx_v_v)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2553; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __pyx_r = __pyx_t_3;
     __pyx_t_3 = 0;
@@ -23678,21 +23410,21 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_6opt(PyObject *__pyx_v_self,
     goto __pyx_L6;
   }
 
-  /* "csamtools.pyx":2640
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2554
  *         elif type == 'f' or type == 'F':
  *             return <float>bam_aux2f(v)
  *         elif type == 'd' or type == 'D':             # <<<<<<<<<<<<<<
  *             return <double>bam_aux2d(v)
  *         elif type == 'A':
  */
-  __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__d), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__d), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   if (!__pyx_t_2) {
-    __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__D), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__D), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __pyx_t_5 = __pyx_t_6;
   } else {
@@ -23700,7 +23432,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_6opt(PyObject *__pyx_v_self,
   }
   if (__pyx_t_5) {
 
-    /* "csamtools.pyx":2641
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2555
  *             return <float>bam_aux2f(v)
  *         elif type == 'd' or type == 'D':
  *             return <double>bam_aux2d(v)             # <<<<<<<<<<<<<<
@@ -23708,7 +23440,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_6opt(PyObject *__pyx_v_self,
  *             # there might a more efficient way
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_3 = PyFloat_FromDouble(bam_aux2d(__pyx_v_v)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyFloat_FromDouble(bam_aux2d(__pyx_v_v)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2555; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __pyx_r = __pyx_t_3;
     __pyx_t_3 = 0;
@@ -23716,20 +23448,20 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_6opt(PyObject *__pyx_v_self,
     goto __pyx_L6;
   }
 
-  /* "csamtools.pyx":2642
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2556
  *         elif type == 'd' or type == 'D':
  *             return <double>bam_aux2d(v)
  *         elif type == 'A':             # <<<<<<<<<<<<<<
  *             # there might a more efficient way
  *             # to convert a char into a string
  */
-  __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__A), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__A), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   if (__pyx_t_5) {
 
-    /* "csamtools.pyx":2645
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2559
  *             # there might a more efficient way
  *             # to convert a char into a string
  *             return '%c' % <char>bam_aux2A(v)             # <<<<<<<<<<<<<<
@@ -23737,9 +23469,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_6opt(PyObject *__pyx_v_self,
  *             return <char*>bam_aux2Z(v)
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_3 = PyInt_FromLong(bam_aux2A(__pyx_v_v)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyInt_FromLong(bam_aux2A(__pyx_v_v)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_121), __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_62), __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_4));
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __pyx_r = ((PyObject *)__pyx_t_4);
@@ -23748,20 +23480,20 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_6opt(PyObject *__pyx_v_self,
     goto __pyx_L6;
   }
 
-  /* "csamtools.pyx":2646
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2560
  *             # to convert a char into a string
  *             return '%c' % <char>bam_aux2A(v)
  *         elif type == 'Z':             # <<<<<<<<<<<<<<
  *             return <char*>bam_aux2Z(v)
  * 
  */
-  __pyx_t_4 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__Z), Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_RichCompare(__pyx_v_type, ((PyObject *)__pyx_n_s__Z), Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   if (__pyx_t_5) {
 
-    /* "csamtools.pyx":2647
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2561
  *             return '%c' % <char>bam_aux2A(v)
  *         elif type == 'Z':
  *             return <char*>bam_aux2Z(v)             # <<<<<<<<<<<<<<
@@ -23769,7 +23501,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_6opt(PyObject *__pyx_v_self,
  *     def fancy_str (self):
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_4 = PyBytes_FromString(bam_aux2Z(__pyx_v_v)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyBytes_FromString(bam_aux2Z(__pyx_v_v)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2561; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_4));
     __pyx_r = ((PyObject *)__pyx_t_4);
     __pyx_t_4 = 0;
@@ -23793,7 +23525,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_6opt(PyObject *__pyx_v_self,
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2649
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2563
  *             return <char*>bam_aux2Z(v)
  * 
  *     def fancy_str (self):             # <<<<<<<<<<<<<<
@@ -23801,9 +23533,9 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_6opt(PyObject *__pyx_v_self,
  *         """
  */
 
-static PyObject *__pyx_pf_9csamtools_11AlignedRead_7fancy_str(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_9csamtools_11AlignedRead_7fancy_str[] = "AlignedRead.fancy_str(self)\nreturns list of fieldnames/values in pretty format for debugging\n        ";
-static PyObject *__pyx_pf_9csamtools_11AlignedRead_7fancy_str(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+static PyObject *__pyx_pf_9csamtools_11AlignedRead_fancy_str(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static char __pyx_doc_9csamtools_11AlignedRead_fancy_str[] = "AlignedRead.fancy_str(self)\nreturns list of fieldnames/values in pretty format for debugging\n        ";
+static PyObject *__pyx_pf_9csamtools_11AlignedRead_fancy_str(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
   PyObject *__pyx_v_ret_string;
   PyObject *__pyx_v_field_names;
   PyObject *__pyx_v_fields_names_in_order;
@@ -23821,64 +23553,64 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_7fancy_str(PyObject *__pyx_v_
   int __pyx_t_10;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("fancy_str");
-  __Pyx_TraceCall("fancy_str", __pyx_f[0], 2649);
-  __pyx_v_ret_string = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
-  __pyx_v_field_names = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
-  __pyx_v_fields_names_in_order = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
+  __Pyx_TraceCall("fancy_str", __pyx_f[0], 2563);
+  __pyx_v_ret_string = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
+  __pyx_v_field_names = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
+  __pyx_v_fields_names_in_order = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
   __pyx_v_f = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "csamtools.pyx":2652
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2566
  *         """returns list of fieldnames/values in pretty format for debugging
  *         """
  *         ret_string = []             # <<<<<<<<<<<<<<
  *         field_names = {
  *            "tid":           "Contig index",
  */
-  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
   __Pyx_DECREF(((PyObject *)__pyx_v_ret_string));
   __pyx_v_ret_string = __pyx_t_1;
   __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":2653
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2567
  *         """
  *         ret_string = []
  *         field_names = {             # <<<<<<<<<<<<<<
  *            "tid":           "Contig index",
  *            "pos":           "Mapped position on contig",
  */
-  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__tid), ((PyObject *)__pyx_kp_s_136)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__pos), ((PyObject *)__pyx_kp_s_137)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__mtid), ((PyObject *)__pyx_kp_s_138)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__mpos), ((PyObject *)__pyx_kp_s_139)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__isize), ((PyObject *)__pyx_kp_s_140)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__flag), ((PyObject *)__pyx_kp_s_141)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__n_cigar), ((PyObject *)__pyx_kp_s_142)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__cigar), ((PyObject *)__pyx_kp_s_143)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__qual), ((PyObject *)__pyx_kp_s_144)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__bin), ((PyObject *)__pyx_kp_s_145)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__l_qname), ((PyObject *)__pyx_kp_s_146)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__qname), ((PyObject *)__pyx_kp_s_147)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__l_qseq), ((PyObject *)__pyx_kp_s_148)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__qseq), ((PyObject *)__pyx_kp_s_149)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__bqual), ((PyObject *)__pyx_kp_s_150)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__l_aux), ((PyObject *)__pyx_kp_s_151)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__m_data), ((PyObject *)__pyx_kp_s_152)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__data_len), ((PyObject *)__pyx_kp_s_153)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__tid), ((PyObject *)__pyx_kp_s_76)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__pos), ((PyObject *)__pyx_kp_s_77)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__mtid), ((PyObject *)__pyx_kp_s_78)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__mpos), ((PyObject *)__pyx_kp_s_79)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__isize), ((PyObject *)__pyx_kp_s_80)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__flag), ((PyObject *)__pyx_kp_s_81)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__n_cigar), ((PyObject *)__pyx_kp_s_82)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__cigar), ((PyObject *)__pyx_kp_s_83)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__qual), ((PyObject *)__pyx_kp_s_84)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__bin), ((PyObject *)__pyx_kp_s_85)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__l_qname), ((PyObject *)__pyx_kp_s_86)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__qname), ((PyObject *)__pyx_kp_s_87)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__l_qseq), ((PyObject *)__pyx_kp_s_88)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__qseq), ((PyObject *)__pyx_kp_s_89)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__bqual), ((PyObject *)__pyx_kp_s_90)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__l_aux), ((PyObject *)__pyx_kp_s_91)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__m_data), ((PyObject *)__pyx_kp_s_92)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__data_len), ((PyObject *)__pyx_kp_s_93)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(((PyObject *)__pyx_v_field_names));
   __pyx_v_field_names = __pyx_t_1;
   __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":2673
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2587
  *            "data_len":      "Current data length",
  *            }
  *         fields_names_in_order = ["tid", "pos", "mtid", "mpos", "isize", "flag",             # <<<<<<<<<<<<<<
  *                                  "n_cigar", "cigar", "qual", "bin", "l_qname", "qname",
  *                                  "l_qseq", "qseq", "bqual", "l_aux", "m_data", "data_len"]
  */
-  __pyx_t_1 = PyList_New(18); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyList_New(18); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__tid));
   PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__tid));
@@ -23938,17 +23670,18 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_7fancy_str(PyObject *__pyx_v_
   __pyx_v_fields_names_in_order = __pyx_t_1;
   __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":2677
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2591
  *                                  "l_qseq", "qseq", "bqual", "l_aux", "m_data", "data_len"]
  * 
  *         for f in fields_names_in_order:             # <<<<<<<<<<<<<<
  *             if not f in self.__dict__:
  *                 continue
  */
-  if (unlikely(__pyx_v_fields_names_in_order == Py_None)) {
-    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2677; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+  if (likely(((PyObject *)__pyx_v_fields_names_in_order) != Py_None)) {
+    __pyx_t_2 = 0; __pyx_t_1 = ((PyObject *)__pyx_v_fields_names_in_order); __Pyx_INCREF(__pyx_t_1);
+  } else {
+    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
-  __pyx_t_2 = 0; __pyx_t_1 = ((PyObject *)__pyx_v_fields_names_in_order); __Pyx_INCREF(__pyx_t_1);
   for (;;) {
     if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
     __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++;
@@ -23956,21 +23689,21 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_7fancy_str(PyObject *__pyx_v_
     __pyx_v_f = __pyx_t_3;
     __pyx_t_3 = 0;
 
-    /* "csamtools.pyx":2678
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2592
  * 
  *         for f in fields_names_in_order:
  *             if not f in self.__dict__:             # <<<<<<<<<<<<<<
  *                 continue
  *             ret_string.append("%-30s %-10s= %s" % (field_names[f], "(" + f + ")", self.__getattribute__(f)))
  */
-    __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s____dict__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s____dict__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_4 = ((PySequence_Contains(__pyx_t_3, __pyx_v_f))); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = ((PySequence_Contains(__pyx_t_3, __pyx_v_f))); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2592; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __pyx_t_5 = (!__pyx_t_4);
     if (__pyx_t_5) {
 
-      /* "csamtools.pyx":2679
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2593
  *         for f in fields_names_in_order:
  *             if not f in self.__dict__:
  *                 continue             # <<<<<<<<<<<<<<
@@ -23982,7 +23715,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_7fancy_str(PyObject *__pyx_v_
     }
     __pyx_L7:;
 
-    /* "csamtools.pyx":2680
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2594
  *             if not f in self.__dict__:
  *                 continue
  *             ret_string.append("%-30s %-10s= %s" % (field_names[f], "(" + f + ")", self.__getattribute__(f)))             # <<<<<<<<<<<<<<
@@ -23990,28 +23723,28 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_7fancy_str(PyObject *__pyx_v_
  *         for f in self.__dict__:
  */
     if (unlikely(__pyx_v_ret_string == Py_None)) {
-      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2680; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2594; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
     }
-    __pyx_t_3 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_field_names), __pyx_v_f); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_field_names), __pyx_v_f); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_6 = PyNumber_Add(((PyObject *)__pyx_kp_s_155), __pyx_v_f); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyNumber_Add(((PyObject *)__pyx_kp_s_95), __pyx_v_f); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
-    __pyx_t_7 = PyNumber_Add(__pyx_t_6, ((PyObject *)__pyx_kp_s_156)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = PyNumber_Add(__pyx_t_6, ((PyObject *)__pyx_kp_s_96)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_7);
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-    __pyx_t_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s____getattribute__); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s____getattribute__); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
-    __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_8));
+    __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_8);
     __Pyx_INCREF(__pyx_v_f);
     PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_f);
     __Pyx_GIVEREF(__pyx_v_f);
-    __pyx_t_9 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_9);
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-    __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
-    __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_8));
+    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+    __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_8);
     PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3);
     __Pyx_GIVEREF(__pyx_t_3);
     PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7);
@@ -24021,28 +23754,28 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_7fancy_str(PyObject *__pyx_v_
     __pyx_t_3 = 0;
     __pyx_t_7 = 0;
     __pyx_t_9 = 0;
-    __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_154), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_94), __pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_9));
-    __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
-    __pyx_t_10 = PyList_Append(__pyx_v_ret_string, ((PyObject *)__pyx_t_9)); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+    __pyx_t_10 = PyList_Append(((PyObject *)__pyx_v_ret_string), ((PyObject *)__pyx_t_9)); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
     __pyx_L5_continue:;
   }
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":2682
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2596
  *             ret_string.append("%-30s %-10s= %s" % (field_names[f], "(" + f + ")", self.__getattribute__(f)))
  * 
  *         for f in self.__dict__:             # <<<<<<<<<<<<<<
  *             if not f in field_names:
  *                 ret_string.append("%-30s %-10s= %s" % (f, "", self.__getattribute__(f)))
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s____dict__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s____dict__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
     __pyx_t_2 = 0; __pyx_t_9 = __pyx_t_1; __Pyx_INCREF(__pyx_t_9);
   } else {
-    __pyx_t_2 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_9);
   }
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
@@ -24056,7 +23789,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_7fancy_str(PyObject *__pyx_v_
     } else {
       __pyx_t_1 = PyIter_Next(__pyx_t_9);
       if (!__pyx_t_1) {
-        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2682; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         break;
       }
       __Pyx_GOTREF(__pyx_t_1);
@@ -24065,21 +23798,22 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_7fancy_str(PyObject *__pyx_v_
     __pyx_v_f = __pyx_t_1;
     __pyx_t_1 = 0;
 
-    /* "csamtools.pyx":2683
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2597
  * 
  *         for f in self.__dict__:
  *             if not f in field_names:             # <<<<<<<<<<<<<<
  *                 ret_string.append("%-30s %-10s= %s" % (f, "", self.__getattribute__(f)))
  *         return ret_string
  */
-    if (unlikely(__pyx_v_field_names == Py_None)) {
-      PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2683; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+    if (unlikely(((PyObject *)__pyx_v_field_names) == Py_None)) {
+      __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    } else {
+      __pyx_t_5 = ((PyDict_Contains(((PyObject *)__pyx_v_field_names), __pyx_v_f))); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     }
-    __pyx_t_5 = ((PyDict_Contains(((PyObject *)__pyx_v_field_names), __pyx_v_f))); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2683; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_t_4 = (!__pyx_t_5);
     if (__pyx_t_4) {
 
-      /* "csamtools.pyx":2684
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2598
  *         for f in self.__dict__:
  *             if not f in field_names:
  *                 ret_string.append("%-30s %-10s= %s" % (f, "", self.__getattribute__(f)))             # <<<<<<<<<<<<<<
@@ -24087,34 +23821,34 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_7fancy_str(PyObject *__pyx_v_
  * 
  */
       if (unlikely(__pyx_v_ret_string == Py_None)) {
-        PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2684; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+        PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2598; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
       }
-      __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s____getattribute__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s____getattribute__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(((PyObject *)__pyx_t_8));
+      __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_8);
       __Pyx_INCREF(__pyx_v_f);
       PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_f);
       __Pyx_GIVEREF(__pyx_v_f);
-      __pyx_t_7 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyObject_Call(__pyx_t_1, __pyx_t_8, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-      __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
-      __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(((PyObject *)__pyx_t_8));
+      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+      __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_8);
       __Pyx_INCREF(__pyx_v_f);
       PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_f);
       __Pyx_GIVEREF(__pyx_v_f);
-      __Pyx_INCREF(((PyObject *)__pyx_kp_s_12));
-      PyTuple_SET_ITEM(__pyx_t_8, 1, ((PyObject *)__pyx_kp_s_12));
-      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_12));
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_8));
+      PyTuple_SET_ITEM(__pyx_t_8, 1, ((PyObject *)__pyx_kp_s_8));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_8));
       PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_7);
       __Pyx_GIVEREF(__pyx_t_7);
       __pyx_t_7 = 0;
-      __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_154), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_94), __pyx_t_8); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_7));
-      __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
-      __pyx_t_10 = PyList_Append(__pyx_v_ret_string, ((PyObject *)__pyx_t_7)); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+      __pyx_t_10 = PyList_Append(((PyObject *)__pyx_v_ret_string), ((PyObject *)__pyx_t_7)); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
       goto __pyx_L10;
     }
@@ -24122,7 +23856,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_7fancy_str(PyObject *__pyx_v_
   }
   __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
 
-  /* "csamtools.pyx":2685
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2599
  *             if not f in field_names:
  *                 ret_string.append("%-30s %-10s= %s" % (f, "", self.__getattribute__(f)))
  *         return ret_string             # <<<<<<<<<<<<<<
@@ -24156,7 +23890,7 @@ static PyObject *__pyx_pf_9csamtools_11AlignedRead_7fancy_str(PyObject *__pyx_v_
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2709
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2623
  *     cdef int n_pu
  * 
  *     def __init__(self):             # <<<<<<<<<<<<<<
@@ -24168,30 +23902,38 @@ static int __pyx_pf_9csamtools_11PileupProxy___init__(PyObject *__pyx_v_self, Py
 static int __pyx_pf_9csamtools_11PileupProxy___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   int __pyx_r;
   PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__init__");
-  __Pyx_TraceCall("__init__", __pyx_f[0], 2709);
+  __Pyx_TraceCall("__init__", __pyx_f[0], 2623);
   if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
     __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
   if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
 
-  /* "csamtools.pyx":2710
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2624
  * 
  *     def __init__(self):
  *         raise TypeError("This class cannot be instantiated from Python")             # <<<<<<<<<<<<<<
  * 
  *     def __str__(self):
  */
-  __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_158), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2710; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __Pyx_Raise(__pyx_t_1, 0, 0);
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_97));
+  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_97));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_97));
+  __pyx_t_2 = PyObject_Call(__pyx_builtin_TypeError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2710; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_Raise(__pyx_t_2, 0, 0);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
   __pyx_r = 0;
   goto __pyx_L0;
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
   __Pyx_AddTraceback("csamtools.PileupProxy.__init__");
   __pyx_r = -1;
   __pyx_L0:;
@@ -24200,7 +23942,7 @@ static int __pyx_pf_9csamtools_11PileupProxy___init__(PyObject *__pyx_v_self, Py
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2712
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2626
  *         raise TypeError("This class cannot be instantiated from Python")
  * 
  *     def __str__(self):             # <<<<<<<<<<<<<<
@@ -24208,8 +23950,8 @@ static int __pyx_pf_9csamtools_11PileupProxy___init__(PyObject *__pyx_v_self, Py
  *             "\n" +\
  */
 
-static PyObject *__pyx_pf_9csamtools_11PileupProxy_1__str__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_9csamtools_11PileupProxy_1__str__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_11PileupProxy___str__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_11PileupProxy___str__(PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   PyObject *__pyx_t_2 = NULL;
@@ -24218,9 +23960,9 @@ static PyObject *__pyx_pf_9csamtools_11PileupProxy_1__str__(PyObject *__pyx_v_se
   PyObject *__pyx_t_5 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__str__");
-  __Pyx_TraceCall("__str__", __pyx_f[0], 2712);
+  __Pyx_TraceCall("__str__", __pyx_f[0], 2626);
 
-  /* "csamtools.pyx":2713
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2627
  * 
  *     def __str__(self):
  *         return "\t".join( map(str, (self.tid, self.pos, self.n))) +\             # <<<<<<<<<<<<<<
@@ -24229,31 +23971,31 @@ static PyObject *__pyx_pf_9csamtools_11PileupProxy_1__str__(PyObject *__pyx_v_se
  */
   __Pyx_XDECREF(__pyx_r);
 
-  /* "csamtools.pyx":2714
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2628
  *     def __str__(self):
  *         return "\t".join( map(str, (self.tid, self.pos, self.n))) +\
  *             "\n" +\             # <<<<<<<<<<<<<<
  *             "\n".join( map(str, self.pileups) )
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_1), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_1), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
 
-  /* "csamtools.pyx":2713
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2627
  * 
  *     def __str__(self):
  *         return "\t".join( map(str, (self.tid, self.pos, self.n))) +\             # <<<<<<<<<<<<<<
  *             "\n" +\
  *             "\n".join( map(str, self.pileups) )
  */
-  __pyx_t_2 = PyInt_FromLong(((struct __pyx_obj_9csamtools_PileupProxy *)__pyx_v_self)->tid); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyInt_FromLong(((struct __pyx_obj_9csamtools_PileupProxy *)__pyx_v_self)->tid); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = PyInt_FromLong(((struct __pyx_obj_9csamtools_PileupProxy *)__pyx_v_self)->pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyInt_FromLong(((struct __pyx_obj_9csamtools_PileupProxy *)__pyx_v_self)->pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__n); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__n); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+  __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
   PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
   __Pyx_GIVEREF(__pyx_t_2);
   PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
@@ -24263,62 +24005,62 @@ static PyObject *__pyx_pf_9csamtools_11PileupProxy_1__str__(PyObject *__pyx_v_se
   __pyx_t_2 = 0;
   __pyx_t_3 = 0;
   __pyx_t_4 = 0;
-  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
-  __Pyx_INCREF(((PyObject *)((PyObject*)(&PyString_Type))));
-  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)((PyObject*)(&PyString_Type))));
-  __Pyx_GIVEREF(((PyObject *)((PyObject*)(&PyString_Type))));
-  PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_t_5));
-  __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
+  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
+  PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)((PyObject*)&PyString_Type)));
+  __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
+  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5);
+  __Pyx_GIVEREF(__pyx_t_5);
   __pyx_t_5 = 0;
-  __pyx_t_5 = PyObject_Call(__pyx_builtin_map, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_Call(__pyx_builtin_map, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
-  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
-  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
   __Pyx_GIVEREF(__pyx_t_5);
   __pyx_t_5 = 0;
-  __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
-  __pyx_t_4 = PyNumber_Add(__pyx_t_5, ((PyObject *)__pyx_kp_s_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_4 = PyNumber_Add(__pyx_t_5, ((PyObject *)__pyx_kp_s_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
-  /* "csamtools.pyx":2715
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2629
  *         return "\t".join( map(str, (self.tid, self.pos, self.n))) +\
  *             "\n" +\
  *             "\n".join( map(str, self.pileups) )             # <<<<<<<<<<<<<<
  * 
  *     property tid:
  */
-  __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_2), __pyx_n_s__join); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_2), __pyx_n_s__join); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__pileups); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__pileups); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-  __Pyx_INCREF(((PyObject *)((PyObject*)(&PyString_Type))));
-  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)((PyObject*)(&PyString_Type))));
-  __Pyx_GIVEREF(((PyObject *)((PyObject*)(&PyString_Type))));
+  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
+  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)((PyObject*)&PyString_Type)));
+  __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
   __Pyx_GIVEREF(__pyx_t_1);
   __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_Call(__pyx_builtin_map, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(__pyx_builtin_map, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
-  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
   __Pyx_GIVEREF(__pyx_t_1);
   __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(__pyx_t_5, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
-  __pyx_t_3 = PyNumber_Add(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2714; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_3 = PyNumber_Add(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
@@ -24343,7 +24085,7 @@ static PyObject *__pyx_pf_9csamtools_11PileupProxy_1__str__(PyObject *__pyx_v_se
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2719
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2633
  *     property tid:
  *         '''the chromosome ID as is defined in the header'''
  *         def __get__(self): return self.tid             # <<<<<<<<<<<<<<
@@ -24357,9 +24099,9 @@ static PyObject *__pyx_pf_9csamtools_11PileupProxy_3tid___get__(PyObject *__pyx_
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2719);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2633);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_PileupProxy *)__pyx_v_self)->tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_PileupProxy *)__pyx_v_self)->tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -24378,7 +24120,7 @@ static PyObject *__pyx_pf_9csamtools_11PileupProxy_3tid___get__(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2723
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2637
  *     property n:
  *         '''number of reads mapping to this column.'''
  *         def __get__(self): return self.n_pu             # <<<<<<<<<<<<<<
@@ -24392,9 +24134,9 @@ static PyObject *__pyx_pf_9csamtools_11PileupProxy_1n___get__(PyObject *__pyx_v_
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2723);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2637);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_PileupProxy *)__pyx_v_self)->n_pu); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_PileupProxy *)__pyx_v_self)->n_pu); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2637; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -24413,7 +24155,7 @@ static PyObject *__pyx_pf_9csamtools_11PileupProxy_1n___get__(PyObject *__pyx_v_
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2724
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2638
  *         '''number of reads mapping to this column.'''
  *         def __get__(self): return self.n_pu
  *         def __set__(self, n): self.n_pu = n             # <<<<<<<<<<<<<<
@@ -24421,14 +24163,14 @@ static PyObject *__pyx_pf_9csamtools_11PileupProxy_1n___get__(PyObject *__pyx_v_
  *     property pos:
  */
 
-static int __pyx_pf_9csamtools_11PileupProxy_1n_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_n); /*proto*/
-static int __pyx_pf_9csamtools_11PileupProxy_1n_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_n) {
+static int __pyx_pf_9csamtools_11PileupProxy_1n___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_n); /*proto*/
+static int __pyx_pf_9csamtools_11PileupProxy_1n___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_n) {
   int __pyx_r;
   int __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__");
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2724);
-  __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_n); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2638);
+  __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_n); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2638; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   ((struct __pyx_obj_9csamtools_PileupProxy *)__pyx_v_self)->n_pu = __pyx_t_1;
 
   __pyx_r = 0;
@@ -24442,7 +24184,7 @@ static int __pyx_pf_9csamtools_11PileupProxy_1n_1__set__(PyObject *__pyx_v_self,
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2727
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2641
  * 
  *     property pos:
  *         def __get__(self): return self.pos             # <<<<<<<<<<<<<<
@@ -24456,9 +24198,9 @@ static PyObject *__pyx_pf_9csamtools_11PileupProxy_3pos___get__(PyObject *__pyx_
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2727);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2641);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_PileupProxy *)__pyx_v_self)->pos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2727; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_PileupProxy *)__pyx_v_self)->pos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -24477,7 +24219,7 @@ static PyObject *__pyx_pf_9csamtools_11PileupProxy_3pos___get__(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2731
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2645
  *     property pileups:
  *         '''list of reads (:class:`pysam.PileupRead`) aligned to this column'''
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -24495,23 +24237,23 @@ static PyObject *__pyx_pf_9csamtools_11PileupProxy_7pileups___get__(PyObject *__
   int __pyx_t_3;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2731);
-  __pyx_v_pileups = ((PyObject*)Py_None); __Pyx_INCREF(Py_None);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2645);
+  __pyx_v_pileups = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
 
-  /* "csamtools.pyx":2733
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2647
  *         def __get__(self):
  *             cdef int x
  *             pileups = []             # <<<<<<<<<<<<<<
  *             # warning: there could be problems if self.n and self.buf are
  *             # out of sync.
  */
-  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2733; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2647; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
   __Pyx_DECREF(((PyObject *)__pyx_v_pileups));
   __pyx_v_pileups = __pyx_t_1;
   __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":2736
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2650
  *             # warning: there could be problems if self.n and self.buf are
  *             # out of sync.
  *             for x from 0 <= x < self.n_pu:             # <<<<<<<<<<<<<<
@@ -24521,7 +24263,7 @@ static PyObject *__pyx_pf_9csamtools_11PileupProxy_7pileups___get__(PyObject *__
   __pyx_t_2 = ((struct __pyx_obj_9csamtools_PileupProxy *)__pyx_v_self)->n_pu;
   for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_2; __pyx_v_x++) {
 
-    /* "csamtools.pyx":2737
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2651
  *             # out of sync.
  *             for x from 0 <= x < self.n_pu:
  *                 pileups.append( makePileupRead( &(self.plp[x])) )             # <<<<<<<<<<<<<<
@@ -24529,15 +24271,15 @@ static PyObject *__pyx_pf_9csamtools_11PileupProxy_7pileups___get__(PyObject *__
  * 
  */
     if (unlikely(__pyx_v_pileups == Py_None)) {
-      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2737; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+      PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2651; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
     }
-    __pyx_t_1 = __pyx_f_9csamtools_makePileupRead((&(((struct __pyx_obj_9csamtools_PileupProxy *)__pyx_v_self)->plp[__pyx_v_x]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2737; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __pyx_f_9csamtools_makePileupRead((&(((struct __pyx_obj_9csamtools_PileupProxy *)__pyx_v_self)->plp[__pyx_v_x]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_3 = PyList_Append(__pyx_v_pileups, __pyx_t_1); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2737; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyList_Append(((PyObject *)__pyx_v_pileups), __pyx_t_1); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   }
 
-  /* "csamtools.pyx":2738
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2652
  *             for x from 0 <= x < self.n_pu:
  *                 pileups.append( makePileupRead( &(self.plp[x])) )
  *             return pileups             # <<<<<<<<<<<<<<
@@ -24563,7 +24305,7 @@ static PyObject *__pyx_pf_9csamtools_11PileupProxy_7pileups___get__(PyObject *__
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2753
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2667
  *          uint32_t _is_tail
  * 
  *     def __init__(self):             # <<<<<<<<<<<<<<
@@ -24575,30 +24317,38 @@ static int __pyx_pf_9csamtools_10PileupRead___init__(PyObject *__pyx_v_self, PyO
 static int __pyx_pf_9csamtools_10PileupRead___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   int __pyx_r;
   PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__init__");
-  __Pyx_TraceCall("__init__", __pyx_f[0], 2753);
+  __Pyx_TraceCall("__init__", __pyx_f[0], 2667);
   if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
     __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
   if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
 
-  /* "csamtools.pyx":2754
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2668
  * 
  *     def __init__(self):
  *         raise TypeError("This class cannot be instantiated from Python")             # <<<<<<<<<<<<<<
  * 
  *     def __str__(self):
  */
-  __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_159), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __Pyx_Raise(__pyx_t_1, 0, 0);
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_97));
+  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_97));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_97));
+  __pyx_t_2 = PyObject_Call(__pyx_builtin_TypeError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_Raise(__pyx_t_2, 0, 0);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
   __pyx_r = 0;
   goto __pyx_L0;
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
   __Pyx_AddTraceback("csamtools.PileupRead.__init__");
   __pyx_r = -1;
   __pyx_L0:;
@@ -24607,7 +24357,7 @@ static int __pyx_pf_9csamtools_10PileupRead___init__(PyObject *__pyx_v_self, PyO
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2756
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2670
  *         raise TypeError("This class cannot be instantiated from Python")
  * 
  *     def __str__(self):             # <<<<<<<<<<<<<<
@@ -24615,8 +24365,8 @@ static int __pyx_pf_9csamtools_10PileupRead___init__(PyObject *__pyx_v_self, PyO
  * 
  */
 
-static PyObject *__pyx_pf_9csamtools_10PileupRead_1__str__(PyObject *__pyx_v_self); /*proto*/
-static PyObject *__pyx_pf_9csamtools_10PileupRead_1__str__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_10PileupRead___str__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_10PileupRead___str__(PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   PyObject *__pyx_t_2 = NULL;
@@ -24629,9 +24379,9 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_1__str__(PyObject *__pyx_v_sel
   PyObject *__pyx_t_9 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__str__");
-  __Pyx_TraceCall("__str__", __pyx_f[0], 2756);
+  __Pyx_TraceCall("__str__", __pyx_f[0], 2670);
 
-  /* "csamtools.pyx":2757
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2671
  * 
  *     def __str__(self):
  *         return "\t".join( map(str, (self.alignment, self.qpos, self.indel, self.level, self.is_del, self.is_head, self.is_tail ) ) )             # <<<<<<<<<<<<<<
@@ -24639,24 +24389,24 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_1__str__(PyObject *__pyx_v_sel
  *     property alignment:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_1), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_1), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__alignment); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__alignment); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__qpos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__qpos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__indel); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__indel); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__level); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__level); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
-  __pyx_t_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__is_del); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__is_del); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_6);
-  __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__is_head); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__is_head); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_7);
-  __pyx_t_8 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__is_tail); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__is_tail); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_8);
-  __pyx_t_9 = PyTuple_New(7); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_9));
+  __pyx_t_9 = PyTuple_New(7); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_9);
   PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_2);
   __Pyx_GIVEREF(__pyx_t_2);
   PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_3);
@@ -24678,26 +24428,26 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_1__str__(PyObject *__pyx_v_sel
   __pyx_t_6 = 0;
   __pyx_t_7 = 0;
   __pyx_t_8 = 0;
-  __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_8));
-  __Pyx_INCREF(((PyObject *)((PyObject*)(&PyString_Type))));
-  PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)((PyObject*)(&PyString_Type))));
-  __Pyx_GIVEREF(((PyObject *)((PyObject*)(&PyString_Type))));
-  PyTuple_SET_ITEM(__pyx_t_8, 1, ((PyObject *)__pyx_t_9));
-  __Pyx_GIVEREF(((PyObject *)__pyx_t_9));
+  __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_8);
+  __Pyx_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
+  PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)((PyObject*)&PyString_Type)));
+  __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
+  PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_9);
+  __Pyx_GIVEREF(__pyx_t_9);
   __pyx_t_9 = 0;
-  __pyx_t_9 = PyObject_Call(__pyx_builtin_map, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_9 = PyObject_Call(__pyx_builtin_map, __pyx_t_8, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_9);
-  __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
-  __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_8));
+  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+  __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_8);
   PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_9);
   __Pyx_GIVEREF(__pyx_t_9);
   __pyx_t_9 = 0;
-  __pyx_t_9 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_9 = PyObject_Call(__pyx_t_1, __pyx_t_8, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_9);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
+  __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
   __pyx_r = __pyx_t_9;
   __pyx_t_9 = 0;
   goto __pyx_L0;
@@ -24723,7 +24473,7 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_1__str__(PyObject *__pyx_v_sel
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2761
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2675
  *     property alignment:
  *         """a :class:`pysam.AlignedRead` object of the aligned read"""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -24736,9 +24486,9 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_9alignment___get__(PyObject *_
   PyObject *__pyx_r = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2761);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2675);
 
-  /* "csamtools.pyx":2762
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2676
  *         """a :class:`pysam.AlignedRead` object of the aligned read"""
  *         def __get__(self):
  *             return self._alignment             # <<<<<<<<<<<<<<
@@ -24758,7 +24508,7 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_9alignment___get__(PyObject *_
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2765
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2679
  *     property qpos:
  *         """position of the read base at the pileup site, 0-based"""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -24772,9 +24522,9 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_4qpos___get__(PyObject *__pyx_
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2765);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2679);
 
-  /* "csamtools.pyx":2766
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2680
  *         """position of the read base at the pileup site, 0-based"""
  *         def __get__(self):
  *             return self._qpos             # <<<<<<<<<<<<<<
@@ -24782,7 +24532,7 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_4qpos___get__(PyObject *__pyx_
  *         """indel length; 0 for no indel, positive for ins and negative for del"""
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_PileupRead *)__pyx_v_self)->_qpos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((struct __pyx_obj_9csamtools_PileupRead *)__pyx_v_self)->_qpos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -24801,7 +24551,7 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_4qpos___get__(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2769
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2683
  *     property indel:
  *         """indel length; 0 for no indel, positive for ins and negative for del"""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -24815,9 +24565,9 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_5indel___get__(PyObject *__pyx
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2769);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2683);
 
-  /* "csamtools.pyx":2770
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2684
  *         """indel length; 0 for no indel, positive for ins and negative for del"""
  *         def __get__(self):
  *             return self._indel             # <<<<<<<<<<<<<<
@@ -24825,7 +24575,7 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_5indel___get__(PyObject *__pyx
  *         """1 iff the base on the padded read is a deletion"""
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_PileupRead *)__pyx_v_self)->_indel); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_PileupRead *)__pyx_v_self)->_indel); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -24844,7 +24594,7 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_5indel___get__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2773
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2687
  *     property is_del:
  *         """1 iff the base on the padded read is a deletion"""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -24858,9 +24608,9 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_6is_del___get__(PyObject *__py
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2773);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2687);
 
-  /* "csamtools.pyx":2774
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2688
  *         """1 iff the base on the padded read is a deletion"""
  *         def __get__(self):
  *             return self._is_del             # <<<<<<<<<<<<<<
@@ -24868,7 +24618,7 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_6is_del___get__(PyObject *__py
  *         def __get__(self):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(((struct __pyx_obj_9csamtools_PileupRead *)__pyx_v_self)->_is_del); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(((struct __pyx_obj_9csamtools_PileupRead *)__pyx_v_self)->_is_del); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2688; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -24887,7 +24637,7 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_6is_del___get__(PyObject *__py
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2776
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2690
  *             return self._is_del
  *     property is_head:
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -24901,9 +24651,9 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_7is_head___get__(PyObject *__p
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2776);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2690);
 
-  /* "csamtools.pyx":2777
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2691
  *     property is_head:
  *         def __get__(self):
  *             return self._is_head             # <<<<<<<<<<<<<<
@@ -24911,7 +24661,7 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_7is_head___get__(PyObject *__p
  *         def __get__(self):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(((struct __pyx_obj_9csamtools_PileupRead *)__pyx_v_self)->_is_head); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(((struct __pyx_obj_9csamtools_PileupRead *)__pyx_v_self)->_is_head); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -24930,7 +24680,7 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_7is_head___get__(PyObject *__p
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2779
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2693
  *             return self._is_head
  *     property is_tail:
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -24944,9 +24694,9 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_7is_tail___get__(PyObject *__p
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2779);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2693);
 
-  /* "csamtools.pyx":2780
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2694
  *     property is_tail:
  *         def __get__(self):
  *             return self._is_tail             # <<<<<<<<<<<<<<
@@ -24954,7 +24704,7 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_7is_tail___get__(PyObject *__p
  *         def __get__(self):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(((struct __pyx_obj_9csamtools_PileupRead *)__pyx_v_self)->_is_tail); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(((struct __pyx_obj_9csamtools_PileupRead *)__pyx_v_self)->_is_tail); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -24973,7 +24723,7 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_7is_tail___get__(PyObject *__p
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2782
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2696
  *             return self._is_tail
  *     property level:
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -24987,9 +24737,9 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_5level___get__(PyObject *__pyx
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2782);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2696);
 
-  /* "csamtools.pyx":2783
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2697
  *     property level:
  *         def __get__(self):
  *             return self._level             # <<<<<<<<<<<<<<
@@ -24997,7 +24747,7 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_5level___get__(PyObject *__pyx
  * class Outs:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_PileupRead *)__pyx_v_self)->_level); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2783; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_PileupRead *)__pyx_v_self)->_level); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -25016,7 +24766,7 @@ static PyObject *__pyx_pf_9csamtools_10PileupRead_5level___get__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2787
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2701
  * class Outs:
  *     '''http://mail.python.org/pipermail/python-list/2000-June/038406.html'''
  *     def __init__(self, id = 1):             # <<<<<<<<<<<<<<
@@ -25035,7 +24785,7 @@ static PyObject *__pyx_pf_9csamtools_4Outs___init__(PyObject *__pyx_self, PyObje
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__id,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__init__");
-  __Pyx_TraceCall("__init__", __pyx_f[0], 2787);
+  __Pyx_TraceCall("__init__", __pyx_f[0], 2701);
   __pyx_self = __pyx_self;
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
@@ -25059,7 +24809,7 @@ static PyObject *__pyx_pf_9csamtools_4Outs___init__(PyObject *__pyx_self, PyObje
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2787; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2701; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_self = values[0];
     __pyx_v_id = values[1];
@@ -25074,33 +24824,33 @@ static PyObject *__pyx_pf_9csamtools_4Outs___init__(PyObject *__pyx_self, PyObje
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2787; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2701; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("csamtools.Outs.__init__");
   __Pyx_RefNannyFinishContext();
   return NULL;
   __pyx_L4_argument_unpacking_done:;
 
-  /* "csamtools.pyx":2788
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2702
  *     '''http://mail.python.org/pipermail/python-list/2000-June/038406.html'''
  *     def __init__(self, id = 1):
  *         self.streams = []             # <<<<<<<<<<<<<<
  *         self.id = id
  * 
  */
-  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__streams, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__streams, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":2789
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2703
  *     def __init__(self, id = 1):
  *         self.streams = []
  *         self.id = id             # <<<<<<<<<<<<<<
  * 
  *     def setdevice(self, filename):
  */
-  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__id, __pyx_v_id) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__id, __pyx_v_id) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   goto __pyx_L0;
@@ -25115,7 +24865,7 @@ static PyObject *__pyx_pf_9csamtools_4Outs___init__(PyObject *__pyx_self, PyObje
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2791
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2705
  *         self.id = id
  * 
  *     def setdevice(self, filename):             # <<<<<<<<<<<<<<
@@ -25123,10 +24873,10 @@ static PyObject *__pyx_pf_9csamtools_4Outs___init__(PyObject *__pyx_self, PyObje
  *         fd = os.open(filename, os.O_WRONLY)
  */
 
-static PyObject *__pyx_pf_9csamtools_4Outs_1setdevice(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_9csamtools_4Outs_1setdevice[] = "Outs.setdevice(self, filename)\nopen an existing file, like \"/dev/null\"";
-static PyMethodDef __pyx_mdef_9csamtools_4Outs_1setdevice = {__Pyx_NAMESTR("setdevice"), (PyCFunction)__pyx_pf_9csamtools_4Outs_1setdevice, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_4Outs_1setdevice)};
-static PyObject *__pyx_pf_9csamtools_4Outs_1setdevice(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+static PyObject *__pyx_pf_9csamtools_4Outs_setdevice(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_9csamtools_4Outs_setdevice[] = "Outs.setdevice(self, filename)\nopen an existing file, like \"/dev/null\"";
+static PyMethodDef __pyx_mdef_9csamtools_4Outs_setdevice = {__Pyx_NAMESTR("setdevice"), (PyCFunction)__pyx_pf_9csamtools_4Outs_setdevice, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_4Outs_setdevice)};
+static PyObject *__pyx_pf_9csamtools_4Outs_setdevice(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   PyObject *__pyx_v_self = 0;
   PyObject *__pyx_v_filename = 0;
   PyObject *__pyx_v_fd;
@@ -25137,7 +24887,7 @@ static PyObject *__pyx_pf_9csamtools_4Outs_1setdevice(PyObject *__pyx_self, PyOb
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__filename,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("setdevice");
-  __Pyx_TraceCall("setdevice", __pyx_f[0], 2791);
+  __Pyx_TraceCall("setdevice", __pyx_f[0], 2705);
   __pyx_self = __pyx_self;
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
@@ -25157,11 +24907,11 @@ static PyObject *__pyx_pf_9csamtools_4Outs_1setdevice(PyObject *__pyx_self, PyOb
       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filename);
       if (likely(values[1])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("setdevice", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2791; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("setdevice", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2705; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "setdevice") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2791; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "setdevice") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2705; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_self = values[0];
     __pyx_v_filename = values[1];
@@ -25173,7 +24923,7 @@ static PyObject *__pyx_pf_9csamtools_4Outs_1setdevice(PyObject *__pyx_self, PyOb
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("setdevice", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2791; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("setdevice", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2705; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("csamtools.Outs.setdevice");
   __Pyx_RefNannyFinishContext();
@@ -25181,57 +24931,57 @@ static PyObject *__pyx_pf_9csamtools_4Outs_1setdevice(PyObject *__pyx_self, PyOb
   __pyx_L4_argument_unpacking_done:;
   __pyx_v_fd = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "csamtools.pyx":2793
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2707
  *     def setdevice(self, filename):
  *         '''open an existing file, like "/dev/null"'''
  *         fd = os.open(filename, os.O_WRONLY)             # <<<<<<<<<<<<<<
  *         self.setfd(fd)
  * 
  */
-  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__open); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__open); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__O_WRONLY); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__O_WRONLY); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
   __Pyx_INCREF(__pyx_v_filename);
   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_filename);
   __Pyx_GIVEREF(__pyx_v_filename);
   PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
   __Pyx_GIVEREF(__pyx_t_3);
   __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(__pyx_v_fd);
   __pyx_v_fd = __pyx_t_3;
   __pyx_t_3 = 0;
 
-  /* "csamtools.pyx":2794
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2708
  *         '''open an existing file, like "/dev/null"'''
  *         fd = os.open(filename, os.O_WRONLY)
  *         self.setfd(fd)             # <<<<<<<<<<<<<<
  * 
  *     def setfile(self, filename):
  */
-  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__setfd); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__setfd); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
   __Pyx_INCREF(__pyx_v_fd);
   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_fd);
   __Pyx_GIVEREF(__pyx_v_fd);
-  __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
@@ -25250,7 +25000,7 @@ static PyObject *__pyx_pf_9csamtools_4Outs_1setdevice(PyObject *__pyx_self, PyOb
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2796
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2710
  *         self.setfd(fd)
  * 
  *     def setfile(self, filename):             # <<<<<<<<<<<<<<
@@ -25258,10 +25008,10 @@ static PyObject *__pyx_pf_9csamtools_4Outs_1setdevice(PyObject *__pyx_self, PyOb
  *         fd = os.open(filename, os.O_WRONLY|os.O_CREAT, 0660);
  */
 
-static PyObject *__pyx_pf_9csamtools_4Outs_2setfile(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_9csamtools_4Outs_2setfile[] = "Outs.setfile(self, filename)\nopen a new file.";
-static PyMethodDef __pyx_mdef_9csamtools_4Outs_2setfile = {__Pyx_NAMESTR("setfile"), (PyCFunction)__pyx_pf_9csamtools_4Outs_2setfile, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_4Outs_2setfile)};
-static PyObject *__pyx_pf_9csamtools_4Outs_2setfile(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+static PyObject *__pyx_pf_9csamtools_4Outs_setfile(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_9csamtools_4Outs_setfile[] = "Outs.setfile(self, filename)\nopen a new file.";
+static PyMethodDef __pyx_mdef_9csamtools_4Outs_setfile = {__Pyx_NAMESTR("setfile"), (PyCFunction)__pyx_pf_9csamtools_4Outs_setfile, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_4Outs_setfile)};
+static PyObject *__pyx_pf_9csamtools_4Outs_setfile(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   PyObject *__pyx_v_self = 0;
   PyObject *__pyx_v_filename = 0;
   PyObject *__pyx_v_fd;
@@ -25273,7 +25023,7 @@ static PyObject *__pyx_pf_9csamtools_4Outs_2setfile(PyObject *__pyx_self, PyObje
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__filename,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("setfile");
-  __Pyx_TraceCall("setfile", __pyx_f[0], 2796);
+  __Pyx_TraceCall("setfile", __pyx_f[0], 2710);
   __pyx_self = __pyx_self;
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
@@ -25293,11 +25043,11 @@ static PyObject *__pyx_pf_9csamtools_4Outs_2setfile(PyObject *__pyx_self, PyObje
       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filename);
       if (likely(values[1])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("setfile", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2796; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("setfile", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2710; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "setfile") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2796; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "setfile") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2710; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_self = values[0];
     __pyx_v_filename = values[1];
@@ -25309,7 +25059,7 @@ static PyObject *__pyx_pf_9csamtools_4Outs_2setfile(PyObject *__pyx_self, PyObje
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("setfile", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2796; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("setfile", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2710; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("csamtools.Outs.setfile");
   __Pyx_RefNannyFinishContext();
@@ -25317,34 +25067,34 @@ static PyObject *__pyx_pf_9csamtools_4Outs_2setfile(PyObject *__pyx_self, PyObje
   __pyx_L4_argument_unpacking_done:;
   __pyx_v_fd = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "csamtools.pyx":2798
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2712
  *     def setfile(self, filename):
  *         '''open a new file.'''
  *         fd = os.open(filename, os.O_WRONLY|os.O_CREAT, 0660);             # <<<<<<<<<<<<<<
  *         self.setfd(fd)
  * 
  */
-  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__open); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__open); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__O_WRONLY); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__O_WRONLY); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__O_CREAT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__O_CREAT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyNumber_Or(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyNumber_Or(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
+  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_INCREF(__pyx_v_filename);
   PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_filename);
   __Pyx_GIVEREF(__pyx_v_filename);
@@ -25354,32 +25104,32 @@ static PyObject *__pyx_pf_9csamtools_4Outs_2setfile(PyObject *__pyx_self, PyObje
   PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_int_0660);
   __Pyx_GIVEREF(__pyx_int_0660);
   __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   __Pyx_DECREF(__pyx_v_fd);
   __pyx_v_fd = __pyx_t_1;
   __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":2799
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2713
  *         '''open a new file.'''
  *         fd = os.open(filename, os.O_WRONLY|os.O_CREAT, 0660);
  *         self.setfd(fd)             # <<<<<<<<<<<<<<
  * 
  *     def setfd(self, fd):
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__setfd); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__setfd); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_4));
+  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_INCREF(__pyx_v_fd);
   PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_fd);
   __Pyx_GIVEREF(__pyx_v_fd);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
@@ -25399,7 +25149,7 @@ static PyObject *__pyx_pf_9csamtools_4Outs_2setfile(PyObject *__pyx_self, PyObje
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2801
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2715
  *         self.setfd(fd)
  * 
  *     def setfd(self, fd):             # <<<<<<<<<<<<<<
@@ -25407,10 +25157,10 @@ static PyObject *__pyx_pf_9csamtools_4Outs_2setfile(PyObject *__pyx_self, PyObje
  *         self.streams.append(ofd)
  */
 
-static PyObject *__pyx_pf_9csamtools_4Outs_3setfd(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_9csamtools_4Outs_3setfd[] = "Outs.setfd(self, fd)";
-static PyMethodDef __pyx_mdef_9csamtools_4Outs_3setfd = {__Pyx_NAMESTR("setfd"), (PyCFunction)__pyx_pf_9csamtools_4Outs_3setfd, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_4Outs_3setfd)};
-static PyObject *__pyx_pf_9csamtools_4Outs_3setfd(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+static PyObject *__pyx_pf_9csamtools_4Outs_setfd(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_9csamtools_4Outs_setfd[] = "Outs.setfd(self, fd)";
+static PyMethodDef __pyx_mdef_9csamtools_4Outs_setfd = {__Pyx_NAMESTR("setfd"), (PyCFunction)__pyx_pf_9csamtools_4Outs_setfd, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_4Outs_setfd)};
+static PyObject *__pyx_pf_9csamtools_4Outs_setfd(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   PyObject *__pyx_v_self = 0;
   PyObject *__pyx_v_fd = 0;
   PyObject *__pyx_v_ofd;
@@ -25421,7 +25171,7 @@ static PyObject *__pyx_pf_9csamtools_4Outs_3setfd(PyObject *__pyx_self, PyObject
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__fd,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("setfd");
-  __Pyx_TraceCall("setfd", __pyx_f[0], 2801);
+  __Pyx_TraceCall("setfd", __pyx_f[0], 2715);
   __pyx_self = __pyx_self;
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
@@ -25441,11 +25191,11 @@ static PyObject *__pyx_pf_9csamtools_4Outs_3setfd(PyObject *__pyx_self, PyObject
       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fd);
       if (likely(values[1])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("setfd", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2801; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("setfd", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2715; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "setfd") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2801; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "setfd") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2715; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_self = values[0];
     __pyx_v_fd = values[1];
@@ -25457,7 +25207,7 @@ static PyObject *__pyx_pf_9csamtools_4Outs_3setfd(PyObject *__pyx_self, PyObject
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("setfd", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2801; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("setfd", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2715; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("csamtools.Outs.setfd");
   __Pyx_RefNannyFinishContext();
@@ -25465,136 +25215,136 @@ static PyObject *__pyx_pf_9csamtools_4Outs_3setfd(PyObject *__pyx_self, PyObject
   __pyx_L4_argument_unpacking_done:;
   __pyx_v_ofd = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "csamtools.pyx":2802
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2716
  * 
  *     def setfd(self, fd):
  *         ofd = os.dup(self.id)      #  Save old stream on new unit.             # <<<<<<<<<<<<<<
  *         self.streams.append(ofd)
  *         sys.stdout.flush()          #  Buffered data goes to old stream.
  */
-  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2716; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__dup); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__dup); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2716; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__id); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__id); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2716; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2716; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
   __Pyx_GIVEREF(__pyx_t_1);
   __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2716; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   __Pyx_DECREF(__pyx_v_ofd);
   __pyx_v_ofd = __pyx_t_1;
   __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":2803
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2717
  *     def setfd(self, fd):
  *         ofd = os.dup(self.id)      #  Save old stream on new unit.
  *         self.streams.append(ofd)             # <<<<<<<<<<<<<<
  *         sys.stdout.flush()          #  Buffered data goes to old stream.
  *         sys.stderr.flush()          #  Buffered data goes to old stream.
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__streams); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__streams); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2717; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_3 = __Pyx_PyObject_Append(__pyx_t_1, __pyx_v_ofd); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_Append(__pyx_t_1, __pyx_v_ofd); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2717; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
-  /* "csamtools.pyx":2804
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2718
  *         ofd = os.dup(self.id)      #  Save old stream on new unit.
  *         self.streams.append(ofd)
  *         sys.stdout.flush()          #  Buffered data goes to old stream.             # <<<<<<<<<<<<<<
  *         sys.stderr.flush()          #  Buffered data goes to old stream.
  *         os.dup2(fd, self.id)        #  Open unit 1 on new stream.
  */
-  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__stdout); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__stdout); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__flush); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__flush); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":2805
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2719
  *         self.streams.append(ofd)
  *         sys.stdout.flush()          #  Buffered data goes to old stream.
  *         sys.stderr.flush()          #  Buffered data goes to old stream.             # <<<<<<<<<<<<<<
  *         os.dup2(fd, self.id)        #  Open unit 1 on new stream.
  *         os.close(fd)                #  Close other unit (look out, caller.)
  */
-  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__stderr); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__stderr); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__flush); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__flush); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
-  /* "csamtools.pyx":2806
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2720
  *         sys.stdout.flush()          #  Buffered data goes to old stream.
  *         sys.stderr.flush()          #  Buffered data goes to old stream.
  *         os.dup2(fd, self.id)        #  Open unit 1 on new stream.             # <<<<<<<<<<<<<<
  *         os.close(fd)                #  Close other unit (look out, caller.)
  * 
  */
-  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__dup2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__dup2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__id); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__id); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
   __Pyx_INCREF(__pyx_v_fd);
   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_fd);
   __Pyx_GIVEREF(__pyx_v_fd);
   PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
   __Pyx_GIVEREF(__pyx_t_3);
   __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2720; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
-  /* "csamtools.pyx":2807
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2721
  *         sys.stderr.flush()          #  Buffered data goes to old stream.
  *         os.dup2(fd, self.id)        #  Open unit 1 on new stream.
  *         os.close(fd)                #  Close other unit (look out, caller.)             # <<<<<<<<<<<<<<
  * 
  *     def restore(self):
  */
-  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2721; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__close); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__close); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2721; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2721; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
   __Pyx_INCREF(__pyx_v_fd);
   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_fd);
   __Pyx_GIVEREF(__pyx_v_fd);
-  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2721; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
@@ -25613,7 +25363,7 @@ static PyObject *__pyx_pf_9csamtools_4Outs_3setfd(PyObject *__pyx_self, PyObject
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2809
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2723
  *         os.close(fd)                #  Close other unit (look out, caller.)
  * 
  *     def restore(self):             # <<<<<<<<<<<<<<
@@ -25621,10 +25371,10 @@ static PyObject *__pyx_pf_9csamtools_4Outs_3setfd(PyObject *__pyx_self, PyObject
  *         if self.streams:
  */
 
-static PyObject *__pyx_pf_9csamtools_4Outs_4restore(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
-static char __pyx_doc_9csamtools_4Outs_4restore[] = "Outs.restore(self)\nrestore previous output stream";
-static PyMethodDef __pyx_mdef_9csamtools_4Outs_4restore = {__Pyx_NAMESTR("restore"), (PyCFunction)__pyx_pf_9csamtools_4Outs_4restore, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_4Outs_4restore)};
-static PyObject *__pyx_pf_9csamtools_4Outs_4restore(PyObject *__pyx_self, PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_4Outs_restore(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
+static char __pyx_doc_9csamtools_4Outs_restore[] = "Outs.restore(self)\nrestore previous output stream";
+static PyMethodDef __pyx_mdef_9csamtools_4Outs_restore = {__Pyx_NAMESTR("restore"), (PyCFunction)__pyx_pf_9csamtools_4Outs_restore, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_4Outs_restore)};
+static PyObject *__pyx_pf_9csamtools_4Outs_restore(PyObject *__pyx_self, PyObject *__pyx_v_self) {
   PyObject *__pyx_r = NULL;
   PyObject *__pyx_t_1 = NULL;
   int __pyx_t_2;
@@ -25633,133 +25383,133 @@ static PyObject *__pyx_pf_9csamtools_4Outs_4restore(PyObject *__pyx_self, PyObje
   PyObject *__pyx_t_5 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("restore");
-  __Pyx_TraceCall("restore", __pyx_f[0], 2809);
+  __Pyx_TraceCall("restore", __pyx_f[0], 2723);
   __pyx_self = __pyx_self;
 
-  /* "csamtools.pyx":2811
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2725
  *     def restore(self):
  *         '''restore previous output stream'''
  *         if self.streams:             # <<<<<<<<<<<<<<
  *             # the following was not sufficient, hence flush both stderr and stdout
  *             # os.fsync( self.id )
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__streams); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__streams); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2725; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2725; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   if (__pyx_t_2) {
 
-    /* "csamtools.pyx":2814
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2728
  *             # the following was not sufficient, hence flush both stderr and stdout
  *             # os.fsync( self.id )
  *             sys.stdout.flush()             # <<<<<<<<<<<<<<
  *             sys.stderr.flush()
  *             os.dup2(self.streams[-1], self.id)
  */
-    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2728; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__stdout); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__stdout); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2728; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__flush); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__flush); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2728; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2728; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
-    /* "csamtools.pyx":2815
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2729
  *             # os.fsync( self.id )
  *             sys.stdout.flush()
  *             sys.stderr.flush()             # <<<<<<<<<<<<<<
  *             os.dup2(self.streams[-1], self.id)
  *             os.close(self.streams[-1])
  */
-    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2729; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__stderr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__stderr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2729; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__flush); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__flush); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2729; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2729; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-    /* "csamtools.pyx":2816
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2730
  *             sys.stdout.flush()
  *             sys.stderr.flush()
  *             os.dup2(self.streams[-1], self.id)             # <<<<<<<<<<<<<<
  *             os.close(self.streams[-1])
  *             del self.streams[-1]
  */
-    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__dup2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__dup2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__streams); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__streams); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__id); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__id); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
     PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
     __Pyx_GIVEREF(__pyx_t_4);
     PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
     __Pyx_GIVEREF(__pyx_t_1);
     __pyx_t_4 = 0;
     __pyx_t_1 = 0;
-    __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-    /* "csamtools.pyx":2817
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2731
  *             sys.stderr.flush()
  *             os.dup2(self.streams[-1], self.id)
  *             os.close(self.streams[-1])             # <<<<<<<<<<<<<<
  *             del self.streams[-1]
  * 
  */
-    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_5 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__close); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__close); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__streams); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__streams); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_1, -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_1, -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
     __Pyx_GIVEREF(__pyx_t_3);
     __pyx_t_3 = 0;
-    __pyx_t_3 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Call(__pyx_t_5, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
-    /* "csamtools.pyx":2818
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2732
  *             os.dup2(self.streams[-1], self.id)
  *             os.close(self.streams[-1])
  *             del self.streams[-1]             # <<<<<<<<<<<<<<
  * 
  * def _samtools_dispatch( method,
  */
-    __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__streams); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__streams); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2732; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    if (__Pyx_DelItemInt(__pyx_t_3, -1, sizeof(long), PyInt_FromLong) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (__Pyx_DelItemInt(__pyx_t_3, -1, sizeof(long), PyInt_FromLong) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2732; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     goto __pyx_L5;
   }
@@ -25781,7 +25531,7 @@ static PyObject *__pyx_pf_9csamtools_4Outs_4restore(PyObject *__pyx_self, PyObje
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2820
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2734
  *             del self.streams[-1]
  * 
  * def _samtools_dispatch( method,             # <<<<<<<<<<<<<<
@@ -25790,8 +25540,7 @@ static PyObject *__pyx_pf_9csamtools_4Outs_4restore(PyObject *__pyx_self, PyObje
  */
 
 static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static char __pyx_doc_9csamtools__samtools_dispatch[] = "_samtools_dispatch(method, args=(), catch_stdout=True, catch_stderr=False)\ncall ``method`` in samtools providing arguments in args.\n    \n    .. note:: \n       This method redirects stdout and (optionally) stderr to capture it \n       from samtools. If for some reason stdout/stderr disappears\n       the reason might be in this method.\n\n    .. note::\n       The current implementation might only work on linux.\n       \n    .. note:: \n       This method captures stdout and stderr using temporary files, \n       which are then read into memory in their entirety. This method\n       is slow and might cause large memory overhead. \n\n    See http://bytes.com/topic/c/answers/487231-how-capture-stdout-temporarily\n    on the topic of redirecting stderr/stdout.\n    ";
-static PyMethodDef __pyx_mdef_9csamtools__samtools_dispatch = {__Pyx_NAMESTR("_samtools_dispatch"), (PyCFunction)__pyx_pf_9csamtools__samtools_dispatch, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools__samtools_dispatch)};
+static char __pyx_doc_9csamtools__samtools_dispatch[] = "_samtools_dispatch(method, args=(), catch_stdout=True, catch_stderr=False)\ncall ``method`` in samtools providing arguments in args.\n    \n    .. note:: \n       This method redirects stdout and stderr to capture it \n       from samtools. If for some reason stdout/stderr disappears\n       the reason might be in this method.\n\n    .. note::\n       The current implementation might only work on linux.\n       \n    .. note:: \n       This method captures stdout and stderr using temporary files, \n       which are then read into memory in their entirety. This method\n       is slow and might cause large memory overhead. \n\n    See http://bytes.com/topic/c/answers/487231-how-capture-stdout-temporarily\n    on the topic of redirecting stderr/stdout.\n    ";
 static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
   PyObject *__pyx_v_method = 0;
   PyObject *__pyx_v_args = 0;
@@ -25822,13 +25571,13 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__method,&__pyx_n_s__args,&__pyx_n_s__catch_stdout,&__pyx_n_s__catch_stderr,0};
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("_samtools_dispatch");
-  __Pyx_TraceCall("_samtools_dispatch", __pyx_f[0], 2820);
+  __Pyx_TraceCall("_samtools_dispatch", __pyx_f[0], 2734);
   __pyx_self = __pyx_self;
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
     PyObject* values[4] = {0,0,0,0};
 
-    /* "csamtools.pyx":2821
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2735
  * 
  * def _samtools_dispatch( method,
  *                         args = (),             # <<<<<<<<<<<<<<
@@ -25836,8 +25585,8 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
  *                         catch_stderr = False,
  */
     values[1] = ((PyObject *)__pyx_empty_tuple);
-    values[2] = __pyx_k_160;
-    values[3] = __pyx_k_161;
+    values[2] = __pyx_k_98;
+    values[3] = __pyx_k_99;
     switch (PyTuple_GET_SIZE(__pyx_args)) {
       case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
       case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
@@ -25868,7 +25617,7 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_samtools_dispatch") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2820; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_samtools_dispatch") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2734; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_method = values[0];
     __pyx_v_args = values[1];
@@ -25876,8 +25625,8 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
     __pyx_v_catch_stderr = values[3];
   } else {
     __pyx_v_args = ((PyObject *)__pyx_empty_tuple);
-    __pyx_v_catch_stdout = __pyx_k_160;
-    __pyx_v_catch_stderr = __pyx_k_161;
+    __pyx_v_catch_stdout = __pyx_k_98;
+    __pyx_v_catch_stderr = __pyx_k_99;
     switch (PyTuple_GET_SIZE(__pyx_args)) {
       case  4: __pyx_v_catch_stderr = PyTuple_GET_ITEM(__pyx_args, 3);
       case  3: __pyx_v_catch_stdout = PyTuple_GET_ITEM(__pyx_args, 2);
@@ -25889,7 +25638,7 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("_samtools_dispatch", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2820; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("_samtools_dispatch", 0, 1, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2734; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("csamtools._samtools_dispatch");
   __Pyx_RefNannyFinishContext();
@@ -25905,73 +25654,73 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
   __pyx_v_out_stdout = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_out_stderr = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "csamtools.pyx":2848
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2762
  * 
  *     # some special cases
  *     if method == "index":             # <<<<<<<<<<<<<<
  *         if not os.path.exists( args[0] ):
  *             raise IOError( "No such file or directory: '%s'" % args[0] )
  */
-  __pyx_t_1 = PyObject_RichCompare(__pyx_v_method, ((PyObject *)__pyx_n_s__index), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2848; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_method, ((PyObject *)__pyx_n_s__index), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2848; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2762; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   if (__pyx_t_2) {
 
-    /* "csamtools.pyx":2849
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2763
  *     # some special cases
  *     if method == "index":
  *         if not os.path.exists( args[0] ):             # <<<<<<<<<<<<<<
  *             raise IOError( "No such file or directory: '%s'" % args[0] )
  * 
  */
-    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__path); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__path); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__exists); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__exists); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_args, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_args, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
+    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
     PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
     __Pyx_GIVEREF(__pyx_t_3);
     __pyx_t_3 = 0;
-    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
-    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __pyx_t_5 = (!__pyx_t_2);
     if (__pyx_t_5) {
 
-      /* "csamtools.pyx":2850
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2764
  *     if method == "index":
  *         if not os.path.exists( args[0] ):
  *             raise IOError( "No such file or directory: '%s'" % args[0] )             # <<<<<<<<<<<<<<
  * 
  *     # redirect stderr and stdout to file
  */
-      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_args, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_args, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
-      __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_162), __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_100), __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_4));
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
       PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_4));
       __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
       __pyx_t_4 = 0;
-      __pyx_t_4 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_4);
-      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
       __Pyx_Raise(__pyx_t_4, 0, 0);
       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L7;
     }
     __pyx_L7:;
@@ -25979,29 +25728,29 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
   }
   __pyx_L6:;
 
-  /* "csamtools.pyx":2853
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2767
  * 
  *     # redirect stderr and stdout to file
  *     if catch_stderr:             # <<<<<<<<<<<<<<
  *         stderr_h, stderr_f = tempfile.mkstemp()
  *         stderr_save = Outs( sys.stderr.fileno() )
  */
-  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_catch_stderr); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_catch_stderr); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2767; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_5) {
 
-    /* "csamtools.pyx":2854
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2768
  *     # redirect stderr and stdout to file
  *     if catch_stderr:
  *         stderr_h, stderr_f = tempfile.mkstemp()             # <<<<<<<<<<<<<<
  *         stderr_save = Outs( sys.stderr.fileno() )
  *         stderr_save.setfd( stderr_h )
  */
-    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__tempfile); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__tempfile); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
-    __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__mkstemp); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__mkstemp); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     if (PyTuple_CheckExact(__pyx_t_4) && likely(PyTuple_GET_SIZE(__pyx_t_4) == 2)) {
@@ -26016,14 +25765,14 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
       __pyx_v_stderr_f = __pyx_t_1;
       __pyx_t_1 = 0;
     } else {
-      __pyx_t_6 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-      __pyx_t_3 = __Pyx_UnpackItem(__pyx_t_6, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = __Pyx_UnpackItem(__pyx_t_6, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
-      __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_6, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_6, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      if (__Pyx_EndUnpack(__pyx_t_6, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      if (__Pyx_EndUnpack(__pyx_t_6, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
       __Pyx_DECREF(__pyx_v_stderr_h);
       __pyx_v_stderr_h = __pyx_t_3;
@@ -26033,85 +25782,85 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
       __pyx_t_1 = 0;
     }
 
-    /* "csamtools.pyx":2855
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2769
  *     if catch_stderr:
  *         stderr_h, stderr_f = tempfile.mkstemp()
  *         stderr_save = Outs( sys.stderr.fileno() )             # <<<<<<<<<<<<<<
  *         stderr_save.setfd( stderr_h )
  * 
  */
-    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__Outs); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__Outs); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
-    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__stderr); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__stderr); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__fileno); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__fileno); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
     __Pyx_GIVEREF(__pyx_t_3);
     __pyx_t_3 = 0;
-    __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __Pyx_DECREF(__pyx_v_stderr_save);
     __pyx_v_stderr_save = __pyx_t_3;
     __pyx_t_3 = 0;
 
-    /* "csamtools.pyx":2856
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2770
  *         stderr_h, stderr_f = tempfile.mkstemp()
  *         stderr_save = Outs( sys.stderr.fileno() )
  *         stderr_save.setfd( stderr_h )             # <<<<<<<<<<<<<<
  * 
  *     if catch_stdout:
  */
-    __pyx_t_3 = PyObject_GetAttr(__pyx_v_stderr_save, __pyx_n_s__setfd); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(__pyx_v_stderr_save, __pyx_n_s__setfd); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
     __Pyx_INCREF(__pyx_v_stderr_h);
     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_stderr_h);
     __Pyx_GIVEREF(__pyx_v_stderr_h);
-    __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_Call(__pyx_t_3, __pyx_t_1, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     goto __pyx_L8;
   }
   __pyx_L8:;
 
-  /* "csamtools.pyx":2858
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2772
  *         stderr_save.setfd( stderr_h )
  * 
  *     if catch_stdout:             # <<<<<<<<<<<<<<
  *         stdout_h, stdout_f = tempfile.mkstemp()
  *         stdout_save = Outs( sys.stdout.fileno() )
  */
-  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_catch_stdout); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_catch_stdout); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_5) {
 
-    /* "csamtools.pyx":2859
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2773
  * 
  *     if catch_stdout:
  *         stdout_h, stdout_f = tempfile.mkstemp()             # <<<<<<<<<<<<<<
  *         stdout_save = Outs( sys.stdout.fileno() )
  *         stdout_save.setfd( stdout_h )
  */
-    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__tempfile); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__tempfile); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
-    __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__mkstemp); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__mkstemp); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     if (PyTuple_CheckExact(__pyx_t_4) && likely(PyTuple_GET_SIZE(__pyx_t_4) == 2)) {
@@ -26126,14 +25875,14 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
       __pyx_v_stdout_f = __pyx_t_3;
       __pyx_t_3 = 0;
     } else {
-      __pyx_t_6 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-      __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_6, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_6, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __pyx_t_3 = __Pyx_UnpackItem(__pyx_t_6, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = __Pyx_UnpackItem(__pyx_t_6, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
-      if (__Pyx_EndUnpack(__pyx_t_6, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      if (__Pyx_EndUnpack(__pyx_t_6, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
       __Pyx_DECREF(__pyx_v_stdout_h);
       __pyx_v_stdout_h = __pyx_t_1;
@@ -26143,111 +25892,117 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
       __pyx_t_3 = 0;
     }
 
-    /* "csamtools.pyx":2860
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2774
  *     if catch_stdout:
  *         stdout_h, stdout_f = tempfile.mkstemp()
  *         stdout_save = Outs( sys.stdout.fileno() )             # <<<<<<<<<<<<<<
  *         stdout_save.setfd( stdout_h )
  * 
  */
-    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__Outs); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2860; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__Outs); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
-    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2860; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__stdout); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2860; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__stdout); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__fileno); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2860; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__fileno); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2860; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2860; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
     PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
     __Pyx_GIVEREF(__pyx_t_1);
     __pyx_t_1 = 0;
-    __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2860; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __Pyx_DECREF(__pyx_v_stdout_save);
     __pyx_v_stdout_save = __pyx_t_1;
     __pyx_t_1 = 0;
 
-    /* "csamtools.pyx":2861
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2775
  *         stdout_h, stdout_f = tempfile.mkstemp()
  *         stdout_save = Outs( sys.stdout.fileno() )
  *         stdout_save.setfd( stdout_h )             # <<<<<<<<<<<<<<
  * 
  *         # patch for `samtools view`
  */
-    __pyx_t_1 = PyObject_GetAttr(__pyx_v_stdout_save, __pyx_n_s__setfd); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2861; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_stdout_save, __pyx_n_s__setfd); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2861; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
     __Pyx_INCREF(__pyx_v_stdout_h);
     PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_stdout_h);
     __Pyx_GIVEREF(__pyx_v_stdout_h);
-    __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2861; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_Call(__pyx_t_1, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
-    /* "csamtools.pyx":2866
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2780
  *         # samtools `view` closes stdout, from which I can not
  *         # recover. Thus redirect output to file with -o option.
  *         if method == "view":             # <<<<<<<<<<<<<<
  *             if "-o" in args: raise ValueError("option -o is forbidden in samtools view")
  *             args = ( "-o", stdout_f ) + args
  */
-    __pyx_t_4 = PyObject_RichCompare(__pyx_v_method, ((PyObject *)__pyx_n_s__view), Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_RichCompare(__pyx_v_method, ((PyObject *)__pyx_n_s__view), Py_EQ); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
-    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     if (__pyx_t_5) {
 
-      /* "csamtools.pyx":2867
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2781
  *         # recover. Thus redirect output to file with -o option.
  *         if method == "view":
  *             if "-o" in args: raise ValueError("option -o is forbidden in samtools view")             # <<<<<<<<<<<<<<
  *             args = ( "-o", stdout_f ) + args
  * 
  */
-      __pyx_t_5 = ((PySequence_Contains(__pyx_v_args, ((PyObject *)__pyx_kp_s_163)))); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = ((PySequence_Contains(__pyx_v_args, ((PyObject *)__pyx_kp_s_101)))); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       if (__pyx_t_5) {
-        __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_165), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_4);
-        __Pyx_Raise(__pyx_t_4, 0, 0);
+        __Pyx_INCREF(((PyObject *)__pyx_kp_s_102));
+        PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_102));
+        __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_102));
+        __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_3);
         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_Raise(__pyx_t_3, 0, 0);
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         goto __pyx_L11;
       }
       __pyx_L11:;
 
-      /* "csamtools.pyx":2868
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2782
  *         if method == "view":
  *             if "-o" in args: raise ValueError("option -o is forbidden in samtools view")
  *             args = ( "-o", stdout_f ) + args             # <<<<<<<<<<<<<<
  * 
- *     # do the function call to samtools
+ * 
  */
-      __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(((PyObject *)__pyx_t_4));
-      __Pyx_INCREF(((PyObject *)__pyx_kp_s_163));
-      PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_163));
-      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_163));
+      __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_101));
+      PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_101));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_101));
       __Pyx_INCREF(__pyx_v_stdout_f);
-      PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_stdout_f);
+      PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_stdout_f);
       __Pyx_GIVEREF(__pyx_v_stdout_f);
-      __pyx_t_3 = PyNumber_Add(((PyObject *)__pyx_t_4), __pyx_v_args); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_3);
-      __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
+      __pyx_t_4 = PyNumber_Add(__pyx_t_3, __pyx_v_args); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
       __Pyx_DECREF(__pyx_v_args);
-      __pyx_v_args = __pyx_t_3;
-      __pyx_t_3 = 0;
+      __pyx_v_args = __pyx_t_4;
+      __pyx_t_4 = 0;
       goto __pyx_L10;
     }
     __pyx_L10:;
@@ -26255,17 +26010,17 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
   }
   __pyx_L9:;
 
-  /* "csamtools.pyx":2874
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2789
  *     cdef int i, n, retval
  * 
  *     n = len(args)             # <<<<<<<<<<<<<<
  *     # allocate two more for first (dummy) argument (contains command)
  *     cargs = <char**>calloc( n+2, sizeof( char *) )
  */
-  __pyx_t_7 = PyObject_Length(__pyx_v_args); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2874; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_7 = PyObject_Length(__pyx_v_args); if (unlikely(__pyx_t_7 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_n = __pyx_t_7;
 
-  /* "csamtools.pyx":2876
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2791
  *     n = len(args)
  *     # allocate two more for first (dummy) argument (contains command)
  *     cargs = <char**>calloc( n+2, sizeof( char *) )             # <<<<<<<<<<<<<<
@@ -26274,7 +26029,7 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
  */
   __pyx_v_cargs = ((char **)calloc((__pyx_v_n + 2), (sizeof(char *))));
 
-  /* "csamtools.pyx":2877
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2792
  *     # allocate two more for first (dummy) argument (contains command)
  *     cargs = <char**>calloc( n+2, sizeof( char *) )
  *     cargs[0] = "samtools"             # <<<<<<<<<<<<<<
@@ -26283,43 +26038,43 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
  */
   (__pyx_v_cargs[0]) = __pyx_k__samtools;
 
-  /* "csamtools.pyx":2878
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2793
  *     cargs = <char**>calloc( n+2, sizeof( char *) )
  *     cargs[0] = "samtools"
  *     cargs[1] = method             # <<<<<<<<<<<<<<
  *     for i from 0 <= i < n: cargs[i+2] = args[i]
- * 
+ *     retval = pysam_dispatch(n+2, cargs)
  */
-  __pyx_t_8 = PyBytes_AsString(__pyx_v_method); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2878; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = PyBytes_AsString(__pyx_v_method); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   (__pyx_v_cargs[1]) = __pyx_t_8;
 
-  /* "csamtools.pyx":2879
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2794
  *     cargs[0] = "samtools"
  *     cargs[1] = method
  *     for i from 0 <= i < n: cargs[i+2] = args[i]             # <<<<<<<<<<<<<<
- * 
  *     retval = pysam_dispatch(n+2, cargs)
+ *     free( cargs )
  */
   __pyx_t_9 = __pyx_v_n;
   for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_9; __pyx_v_i++) {
-    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_args, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2879; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_8 = PyBytes_AsString(__pyx_t_3); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2879; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_args, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_8 = PyBytes_AsString(__pyx_t_4); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     (__pyx_v_cargs[(__pyx_v_i + 2)]) = __pyx_t_8;
   }
 
-  /* "csamtools.pyx":2881
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2795
+ *     cargs[1] = method
  *     for i from 0 <= i < n: cargs[i+2] = args[i]
- * 
  *     retval = pysam_dispatch(n+2, cargs)             # <<<<<<<<<<<<<<
  *     free( cargs )
  * 
  */
   __pyx_v_retval = pysam_dispatch((__pyx_v_n + 2), __pyx_v_cargs);
 
-  /* "csamtools.pyx":2882
- * 
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2796
+ *     for i from 0 <= i < n: cargs[i+2] = args[i]
  *     retval = pysam_dispatch(n+2, cargs)
  *     free( cargs )             # <<<<<<<<<<<<<<
  * 
@@ -26327,92 +26082,92 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
  */
   free(__pyx_v_cargs);
 
-  /* "csamtools.pyx":2886
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2800
  *     # restore stdout/stderr. This will also flush, so
  *     # needs to be before reading back the file contents
  *     if catch_stdout:             # <<<<<<<<<<<<<<
  *         stdout_save.restore()
  *         out_stdout = open( stdout_f, "r").readlines()
  */
-  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_catch_stdout); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_catch_stdout); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_5) {
 
-    /* "csamtools.pyx":2887
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2801
  *     # needs to be before reading back the file contents
  *     if catch_stdout:
  *         stdout_save.restore()             # <<<<<<<<<<<<<<
  *         out_stdout = open( stdout_f, "r").readlines()
  *         os.remove( stdout_f )
  */
-    __pyx_t_3 = PyObject_GetAttr(__pyx_v_stdout_save, __pyx_n_s__restore); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_GetAttr(__pyx_v_stdout_save, __pyx_n_s__restore); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2801; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
-    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2801; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
-    /* "csamtools.pyx":2888
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2802
  *     if catch_stdout:
  *         stdout_save.restore()
  *         out_stdout = open( stdout_f, "r").readlines()             # <<<<<<<<<<<<<<
  *         os.remove( stdout_f )
  *     else:
  */
-    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
+    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
     __Pyx_INCREF(__pyx_v_stdout_f);
-    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_stdout_f);
+    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_stdout_f);
     __Pyx_GIVEREF(__pyx_v_stdout_f);
     __Pyx_INCREF(((PyObject *)__pyx_n_s__r));
-    PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_n_s__r));
+    PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_n_s__r));
     __Pyx_GIVEREF(((PyObject *)__pyx_n_s__r));
-    __pyx_t_3 = PyObject_Call(__pyx_builtin_open, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_3);
-    __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
-    __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__readlines); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_Call(__pyx_builtin_open, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__readlines); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __Pyx_DECREF(__pyx_v_out_stdout);
-    __pyx_v_out_stdout = __pyx_t_3;
-    __pyx_t_3 = 0;
+    __pyx_v_out_stdout = __pyx_t_4;
+    __pyx_t_4 = 0;
 
-    /* "csamtools.pyx":2889
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2803
  *         stdout_save.restore()
  *         out_stdout = open( stdout_f, "r").readlines()
  *         os.remove( stdout_f )             # <<<<<<<<<<<<<<
  *     else:
  *         out_stdout = []
  */
-    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__remove); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__remove); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
-    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
     __Pyx_INCREF(__pyx_v_stdout_f);
-    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_stdout_f);
+    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_stdout_f);
     __Pyx_GIVEREF(__pyx_v_stdout_f);
-    __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     goto __pyx_L14;
   }
   /*else*/ {
 
-    /* "csamtools.pyx":2891
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2805
  *         os.remove( stdout_f )
  *     else:
  *         out_stdout = []             # <<<<<<<<<<<<<<
  * 
  *     if catch_stderr:
  */
-    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2891; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_1));
     __Pyx_DECREF(__pyx_v_out_stdout);
     __pyx_v_out_stdout = ((PyObject *)__pyx_t_1);
@@ -26420,100 +26175,100 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
   }
   __pyx_L14:;
 
-  /* "csamtools.pyx":2893
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2807
  *         out_stdout = []
  * 
  *     if catch_stderr:             # <<<<<<<<<<<<<<
  *         stderr_save.restore()
  *         out_stderr = open( stderr_f, "r").readlines()
  */
-  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_catch_stderr); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_catch_stderr); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_5) {
 
-    /* "csamtools.pyx":2894
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2808
  * 
  *     if catch_stderr:
  *         stderr_save.restore()             # <<<<<<<<<<<<<<
  *         out_stderr = open( stderr_f, "r").readlines()
  *         os.remove( stderr_f )
  */
-    __pyx_t_1 = PyObject_GetAttr(__pyx_v_stderr_save, __pyx_n_s__restore); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_stderr_save, __pyx_n_s__restore); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
-    /* "csamtools.pyx":2895
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2809
  *     if catch_stderr:
  *         stderr_save.restore()
  *         out_stderr = open( stderr_f, "r").readlines()             # <<<<<<<<<<<<<<
  *         os.remove( stderr_f )
  *     else:
  */
-    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2895; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+    __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
     __Pyx_INCREF(__pyx_v_stderr_f);
-    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_stderr_f);
+    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_stderr_f);
     __Pyx_GIVEREF(__pyx_v_stderr_f);
     __Pyx_INCREF(((PyObject *)__pyx_n_s__r));
-    PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_n_s__r));
+    PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_n_s__r));
     __Pyx_GIVEREF(((PyObject *)__pyx_n_s__r));
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_open, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2895; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_open, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
-    __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__readlines); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2895; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__readlines); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2895; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     __Pyx_DECREF(__pyx_v_out_stderr);
     __pyx_v_out_stderr = __pyx_t_1;
     __pyx_t_1 = 0;
 
-    /* "csamtools.pyx":2896
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2810
  *         stderr_save.restore()
  *         out_stderr = open( stderr_f, "r").readlines()
  *         os.remove( stderr_f )             # <<<<<<<<<<<<<<
  *     else:
  *         out_stderr = []
  */
-    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__remove); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__remove); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
     __Pyx_INCREF(__pyx_v_stderr_f);
     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_stderr_f);
     __Pyx_GIVEREF(__pyx_v_stderr_f);
-    __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_4);
-    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+    __pyx_t_3 = PyObject_Call(__pyx_t_4, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     goto __pyx_L15;
   }
   /*else*/ {
 
-    /* "csamtools.pyx":2898
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2812
  *         os.remove( stderr_f )
  *     else:
  *         out_stderr = []             # <<<<<<<<<<<<<<
  * 
  *     return retval, out_stderr, out_stdout
  */
-    __pyx_t_4 = PyList_New(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2898; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
+    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
     __Pyx_DECREF(__pyx_v_out_stderr);
-    __pyx_v_out_stderr = ((PyObject *)__pyx_t_4);
-    __pyx_t_4 = 0;
+    __pyx_v_out_stderr = ((PyObject *)__pyx_t_3);
+    __pyx_t_3 = 0;
   }
   __pyx_L15:;
 
-  /* "csamtools.pyx":2900
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2814
  *         out_stderr = []
  * 
  *     return retval, out_stderr, out_stdout             # <<<<<<<<<<<<<<
@@ -26521,20 +26276,20 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
  * cdef class SNPCall:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_4 = PyInt_FromLong(__pyx_v_retval); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2900; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2900; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_4);
-  __Pyx_GIVEREF(__pyx_t_4);
+  __pyx_t_3 = PyInt_FromLong(__pyx_v_retval); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
+  __Pyx_GIVEREF(__pyx_t_3);
   __Pyx_INCREF(__pyx_v_out_stderr);
   PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_out_stderr);
   __Pyx_GIVEREF(__pyx_v_out_stderr);
   __Pyx_INCREF(__pyx_v_out_stdout);
   PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_out_stdout);
   __Pyx_GIVEREF(__pyx_v_out_stdout);
-  __pyx_t_4 = 0;
-  __pyx_r = ((PyObject *)__pyx_t_1);
+  __pyx_t_3 = 0;
+  __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
   goto __pyx_L0;
 
@@ -26563,7 +26318,7 @@ static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, Py
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2915
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2829
  *     property tid:
  *         '''the chromosome ID as is defined in the header'''
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -26577,9 +26332,9 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall_3tid___get__(PyObject *__pyx_v_sel
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2915);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2829);
 
-  /* "csamtools.pyx":2916
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2830
  *         '''the chromosome ID as is defined in the header'''
  *         def __get__(self):
  *             return self._tid             # <<<<<<<<<<<<<<
@@ -26587,7 +26342,7 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall_3tid___get__(PyObject *__pyx_v_sel
  *     property pos:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_SNPCall *)__pyx_v_self)->_tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_SNPCall *)__pyx_v_self)->_tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -26606,7 +26361,7 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall_3tid___get__(PyObject *__pyx_v_sel
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2920
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2834
  *     property pos:
  *        '''nucleotide position of SNP.'''
  *        def __get__(self): return self._pos             # <<<<<<<<<<<<<<
@@ -26620,9 +26375,9 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall_3pos___get__(PyObject *__pyx_v_sel
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2920);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2834);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_SNPCall *)__pyx_v_self)->_pos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_SNPCall *)__pyx_v_self)->_pos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -26641,7 +26396,7 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall_3pos___get__(PyObject *__pyx_v_sel
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2924
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2838
  *     property reference_base:
  *        '''reference base at pos. ``N`` if no reference sequence supplied.'''
  *        def __get__(self): return PyString_FromStringAndSize( &self._reference_base, 1 )             # <<<<<<<<<<<<<<
@@ -26655,9 +26410,9 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall_14reference_base___get__(PyObject
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2924);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2838);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyString_FromStringAndSize((&((struct __pyx_obj_9csamtools_SNPCall *)__pyx_v_self)->_reference_base), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyString_FromStringAndSize((&((struct __pyx_obj_9csamtools_SNPCall *)__pyx_v_self)->_reference_base), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -26676,7 +26431,7 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall_14reference_base___get__(PyObject
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2928
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2842
  *     property genotype:
  *        '''the genotype called.'''
  *        def __get__(self): return PyString_FromStringAndSize( &self._genotype, 1 )             # <<<<<<<<<<<<<<
@@ -26690,9 +26445,9 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall_8genotype___get__(PyObject *__pyx_
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2928);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2842);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyString_FromStringAndSize((&((struct __pyx_obj_9csamtools_SNPCall *)__pyx_v_self)->_genotype), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyString_FromStringAndSize((&((struct __pyx_obj_9csamtools_SNPCall *)__pyx_v_self)->_genotype), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -26711,7 +26466,7 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall_8genotype___get__(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2932
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2846
  *     property consensus_quality:
  *        '''the genotype quality (Phred-scaled).'''
  *        def __get__(self): return self._consensus_quality             # <<<<<<<<<<<<<<
@@ -26725,9 +26480,9 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall_17consensus_quality___get__(PyObje
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2932);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2846);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_SNPCall *)__pyx_v_self)->_consensus_quality); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_SNPCall *)__pyx_v_self)->_consensus_quality); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -26746,7 +26501,7 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall_17consensus_quality___get__(PyObje
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2936
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2850
  *     property snp_quality:
  *        '''the snp quality (Phred scaled) - probability of consensus being identical to reference sequence.'''
  *        def __get__(self): return self._snp_quality             # <<<<<<<<<<<<<<
@@ -26760,9 +26515,9 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall_11snp_quality___get__(PyObject *__
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2936);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2850);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_SNPCall *)__pyx_v_self)->_snp_quality); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2936; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_SNPCall *)__pyx_v_self)->_snp_quality); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -26781,7 +26536,7 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall_11snp_quality___get__(PyObject *__
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2940
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2854
  *     property mapping_quality:
  *        '''the root mean square (rms) of the mapping quality of all reads involved in the call.'''
  *        def __get__(self): return self._rms_mapping_quality             # <<<<<<<<<<<<<<
@@ -26795,9 +26550,9 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall_15mapping_quality___get__(PyObject
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2940);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2854);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_SNPCall *)__pyx_v_self)->_rms_mapping_quality); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_SNPCall *)__pyx_v_self)->_rms_mapping_quality); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -26816,7 +26571,7 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall_15mapping_quality___get__(PyObject
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2944
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2858
  *     property coverage:
  *        '''coverage or read depth - the number of reads involved in the call.'''
  *        def __get__(self): return self._coverage             # <<<<<<<<<<<<<<
@@ -26830,9 +26585,9 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall_8coverage___get__(PyObject *__pyx_
   PyObject *__pyx_t_1 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__");
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2944);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2858);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_SNPCall *)__pyx_v_self)->_coverage); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2944; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_SNPCall *)__pyx_v_self)->_coverage); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -26851,7 +26606,7 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall_8coverage___get__(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "csamtools.pyx":2946
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2860
  *        def __get__(self): return self._coverage
  * 
  *     def __str__(self):             # <<<<<<<<<<<<<<
@@ -26874,9 +26629,9 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall___str__(PyObject *__pyx_v_self) {
   PyObject *__pyx_t_10 = NULL;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__str__");
-  __Pyx_TraceCall("__str__", __pyx_f[0], 2946);
+  __Pyx_TraceCall("__str__", __pyx_f[0], 2860);
 
-  /* "csamtools.pyx":2948
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2862
  *     def __str__(self):
  * 
  *         return "\t".join( map(str, (             # <<<<<<<<<<<<<<
@@ -26884,90 +26639,90 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall___str__(PyObject *__pyx_v_self) {
  *                     self.pos,
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_1), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_1), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
 
-  /* "csamtools.pyx":2949
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2863
  * 
  *         return "\t".join( map(str, (
  *                     self.tid,             # <<<<<<<<<<<<<<
  *                     self.pos,
  *                     self.reference_base,
  */
-  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__tid); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2949; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__tid); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2863; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
 
-  /* "csamtools.pyx":2950
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2864
  *         return "\t".join( map(str, (
  *                     self.tid,
  *                     self.pos,             # <<<<<<<<<<<<<<
  *                     self.reference_base,
  *                     self.genotype,
  */
-  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2950; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
 
-  /* "csamtools.pyx":2951
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2865
  *                     self.tid,
  *                     self.pos,
  *                     self.reference_base,             # <<<<<<<<<<<<<<
  *                     self.genotype,
  *                     self.consensus_quality,
  */
-  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__reference_base); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2951; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__reference_base); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2865; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
 
-  /* "csamtools.pyx":2952
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2866
  *                     self.pos,
  *                     self.reference_base,
  *                     self.genotype,             # <<<<<<<<<<<<<<
  *                     self.consensus_quality,
  *                     self.snp_quality,
  */
-  __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__genotype); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2952; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__genotype); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
 
-  /* "csamtools.pyx":2953
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2867
  *                     self.reference_base,
  *                     self.genotype,
  *                     self.consensus_quality,             # <<<<<<<<<<<<<<
  *                     self.snp_quality,
  *                     self.mapping_quality,
  */
-  __pyx_t_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__consensus_quality); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__consensus_quality); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_6);
 
-  /* "csamtools.pyx":2954
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2868
  *                     self.genotype,
  *                     self.consensus_quality,
  *                     self.snp_quality,             # <<<<<<<<<<<<<<
  *                     self.mapping_quality,
  *                     self.coverage ) ) )
  */
-  __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__snp_quality); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2954; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__snp_quality); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_7);
 
-  /* "csamtools.pyx":2955
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2869
  *                     self.consensus_quality,
  *                     self.snp_quality,
  *                     self.mapping_quality,             # <<<<<<<<<<<<<<
  *                     self.coverage ) ) )
  * 
  */
-  __pyx_t_8 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__mapping_quality); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2955; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__mapping_quality); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2869; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_8);
 
-  /* "csamtools.pyx":2956
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2870
  *                     self.snp_quality,
  *                     self.mapping_quality,
  *                     self.coverage ) ) )             # <<<<<<<<<<<<<<
  * 
  * 
  */
-  __pyx_t_9 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__coverage); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_9 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__coverage); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_9);
-  __pyx_t_10 = PyTuple_New(8); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2949; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_10));
+  __pyx_t_10 = PyTuple_New(8); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2863; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_10);
   PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_2);
   __Pyx_GIVEREF(__pyx_t_2);
   PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_3);
@@ -26992,26 +26747,26 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall___str__(PyObject *__pyx_v_self) {
   __pyx_t_7 = 0;
   __pyx_t_8 = 0;
   __pyx_t_9 = 0;
-  __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_9));
-  __Pyx_INCREF(((PyObject *)((PyObject*)(&PyString_Type))));
-  PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)((PyObject*)(&PyString_Type))));
-  __Pyx_GIVEREF(((PyObject *)((PyObject*)(&PyString_Type))));
-  PyTuple_SET_ITEM(__pyx_t_9, 1, ((PyObject *)__pyx_t_10));
-  __Pyx_GIVEREF(((PyObject *)__pyx_t_10));
+  __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_9);
+  __Pyx_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
+  PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)((PyObject*)&PyString_Type)));
+  __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
+  PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_10);
+  __Pyx_GIVEREF(__pyx_t_10);
   __pyx_t_10 = 0;
-  __pyx_t_10 = PyObject_Call(__pyx_builtin_map, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_10 = PyObject_Call(__pyx_builtin_map, __pyx_t_9, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_10);
-  __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
-  __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_9));
+  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+  __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_9);
   PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_10);
   __Pyx_GIVEREF(__pyx_t_10);
   __pyx_t_10 = 0;
-  __pyx_t_10 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2948; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_10 = PyObject_Call(__pyx_t_1, __pyx_t_9, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_10);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
+  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
   __pyx_r = __pyx_t_10;
   __pyx_t_10 = 0;
   goto __pyx_L0;
@@ -27038,401 +26793,533 @@ static PyObject *__pyx_pf_9csamtools_7SNPCall___str__(PyObject *__pyx_v_self) {
   return __pyx_r;
 }
 
-/* "csamtools.pyx":3472
- *     cdef int owns_samfile
- * 
- *     def __init__(self, Samfile samfile, int reopen = True ):             # <<<<<<<<<<<<<<
- *         self.samfile = samfile
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2891
+ *     cdef IteratorColumn iter
  * 
+ *     def __cinit__(self,             # <<<<<<<<<<<<<<
+ *                   IteratorColumn iterator_column,
+ *                   **kwargs ):
  */
 
-static int __pyx_pf_9csamtools_12IndexedReads___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
-static int __pyx_pf_9csamtools_12IndexedReads___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
-  struct __pyx_obj_9csamtools_Samfile *__pyx_v_samfile = 0;
-  int __pyx_v_reopen;
-  PyObject *__pyx_v_mode;
-  PyObject *__pyx_v_store;
+static int __pyx_pf_9csamtools_13SNPCallerBase___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pf_9csamtools_13SNPCallerBase___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  struct __pyx_obj_9csamtools_IteratorColumn *__pyx_v_iterator_column = 0;
+  PyObject *__pyx_v_kwargs = 0;
   int __pyx_r;
   PyObject *__pyx_t_1 = NULL;
   PyObject *__pyx_t_2 = NULL;
-  char *__pyx_t_3;
-  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__samfile,&__pyx_n_s__reopen,0};
+  int __pyx_t_3;
+  float __pyx_t_4;
+  int __pyx_t_5;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__iterator_column,0};
   __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("__init__");
-  __Pyx_TraceCall("__init__", __pyx_f[0], 3472);
+  __Pyx_RefNannySetupContext("__cinit__");
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 2891);
+  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
+  __Pyx_GOTREF(__pyx_v_kwargs);
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
-    PyObject* values[2] = {0,0};
+    PyObject* values[1] = {0};
     switch (PyTuple_GET_SIZE(__pyx_args)) {
-      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
       case  0: break;
       default: goto __pyx_L5_argtuple_error;
     }
     switch (PyTuple_GET_SIZE(__pyx_args)) {
       case  0:
-      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__samfile);
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__iterator_column);
       if (likely(values[0])) kw_args--;
       else goto __pyx_L5_argtuple_error;
-      case  1:
-      if (kw_args > 0) {
-        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reopen);
-        if (value) { values[1] = value; kw_args--; }
-      }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3472; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-    }
-    __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)values[0]);
-    if (values[1]) {
-      __pyx_v_reopen = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_reopen == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3472; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-    } else {
-      __pyx_v_reopen = ((int)1);
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2891; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
+    __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)values[0]);
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
+    goto __pyx_L5_argtuple_error;
   } else {
-    __pyx_v_reopen = ((int)1);
-    switch (PyTuple_GET_SIZE(__pyx_args)) {
-      case  2: __pyx_v_reopen = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_reopen == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3472; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-      case  1: __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)PyTuple_GET_ITEM(__pyx_args, 0));
-      break;
-      default: goto __pyx_L5_argtuple_error;
-    }
+    __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)PyTuple_GET_ITEM(__pyx_args, 0));
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3472; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2891; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
-  __Pyx_AddTraceback("csamtools.IndexedReads.__init__");
+  __Pyx_DECREF(__pyx_v_kwargs);
+  __Pyx_AddTraceback("csamtools.SNPCallerBase.__cinit__");
   __Pyx_RefNannyFinishContext();
   return -1;
   __pyx_L4_argument_unpacking_done:;
-  __pyx_v_mode = Py_None; __Pyx_INCREF(Py_None);
-  __pyx_v_store = Py_None; __Pyx_INCREF(Py_None);
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_iterator_column), __pyx_ptype_9csamtools_IteratorColumn, 1, "iterator_column", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2892; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "csamtools.pyx":3473
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2895
+ *                   **kwargs ):
  * 
- *     def __init__(self, Samfile samfile, int reopen = True ):
- *         self.samfile = samfile             # <<<<<<<<<<<<<<
+ *         self.iter = iterator_column             # <<<<<<<<<<<<<<
+ *         self.c =  bam_maqcns_init()
  * 
- *         if samfile.isbam: mode = "rb"
  */
-  __Pyx_INCREF(((PyObject *)__pyx_v_samfile));
-  __Pyx_GIVEREF(((PyObject *)__pyx_v_samfile));
-  __Pyx_GOTREF(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->samfile);
-  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->samfile));
-  ((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->samfile = __pyx_v_samfile;
+  __Pyx_INCREF(((PyObject *)__pyx_v_iterator_column));
+  __Pyx_GIVEREF(((PyObject *)__pyx_v_iterator_column));
+  __Pyx_GOTREF(((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->iter);
+  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->iter));
+  ((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->iter = __pyx_v_iterator_column;
 
-  /* "csamtools.pyx":3475
- *         self.samfile = samfile
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2896
  * 
- *         if samfile.isbam: mode = "rb"             # <<<<<<<<<<<<<<
- *         else: mode = "r"
+ *         self.iter = iterator_column
+ *         self.c =  bam_maqcns_init()             # <<<<<<<<<<<<<<
  * 
+ *         # set the default parameterization according to
  */
-  if (__pyx_v_samfile->isbam) {
-    __Pyx_INCREF(((PyObject *)__pyx_n_s__rb));
-    __Pyx_DECREF(__pyx_v_mode);
-    __pyx_v_mode = ((PyObject *)__pyx_n_s__rb);
-    goto __pyx_L6;
-  }
-  /*else*/ {
+  ((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->c = bam_maqcns_init();
 
-    /* "csamtools.pyx":3476
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2902
  * 
- *         if samfile.isbam: mode = "rb"
- *         else: mode = "r"             # <<<<<<<<<<<<<<
+ *         # new default mode for samtools >0.1.10
+ *         self.c.errmod = kwargs.get( "errmod", BAM_ERRMOD_MAQ2 )             # <<<<<<<<<<<<<<
  * 
- *         # reopen the file - note that this makes the iterator
+ *         self.c.min_baseQ = kwargs.get( "min_baseQ", 13 )
  */
-    __Pyx_INCREF(((PyObject *)__pyx_n_s__r));
-    __Pyx_DECREF(__pyx_v_mode);
-    __pyx_v_mode = ((PyObject *)__pyx_n_s__r);
+  if (unlikely(__pyx_v_kwargs == Py_None)) {
+    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2902; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
   }
-  __pyx_L6:;
-
-  /* "csamtools.pyx":3480
- *         # reopen the file - note that this makes the iterator
- *         # slow and causes pileup to slow down significantly.
- *         if reopen:             # <<<<<<<<<<<<<<
- *             store = StderrStore()
- *             self.fp = samopen( samfile._filename, mode, NULL )
- */
-  if (__pyx_v_reopen) {
-
-    /* "csamtools.pyx":3481
- *         # slow and causes pileup to slow down significantly.
- *         if reopen:
- *             store = StderrStore()             # <<<<<<<<<<<<<<
- *             self.fp = samopen( samfile._filename, mode, NULL )
- *             store.release()
- */
-    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__StderrStore); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_2);
-    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __Pyx_DECREF(__pyx_v_store);
-    __pyx_v_store = __pyx_t_2;
-    __pyx_t_2 = 0;
+  __pyx_t_1 = PyInt_FromLong(BAM_ERRMOD_MAQ2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__errmod), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  ((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->c->errmod = __pyx_t_3;
 
-    /* "csamtools.pyx":3482
- *         if reopen:
- *             store = StderrStore()
- *             self.fp = samopen( samfile._filename, mode, NULL )             # <<<<<<<<<<<<<<
- *             store.release()
- *             assert self.fp != NULL
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2904
+ *         self.c.errmod = kwargs.get( "errmod", BAM_ERRMOD_MAQ2 )
+ * 
+ *         self.c.min_baseQ = kwargs.get( "min_baseQ", 13 )             # <<<<<<<<<<<<<<
+ *         # self.c.capQ_thres = kwargs.get( "capQ_threshold", 60 )
+ *         self.c.n_hap = kwargs.get( "n_haplotypes", 2 )
  */
-    __pyx_t_3 = PyBytes_AsString(__pyx_v_mode); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    ((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->fp = samopen(__pyx_v_samfile->_filename, __pyx_t_3, NULL);
+  if (unlikely(__pyx_v_kwargs == Py_None)) {
+    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2904; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+  }
+  __pyx_t_2 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__min_baseQ), __pyx_int_13); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2904; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2904; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  ((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->c->min_baseQ = __pyx_t_3;
 
-    /* "csamtools.pyx":3483
- *             store = StderrStore()
- *             self.fp = samopen( samfile._filename, mode, NULL )
- *             store.release()             # <<<<<<<<<<<<<<
- *             assert self.fp != NULL
- *             self.owns_samfile = True
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2906
+ *         self.c.min_baseQ = kwargs.get( "min_baseQ", 13 )
+ *         # self.c.capQ_thres = kwargs.get( "capQ_threshold", 60 )
+ *         self.c.n_hap = kwargs.get( "n_haplotypes", 2 )             # <<<<<<<<<<<<<<
+ *         self.c.het_rate = kwargs.get( "het_rate", 0.001 )
+ *         self.c.theta = kwargs.get( "theta", 0.83 )
  */
-    __pyx_t_2 = PyObject_GetAttr(__pyx_v_store, __pyx_n_s__release); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_1);
-    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (unlikely(__pyx_v_kwargs == Py_None)) {
+    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2906; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+  }
+  __pyx_t_2 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__n_haplotypes), __pyx_int_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2906; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2906; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  ((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->c->n_hap = __pyx_t_3;
 
-    /* "csamtools.pyx":3484
- *             self.fp = samopen( samfile._filename, mode, NULL )
- *             store.release()
- *             assert self.fp != NULL             # <<<<<<<<<<<<<<
- *             self.owns_samfile = True
- *         else:
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2907
+ *         # self.c.capQ_thres = kwargs.get( "capQ_threshold", 60 )
+ *         self.c.n_hap = kwargs.get( "n_haplotypes", 2 )
+ *         self.c.het_rate = kwargs.get( "het_rate", 0.001 )             # <<<<<<<<<<<<<<
+ *         self.c.theta = kwargs.get( "theta", 0.83 )
+ * 
  */
-    #ifndef CYTHON_WITHOUT_ASSERTIONS
-    if (unlikely(!(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->fp != NULL))) {
-      PyErr_SetNone(PyExc_AssertionError);
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    }
-    #endif
+  if (unlikely(__pyx_v_kwargs == Py_None)) {
+    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2907; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+  }
+  __pyx_t_2 = PyFloat_FromDouble(0.001); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2907; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_1 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__het_rate), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2907; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_4 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2907; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  ((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->c->het_rate = __pyx_t_4;
 
-    /* "csamtools.pyx":3485
- *             store.release()
- *             assert self.fp != NULL
- *             self.owns_samfile = True             # <<<<<<<<<<<<<<
- *         else:
- *             self.fp = samfile.samfile
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2908
+ *         self.c.n_hap = kwargs.get( "n_haplotypes", 2 )
+ *         self.c.het_rate = kwargs.get( "het_rate", 0.001 )
+ *         self.c.theta = kwargs.get( "theta", 0.83 )             # <<<<<<<<<<<<<<
+ * 
+ *         if self.c.errmod != BAM_ERRMOD_MAQ2:
  */
-    ((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->owns_samfile = 1;
-    goto __pyx_L7;
+  if (unlikely(__pyx_v_kwargs == Py_None)) {
+    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2908; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
   }
-  /*else*/ {
+  __pyx_t_1 = PyFloat_FromDouble(0.83); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__theta), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_4 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2908; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  ((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->c->theta = __pyx_t_4;
 
-    /* "csamtools.pyx":3487
- *             self.owns_samfile = True
- *         else:
- *             self.fp = samfile.samfile             # <<<<<<<<<<<<<<
- *             self.owns_samfile = False
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2910
+ *         self.c.theta = kwargs.get( "theta", 0.83 )
+ * 
+ *         if self.c.errmod != BAM_ERRMOD_MAQ2:             # <<<<<<<<<<<<<<
+ *             self.c.theta += 0.02
  * 
  */
-    ((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->fp = __pyx_v_samfile->samfile;
+  __pyx_t_5 = (((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->c->errmod != BAM_ERRMOD_MAQ2);
+  if (__pyx_t_5) {
 
-    /* "csamtools.pyx":3488
- *         else:
- *             self.fp = samfile.samfile
- *             self.owns_samfile = False             # <<<<<<<<<<<<<<
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2911
  * 
- *         assert samfile.isbam, "can only IndexReads on bam files"
+ *         if self.c.errmod != BAM_ERRMOD_MAQ2:
+ *             self.c.theta += 0.02             # <<<<<<<<<<<<<<
+ * 
+ *         # call prepare AFTER setting parameters
  */
-    ((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->owns_samfile = 0;
+    ((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->c->theta += 0.02;
+    goto __pyx_L6;
   }
-  __pyx_L7:;
+  __pyx_L6:;
 
-  /* "csamtools.pyx":3490
- *             self.owns_samfile = False
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2914
  * 
- *         assert samfile.isbam, "can only IndexReads on bam files"             # <<<<<<<<<<<<<<
+ *         # call prepare AFTER setting parameters
+ *         bam_maqcns_prepare( self.c )             # <<<<<<<<<<<<<<
  * 
- *     def build( self ):
+ *     def __dealloc__(self):
  */
-  #ifndef CYTHON_WITHOUT_ASSERTIONS
-  if (unlikely(!__pyx_v_samfile->isbam)) {
-    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_167));
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  }
-  #endif
+  bam_maqcns_prepare(((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->c);
 
   __pyx_r = 0;
   goto __pyx_L0;
   __pyx_L1_error:;
   __Pyx_XDECREF(__pyx_t_1);
   __Pyx_XDECREF(__pyx_t_2);
-  __Pyx_AddTraceback("csamtools.IndexedReads.__init__");
+  __Pyx_AddTraceback("csamtools.SNPCallerBase.__cinit__");
   __pyx_r = -1;
   __pyx_L0:;
-  __Pyx_DECREF(__pyx_v_mode);
-  __Pyx_DECREF(__pyx_v_store);
+  __Pyx_DECREF(__pyx_v_kwargs);
   __Pyx_TraceReturn(Py_None);
   __Pyx_RefNannyFinishContext();
   return __pyx_r;
 }
 
-/* "csamtools.pyx":3492
- *         assert samfile.isbam, "can only IndexReads on bam files"
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2916
+ *         bam_maqcns_prepare( self.c )
  * 
- *     def build( self ):             # <<<<<<<<<<<<<<
- *         '''build index.'''
+ *     def __dealloc__(self):             # <<<<<<<<<<<<<<
+ *         bam_maqcns_destroy( self.c )
  * 
  */
 
-static PyObject *__pyx_pf_9csamtools_12IndexedReads_1build(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
-static char __pyx_doc_9csamtools_12IndexedReads_1build[] = "IndexedReads.build(self)\nbuild index.";
-static PyObject *__pyx_pf_9csamtools_12IndexedReads_1build(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
-  int __pyx_v_ret;
-  bam1_t *__pyx_v_b;
-  uint64_t __pyx_v_pos;
-  char *__pyx_v_qname;
-  PyObject *__pyx_r = NULL;
-  PyObject *__pyx_t_1 = NULL;
-  PyObject *__pyx_t_2 = NULL;
-  PyObject *__pyx_t_3 = NULL;
-  int __pyx_t_4;
+static void __pyx_pf_9csamtools_13SNPCallerBase___dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_pf_9csamtools_13SNPCallerBase___dealloc__(PyObject *__pyx_v_self) {
   __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("build");
-  __Pyx_TraceCall("build", __pyx_f[0], 3492);
+  __Pyx_RefNannySetupContext("__dealloc__");
+  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 2916);
 
-  /* "csamtools.pyx":3495
- *         '''build index.'''
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2917
  * 
- *         self.index = collections.defaultdict( list )             # <<<<<<<<<<<<<<
+ *     def __dealloc__(self):
+ *         bam_maqcns_destroy( self.c )             # <<<<<<<<<<<<<<
  * 
- *         # this method will start indexing from the current file position
+ *     cdef __dump( self, glf1_t * g, uint32_t cns, int rb ):
  */
-  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__collections); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__defaultdict); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-  __Pyx_INCREF(((PyObject *)((PyObject*)(&PyList_Type))));
-  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)(&PyList_Type))));
-  __Pyx_GIVEREF(((PyObject *)((PyObject*)(&PyList_Type))));
-  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3495; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
-  __Pyx_GIVEREF(__pyx_t_3);
-  __Pyx_GOTREF(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->index);
-  __Pyx_DECREF(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->index);
-  ((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->index = __pyx_t_3;
-  __pyx_t_3 = 0;
+  bam_maqcns_destroy(((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->c);
 
-  /* "csamtools.pyx":3499
- *         # this method will start indexing from the current file position
- *         # if you decide
- *         cdef int ret = 1             # <<<<<<<<<<<<<<
- *         cdef bam1_t * b = <bam1_t*> calloc(1, sizeof( bam1_t) )
+  __Pyx_TraceReturn(Py_None);
+  __Pyx_RefNannyFinishContext();
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2919
+ *         bam_maqcns_destroy( self.c )
+ * 
+ *     cdef __dump( self, glf1_t * g, uint32_t cns, int rb ):             # <<<<<<<<<<<<<<
+ *         '''debugging output.'''
  * 
  */
-  __pyx_v_ret = 1;
 
-  /* "csamtools.pyx":3500
- *         # if you decide
- *         cdef int ret = 1
- *         cdef bam1_t * b = <bam1_t*> calloc(1, sizeof( bam1_t) )             # <<<<<<<<<<<<<<
+static  PyObject *__pyx_f_9csamtools_13SNPCallerBase___dump(struct __pyx_obj_9csamtools_SNPCallerBase *__pyx_v_self, glf1_t *__pyx_v_g, uint32_t __pyx_v_cns, int __pyx_v_rb) {
+  int __pyx_v_x;
+  PyObject *__pyx_r = NULL;
+  int __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  PyObject *__pyx_t_9 = NULL;
+  PyObject *__pyx_t_10 = NULL;
+  PyObject *__pyx_t_11 = NULL;
+  PyObject *__pyx_t_12 = NULL;
+  PyObject *__pyx_t_13 = NULL;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__dump");
+  __Pyx_TraceCall("__dump", __pyx_f[0], 2919);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2922
+ *         '''debugging output.'''
  * 
- *         cdef uint64_t pos
+ *         pysam_dump_glf( g, self.c );             # <<<<<<<<<<<<<<
+ *         print ""
+ *         for x in range(self.iter.n_plp):
  */
-  __pyx_v_b = ((bam1_t *)calloc(1, (sizeof(bam1_t))));
+  pysam_dump_glf(__pyx_v_g, __pyx_v_self->c);
 
-  /* "csamtools.pyx":3504
- *         cdef uint64_t pos
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2923
  * 
- *         while ret > 0:             # <<<<<<<<<<<<<<
- *             pos = bam_tell( self.fp.x.bam )
- *             ret = samread( self.fp, b)
+ *         pysam_dump_glf( g, self.c );
+ *         print ""             # <<<<<<<<<<<<<<
+ *         for x in range(self.iter.n_plp):
+ *             print "--> read %i %s %i" % (x,
  */
-  while (1) {
-    __pyx_t_4 = (__pyx_v_ret > 0);
-    if (!__pyx_t_4) break;
+  if (__Pyx_PrintOne(0, ((PyObject *)__pyx_kp_s_8)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2923; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-    /* "csamtools.pyx":3505
- * 
- *         while ret > 0:
- *             pos = bam_tell( self.fp.x.bam )             # <<<<<<<<<<<<<<
- *             ret = samread( self.fp, b)
- *             if ret > 0:
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2924
+ *         pysam_dump_glf( g, self.c );
+ *         print ""
+ *         for x in range(self.iter.n_plp):             # <<<<<<<<<<<<<<
+ *             print "--> read %i %s %i" % (x,
+ *                                          bam1_qname(self.iter.plp[x].b),
  */
-    __pyx_v_pos = bam_tell(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->fp->x.bam);
+  __pyx_t_1 = __pyx_v_self->iter->n_plp;
+  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
+    __pyx_v_x = __pyx_t_2;
 
-    /* "csamtools.pyx":3506
- *         while ret > 0:
- *             pos = bam_tell( self.fp.x.bam )
- *             ret = samread( self.fp, b)             # <<<<<<<<<<<<<<
- *             if ret > 0:
- *                 qname = bam1_qname( b )
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2925
+ *         print ""
+ *         for x in range(self.iter.n_plp):
+ *             print "--> read %i %s %i" % (x,             # <<<<<<<<<<<<<<
+ *                                          bam1_qname(self.iter.plp[x].b),
+ *                                          self.iter.plp[x].qpos,
  */
-    __pyx_v_ret = samread(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->fp, __pyx_v_b);
+    __pyx_t_3 = PyInt_FromLong(__pyx_v_x); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
 
-    /* "csamtools.pyx":3507
- *             pos = bam_tell( self.fp.x.bam )
- *             ret = samread( self.fp, b)
- *             if ret > 0:             # <<<<<<<<<<<<<<
- *                 qname = bam1_qname( b )
- *                 self.index[qname].append( pos )
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2926
+ *         for x in range(self.iter.n_plp):
+ *             print "--> read %i %s %i" % (x,
+ *                                          bam1_qname(self.iter.plp[x].b),             # <<<<<<<<<<<<<<
+ *                                          self.iter.plp[x].qpos,
+ *                                          )
  */
-    __pyx_t_4 = (__pyx_v_ret > 0);
-    if (__pyx_t_4) {
+    __pyx_t_4 = PyBytes_FromString(bam1_qname((__pyx_v_self->iter->plp[__pyx_v_x]).b)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2926; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
 
-      /* "csamtools.pyx":3508
- *             ret = samread( self.fp, b)
- *             if ret > 0:
- *                 qname = bam1_qname( b )             # <<<<<<<<<<<<<<
- *                 self.index[qname].append( pos )
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2927
+ *             print "--> read %i %s %i" % (x,
+ *                                          bam1_qname(self.iter.plp[x].b),
+ *                                          self.iter.plp[x].qpos,             # <<<<<<<<<<<<<<
+ *                                          )
  * 
  */
-      __pyx_v_qname = bam1_qname(__pyx_v_b);
+    __pyx_t_5 = __Pyx_PyInt_to_py_int32_t((__pyx_v_self->iter->plp[__pyx_v_x]).qpos); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3);
+    __Pyx_GIVEREF(__pyx_t_3);
+    PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_t_4));
+    __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
+    PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_5);
+    __Pyx_GIVEREF(__pyx_t_5);
+    __pyx_t_3 = 0;
+    __pyx_t_4 = 0;
+    __pyx_t_5 = 0;
+    __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_104), __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    if (__Pyx_PrintOne(0, ((PyObject *)__pyx_t_5)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
+  }
 
-      /* "csamtools.pyx":3509
- *             if ret > 0:
- *                 qname = bam1_qname( b )
- *                 self.index[qname].append( pos )             # <<<<<<<<<<<<<<
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2931
  * 
- *         bam_destroy1( b )
+ *         print "pos=%i, cns=%i, q_r = %f, depth=%i, n=%i, rb=%i, cns-cq=%i %i %i %i" \
+ *             % (self.iter.pos,             # <<<<<<<<<<<<<<
+ *                cns,
+ *                self.c.q_r,
  */
-      __pyx_t_3 = PyBytes_FromString(__pyx_v_qname); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-      __pyx_t_1 = PyObject_GetItem(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->index, ((PyObject *)__pyx_t_3)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_1);
-      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
-      __pyx_t_3 = __Pyx_PyInt_to_py_uint64_t(__pyx_v_pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_3);
-      __pyx_t_2 = __Pyx_PyObject_Append(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_2);
-      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-      goto __pyx_L7;
-    }
-    __pyx_L7:;
-  }
+  __pyx_t_5 = PyInt_FromLong(__pyx_v_self->iter->pos); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
 
-  /* "csamtools.pyx":3511
- *                 self.index[qname].append( pos )
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2932
+ *         print "pos=%i, cns=%i, q_r = %f, depth=%i, n=%i, rb=%i, cns-cq=%i %i %i %i" \
+ *             % (self.iter.pos,
+ *                cns,             # <<<<<<<<<<<<<<
+ *                self.c.q_r,
+ *                self.iter.n_plp,
+ */
+  __pyx_t_6 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_cns); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_6);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2933
+ *             % (self.iter.pos,
+ *                cns,
+ *                self.c.q_r,             # <<<<<<<<<<<<<<
+ *                self.iter.n_plp,
+ *                self.iter.n_plp,
+ */
+  __pyx_t_4 = PyFloat_FromDouble(__pyx_v_self->c->q_r); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2933; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2934
+ *                cns,
+ *                self.c.q_r,
+ *                self.iter.n_plp,             # <<<<<<<<<<<<<<
+ *                self.iter.n_plp,
+ *                rb,
+ */
+  __pyx_t_3 = PyInt_FromLong(__pyx_v_self->iter->n_plp); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2935
+ *                self.c.q_r,
+ *                self.iter.n_plp,
+ *                self.iter.n_plp,             # <<<<<<<<<<<<<<
+ *                rb,
+ *                cns >> 8 & 0xff,
+ */
+  __pyx_t_7 = PyInt_FromLong(__pyx_v_self->iter->n_plp); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2935; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_7);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2936
+ *                self.iter.n_plp,
+ *                self.iter.n_plp,
+ *                rb,             # <<<<<<<<<<<<<<
+ *                cns >> 8 & 0xff,
+ *                cns >> 16 & 0xff,
+ */
+  __pyx_t_8 = PyInt_FromLong(__pyx_v_rb); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2936; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_8);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2937
+ *                self.iter.n_plp,
+ *                rb,
+ *                cns >> 8 & 0xff,             # <<<<<<<<<<<<<<
+ *                cns >> 16 & 0xff,
+ *                cns & 0xff,
+ */
+  __pyx_t_9 = PyInt_FromLong(((__pyx_v_cns >> 8) & 0xff)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2937; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_9);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2938
+ *                rb,
+ *                cns >> 8 & 0xff,
+ *                cns >> 16 & 0xff,             # <<<<<<<<<<<<<<
+ *                cns & 0xff,
+ *                cns >> 28,
+ */
+  __pyx_t_10 = PyInt_FromLong(((__pyx_v_cns >> 16) & 0xff)); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2938; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_10);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2939
+ *                cns >> 8 & 0xff,
+ *                cns >> 16 & 0xff,
+ *                cns & 0xff,             # <<<<<<<<<<<<<<
+ *                cns >> 28,
+ *                )
+ */
+  __pyx_t_11 = PyInt_FromLong((__pyx_v_cns & 0xff)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_11);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2940
+ *                cns >> 16 & 0xff,
+ *                cns & 0xff,
+ *                cns >> 28,             # <<<<<<<<<<<<<<
+ *                )
  * 
- *         bam_destroy1( b )             # <<<<<<<<<<<<<<
+ */
+  __pyx_t_12 = PyInt_FromLong((__pyx_v_cns >> 28)); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_12);
+  __pyx_t_13 = PyTuple_New(10); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_13);
+  PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_5);
+  __Pyx_GIVEREF(__pyx_t_5);
+  PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_6);
+  __Pyx_GIVEREF(__pyx_t_6);
+  PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_t_4);
+  __Pyx_GIVEREF(__pyx_t_4);
+  PyTuple_SET_ITEM(__pyx_t_13, 3, __pyx_t_3);
+  __Pyx_GIVEREF(__pyx_t_3);
+  PyTuple_SET_ITEM(__pyx_t_13, 4, __pyx_t_7);
+  __Pyx_GIVEREF(__pyx_t_7);
+  PyTuple_SET_ITEM(__pyx_t_13, 5, __pyx_t_8);
+  __Pyx_GIVEREF(__pyx_t_8);
+  PyTuple_SET_ITEM(__pyx_t_13, 6, __pyx_t_9);
+  __Pyx_GIVEREF(__pyx_t_9);
+  PyTuple_SET_ITEM(__pyx_t_13, 7, __pyx_t_10);
+  __Pyx_GIVEREF(__pyx_t_10);
+  PyTuple_SET_ITEM(__pyx_t_13, 8, __pyx_t_11);
+  __Pyx_GIVEREF(__pyx_t_11);
+  PyTuple_SET_ITEM(__pyx_t_13, 9, __pyx_t_12);
+  __Pyx_GIVEREF(__pyx_t_12);
+  __pyx_t_5 = 0;
+  __pyx_t_6 = 0;
+  __pyx_t_4 = 0;
+  __pyx_t_3 = 0;
+  __pyx_t_7 = 0;
+  __pyx_t_8 = 0;
+  __pyx_t_9 = 0;
+  __pyx_t_10 = 0;
+  __pyx_t_11 = 0;
+  __pyx_t_12 = 0;
+  __pyx_t_12 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_105), __pyx_t_13); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2931; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_12));
+  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+  if (__Pyx_PrintOne(0, ((PyObject *)__pyx_t_12)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2943
+ *                )
+ * 
+ *         printf("-------------------------------------\n");             # <<<<<<<<<<<<<<
+ *         sys.stdout.flush()
  * 
- *     def find( self, qname ):
  */
-  bam_destroy1(__pyx_v_b);
+  printf(__pyx_k_106);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2944
+ * 
+ *         printf("-------------------------------------\n");
+ *         sys.stdout.flush()             # <<<<<<<<<<<<<<
+ * 
+ * cdef class IteratorSNPCalls( SNPCallerBase ):
+ */
+  __pyx_t_12 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2944; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_12);
+  __pyx_t_13 = PyObject_GetAttr(__pyx_t_12, __pyx_n_s__stdout); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2944; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_13);
+  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+  __pyx_t_12 = PyObject_GetAttr(__pyx_t_13, __pyx_n_s__flush); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2944; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_12);
+  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+  __pyx_t_13 = PyObject_Call(__pyx_t_12, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2944; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_13);
+  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
 
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   goto __pyx_L0;
   __pyx_L1_error:;
-  __Pyx_XDECREF(__pyx_t_1);
-  __Pyx_XDECREF(__pyx_t_2);
   __Pyx_XDECREF(__pyx_t_3);
-  __Pyx_AddTraceback("csamtools.IndexedReads.build");
-  __pyx_r = NULL;
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_XDECREF(__pyx_t_10);
+  __Pyx_XDECREF(__pyx_t_11);
+  __Pyx_XDECREF(__pyx_t_12);
+  __Pyx_XDECREF(__pyx_t_13);
+  __Pyx_AddTraceback("csamtools.SNPCallerBase.__dump");
+  __pyx_r = 0;
   __pyx_L0:;
   __Pyx_XGIVEREF(__pyx_r);
   __Pyx_TraceReturn(__pyx_r);
@@ -27440,1439 +27327,6006 @@ static PyObject *__pyx_pf_9csamtools_12IndexedReads_1build(PyObject *__pyx_v_sel
   return __pyx_r;
 }
 
-/* "csamtools.pyx":3513
- *         bam_destroy1( b )
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2960
+ *     """
  * 
- *     def find( self, qname ):             # <<<<<<<<<<<<<<
- *         if qname in self.index:
- *             return IteratorRowSelection( self.samfile, self.index[qname], reopen = False )
+ *     def __cinit__(self,             # <<<<<<<<<<<<<<
+ *                   IteratorColumn iterator_column,
+ *                   **kwargs ):
  */
 
-static PyObject *__pyx_pf_9csamtools_12IndexedReads_2find(PyObject *__pyx_v_self, PyObject *__pyx_v_qname); /*proto*/
-static char __pyx_doc_9csamtools_12IndexedReads_2find[] = "IndexedReads.find(self, qname)";
-static PyObject *__pyx_pf_9csamtools_12IndexedReads_2find(PyObject *__pyx_v_self, PyObject *__pyx_v_qname) {
-  PyObject *__pyx_r = NULL;
-  int __pyx_t_1;
+static int __pyx_pf_9csamtools_16IteratorSNPCalls___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pf_9csamtools_16IteratorSNPCalls___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  struct __pyx_obj_9csamtools_IteratorColumn *__pyx_v_iterator_column = 0;
+  PyObject *__pyx_v_kwargs = 0;
+  int __pyx_r;
+  PyObject *__pyx_t_1 = NULL;
   PyObject *__pyx_t_2 = NULL;
-  PyObject *__pyx_t_3 = NULL;
-  PyObject *__pyx_t_4 = NULL;
+  int __pyx_t_3;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__iterator_column,0};
   __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("find");
-  __Pyx_TraceCall("find", __pyx_f[0], 3513);
-
-  /* "csamtools.pyx":3514
- * 
- *     def find( self, qname ):
- *         if qname in self.index:             # <<<<<<<<<<<<<<
- *             return IteratorRowSelection( self.samfile, self.index[qname], reopen = False )
- *         else:
- */
-  __pyx_t_1 = ((PySequence_Contains(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->index, __pyx_v_qname))); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__pyx_t_1) {
-
-    /* "csamtools.pyx":3515
- *     def find( self, qname ):
- *         if qname in self.index:
- *             return IteratorRowSelection( self.samfile, self.index[qname], reopen = False )             # <<<<<<<<<<<<<<
- *         else:
- *             raise KeyError( "read %s not found" % qname )
- */
-    __Pyx_XDECREF(__pyx_r);
-    __pyx_t_2 = PyObject_GetItem(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->index, __pyx_v_qname); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-    __Pyx_INCREF(((PyObject *)((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->samfile));
-    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->samfile));
-    __Pyx_GIVEREF(((PyObject *)((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->samfile));
-    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
-    __Pyx_GIVEREF(__pyx_t_2);
-    __pyx_t_2 = 0;
-    __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-    __pyx_t_4 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_4);
-    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__reopen), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    __pyx_t_4 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorRowSelection)), ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_4);
-    __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
-    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
-    __pyx_r = __pyx_t_4;
-    __pyx_t_4 = 0;
-    goto __pyx_L0;
-    goto __pyx_L5;
+  __Pyx_RefNannySetupContext("__cinit__");
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 2960);
+  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
+  __Pyx_GOTREF(__pyx_v_kwargs);
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[1] = {0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__iterator_column);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2960; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)values[0]);
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)PyTuple_GET_ITEM(__pyx_args, 0));
   }
-  /*else*/ {
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2960; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_DECREF(__pyx_v_kwargs);
+  __Pyx_AddTraceback("csamtools.IteratorSNPCalls.__cinit__");
+  __Pyx_RefNannyFinishContext();
+  return -1;
+  __pyx_L4_argument_unpacking_done:;
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_iterator_column), __pyx_ptype_9csamtools_IteratorColumn, 1, "iterator_column", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2961; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-    /* "csamtools.pyx":3517
- *             return IteratorRowSelection( self.samfile, self.index[qname], reopen = False )
- *         else:
- *             raise KeyError( "read %s not found" % qname )             # <<<<<<<<<<<<<<
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2964
+ *                   **kwargs ):
  * 
- *     def __dealloc__(self):
+ *         assert self.iter.hasReference(), "IteratorSNPCalls requires an pileup iterator with reference sequence"             # <<<<<<<<<<<<<<
+ * 
+ *     def __iter__(self):
  */
-    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_168), __pyx_v_qname); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
-    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_4));
-    __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
-    __pyx_t_4 = 0;
-    __pyx_t_4 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_4);
-    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
-    __Pyx_Raise(__pyx_t_4, 0, 0);
-    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #ifndef PYREX_WITHOUT_ASSERTIONS
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter), __pyx_n_s__hasReference); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (unlikely(!__pyx_t_3)) {
+    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_107));
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
-  __pyx_L5:;
+  #endif
 
-  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_r = 0;
   goto __pyx_L0;
   __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
   __Pyx_XDECREF(__pyx_t_2);
-  __Pyx_XDECREF(__pyx_t_3);
-  __Pyx_XDECREF(__pyx_t_4);
-  __Pyx_AddTraceback("csamtools.IndexedReads.find");
-  __pyx_r = NULL;
+  __Pyx_AddTraceback("csamtools.IteratorSNPCalls.__cinit__");
+  __pyx_r = -1;
   __pyx_L0:;
-  __Pyx_XGIVEREF(__pyx_r);
-  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_DECREF(__pyx_v_kwargs);
+  __Pyx_TraceReturn(Py_None);
   __Pyx_RefNannyFinishContext();
   return __pyx_r;
 }
 
-/* "csamtools.pyx":3519
- *             raise KeyError( "read %s not found" % qname )
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2966
+ *         assert self.iter.hasReference(), "IteratorSNPCalls requires an pileup iterator with reference sequence"
  * 
- *     def __dealloc__(self):             # <<<<<<<<<<<<<<
- *         if self.owns_samfile: samclose( self.fp )
+ *     def __iter__(self):             # <<<<<<<<<<<<<<
+ *         return self
  * 
  */
 
-static void __pyx_pf_9csamtools_12IndexedReads_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
-static void __pyx_pf_9csamtools_12IndexedReads_3__dealloc__(PyObject *__pyx_v_self) {
+static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___iter__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___iter__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
   __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("__dealloc__");
-  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 3519);
+  __Pyx_RefNannySetupContext("__iter__");
+  __Pyx_TraceCall("__iter__", __pyx_f[0], 2966);
 
-  /* "csamtools.pyx":3520
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2967
  * 
- *     def __dealloc__(self):
- *         if self.owns_samfile: samclose( self.fp )             # <<<<<<<<<<<<<<
+ *     def __iter__(self):
+ *         return self             # <<<<<<<<<<<<<<
  * 
- * __all__ = ["Samfile",
+ *     def __next__(self):
  */
-  if (((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->owns_samfile) {
-    samclose(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->fp);
-    goto __pyx_L5;
-  }
-  __pyx_L5:;
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_v_self);
+  __pyx_r = __pyx_v_self;
+  goto __pyx_L0;
 
-  __Pyx_TraceReturn(Py_None);
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
   __Pyx_RefNannyFinishContext();
+  return __pyx_r;
 }
 
-static PyObject *__pyx_tp_new_9csamtools_AlignedRead(PyTypeObject *t, PyObject *a, PyObject *k) {
-  PyObject *o = (*t->tp_alloc)(t, 0);
-  if (!o) return 0;
-  return o;
-}
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2969
+ *         return self
+ * 
+ *     def __next__(self):             # <<<<<<<<<<<<<<
+ *         """python version of next().
+ *         """
+ */
 
-static void __pyx_tp_dealloc_9csamtools_AlignedRead(PyObject *o) {
-  {
-    PyObject *etype, *eval, *etb;
-    PyErr_Fetch(&etype, &eval, &etb);
-    ++Py_REFCNT(o);
-    __pyx_pf_9csamtools_11AlignedRead_1__dealloc__(o);
-    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
-    --Py_REFCNT(o);
-    PyErr_Restore(etype, eval, etb);
-  }
-  (*Py_TYPE(o)->tp_free)(o);
-}
+static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___next__(PyObject *__pyx_v_self); /*proto*/
+static char __pyx_doc_9csamtools_16IteratorSNPCalls___next__[] = "python version of next().\n        ";
+struct wrapperbase __pyx_wrapperbase_9csamtools_16IteratorSNPCalls___next__;
+static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___next__(PyObject *__pyx_v_self) {
+  char *__pyx_v_seq;
+  int __pyx_v_seq_len;
+  int __pyx_v_rb;
+  uint32_t __pyx_v_cns;
+  glf1_t *__pyx_v_g;
+  struct __pyx_obj_9csamtools_SNPCall *__pyx_v_call;
+  PyObject *__pyx_r = NULL;
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  int __pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__next__");
+  __Pyx_TraceCall("__next__", __pyx_f[0], 2969);
+  __pyx_v_call = ((struct __pyx_obj_9csamtools_SNPCall *)Py_None); __Pyx_INCREF(Py_None);
 
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_qname(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_5qname___get__(o);
-}
-
-static int __pyx_setprop_9csamtools_11AlignedRead_qname(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_9csamtools_11AlignedRead_5qname_1__set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
-  }
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2974
+ * 
+ *         # the following code was adapted from bam_plcmd.c:pileup_func()
+ *         self.iter.cnext()             # <<<<<<<<<<<<<<
+ * 
+ *         if self.iter.n_plp < 0:
+ */
+  ((struct __pyx_vtabstruct_9csamtools_IteratorColumn *)((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->__pyx_vtab)->cnext(((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter);
 
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_cigar(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_5cigar___get__(o);
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2976
+ *         self.iter.cnext()
+ * 
+ *         if self.iter.n_plp < 0:             # <<<<<<<<<<<<<<
+ *             raise ValueError("error during iteration" )
+ * 
+ */
+  __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->n_plp < 0);
+  if (__pyx_t_1) {
 
-static int __pyx_setprop_9csamtools_11AlignedRead_cigar(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_9csamtools_11AlignedRead_5cigar_1__set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2977
+ * 
+ *         if self.iter.n_plp < 0:
+ *             raise ValueError("error during iteration" )             # <<<<<<<<<<<<<<
+ * 
+ *         if self.iter.plp == NULL:
+ */
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2977; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_59));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_59));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_59));
+    __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2977; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_Raise(__pyx_t_3, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2977; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L5;
   }
-}
+  __pyx_L5:;
 
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_seq(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_3seq___get__(o);
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2979
+ *             raise ValueError("error during iteration" )
+ * 
+ *         if self.iter.plp == NULL:             # <<<<<<<<<<<<<<
+ *            raise StopIteration
+ * 
+ */
+  __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->plp == NULL);
+  if (__pyx_t_1) {
 
-static int __pyx_setprop_9csamtools_11AlignedRead_seq(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_9csamtools_11AlignedRead_3seq_1__set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2980
+ * 
+ *         if self.iter.plp == NULL:
+ *            raise StopIteration             # <<<<<<<<<<<<<<
+ * 
+ *         cdef char * seq = self.iter.getSequence()
+ */
+    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L6;
   }
-}
+  __pyx_L6:;
 
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_qual(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_4qual___get__(o);
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2982
+ *            raise StopIteration
+ * 
+ *         cdef char * seq = self.iter.getSequence()             # <<<<<<<<<<<<<<
+ *         cdef int seq_len = self.iter.seq_len
+ * 
+ */
+  __pyx_v_seq = ((struct __pyx_vtabstruct_9csamtools_IteratorColumn *)((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->__pyx_vtab)->getSequence(((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter);
 
-static int __pyx_setprop_9csamtools_11AlignedRead_qual(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_9csamtools_11AlignedRead_4qual_1__set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
-  }
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2983
+ * 
+ *         cdef char * seq = self.iter.getSequence()
+ *         cdef int seq_len = self.iter.seq_len             # <<<<<<<<<<<<<<
+ * 
+ *         assert seq != NULL
+ */
+  __pyx_t_3 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter), __pyx_n_s__seq_len); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2983; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2983; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_v_seq_len = __pyx_t_4;
 
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_query(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_5query___get__(o);
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2985
+ *         cdef int seq_len = self.iter.seq_len
+ * 
+ *         assert seq != NULL             # <<<<<<<<<<<<<<
+ * 
+ *         # reference base
+ */
+  #ifndef PYREX_WITHOUT_ASSERTIONS
+  if (unlikely(!(__pyx_v_seq != NULL))) {
+    PyErr_SetNone(PyExc_AssertionError);
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  #endif
 
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_qqual(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_5qqual___get__(o);
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2988
+ * 
+ *         # reference base
+ *         if self.iter.pos >= seq_len:             # <<<<<<<<<<<<<<
+ *             raise ValueError( "position %i out of bounds on reference sequence (len=%i)" % (self.iter.pos, seq_len) )
+ * 
+ */
+  __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->pos >= __pyx_v_seq_len);
+  if (__pyx_t_1) {
 
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_qstart(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_6qstart___get__(o);
-}
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2989
+ *         # reference base
+ *         if self.iter.pos >= seq_len:
+ *             raise ValueError( "position %i out of bounds on reference sequence (len=%i)" % (self.iter.pos, seq_len) )             # <<<<<<<<<<<<<<
+ * 
+ *         cdef int rb = seq[self.iter.pos]
+ */
+    __pyx_t_3 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_2 = PyInt_FromLong(__pyx_v_seq_len); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
+    __Pyx_GIVEREF(__pyx_t_3);
+    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
+    __Pyx_GIVEREF(__pyx_t_2);
+    __pyx_t_3 = 0;
+    __pyx_t_2 = 0;
+    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_108), __pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_2));
+    __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
+    __pyx_t_2 = 0;
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __Pyx_Raise(__pyx_t_2, 0, 0);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L7;
+  }
+  __pyx_L7:;
 
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_qend(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_4qend___get__(o);
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2991
+ *             raise ValueError( "position %i out of bounds on reference sequence (len=%i)" % (self.iter.pos, seq_len) )
+ * 
+ *         cdef int rb = seq[self.iter.pos]             # <<<<<<<<<<<<<<
+ *         cdef uint32_t cns
+ *         cdef glf1_t * g
+ */
+  __pyx_v_rb = (__pyx_v_seq[((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->pos]);
 
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_qlen(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_4qlen___get__(o);
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2998
+ *                                self.iter.plp,
+ *                                bam_nt16_table[rb],
+ *                                self.c )             # <<<<<<<<<<<<<<
+ * 
+ *         if pysam_glf_depth( g ) == 0:
+ */
+  __pyx_v_g = bam_maqcns_glfgen(((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->n_plp, ((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->plp, (bam_nt16_table[__pyx_v_rb]), ((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.c);
 
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_tags(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_4tags___get__(o);
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3000
+ *                                self.c )
+ * 
+ *         if pysam_glf_depth( g ) == 0:             # <<<<<<<<<<<<<<
+ *             cns = 0xfu << 28 | 0xf << 24
+ *         else:
+ */
+  __pyx_t_1 = (pysam_glf_depth(__pyx_v_g) == 0);
+  if (__pyx_t_1) {
 
-static int __pyx_setprop_9csamtools_11AlignedRead_tags(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_9csamtools_11AlignedRead_4tags_1__set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3001
+ * 
+ *         if pysam_glf_depth( g ) == 0:
+ *             cns = 0xfu << 28 | 0xf << 24             # <<<<<<<<<<<<<<
+ *         else:
+ *             cns = glf2cns(g, <int>(self.c.q_r + .499))
+ */
+    __pyx_v_cns = 4278190080U;
+    goto __pyx_L8;
   }
-}
-
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_flag(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_4flag___get__(o);
-}
+  /*else*/ {
 
-static int __pyx_setprop_9csamtools_11AlignedRead_flag(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_9csamtools_11AlignedRead_4flag_1__set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3003
+ *             cns = 0xfu << 28 | 0xf << 24
+ *         else:
+ *             cns = glf2cns(g, <int>(self.c.q_r + .499))             # <<<<<<<<<<<<<<
+ * 
+ *         free(g)
+ */
+    __pyx_v_cns = glf2cns(__pyx_v_g, ((int)(((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.c->q_r + .499)));
   }
-}
+  __pyx_L8:;
 
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_rname(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_5rname___get__(o);
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3005
+ *             cns = glf2cns(g, <int>(self.c.q_r + .499))
+ * 
+ *         free(g)             # <<<<<<<<<<<<<<
+ * 
+ *         cdef SNPCall call
+ */
+  free(__pyx_v_g);
 
-static int __pyx_setprop_9csamtools_11AlignedRead_rname(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_9csamtools_11AlignedRead_5rname_1__set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
-  }
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3009
+ *         cdef SNPCall call
+ * 
+ *         call = SNPCall()             # <<<<<<<<<<<<<<
+ *         call._tid = self.iter.tid
+ *         call._pos = self.iter.pos
+ */
+  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_SNPCall)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(((PyObject *)__pyx_v_call));
+  __pyx_v_call = ((struct __pyx_obj_9csamtools_SNPCall *)__pyx_t_2);
+  __pyx_t_2 = 0;
 
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_tid(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_3tid___get__(o);
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3010
+ * 
+ *         call = SNPCall()
+ *         call._tid = self.iter.tid             # <<<<<<<<<<<<<<
+ *         call._pos = self.iter.pos
+ *         call._reference_base = rb
+ */
+  __pyx_v_call->_tid = ((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->tid;
 
-static int __pyx_setprop_9csamtools_11AlignedRead_tid(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_9csamtools_11AlignedRead_3tid_1__set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
-  }
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3011
+ *         call = SNPCall()
+ *         call._tid = self.iter.tid
+ *         call._pos = self.iter.pos             # <<<<<<<<<<<<<<
+ *         call._reference_base = rb
+ *         call._genotype = bam_nt16_rev_table[cns>>28]
+ */
+  __pyx_v_call->_pos = ((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->pos;
 
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_pos(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_3pos___get__(o);
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3012
+ *         call._tid = self.iter.tid
+ *         call._pos = self.iter.pos
+ *         call._reference_base = rb             # <<<<<<<<<<<<<<
+ *         call._genotype = bam_nt16_rev_table[cns>>28]
+ *         call._consensus_quality = cns >> 8 & 0xff
+ */
+  __pyx_v_call->_reference_base = __pyx_v_rb;
 
-static int __pyx_setprop_9csamtools_11AlignedRead_pos(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_9csamtools_11AlignedRead_3pos_1__set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
-  }
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3013
+ *         call._pos = self.iter.pos
+ *         call._reference_base = rb
+ *         call._genotype = bam_nt16_rev_table[cns>>28]             # <<<<<<<<<<<<<<
+ *         call._consensus_quality = cns >> 8 & 0xff
+ *         call._snp_quality = cns & 0xff
+ */
+  __pyx_v_call->_genotype = (__pyx_v_9csamtools_bam_nt16_rev_table[(__pyx_v_cns >> 28)]);
 
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_bin(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_3bin___get__(o);
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3014
+ *         call._reference_base = rb
+ *         call._genotype = bam_nt16_rev_table[cns>>28]
+ *         call._consensus_quality = cns >> 8 & 0xff             # <<<<<<<<<<<<<<
+ *         call._snp_quality = cns & 0xff
+ *         call._rms_mapping_quality = cns >> 16&0xff
+ */
+  __pyx_v_call->_consensus_quality = ((__pyx_v_cns >> 8) & 0xff);
 
-static int __pyx_setprop_9csamtools_11AlignedRead_bin(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_9csamtools_11AlignedRead_3bin_1__set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
-  }
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3015
+ *         call._genotype = bam_nt16_rev_table[cns>>28]
+ *         call._consensus_quality = cns >> 8 & 0xff
+ *         call._snp_quality = cns & 0xff             # <<<<<<<<<<<<<<
+ *         call._rms_mapping_quality = cns >> 16&0xff
+ *         call._coverage = self.iter.n_plp
+ */
+  __pyx_v_call->_snp_quality = (__pyx_v_cns & 0xff);
 
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_rlen(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_4rlen___get__(o);
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3016
+ *         call._consensus_quality = cns >> 8 & 0xff
+ *         call._snp_quality = cns & 0xff
+ *         call._rms_mapping_quality = cns >> 16&0xff             # <<<<<<<<<<<<<<
+ *         call._coverage = self.iter.n_plp
+ * 
+ */
+  __pyx_v_call->_rms_mapping_quality = ((__pyx_v_cns >> 16) & 0xff);
 
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_aend(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_4aend___get__(o);
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3017
+ *         call._snp_quality = cns & 0xff
+ *         call._rms_mapping_quality = cns >> 16&0xff
+ *         call._coverage = self.iter.n_plp             # <<<<<<<<<<<<<<
+ * 
+ *         return call
+ */
+  __pyx_v_call->_coverage = ((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->n_plp;
 
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_alen(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_4alen___get__(o);
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3019
+ *         call._coverage = self.iter.n_plp
+ * 
+ *         return call             # <<<<<<<<<<<<<<
+ * 
+ * cdef class SNPCaller( SNPCallerBase ):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(((PyObject *)__pyx_v_call));
+  __pyx_r = ((PyObject *)__pyx_v_call);
+  goto __pyx_L0;
 
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_mapq(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_4mapq___get__(o);
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_AddTraceback("csamtools.IteratorSNPCalls.__next__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF((PyObject *)__pyx_v_call);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
 }
 
-static int __pyx_setprop_9csamtools_11AlignedRead_mapq(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_9csamtools_11AlignedRead_4mapq_1__set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
-  }
-}
-
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_mrnm(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_4mrnm___get__(o);
-}
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3035
+ * 
+ * 
+ *     def __cinit__(self,             # <<<<<<<<<<<<<<
+ *                   IteratorColumn iterator_column,
+ *                   **kwargs ):
+ */
 
-static int __pyx_setprop_9csamtools_11AlignedRead_mrnm(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_9csamtools_11AlignedRead_4mrnm_1__set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
+static int __pyx_pf_9csamtools_9SNPCaller___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pf_9csamtools_9SNPCaller___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  struct __pyx_obj_9csamtools_IteratorColumn *__pyx_v_iterator_column = 0;
+  PyObject *__pyx_v_kwargs = 0;
+  int __pyx_r;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__iterator_column,0};
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__cinit__");
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 3035);
+  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
+  __Pyx_GOTREF(__pyx_v_kwargs);
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[1] = {0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__iterator_column);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3035; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)values[0]);
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)PyTuple_GET_ITEM(__pyx_args, 0));
   }
-}
-
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_rnext(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_5rnext___get__(o);
-}
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3035; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_DECREF(__pyx_v_kwargs);
+  __Pyx_AddTraceback("csamtools.SNPCaller.__cinit__");
+  __Pyx_RefNannyFinishContext();
+  return -1;
+  __pyx_L4_argument_unpacking_done:;
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_iterator_column), __pyx_ptype_9csamtools_IteratorColumn, 1, "iterator_column", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3036; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-static int __pyx_setprop_9csamtools_11AlignedRead_rnext(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_9csamtools_11AlignedRead_5rnext_1__set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
-  }
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("csamtools.SNPCaller.__cinit__");
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_kwargs);
+  __Pyx_TraceReturn(Py_None);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
 }
 
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_mpos(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_4mpos___get__(o);
-}
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3041
+ *         pass
+ * 
+ *     def call(self, reference, int pos ):             # <<<<<<<<<<<<<<
+ *         """call a snp on chromosome *reference*
+ *         and position *pos*.
+ */
 
-static int __pyx_setprop_9csamtools_11AlignedRead_mpos(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_9csamtools_11AlignedRead_4mpos_1__set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
+static PyObject *__pyx_pf_9csamtools_9SNPCaller_call(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_9csamtools_9SNPCaller_call[] = "SNPCaller.call(self, reference, int pos)\ncall a snp on chromosome *reference*\n        and position *pos*.\n\n        returns a :class:`SNPCall` object.\n        ";
+static PyObject *__pyx_pf_9csamtools_9SNPCaller_call(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_reference = 0;
+  int __pyx_v_pos;
+  int __pyx_v_tid;
+  char *__pyx_v_seq;
+  int __pyx_v_seq_len;
+  int __pyx_v_rb;
+  uint32_t __pyx_v_cns;
+  glf1_t *__pyx_v_g;
+  struct __pyx_obj_9csamtools_SNPCall *__pyx_v_call;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  int __pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  int __pyx_t_6;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__reference,&__pyx_n_s__pos,0};
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("call");
+  __Pyx_TraceCall("call", __pyx_f[0], 3041);
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[2] = {0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reference);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pos);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("call", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3041; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "call") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3041; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_reference = values[0];
+    __pyx_v_pos = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_pos == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3041; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_reference = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_pos = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_pos == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3041; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   }
-}
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("call", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3041; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("csamtools.SNPCaller.call");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_v_call = ((struct __pyx_obj_9csamtools_SNPCall *)Py_None); __Pyx_INCREF(Py_None);
 
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_pnext(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_5pnext___get__(o);
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3048
+ *         """
+ * 
+ *         cdef int tid = self.iter.samfile.gettid( reference )             # <<<<<<<<<<<<<<
+ * 
+ *         self.iter.reset( tid, pos, pos + 1 )
+ */
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->samfile), __pyx_n_s__gettid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_v_reference);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_reference);
+  __Pyx_GIVEREF(__pyx_v_reference);
+  __pyx_t_3 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_v_tid = __pyx_t_4;
 
-static int __pyx_setprop_9csamtools_11AlignedRead_pnext(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_9csamtools_11AlignedRead_5pnext_1__set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
-  }
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3050
+ *         cdef int tid = self.iter.samfile.gettid( reference )
+ * 
+ *         self.iter.reset( tid, pos, pos + 1 )             # <<<<<<<<<<<<<<
+ * 
+ *         while 1:
+ */
+  __pyx_t_3 = PyInt_FromLong(__pyx_v_tid); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_2 = PyInt_FromLong(__pyx_v_pos); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_1 = PyInt_FromLong((__pyx_v_pos + 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_5 = ((struct __pyx_vtabstruct_9csamtools_IteratorColumn *)((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->__pyx_vtab)->reset(((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter, __pyx_t_3, __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_isize(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_5isize___get__(o);
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3052
+ *         self.iter.reset( tid, pos, pos + 1 )
+ * 
+ *         while 1:             # <<<<<<<<<<<<<<
+ *             self.iter.cnext()
+ * 
+ */
+  while (1) {
+    if (!1) break;
 
-static int __pyx_setprop_9csamtools_11AlignedRead_isize(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_9csamtools_11AlignedRead_5isize_1__set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
-  }
-}
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3053
+ * 
+ *         while 1:
+ *             self.iter.cnext()             # <<<<<<<<<<<<<<
+ * 
+ *             if self.iter.n_plp < 0:
+ */
+    ((struct __pyx_vtabstruct_9csamtools_IteratorColumn *)((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->__pyx_vtab)->cnext(((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter);
 
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_tlen(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_4tlen___get__(o);
-}
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3055
+ *             self.iter.cnext()
+ * 
+ *             if self.iter.n_plp < 0:             # <<<<<<<<<<<<<<
+ *                 raise ValueError("error during iteration" )
+ * 
+ */
+    __pyx_t_6 = (((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->n_plp < 0);
+    if (__pyx_t_6) {
 
-static int __pyx_setprop_9csamtools_11AlignedRead_tlen(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_9csamtools_11AlignedRead_4tlen_1__set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
-  }
-}
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3056
+ * 
+ *             if self.iter.n_plp < 0:
+ *                 raise ValueError("error during iteration" )             # <<<<<<<<<<<<<<
+ * 
+ *             if self.iter.plp == NULL:
+ */
+      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_59));
+      PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_59));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_59));
+      __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_Raise(__pyx_t_1, 0, 0);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      goto __pyx_L8;
+    }
+    __pyx_L8:;
 
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_paired(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_9is_paired___get__(o);
-}
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3058
+ *                 raise ValueError("error during iteration" )
+ * 
+ *             if self.iter.plp == NULL:             # <<<<<<<<<<<<<<
+ *                 raise ValueError( "no reads in region - no call" )
+ * 
+ */
+    __pyx_t_6 = (((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->plp == NULL);
+    if (__pyx_t_6) {
 
-static int __pyx_setprop_9csamtools_11AlignedRead_is_paired(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_9csamtools_11AlignedRead_9is_paired_1__set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3059
+ * 
+ *             if self.iter.plp == NULL:
+ *                 raise ValueError( "no reads in region - no call" )             # <<<<<<<<<<<<<<
+ * 
+ *             if self.iter.pos == pos: break
+ */
+      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_109));
+      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_109));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_109));
+      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_Raise(__pyx_t_5, 0, 0);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      goto __pyx_L9;
+    }
+    __pyx_L9:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3061
+ *                 raise ValueError( "no reads in region - no call" )
+ * 
+ *             if self.iter.pos == pos: break             # <<<<<<<<<<<<<<
+ * 
+ *         cdef char * seq = self.iter.getSequence()
+ */
+    __pyx_t_6 = (((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->pos == __pyx_v_pos);
+    if (__pyx_t_6) {
+      goto __pyx_L7_break;
+      goto __pyx_L10;
+    }
+    __pyx_L10:;
   }
-}
+  __pyx_L7_break:;
 
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_proper_pair(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_14is_proper_pair___get__(o);
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3063
+ *             if self.iter.pos == pos: break
+ * 
+ *         cdef char * seq = self.iter.getSequence()             # <<<<<<<<<<<<<<
+ *         cdef int seq_len = self.iter.seq_len
+ * 
+ */
+  __pyx_v_seq = ((struct __pyx_vtabstruct_9csamtools_IteratorColumn *)((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->__pyx_vtab)->getSequence(((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter);
 
-static int __pyx_setprop_9csamtools_11AlignedRead_is_proper_pair(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_9csamtools_11AlignedRead_14is_proper_pair_1__set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3064
+ * 
+ *         cdef char * seq = self.iter.getSequence()
+ *         cdef int seq_len = self.iter.seq_len             # <<<<<<<<<<<<<<
+ * 
+ *         assert seq != NULL
+ */
+  __pyx_t_5 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter), __pyx_n_s__seq_len); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+  __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_5); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __pyx_v_seq_len = __pyx_t_4;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3066
+ *         cdef int seq_len = self.iter.seq_len
+ * 
+ *         assert seq != NULL             # <<<<<<<<<<<<<<
+ * 
+ *         # reference base
+ */
+  #ifndef PYREX_WITHOUT_ASSERTIONS
+  if (unlikely(!(__pyx_v_seq != NULL))) {
+    PyErr_SetNone(PyExc_AssertionError);
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
-}
+  #endif
 
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_unmapped(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_11is_unmapped___get__(o);
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3069
+ * 
+ *         # reference base
+ *         if self.iter.pos >= seq_len:             # <<<<<<<<<<<<<<
+ *             raise ValueError( "position %i out of bounds on reference sequence (len=%i)" % (self.iter.pos, seq_len) )
+ * 
+ */
+  __pyx_t_6 = (((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->pos >= __pyx_v_seq_len);
+  if (__pyx_t_6) {
 
-static int __pyx_setprop_9csamtools_11AlignedRead_is_unmapped(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_9csamtools_11AlignedRead_11is_unmapped_1__set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3070
+ *         # reference base
+ *         if self.iter.pos >= seq_len:
+ *             raise ValueError( "position %i out of bounds on reference sequence (len=%i)" % (self.iter.pos, seq_len) )             # <<<<<<<<<<<<<<
+ * 
+ *         cdef int rb = seq[self.iter.pos]
+ */
+    __pyx_t_5 = PyInt_FromLong(((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->pos); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_1 = PyInt_FromLong(__pyx_v_seq_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5);
+    __Pyx_GIVEREF(__pyx_t_5);
+    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
+    __Pyx_GIVEREF(__pyx_t_1);
+    __pyx_t_5 = 0;
+    __pyx_t_1 = 0;
+    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_108), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
+    __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
+    __pyx_t_1 = 0;
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_Raise(__pyx_t_1, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L11;
   }
-}
+  __pyx_L11:;
 
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_mate_is_unmapped(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_16mate_is_unmapped___get__(o);
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3072
+ *             raise ValueError( "position %i out of bounds on reference sequence (len=%i)" % (self.iter.pos, seq_len) )
+ * 
+ *         cdef int rb = seq[self.iter.pos]             # <<<<<<<<<<<<<<
+ *         cdef uint32_t cns
+ *         cdef glf1_t * g
+ */
+  __pyx_v_rb = (__pyx_v_seq[((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->pos]);
 
-static int __pyx_setprop_9csamtools_11AlignedRead_mate_is_unmapped(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_9csamtools_11AlignedRead_16mate_is_unmapped_1__set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
-  }
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3079
+ *                                self.iter.plp,
+ *                                bam_nt16_table[rb],
+ *                                self.c )             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_v_g = bam_maqcns_glfgen(((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->n_plp, ((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->plp, (bam_nt16_table[__pyx_v_rb]), ((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.c);
 
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_reverse(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_10is_reverse___get__(o);
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3082
+ * 
+ * 
+ *         if pysam_glf_depth( g ) == 0:             # <<<<<<<<<<<<<<
+ *             cns = 0xfu << 28 | 0xf << 24
+ *         else:
+ */
+  __pyx_t_6 = (pysam_glf_depth(__pyx_v_g) == 0);
+  if (__pyx_t_6) {
 
-static int __pyx_setprop_9csamtools_11AlignedRead_is_reverse(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_9csamtools_11AlignedRead_10is_reverse_1__set__(o, v);
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3083
+ * 
+ *         if pysam_glf_depth( g ) == 0:
+ *             cns = 0xfu << 28 | 0xf << 24             # <<<<<<<<<<<<<<
+ *         else:
+ *             cns = glf2cns(g, <int>(self.c.q_r + .499))
+ */
+    __pyx_v_cns = 4278190080U;
+    goto __pyx_L12;
   }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
+  /*else*/ {
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3085
+ *             cns = 0xfu << 28 | 0xf << 24
+ *         else:
+ *             cns = glf2cns(g, <int>(self.c.q_r + .499))             # <<<<<<<<<<<<<<
+ * 
+ *         free(g)
+ */
+    __pyx_v_cns = glf2cns(__pyx_v_g, ((int)(((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.c->q_r + .499)));
   }
-}
+  __pyx_L12:;
 
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_mate_is_reverse(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_15mate_is_reverse___get__(o);
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3087
+ *             cns = glf2cns(g, <int>(self.c.q_r + .499))
+ * 
+ *         free(g)             # <<<<<<<<<<<<<<
+ * 
+ *         cdef SNPCall call
+ */
+  free(__pyx_v_g);
 
-static int __pyx_setprop_9csamtools_11AlignedRead_mate_is_reverse(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_9csamtools_11AlignedRead_15mate_is_reverse_1__set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
-  }
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3091
+ *         cdef SNPCall call
+ * 
+ *         call = SNPCall()             # <<<<<<<<<<<<<<
+ *         call._tid = self.iter.tid
+ *         call._pos = self.iter.pos
+ */
+  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_SNPCall)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(((PyObject *)__pyx_v_call));
+  __pyx_v_call = ((struct __pyx_obj_9csamtools_SNPCall *)__pyx_t_1);
+  __pyx_t_1 = 0;
 
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_read1(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_8is_read1___get__(o);
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3092
+ * 
+ *         call = SNPCall()
+ *         call._tid = self.iter.tid             # <<<<<<<<<<<<<<
+ *         call._pos = self.iter.pos
+ *         call._reference_base = rb
+ */
+  __pyx_v_call->_tid = ((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->tid;
 
-static int __pyx_setprop_9csamtools_11AlignedRead_is_read1(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_9csamtools_11AlignedRead_8is_read1_1__set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
-  }
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3093
+ *         call = SNPCall()
+ *         call._tid = self.iter.tid
+ *         call._pos = self.iter.pos             # <<<<<<<<<<<<<<
+ *         call._reference_base = rb
+ *         call._genotype = bam_nt16_rev_table[cns>>28]
+ */
+  __pyx_v_call->_pos = ((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->pos;
 
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_read2(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_8is_read2___get__(o);
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3094
+ *         call._tid = self.iter.tid
+ *         call._pos = self.iter.pos
+ *         call._reference_base = rb             # <<<<<<<<<<<<<<
+ *         call._genotype = bam_nt16_rev_table[cns>>28]
+ *         call._consensus_quality = cns >> 8 & 0xff
+ */
+  __pyx_v_call->_reference_base = __pyx_v_rb;
 
-static int __pyx_setprop_9csamtools_11AlignedRead_is_read2(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_9csamtools_11AlignedRead_8is_read2_1__set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
-  }
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3095
+ *         call._pos = self.iter.pos
+ *         call._reference_base = rb
+ *         call._genotype = bam_nt16_rev_table[cns>>28]             # <<<<<<<<<<<<<<
+ *         call._consensus_quality = cns >> 8 & 0xff
+ *         call._snp_quality = cns & 0xff
+ */
+  __pyx_v_call->_genotype = (__pyx_v_9csamtools_bam_nt16_rev_table[(__pyx_v_cns >> 28)]);
 
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_secondary(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_12is_secondary___get__(o);
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3096
+ *         call._reference_base = rb
+ *         call._genotype = bam_nt16_rev_table[cns>>28]
+ *         call._consensus_quality = cns >> 8 & 0xff             # <<<<<<<<<<<<<<
+ *         call._snp_quality = cns & 0xff
+ *         call._rms_mapping_quality = cns >> 16&0xff
+ */
+  __pyx_v_call->_consensus_quality = ((__pyx_v_cns >> 8) & 0xff);
 
-static int __pyx_setprop_9csamtools_11AlignedRead_is_secondary(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_9csamtools_11AlignedRead_12is_secondary_1__set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
-  }
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3097
+ *         call._genotype = bam_nt16_rev_table[cns>>28]
+ *         call._consensus_quality = cns >> 8 & 0xff
+ *         call._snp_quality = cns & 0xff             # <<<<<<<<<<<<<<
+ *         call._rms_mapping_quality = cns >> 16&0xff
+ *         call._coverage = self.iter.n_plp
+ */
+  __pyx_v_call->_snp_quality = (__pyx_v_cns & 0xff);
 
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_qcfail(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_9is_qcfail___get__(o);
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3098
+ *         call._consensus_quality = cns >> 8 & 0xff
+ *         call._snp_quality = cns & 0xff
+ *         call._rms_mapping_quality = cns >> 16&0xff             # <<<<<<<<<<<<<<
+ *         call._coverage = self.iter.n_plp
+ * 
+ */
+  __pyx_v_call->_rms_mapping_quality = ((__pyx_v_cns >> 16) & 0xff);
 
-static int __pyx_setprop_9csamtools_11AlignedRead_is_qcfail(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_9csamtools_11AlignedRead_9is_qcfail_1__set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
-  }
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3099
+ *         call._snp_quality = cns & 0xff
+ *         call._rms_mapping_quality = cns >> 16&0xff
+ *         call._coverage = self.iter.n_plp             # <<<<<<<<<<<<<<
+ * 
+ *         return call
+ */
+  __pyx_v_call->_coverage = ((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->n_plp;
 
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_duplicate(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_12is_duplicate___get__(o);
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3101
+ *         call._coverage = self.iter.n_plp
+ * 
+ *         return call             # <<<<<<<<<<<<<<
+ * 
+ * cdef class IndelCall:
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(((PyObject *)__pyx_v_call));
+  __pyx_r = ((PyObject *)__pyx_v_call);
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_AddTraceback("csamtools.SNPCaller.call");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF((PyObject *)__pyx_v_call);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
 }
 
-static int __pyx_setprop_9csamtools_11AlignedRead_is_duplicate(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_9csamtools_11AlignedRead_12is_duplicate_1__set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
-  }
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3111
+ *     cdef bam_maqindel_ret_t * _r
+ * 
+ *     def __cinit__(self):             # <<<<<<<<<<<<<<
+ *         #assert r != NULL
+ *         #self._r = r
+ */
+
+static int __pyx_pf_9csamtools_9IndelCall___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pf_9csamtools_9IndelCall___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  int __pyx_r;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__cinit__");
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 3111);
+  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
+    __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
+  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;
+
+  __pyx_r = 0;
+  __Pyx_TraceReturn(Py_None);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
 }
 
-static PyObject *__pyx_getprop_9csamtools_11AlignedRead_positions(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11AlignedRead_9positions___get__(o);
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3118
+ *     property tid:
+ *         '''the chromosome ID as is defined in the header'''
+ *         def __get__(self):             # <<<<<<<<<<<<<<
+ *             return self._tid
+ * 
+ */
+
+static PyObject *__pyx_pf_9csamtools_9IndelCall_3tid___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_9IndelCall_3tid___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__get__");
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3118);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3119
+ *         '''the chromosome ID as is defined in the header'''
+ *         def __get__(self):
+ *             return self._tid             # <<<<<<<<<<<<<<
+ * 
+ *     property pos:
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("csamtools.IndelCall.tid.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
 }
 
-static PyMethodDef __pyx_methods_9csamtools_AlignedRead[] = {
-  {__Pyx_NAMESTR("compare"), (PyCFunction)__pyx_pf_9csamtools_11AlignedRead_3compare, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_11AlignedRead_3compare)},
-  {__Pyx_NAMESTR("overlap"), (PyCFunction)__pyx_pf_9csamtools_11AlignedRead_5overlap, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_11AlignedRead_5overlap)},
-  {__Pyx_NAMESTR("opt"), (PyCFunction)__pyx_pf_9csamtools_11AlignedRead_6opt, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_11AlignedRead_6opt)},
-  {__Pyx_NAMESTR("fancy_str"), (PyCFunction)__pyx_pf_9csamtools_11AlignedRead_7fancy_str, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_11AlignedRead_7fancy_str)},
-  {0, 0, 0, 0}
-};
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3123
+ *     property pos:
+ *        '''nucleotide position of SNP.'''
+ *        def __get__(self): return self._pos             # <<<<<<<<<<<<<<
+ * 
+ *     property genotype:
+ */
 
-static struct PyGetSetDef __pyx_getsets_9csamtools_AlignedRead[] = {
-  {(char *)"qname", __pyx_getprop_9csamtools_11AlignedRead_qname, __pyx_setprop_9csamtools_11AlignedRead_qname, __Pyx_DOCSTR(__pyx_k_169), 0},
-  {(char *)"cigar", __pyx_getprop_9csamtools_11AlignedRead_cigar, __pyx_setprop_9csamtools_11AlignedRead_cigar, __Pyx_DOCSTR(__pyx_k_170), 0},
-  {(char *)"seq", __pyx_getprop_9csamtools_11AlignedRead_seq, __pyx_setprop_9csamtools_11AlignedRead_seq, __Pyx_DOCSTR(__pyx_k_171), 0},
-  {(char *)"qual", __pyx_getprop_9csamtools_11AlignedRead_qual, __pyx_setprop_9csamtools_11AlignedRead_qual, __Pyx_DOCSTR(__pyx_k_172), 0},
-  {(char *)"query", __pyx_getprop_9csamtools_11AlignedRead_query, 0, __Pyx_DOCSTR(__pyx_k_173), 0},
-  {(char *)"qqual", __pyx_getprop_9csamtools_11AlignedRead_qqual, 0, __Pyx_DOCSTR(__pyx_k_174), 0},
-  {(char *)"qstart", __pyx_getprop_9csamtools_11AlignedRead_qstart, 0, __Pyx_DOCSTR(__pyx_k_175), 0},
-  {(char *)"qend", __pyx_getprop_9csamtools_11AlignedRead_qend, 0, __Pyx_DOCSTR(__pyx_k_176), 0},
-  {(char *)"qlen", __pyx_getprop_9csamtools_11AlignedRead_qlen, 0, __Pyx_DOCSTR(__pyx_k_177), 0},
-  {(char *)"tags", __pyx_getprop_9csamtools_11AlignedRead_tags, __pyx_setprop_9csamtools_11AlignedRead_tags, __Pyx_DOCSTR(__pyx_k_178), 0},
-  {(char *)"flag", __pyx_getprop_9csamtools_11AlignedRead_flag, __pyx_setprop_9csamtools_11AlignedRead_flag, __Pyx_DOCSTR(__pyx_k_179), 0},
-  {(char *)"rname", __pyx_getprop_9csamtools_11AlignedRead_rname, __pyx_setprop_9csamtools_11AlignedRead_rname, __Pyx_DOCSTR(__pyx_k_180), 0},
-  {(char *)"tid", __pyx_getprop_9csamtools_11AlignedRead_tid, __pyx_setprop_9csamtools_11AlignedRead_tid, __Pyx_DOCSTR(__pyx_k_181), 0},
-  {(char *)"pos", __pyx_getprop_9csamtools_11AlignedRead_pos, __pyx_setprop_9csamtools_11AlignedRead_pos, __Pyx_DOCSTR(__pyx_k_182), 0},
-  {(char *)"bin", __pyx_getprop_9csamtools_11AlignedRead_bin, __pyx_setprop_9csamtools_11AlignedRead_bin, __Pyx_DOCSTR(__pyx_k_183), 0},
-  {(char *)"rlen", __pyx_getprop_9csamtools_11AlignedRead_rlen, 0, __Pyx_DOCSTR(__pyx_k_184), 0},
-  {(char *)"aend", __pyx_getprop_9csamtools_11AlignedRead_aend, 0, __Pyx_DOCSTR(__pyx_k_185), 0},
-  {(char *)"alen", __pyx_getprop_9csamtools_11AlignedRead_alen, 0, __Pyx_DOCSTR(__pyx_k_186), 0},
-  {(char *)"mapq", __pyx_getprop_9csamtools_11AlignedRead_mapq, __pyx_setprop_9csamtools_11AlignedRead_mapq, __Pyx_DOCSTR(__pyx_k_187), 0},
-  {(char *)"mrnm", __pyx_getprop_9csamtools_11AlignedRead_mrnm, __pyx_setprop_9csamtools_11AlignedRead_mrnm, __Pyx_DOCSTR(__pyx_k_188), 0},
-  {(char *)"rnext", __pyx_getprop_9csamtools_11AlignedRead_rnext, __pyx_setprop_9csamtools_11AlignedRead_rnext, __Pyx_DOCSTR(__pyx_k_189), 0},
-  {(char *)"mpos", __pyx_getprop_9csamtools_11AlignedRead_mpos, __pyx_setprop_9csamtools_11AlignedRead_mpos, __Pyx_DOCSTR(__pyx_k_190), 0},
-  {(char *)"pnext", __pyx_getprop_9csamtools_11AlignedRead_pnext, __pyx_setprop_9csamtools_11AlignedRead_pnext, __Pyx_DOCSTR(__pyx_k_191), 0},
-  {(char *)"isize", __pyx_getprop_9csamtools_11AlignedRead_isize, __pyx_setprop_9csamtools_11AlignedRead_isize, __Pyx_DOCSTR(__pyx_k_192), 0},
-  {(char *)"tlen", __pyx_getprop_9csamtools_11AlignedRead_tlen, __pyx_setprop_9csamtools_11AlignedRead_tlen, __Pyx_DOCSTR(__pyx_k_193), 0},
-  {(char *)"is_paired", __pyx_getprop_9csamtools_11AlignedRead_is_paired, __pyx_setprop_9csamtools_11AlignedRead_is_paired, __Pyx_DOCSTR(__pyx_k_194), 0},
-  {(char *)"is_proper_pair", __pyx_getprop_9csamtools_11AlignedRead_is_proper_pair, __pyx_setprop_9csamtools_11AlignedRead_is_proper_pair, __Pyx_DOCSTR(__pyx_k_195), 0},
-  {(char *)"is_unmapped", __pyx_getprop_9csamtools_11AlignedRead_is_unmapped, __pyx_setprop_9csamtools_11AlignedRead_is_unmapped, __Pyx_DOCSTR(__pyx_k_196), 0},
-  {(char *)"mate_is_unmapped", __pyx_getprop_9csamtools_11AlignedRead_mate_is_unmapped, __pyx_setprop_9csamtools_11AlignedRead_mate_is_unmapped, __Pyx_DOCSTR(__pyx_k_197), 0},
-  {(char *)"is_reverse", __pyx_getprop_9csamtools_11AlignedRead_is_reverse, __pyx_setprop_9csamtools_11AlignedRead_is_reverse, __Pyx_DOCSTR(__pyx_k_198), 0},
-  {(char *)"mate_is_reverse", __pyx_getprop_9csamtools_11AlignedRead_mate_is_reverse, __pyx_setprop_9csamtools_11AlignedRead_mate_is_reverse, __Pyx_DOCSTR(__pyx_k_199), 0},
-  {(char *)"is_read1", __pyx_getprop_9csamtools_11AlignedRead_is_read1, __pyx_setprop_9csamtools_11AlignedRead_is_read1, __Pyx_DOCSTR(__pyx_k_200), 0},
-  {(char *)"is_read2", __pyx_getprop_9csamtools_11AlignedRead_is_read2, __pyx_setprop_9csamtools_11AlignedRead_is_read2, __Pyx_DOCSTR(__pyx_k_201), 0},
-  {(char *)"is_secondary", __pyx_getprop_9csamtools_11AlignedRead_is_secondary, __pyx_setprop_9csamtools_11AlignedRead_is_secondary, __Pyx_DOCSTR(__pyx_k_202), 0},
-  {(char *)"is_qcfail", __pyx_getprop_9csamtools_11AlignedRead_is_qcfail, __pyx_setprop_9csamtools_11AlignedRead_is_qcfail, __Pyx_DOCSTR(__pyx_k_203), 0},
-  {(char *)"is_duplicate", __pyx_getprop_9csamtools_11AlignedRead_is_duplicate, __pyx_setprop_9csamtools_11AlignedRead_is_duplicate, __Pyx_DOCSTR(__pyx_k_204), 0},
-  {(char *)"positions", __pyx_getprop_9csamtools_11AlignedRead_positions, 0, __Pyx_DOCSTR(__pyx_k_205), 0},
-  {0, 0, 0, 0, 0}
-};
+static PyObject *__pyx_pf_9csamtools_9IndelCall_3pos___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_9IndelCall_3pos___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__get__");
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3123);
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_pos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
 
-static PyNumberMethods __pyx_tp_as_number_AlignedRead = {
-  0, /*nb_add*/
-  0, /*nb_subtract*/
-  0, /*nb_multiply*/
-  #if PY_MAJOR_VERSION < 3
-  0, /*nb_divide*/
-  #endif
-  0, /*nb_remainder*/
-  0, /*nb_divmod*/
-  0, /*nb_power*/
-  0, /*nb_negative*/
-  0, /*nb_positive*/
-  0, /*nb_absolute*/
-  0, /*nb_nonzero*/
-  0, /*nb_invert*/
-  0, /*nb_lshift*/
-  0, /*nb_rshift*/
-  0, /*nb_and*/
-  0, /*nb_xor*/
-  0, /*nb_or*/
-  #if PY_MAJOR_VERSION < 3
-  0, /*nb_coerce*/
-  #endif
-  0, /*nb_int*/
-  #if PY_MAJOR_VERSION < 3
-  0, /*nb_long*/
-  #else
-  0, /*reserved*/
-  #endif
-  0, /*nb_float*/
-  #if PY_MAJOR_VERSION < 3
-  0, /*nb_oct*/
-  #endif
-  #if PY_MAJOR_VERSION < 3
-  0, /*nb_hex*/
-  #endif
-  0, /*nb_inplace_add*/
-  0, /*nb_inplace_subtract*/
-  0, /*nb_inplace_multiply*/
-  #if PY_MAJOR_VERSION < 3
-  0, /*nb_inplace_divide*/
-  #endif
-  0, /*nb_inplace_remainder*/
-  0, /*nb_inplace_power*/
-  0, /*nb_inplace_lshift*/
-  0, /*nb_inplace_rshift*/
-  0, /*nb_inplace_and*/
-  0, /*nb_inplace_xor*/
-  0, /*nb_inplace_or*/
-  0, /*nb_floor_divide*/
-  0, /*nb_true_divide*/
-  0, /*nb_inplace_floor_divide*/
-  0, /*nb_inplace_true_divide*/
-  #if PY_VERSION_HEX >= 0x02050000
-  0, /*nb_index*/
-  #endif
-};
-
-static PySequenceMethods __pyx_tp_as_sequence_AlignedRead = {
-  0, /*sq_length*/
-  0, /*sq_concat*/
-  0, /*sq_repeat*/
-  0, /*sq_item*/
-  0, /*sq_slice*/
-  0, /*sq_ass_item*/
-  0, /*sq_ass_slice*/
-  0, /*sq_contains*/
-  0, /*sq_inplace_concat*/
-  0, /*sq_inplace_repeat*/
-};
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("csamtools.IndelCall.pos.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
 
-static PyMappingMethods __pyx_tp_as_mapping_AlignedRead = {
-  0, /*mp_length*/
-  0, /*mp_subscript*/
-  0, /*mp_ass_subscript*/
-};
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3127
+ *     property genotype:
+ *        '''the genotype called.'''
+ *        def __get__(self):             # <<<<<<<<<<<<<<
+ *            if self._r.gt == 0:
+ *                s = PyString_FromStringAndSize( self._r.s[0], self._r.indel1 + 1)
+ */
 
-static PyBufferProcs __pyx_tp_as_buffer_AlignedRead = {
-  #if PY_MAJOR_VERSION < 3
-  0, /*bf_getreadbuffer*/
-  #endif
-  #if PY_MAJOR_VERSION < 3
-  0, /*bf_getwritebuffer*/
-  #endif
-  #if PY_MAJOR_VERSION < 3
-  0, /*bf_getsegcount*/
-  #endif
-  #if PY_MAJOR_VERSION < 3
-  0, /*bf_getcharbuffer*/
-  #endif
-  #if PY_VERSION_HEX >= 0x02060000
-  0, /*bf_getbuffer*/
-  #endif
-  #if PY_VERSION_HEX >= 0x02060000
-  0, /*bf_releasebuffer*/
-  #endif
-};
+static PyObject *__pyx_pf_9csamtools_9IndelCall_8genotype___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_9IndelCall_8genotype___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_v_s;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__get__");
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3127);
+  __pyx_v_s = Py_None; __Pyx_INCREF(Py_None);
 
-static PyTypeObject __pyx_type_9csamtools_AlignedRead = {
-  PyVarObject_HEAD_INIT(0, 0)
-  __Pyx_NAMESTR("csamtools.AlignedRead"), /*tp_name*/
-  sizeof(struct __pyx_obj_9csamtools_AlignedRead), /*tp_basicsize*/
-  0, /*tp_itemsize*/
-  __pyx_tp_dealloc_9csamtools_AlignedRead, /*tp_dealloc*/
-  0, /*tp_print*/
-  0, /*tp_getattr*/
-  0, /*tp_setattr*/
-  #if PY_MAJOR_VERSION < 3
-  0, /*tp_compare*/
-  #else
-  0, /*reserved*/
-  #endif
-  0, /*tp_repr*/
-  &__pyx_tp_as_number_AlignedRead, /*tp_as_number*/
-  &__pyx_tp_as_sequence_AlignedRead, /*tp_as_sequence*/
-  &__pyx_tp_as_mapping_AlignedRead, /*tp_as_mapping*/
-  __pyx_pf_9csamtools_11AlignedRead_4__hash__, /*tp_hash*/
-  0, /*tp_call*/
-  __pyx_pf_9csamtools_11AlignedRead_2__str__, /*tp_str*/
-  0, /*tp_getattro*/
-  0, /*tp_setattro*/
-  &__pyx_tp_as_buffer_AlignedRead, /*tp_as_buffer*/
-  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
-  __Pyx_DOCSTR("AlignedRead()\n\n    Class representing an aligned read. see SAM format specification for \n    the meaning of fields (http://samtools.sourceforge.net/).\n\n    This class stores a handle to the samtools C-structure representing\n    an aligned read. Member read access is forwarded to the C-structure\n    and converted into python objects. This implementation should be fast,\n    as only the data needed is converted.\n\n    For write access, the C-structure is updated in-place. This is\n    not the most efficient way to build BAM entries, as the variable\n    length data is concatenated and thus needs to resized if\n    a field is updated. Furthermore, the BAM entry might be\n    in an inconsistent state. The :meth:`~validate` method can\n    be used to check if an entry is consistent.\n\n    One issue to look out for is that the sequence should always\n    be set *before* the quality scores. Setting the sequence will\n    also erase any quality scores that were set previously.\n    "), /*tp_doc*/
-  0, /*tp_traverse*/
-  0, /*tp_clear*/
-  0, /*tp_richcompare*/
-  0, /*tp_weaklistoffset*/
-  0, /*tp_iter*/
-  0, /*tp_iternext*/
-  __pyx_methods_9csamtools_AlignedRead, /*tp_methods*/
-  0, /*tp_members*/
-  __pyx_getsets_9csamtools_AlignedRead, /*tp_getset*/
-  0, /*tp_base*/
-  0, /*tp_dict*/
-  0, /*tp_descr_get*/
-  0, /*tp_descr_set*/
-  0, /*tp_dictoffset*/
-  __pyx_pf_9csamtools_11AlignedRead___init__, /*tp_init*/
-  0, /*tp_alloc*/
-  __pyx_tp_new_9csamtools_AlignedRead, /*tp_new*/
-  0, /*tp_free*/
-  0, /*tp_is_gc*/
-  0, /*tp_bases*/
-  0, /*tp_mro*/
-  0, /*tp_cache*/
-  0, /*tp_subclasses*/
-  0, /*tp_weaklist*/
-  0, /*tp_del*/
-  #if PY_VERSION_HEX >= 0x02060000
-  0, /*tp_version_tag*/
-  #endif
-};
-static struct __pyx_vtabstruct_9csamtools_Samfile __pyx_vtable_9csamtools_Samfile;
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3128
+ *        '''the genotype called.'''
+ *        def __get__(self):
+ *            if self._r.gt == 0:             # <<<<<<<<<<<<<<
+ *                s = PyString_FromStringAndSize( self._r.s[0], self._r.indel1 + 1)
+ *                return "%s/%s" % (s,s)
+ */
+  switch (((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->gt) {
+    case 0:
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3129
+ *        def __get__(self):
+ *            if self._r.gt == 0:
+ *                s = PyString_FromStringAndSize( self._r.s[0], self._r.indel1 + 1)             # <<<<<<<<<<<<<<
+ *                return "%s/%s" % (s,s)
+ *            elif self._r.gt == 1:
+ */
+    __pyx_t_1 = PyString_FromStringAndSize((((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->s[0]), (((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->indel1 + 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_v_s);
+    __pyx_v_s = __pyx_t_1;
+    __pyx_t_1 = 0;
 
-static PyObject *__pyx_tp_new_9csamtools_Samfile(PyTypeObject *t, PyObject *a, PyObject *k) {
-  struct __pyx_obj_9csamtools_Samfile *p;
-  PyObject *o = (*t->tp_alloc)(t, 0);
-  if (!o) return 0;
-  p = ((struct __pyx_obj_9csamtools_Samfile *)o);
-  p->__pyx_vtab = __pyx_vtabptr_9csamtools_Samfile;
-  if (__pyx_pf_9csamtools_7Samfile___cinit__(o, a, k) < 0) {
-    Py_DECREF(o); o = 0;
-  }
-  return o;
-}
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3130
+ *            if self._r.gt == 0:
+ *                s = PyString_FromStringAndSize( self._r.s[0], self._r.indel1 + 1)
+ *                return "%s/%s" % (s,s)             # <<<<<<<<<<<<<<
+ *            elif self._r.gt == 1:
+ *                s = PyString_FromStringAndSize( self._r.s[1], self._r.indel2 + 1)
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_INCREF(__pyx_v_s);
+    PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_s);
+    __Pyx_GIVEREF(__pyx_v_s);
+    __Pyx_INCREF(__pyx_v_s);
+    PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_s);
+    __Pyx_GIVEREF(__pyx_v_s);
+    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_110), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_r = ((PyObject *)__pyx_t_2);
+    __pyx_t_2 = 0;
+    goto __pyx_L0;
+    break;
 
-static void __pyx_tp_dealloc_9csamtools_Samfile(PyObject *o) {
-  {
-    PyObject *etype, *eval, *etb;
-    PyErr_Fetch(&etype, &eval, &etb);
-    ++Py_REFCNT(o);
-    __pyx_pf_9csamtools_7Samfile_15__dealloc__(o);
-    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
-    --Py_REFCNT(o);
-    PyErr_Restore(etype, eval, etb);
-  }
-  (*Py_TYPE(o)->tp_free)(o);
-}
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3131
+ *                s = PyString_FromStringAndSize( self._r.s[0], self._r.indel1 + 1)
+ *                return "%s/%s" % (s,s)
+ *            elif self._r.gt == 1:             # <<<<<<<<<<<<<<
+ *                s = PyString_FromStringAndSize( self._r.s[1], self._r.indel2 + 1)
+ *                return "%s/%s" % (s,s)
+ */
+    case 1:
 
-static PyObject *__pyx_getprop_9csamtools_7Samfile_filename(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_7Samfile_8filename___get__(o);
-}
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3132
+ *                return "%s/%s" % (s,s)
+ *            elif self._r.gt == 1:
+ *                s = PyString_FromStringAndSize( self._r.s[1], self._r.indel2 + 1)             # <<<<<<<<<<<<<<
+ *                return "%s/%s" % (s,s)
+ *            else:
+ */
+    __pyx_t_2 = PyString_FromStringAndSize((((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->s[1]), (((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->indel2 + 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_v_s);
+    __pyx_v_s = __pyx_t_2;
+    __pyx_t_2 = 0;
 
-static PyObject *__pyx_getprop_9csamtools_7Samfile_nreferences(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_7Samfile_11nreferences___get__(o);
-}
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3133
+ *            elif self._r.gt == 1:
+ *                s = PyString_FromStringAndSize( self._r.s[1], self._r.indel2 + 1)
+ *                return "%s/%s" % (s,s)             # <<<<<<<<<<<<<<
+ *            else:
+ *                return "%s/%s" % (self.first_allele, self.second_allele )
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_INCREF(__pyx_v_s);
+    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_s);
+    __Pyx_GIVEREF(__pyx_v_s);
+    __Pyx_INCREF(__pyx_v_s);
+    PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_s);
+    __Pyx_GIVEREF(__pyx_v_s);
+    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_110), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_r = ((PyObject *)__pyx_t_1);
+    __pyx_t_1 = 0;
+    goto __pyx_L0;
+    break;
+    default:
 
-static PyObject *__pyx_getprop_9csamtools_7Samfile_references(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_7Samfile_10references___get__(o);
-}
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3135
+ *                return "%s/%s" % (s,s)
+ *            else:
+ *                return "%s/%s" % (self.first_allele, self.second_allele )             # <<<<<<<<<<<<<<
+ * 
+ *     property consensus_quality:
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__first_allele); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__second_allele); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
+    __Pyx_GIVEREF(__pyx_t_1);
+    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
+    __Pyx_GIVEREF(__pyx_t_2);
+    __pyx_t_1 = 0;
+    __pyx_t_2 = 0;
+    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_110), __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_r = ((PyObject *)__pyx_t_2);
+    __pyx_t_2 = 0;
+    goto __pyx_L0;
+    break;
+  }
 
-static PyObject *__pyx_getprop_9csamtools_7Samfile_lengths(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_7Samfile_7lengths___get__(o);
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("csamtools.IndelCall.genotype.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_s);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
 }
 
-static PyObject *__pyx_getprop_9csamtools_7Samfile_mapped(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_7Samfile_6mapped___get__(o);
-}
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3139
+ *     property consensus_quality:
+ *        '''the genotype quality (Phred-scaled).'''
+ *        def __get__(self): return self._r.q_cns             # <<<<<<<<<<<<<<
+ * 
+ *     property snp_quality:
+ */
 
-static PyObject *__pyx_getprop_9csamtools_7Samfile_unmapped(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_7Samfile_8unmapped___get__(o);
-}
+static PyObject *__pyx_pf_9csamtools_9IndelCall_17consensus_quality___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_9IndelCall_17consensus_quality___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__get__");
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3139);
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->q_cns); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
 
-static PyObject *__pyx_getprop_9csamtools_7Samfile_text(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_7Samfile_4text___get__(o);
-}
-
-static PyObject *__pyx_getprop_9csamtools_7Samfile_header(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_7Samfile_6header___get__(o);
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("csamtools.IndelCall.consensus_quality.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
 }
 
-static PyMethodDef __pyx_methods_9csamtools_Samfile[] = {
-  {__Pyx_NAMESTR("_isOpen"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_1_isOpen, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_1_isOpen)},
-  {__Pyx_NAMESTR("_hasIndex"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_2_hasIndex, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_2_hasIndex)},
-  {__Pyx_NAMESTR("_open"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_3_open, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_3_open)},
-  {__Pyx_NAMESTR("gettid"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_4gettid, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_4gettid)},
-  {__Pyx_NAMESTR("getrname"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_5getrname, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_5getrname)},
-  {__Pyx_NAMESTR("_parseRegion"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_6_parseRegion, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_6_parseRegion)},
-  {__Pyx_NAMESTR("reset"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_7reset, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_7reset)},
-  {__Pyx_NAMESTR("seek"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_8seek, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_8seek)},
-  {__Pyx_NAMESTR("tell"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_9tell, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_9tell)},
-  {__Pyx_NAMESTR("fetch"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_10fetch, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_10fetch)},
-  {__Pyx_NAMESTR("mate"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_11mate, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_11mate)},
-  {__Pyx_NAMESTR("count"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_12count, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_12count)},
-  {__Pyx_NAMESTR("pileup"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_13pileup, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_13pileup)},
-  {__Pyx_NAMESTR("close"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_14close, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_14close)},
-  {__Pyx_NAMESTR("write"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_16write, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_16write)},
-  {__Pyx_NAMESTR("__enter__"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_17__enter__, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_17__enter__)},
-  {__Pyx_NAMESTR("__exit__"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_18__exit__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_18__exit__)},
-  {__Pyx_NAMESTR("_buildLine"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_19_buildLine, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_19_buildLine)},
-  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_21__next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_21__next__)},
-  {0, 0, 0, 0}
-};
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3143
+ *     property snp_quality:
+ *        '''the snp quality (Phred scaled) - probability of consensus being identical to reference sequence.'''
+ *        def __get__(self): return self._r.q_ref             # <<<<<<<<<<<<<<
+ * 
+ *     property mapping_quality:
+ */
 
-static struct PyGetSetDef __pyx_getsets_9csamtools_Samfile[] = {
-  {(char *)"filename", __pyx_getprop_9csamtools_7Samfile_filename, 0, __Pyx_DOCSTR(__pyx_k_206), 0},
-  {(char *)"nreferences", __pyx_getprop_9csamtools_7Samfile_nreferences, 0, __Pyx_DOCSTR(__pyx_k_207), 0},
-  {(char *)"references", __pyx_getprop_9csamtools_7Samfile_references, 0, __Pyx_DOCSTR(__pyx_k_208), 0},
-  {(char *)"lengths", __pyx_getprop_9csamtools_7Samfile_lengths, 0, __Pyx_DOCSTR(__pyx_k_209), 0},
-  {(char *)"mapped", __pyx_getprop_9csamtools_7Samfile_mapped, 0, __Pyx_DOCSTR(__pyx_k_210), 0},
-  {(char *)"unmapped", __pyx_getprop_9csamtools_7Samfile_unmapped, 0, __Pyx_DOCSTR(__pyx_k_211), 0},
-  {(char *)"text", __pyx_getprop_9csamtools_7Samfile_text, 0, __Pyx_DOCSTR(__pyx_k_212), 0},
-  {(char *)"header", __pyx_getprop_9csamtools_7Samfile_header, 0, __Pyx_DOCSTR(__pyx_k_213), 0},
-  {0, 0, 0, 0, 0}
-};
+static PyObject *__pyx_pf_9csamtools_9IndelCall_11snp_quality___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_9IndelCall_11snp_quality___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__get__");
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3143);
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->q_ref); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
 
-static PyNumberMethods __pyx_tp_as_number_Samfile = {
-  0, /*nb_add*/
-  0, /*nb_subtract*/
-  0, /*nb_multiply*/
-  #if PY_MAJOR_VERSION < 3
-  0, /*nb_divide*/
-  #endif
-  0, /*nb_remainder*/
-  0, /*nb_divmod*/
-  0, /*nb_power*/
-  0, /*nb_negative*/
-  0, /*nb_positive*/
-  0, /*nb_absolute*/
-  0, /*nb_nonzero*/
-  0, /*nb_invert*/
-  0, /*nb_lshift*/
-  0, /*nb_rshift*/
-  0, /*nb_and*/
-  0, /*nb_xor*/
-  0, /*nb_or*/
-  #if PY_MAJOR_VERSION < 3
-  0, /*nb_coerce*/
-  #endif
-  0, /*nb_int*/
-  #if PY_MAJOR_VERSION < 3
-  0, /*nb_long*/
-  #else
-  0, /*reserved*/
-  #endif
-  0, /*nb_float*/
-  #if PY_MAJOR_VERSION < 3
-  0, /*nb_oct*/
-  #endif
-  #if PY_MAJOR_VERSION < 3
-  0, /*nb_hex*/
-  #endif
-  0, /*nb_inplace_add*/
-  0, /*nb_inplace_subtract*/
-  0, /*nb_inplace_multiply*/
-  #if PY_MAJOR_VERSION < 3
-  0, /*nb_inplace_divide*/
-  #endif
-  0, /*nb_inplace_remainder*/
-  0, /*nb_inplace_power*/
-  0, /*nb_inplace_lshift*/
-  0, /*nb_inplace_rshift*/
-  0, /*nb_inplace_and*/
-  0, /*nb_inplace_xor*/
-  0, /*nb_inplace_or*/
-  0, /*nb_floor_divide*/
-  0, /*nb_true_divide*/
-  0, /*nb_inplace_floor_divide*/
-  0, /*nb_inplace_true_divide*/
-  #if PY_VERSION_HEX >= 0x02050000
-  0, /*nb_index*/
-  #endif
-};
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("csamtools.IndelCall.snp_quality.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
 
-static PySequenceMethods __pyx_tp_as_sequence_Samfile = {
-  0, /*sq_length*/
-  0, /*sq_concat*/
-  0, /*sq_repeat*/
-  0, /*sq_item*/
-  0, /*sq_slice*/
-  0, /*sq_ass_item*/
-  0, /*sq_ass_slice*/
-  0, /*sq_contains*/
-  0, /*sq_inplace_concat*/
-  0, /*sq_inplace_repeat*/
-};
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3147
+ *     property mapping_quality:
+ *        '''the root mean square (rms) of the mapping quality of all reads involved in the call.'''
+ *        def __get__(self): return self._rms_mapping_quality             # <<<<<<<<<<<<<<
+ * 
+ *     property coverage:
+ */
 
-static PyMappingMethods __pyx_tp_as_mapping_Samfile = {
-  0, /*mp_length*/
-  0, /*mp_subscript*/
-  0, /*mp_ass_subscript*/
-};
+static PyObject *__pyx_pf_9csamtools_9IndelCall_15mapping_quality___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_9IndelCall_15mapping_quality___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__get__");
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3147);
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_rms_mapping_quality); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
 
-static PyBufferProcs __pyx_tp_as_buffer_Samfile = {
-  #if PY_MAJOR_VERSION < 3
-  0, /*bf_getreadbuffer*/
-  #endif
-  #if PY_MAJOR_VERSION < 3
-  0, /*bf_getwritebuffer*/
-  #endif
-  #if PY_MAJOR_VERSION < 3
-  0, /*bf_getsegcount*/
-  #endif
-  #if PY_MAJOR_VERSION < 3
-  0, /*bf_getcharbuffer*/
-  #endif
-  #if PY_VERSION_HEX >= 0x02060000
-  0, /*bf_getbuffer*/
-  #endif
-  #if PY_VERSION_HEX >= 0x02060000
-  0, /*bf_releasebuffer*/
-  #endif
-};
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("csamtools.IndelCall.mapping_quality.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
 
-static PyTypeObject __pyx_type_9csamtools_Samfile = {
-  PyVarObject_HEAD_INIT(0, 0)
-  __Pyx_NAMESTR("csamtools.Samfile"), /*tp_name*/
-  sizeof(struct __pyx_obj_9csamtools_Samfile), /*tp_basicsize*/
-  0, /*tp_itemsize*/
-  __pyx_tp_dealloc_9csamtools_Samfile, /*tp_dealloc*/
-  0, /*tp_print*/
-  0, /*tp_getattr*/
-  0, /*tp_setattr*/
-  #if PY_MAJOR_VERSION < 3
-  0, /*tp_compare*/
-  #else
-  0, /*reserved*/
-  #endif
-  0, /*tp_repr*/
-  &__pyx_tp_as_number_Samfile, /*tp_as_number*/
-  &__pyx_tp_as_sequence_Samfile, /*tp_as_sequence*/
-  &__pyx_tp_as_mapping_Samfile, /*tp_as_mapping*/
-  0, /*tp_hash*/
-  0, /*tp_call*/
-  0, /*tp_str*/
-  0, /*tp_getattro*/
-  0, /*tp_setattro*/
-  &__pyx_tp_as_buffer_Samfile, /*tp_as_buffer*/
-  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
-  __Pyx_DOCSTR("*(filename, mode=None, template = None, referencenames = None, referencelengths = None, text = NULL, header = None,\n         add_sq_text = False )*\n              \n    A :term:`SAM`/:term:`BAM` formatted file. The file is automatically opened.\n    \n    *mode* should be ``r`` for reading or ``w`` for writing. The default is text mode (:term:`SAM`). For binary \n    (:term:`BAM`) I/O you should append ``b`` for compressed or ``u`` for uncompressed :term:`BAM` output. \n    Use ``h`` to output header information in text (:term:`TAM`)  mode.\n\n    If ``b`` is present, it must immediately follow ``r`` or ``w``. \n    Valid modes are ``r``, ``w``, ``wh``, ``rb``, ``wb`` and ``wbu``. For instance, to open \n    a :term:`BAM` formatted file for reading, type::\n\n        f = pysam.Samfile('ex1.bam','rb')\n\n    If mode is not specified, we will try to auto-detect in the order 'rb', 'r', thus both the following\n    should work::\n\n        f1 = pysam.Samfile('ex1.bam' )\n        f2 = pysam.Samfile('ex1.sam' )\n\n    If an index for a BAM file exists (.bai), it will be opened automatically. Without an index random\n    access to reads via :meth:`fetch` and :meth:`pileup` is disabled.\n\n    For writing, the header of a :term:`SAM` file/:term:`BAM` file can be constituted from several\n    sources (see also the samtools format specification):\n\n        1. If *template* is given, the header is copied from a another *Samfile* \n           (*template* must be of type *Samfile*).\n\n        2. If *header* is given, the header is built from a multi-level dictionary. The first level \n           are the four types ('HD', 'SQ', ...). The second level are a list of lines, with each line \n           being a list of tag-value pairs.\n\n        3. If *text* is given, new header text is copied from raw text.\n\n        4. The names (*referencenames*) and lengths (*referencelengths*) are supplied directly as lists. \n           By default, 'SQ' and 'LN' tags will be added to the header text. This option can be\n           changed by unsetting the flag *add_sq_text*. \n\n    "), /*tp_doc*/
-  0, /*tp_traverse*/
-  0, /*tp_clear*/
-  0, /*tp_richcompare*/
-  0, /*tp_weaklistoffset*/
-  __pyx_pf_9csamtools_7Samfile_20__iter__, /*tp_iter*/
-  __pyx_pf_9csamtools_7Samfile_21__next__, /*tp_iternext*/
-  __pyx_methods_9csamtools_Samfile, /*tp_methods*/
-  0, /*tp_members*/
-  __pyx_getsets_9csamtools_Samfile, /*tp_getset*/
-  0, /*tp_base*/
-  0, /*tp_dict*/
-  0, /*tp_descr_get*/
-  0, /*tp_descr_set*/
-  0, /*tp_dictoffset*/
-  0, /*tp_init*/
-  0, /*tp_alloc*/
-  __pyx_tp_new_9csamtools_Samfile, /*tp_new*/
-  0, /*tp_free*/
-  0, /*tp_is_gc*/
-  0, /*tp_bases*/
-  0, /*tp_mro*/
-  0, /*tp_cache*/
-  0, /*tp_subclasses*/
-  0, /*tp_weaklist*/
-  0, /*tp_del*/
-  #if PY_VERSION_HEX >= 0x02060000
-  0, /*tp_version_tag*/
-  #endif
-};
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3151
+ *     property coverage:
+ *        '''coverage or read depth - the number of reads involved in the call.'''
+ *        def __get__(self): return self._coverage             # <<<<<<<<<<<<<<
+ * 
+ *     property first_allele:
+ */
 
-static PyObject *__pyx_tp_new_9csamtools_IteratorRow(PyTypeObject *t, PyObject *a, PyObject *k) {
-  PyObject *o = (*t->tp_alloc)(t, 0);
-  if (!o) return 0;
-  return o;
-}
+static PyObject *__pyx_pf_9csamtools_9IndelCall_8coverage___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_9IndelCall_8coverage___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__get__");
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3151);
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_coverage); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
 
-static void __pyx_tp_dealloc_9csamtools_IteratorRow(PyObject *o) {
-  (*Py_TYPE(o)->tp_free)(o);
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("csamtools.IndelCall.coverage.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
 }
 
-static PyMethodDef __pyx_methods_9csamtools_IteratorRow[] = {
-  {0, 0, 0, 0}
-};
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3155
+ *     property first_allele:
+ *        '''sequence of first allele.'''
+ *        def __get__(self): return PyString_FromStringAndSize( self._r.s[0], self._r.indel1 + 1)             # <<<<<<<<<<<<<<
+ * 
+ *     property second_allele:
+ */
 
-static PyNumberMethods __pyx_tp_as_number_IteratorRow = {
-  0, /*nb_add*/
-  0, /*nb_subtract*/
-  0, /*nb_multiply*/
-  #if PY_MAJOR_VERSION < 3
-  0, /*nb_divide*/
-  #endif
-  0, /*nb_remainder*/
-  0, /*nb_divmod*/
-  0, /*nb_power*/
-  0, /*nb_negative*/
-  0, /*nb_positive*/
-  0, /*nb_absolute*/
-  0, /*nb_nonzero*/
-  0, /*nb_invert*/
-  0, /*nb_lshift*/
-  0, /*nb_rshift*/
-  0, /*nb_and*/
-  0, /*nb_xor*/
-  0, /*nb_or*/
-  #if PY_MAJOR_VERSION < 3
-  0, /*nb_coerce*/
-  #endif
-  0, /*nb_int*/
-  #if PY_MAJOR_VERSION < 3
-  0, /*nb_long*/
-  #else
-  0, /*reserved*/
-  #endif
-  0, /*nb_float*/
-  #if PY_MAJOR_VERSION < 3
-  0, /*nb_oct*/
-  #endif
-  #if PY_MAJOR_VERSION < 3
-  0, /*nb_hex*/
-  #endif
-  0, /*nb_inplace_add*/
-  0, /*nb_inplace_subtract*/
-  0, /*nb_inplace_multiply*/
-  #if PY_MAJOR_VERSION < 3
-  0, /*nb_inplace_divide*/
-  #endif
-  0, /*nb_inplace_remainder*/
-  0, /*nb_inplace_power*/
-  0, /*nb_inplace_lshift*/
-  0, /*nb_inplace_rshift*/
-  0, /*nb_inplace_and*/
-  0, /*nb_inplace_xor*/
-  0, /*nb_inplace_or*/
-  0, /*nb_floor_divide*/
-  0, /*nb_true_divide*/
-  0, /*nb_inplace_floor_divide*/
-  0, /*nb_inplace_true_divide*/
-  #if PY_VERSION_HEX >= 0x02050000
-  0, /*nb_index*/
-  #endif
-};
-
-static PySequenceMethods __pyx_tp_as_sequence_IteratorRow = {
-  0, /*sq_length*/
-  0, /*sq_concat*/
-  0, /*sq_repeat*/
-  0, /*sq_item*/
-  0, /*sq_slice*/
-  0, /*sq_ass_item*/
-  0, /*sq_ass_slice*/
-  0, /*sq_contains*/
-  0, /*sq_inplace_concat*/
-  0, /*sq_inplace_repeat*/
-};
+static PyObject *__pyx_pf_9csamtools_9IndelCall_12first_allele___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_9IndelCall_12first_allele___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__get__");
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3155);
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyString_FromStringAndSize((((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->s[0]), (((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->indel1 + 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
 
-static PyMappingMethods __pyx_tp_as_mapping_IteratorRow = {
-  0, /*mp_length*/
-  0, /*mp_subscript*/
-  0, /*mp_ass_subscript*/
-};
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("csamtools.IndelCall.first_allele.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
 
-static PyBufferProcs __pyx_tp_as_buffer_IteratorRow = {
-  #if PY_MAJOR_VERSION < 3
-  0, /*bf_getreadbuffer*/
-  #endif
-  #if PY_MAJOR_VERSION < 3
-  0, /*bf_getwritebuffer*/
-  #endif
-  #if PY_MAJOR_VERSION < 3
-  0, /*bf_getsegcount*/
-  #endif
-  #if PY_MAJOR_VERSION < 3
-  0, /*bf_getcharbuffer*/
-  #endif
-  #if PY_VERSION_HEX >= 0x02060000
-  0, /*bf_getbuffer*/
-  #endif
-  #if PY_VERSION_HEX >= 0x02060000
-  0, /*bf_releasebuffer*/
-  #endif
-};
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3159
+ *     property second_allele:
+ *        '''sequence of second allele.'''
+ *        def __get__(self): return PyString_FromStringAndSize( self._r.s[1], self._r.indel2 + 1)             # <<<<<<<<<<<<<<
+ * 
+ *     property reads_first:
+ */
 
-static PyTypeObject __pyx_type_9csamtools_IteratorRow = {
-  PyVarObject_HEAD_INIT(0, 0)
-  __Pyx_NAMESTR("csamtools.IteratorRow"), /*tp_name*/
-  sizeof(struct __pyx_obj_9csamtools_IteratorRow), /*tp_basicsize*/
-  0, /*tp_itemsize*/
-  __pyx_tp_dealloc_9csamtools_IteratorRow, /*tp_dealloc*/
-  0, /*tp_print*/
-  0, /*tp_getattr*/
-  0, /*tp_setattr*/
-  #if PY_MAJOR_VERSION < 3
-  0, /*tp_compare*/
-  #else
-  0, /*reserved*/
-  #endif
-  0, /*tp_repr*/
-  &__pyx_tp_as_number_IteratorRow, /*tp_as_number*/
-  &__pyx_tp_as_sequence_IteratorRow, /*tp_as_sequence*/
-  &__pyx_tp_as_mapping_IteratorRow, /*tp_as_mapping*/
-  0, /*tp_hash*/
-  0, /*tp_call*/
-  0, /*tp_str*/
-  0, /*tp_getattro*/
-  0, /*tp_setattro*/
-  &__pyx_tp_as_buffer_IteratorRow, /*tp_as_buffer*/
-  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
-  __Pyx_DOCSTR("abstract base class for iterators over mapped reads.\n\n    Various iterators implement different behaviours for wrapping around\n    contig boundaries. Examples include:\n\n    :class:`pysam.IteratorRowRegion`\n        iterate within a single contig and a defined region.\n\n    :class:`pysam.IteratorRowAll`\n        iterate until EOF. This iterator will also include unmapped reads.\n\n    :class:`pysam.IteratorRowAllRefs`\n        iterate over all reads in all reference sequences.\n        \n    The method :meth:`Samfile.fetch` returns an IteratorRow.\n    "), /*tp_doc*/
-  0, /*tp_traverse*/
-  0, /*tp_clear*/
-  0, /*tp_richcompare*/
-  0, /*tp_weaklistoffset*/
-  0, /*tp_iter*/
-  0, /*tp_iternext*/
-  __pyx_methods_9csamtools_IteratorRow, /*tp_methods*/
-  0, /*tp_members*/
-  0, /*tp_getset*/
-  0, /*tp_base*/
-  0, /*tp_dict*/
-  0, /*tp_descr_get*/
-  0, /*tp_descr_set*/
-  0, /*tp_dictoffset*/
-  0, /*tp_init*/
-  0, /*tp_alloc*/
-  __pyx_tp_new_9csamtools_IteratorRow, /*tp_new*/
-  0, /*tp_free*/
-  0, /*tp_is_gc*/
-  0, /*tp_bases*/
-  0, /*tp_mro*/
-  0, /*tp_cache*/
-  0, /*tp_subclasses*/
-  0, /*tp_weaklist*/
-  0, /*tp_del*/
-  #if PY_VERSION_HEX >= 0x02060000
-  0, /*tp_version_tag*/
-  #endif
-};
-static struct __pyx_vtabstruct_9csamtools_IteratorRowAll __pyx_vtable_9csamtools_IteratorRowAll;
+static PyObject *__pyx_pf_9csamtools_9IndelCall_13second_allele___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_9IndelCall_13second_allele___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__get__");
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3159);
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyString_FromStringAndSize((((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->s[1]), (((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->indel2 + 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
 
-static PyObject *__pyx_tp_new_9csamtools_IteratorRowAll(PyTypeObject *t, PyObject *a, PyObject *k) {
-  struct __pyx_obj_9csamtools_IteratorRowAll *p;
-  PyObject *o = __pyx_tp_new_9csamtools_IteratorRow(t, a, k);
-  if (!o) return 0;
-  p = ((struct __pyx_obj_9csamtools_IteratorRowAll *)o);
-  p->__pyx_vtab = __pyx_vtabptr_9csamtools_IteratorRowAll;
-  if (__pyx_pf_9csamtools_14IteratorRowAll___cinit__(o, a, k) < 0) {
-    Py_DECREF(o); o = 0;
-  }
-  return o;
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("csamtools.IndelCall.second_allele.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
 }
 
-static void __pyx_tp_dealloc_9csamtools_IteratorRowAll(PyObject *o) {
-  {
-    PyObject *etype, *eval, *etb;
-    PyErr_Fetch(&etype, &eval, &etb);
-    ++Py_REFCNT(o);
-    __pyx_pf_9csamtools_14IteratorRowAll_3__dealloc__(o);
-    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
-    --Py_REFCNT(o);
-    PyErr_Restore(etype, eval, etb);
-  }
-  __pyx_tp_dealloc_9csamtools_IteratorRow(o);
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3163
+ *     property reads_first:
+ *        '''reads supporting first allele.'''
+ *        def __get__(self): return self._r.cnt1             # <<<<<<<<<<<<<<
+ * 
+ *     property reads_second:
+ */
+
+static PyObject *__pyx_pf_9csamtools_9IndelCall_11reads_first___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_9IndelCall_11reads_first___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__get__");
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3163);
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->cnt1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("csamtools.IndelCall.reads_first.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
 }
 
-static PyMethodDef __pyx_methods_9csamtools_IteratorRowAll[] = {
-  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_14IteratorRowAll_2__next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_14IteratorRowAll_2__next__)},
-  {0, 0, 0, 0}
-};
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3167
+ *     property reads_second:
+ *        '''reads supporting first allele.'''
+ *        def __get__(self): return self._r.cnt2             # <<<<<<<<<<<<<<
+ * 
+ *     property reads_diff:
+ */
 
-static PyNumberMethods __pyx_tp_as_number_IteratorRowAll = {
-  0, /*nb_add*/
-  0, /*nb_subtract*/
-  0, /*nb_multiply*/
-  #if PY_MAJOR_VERSION < 3
-  0, /*nb_divide*/
-  #endif
-  0, /*nb_remainder*/
-  0, /*nb_divmod*/
-  0, /*nb_power*/
-  0, /*nb_negative*/
-  0, /*nb_positive*/
-  0, /*nb_absolute*/
-  0, /*nb_nonzero*/
-  0, /*nb_invert*/
-  0, /*nb_lshift*/
-  0, /*nb_rshift*/
-  0, /*nb_and*/
-  0, /*nb_xor*/
-  0, /*nb_or*/
-  #if PY_MAJOR_VERSION < 3
-  0, /*nb_coerce*/
-  #endif
-  0, /*nb_int*/
-  #if PY_MAJOR_VERSION < 3
-  0, /*nb_long*/
-  #else
-  0, /*reserved*/
-  #endif
-  0, /*nb_float*/
-  #if PY_MAJOR_VERSION < 3
-  0, /*nb_oct*/
-  #endif
-  #if PY_MAJOR_VERSION < 3
-  0, /*nb_hex*/
-  #endif
-  0, /*nb_inplace_add*/
-  0, /*nb_inplace_subtract*/
-  0, /*nb_inplace_multiply*/
-  #if PY_MAJOR_VERSION < 3
-  0, /*nb_inplace_divide*/
-  #endif
-  0, /*nb_inplace_remainder*/
-  0, /*nb_inplace_power*/
-  0, /*nb_inplace_lshift*/
-  0, /*nb_inplace_rshift*/
-  0, /*nb_inplace_and*/
-  0, /*nb_inplace_xor*/
-  0, /*nb_inplace_or*/
-  0, /*nb_floor_divide*/
-  0, /*nb_true_divide*/
-  0, /*nb_inplace_floor_divide*/
-  0, /*nb_inplace_true_divide*/
-  #if PY_VERSION_HEX >= 0x02050000
-  0, /*nb_index*/
-  #endif
-};
-
-static PySequenceMethods __pyx_tp_as_sequence_IteratorRowAll = {
-  0, /*sq_length*/
-  0, /*sq_concat*/
-  0, /*sq_repeat*/
-  0, /*sq_item*/
-  0, /*sq_slice*/
-  0, /*sq_ass_item*/
-  0, /*sq_ass_slice*/
-  0, /*sq_contains*/
-  0, /*sq_inplace_concat*/
-  0, /*sq_inplace_repeat*/
-};
+static PyObject *__pyx_pf_9csamtools_9IndelCall_12reads_second___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_9IndelCall_12reads_second___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__get__");
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3167);
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->cnt2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
 
-static PyMappingMethods __pyx_tp_as_mapping_IteratorRowAll = {
-  0, /*mp_length*/
-  0, /*mp_subscript*/
-  0, /*mp_ass_subscript*/
-};
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("csamtools.IndelCall.reads_second.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
 
-static PyBufferProcs __pyx_tp_as_buffer_IteratorRowAll = {
-  #if PY_MAJOR_VERSION < 3
-  0, /*bf_getreadbuffer*/
-  #endif
-  #if PY_MAJOR_VERSION < 3
-  0, /*bf_getwritebuffer*/
-  #endif
-  #if PY_MAJOR_VERSION < 3
-  0, /*bf_getsegcount*/
-  #endif
-  #if PY_MAJOR_VERSION < 3
-  0, /*bf_getcharbuffer*/
-  #endif
-  #if PY_VERSION_HEX >= 0x02060000
-  0, /*bf_getbuffer*/
-  #endif
-  #if PY_VERSION_HEX >= 0x02060000
-  0, /*bf_releasebuffer*/
-  #endif
-};
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3171
+ *     property reads_diff:
+ *        '''reads supporting first allele.'''
+ *        def __get__(self): return self._r.cnt_anti             # <<<<<<<<<<<<<<
+ * 
+ *     def __str__(self):
+ */
 
-static PyTypeObject __pyx_type_9csamtools_IteratorRowAll = {
-  PyVarObject_HEAD_INIT(0, 0)
-  __Pyx_NAMESTR("csamtools.IteratorRowAll"), /*tp_name*/
-  sizeof(struct __pyx_obj_9csamtools_IteratorRowAll), /*tp_basicsize*/
-  0, /*tp_itemsize*/
-  __pyx_tp_dealloc_9csamtools_IteratorRowAll, /*tp_dealloc*/
-  0, /*tp_print*/
-  0, /*tp_getattr*/
-  0, /*tp_setattr*/
-  #if PY_MAJOR_VERSION < 3
-  0, /*tp_compare*/
-  #else
-  0, /*reserved*/
-  #endif
-  0, /*tp_repr*/
-  &__pyx_tp_as_number_IteratorRowAll, /*tp_as_number*/
-  &__pyx_tp_as_sequence_IteratorRowAll, /*tp_as_sequence*/
-  &__pyx_tp_as_mapping_IteratorRowAll, /*tp_as_mapping*/
-  0, /*tp_hash*/
-  0, /*tp_call*/
-  0, /*tp_str*/
-  0, /*tp_getattro*/
-  0, /*tp_setattro*/
-  &__pyx_tp_as_buffer_IteratorRowAll, /*tp_as_buffer*/
-  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
-  __Pyx_DOCSTR("*(Samfile samfile, int reopen = True)*\n\n    iterate over all reads in *samfile*\n\n    By default, the file is re-openend to avoid conflicts between\n    multiple iterators working on the same file. Set *reopen* = False\n    to not re-open *samfile*.\n    "), /*tp_doc*/
-  0, /*tp_traverse*/
-  0, /*tp_clear*/
-  0, /*tp_richcompare*/
-  0, /*tp_weaklistoffset*/
-  __pyx_pf_9csamtools_14IteratorRowAll_1__iter__, /*tp_iter*/
-  __pyx_pf_9csamtools_14IteratorRowAll_2__next__, /*tp_iternext*/
-  __pyx_methods_9csamtools_IteratorRowAll, /*tp_methods*/
-  0, /*tp_members*/
-  0, /*tp_getset*/
-  0, /*tp_base*/
-  0, /*tp_dict*/
-  0, /*tp_descr_get*/
-  0, /*tp_descr_set*/
-  0, /*tp_dictoffset*/
-  0, /*tp_init*/
-  0, /*tp_alloc*/
-  __pyx_tp_new_9csamtools_IteratorRowAll, /*tp_new*/
-  0, /*tp_free*/
-  0, /*tp_is_gc*/
-  0, /*tp_bases*/
-  0, /*tp_mro*/
-  0, /*tp_cache*/
-  0, /*tp_subclasses*/
-  0, /*tp_weaklist*/
-  0, /*tp_del*/
-  #if PY_VERSION_HEX >= 0x02060000
-  0, /*tp_version_tag*/
-  #endif
-};
+static PyObject *__pyx_pf_9csamtools_9IndelCall_10reads_diff___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_9IndelCall_10reads_diff___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__get__");
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3171);
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->cnt_anti); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
 
-static PyObject *__pyx_tp_new_9csamtools_PileupProxy(PyTypeObject *t, PyObject *a, PyObject *k) {
-  PyObject *o = (*t->tp_alloc)(t, 0);
-  if (!o) return 0;
-  return o;
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("csamtools.IndelCall.reads_diff.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
 }
 
-static void __pyx_tp_dealloc_9csamtools_PileupProxy(PyObject *o) {
-  (*Py_TYPE(o)->tp_free)(o);
-}
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3173
+ *        def __get__(self): return self._r.cnt_anti
+ * 
+ *     def __str__(self):             # <<<<<<<<<<<<<<
+ * 
+ *         return "\t".join( map(str, (
+ */
 
-static PyObject *__pyx_getprop_9csamtools_11PileupProxy_tid(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11PileupProxy_3tid___get__(o);
-}
+static PyObject *__pyx_pf_9csamtools_9IndelCall___str__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_9IndelCall___str__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  PyObject *__pyx_t_9 = NULL;
+  PyObject *__pyx_t_10 = NULL;
+  PyObject *__pyx_t_11 = NULL;
+  PyObject *__pyx_t_12 = NULL;
+  PyObject *__pyx_t_13 = NULL;
+  PyObject *__pyx_t_14 = NULL;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__str__");
+  __Pyx_TraceCall("__str__", __pyx_f[0], 3173);
 
-static PyObject *__pyx_getprop_9csamtools_11PileupProxy_n(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11PileupProxy_1n___get__(o);
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3175
+ *     def __str__(self):
+ * 
+ *         return "\t".join( map(str, (             # <<<<<<<<<<<<<<
+ *                     self.tid,
+ *                     self.pos,
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_1), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
 
-static int __pyx_setprop_9csamtools_11PileupProxy_n(PyObject *o, PyObject *v, void *x) {
-  if (v) {
-    return __pyx_pf_9csamtools_11PileupProxy_1n_1__set__(o, v);
-  }
-  else {
-    PyErr_SetString(PyExc_NotImplementedError, "__del__");
-    return -1;
-  }
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3176
+ * 
+ *         return "\t".join( map(str, (
+ *                     self.tid,             # <<<<<<<<<<<<<<
+ *                     self.pos,
+ *                     self.genotype,
+ */
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__tid); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
 
-static PyObject *__pyx_getprop_9csamtools_11PileupProxy_pos(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11PileupProxy_3pos___get__(o);
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3177
+ *         return "\t".join( map(str, (
+ *                     self.tid,
+ *                     self.pos,             # <<<<<<<<<<<<<<
+ *                     self.genotype,
+ *                     self.consensus_quality,
+ */
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
 
-static PyObject *__pyx_getprop_9csamtools_11PileupProxy_pileups(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_11PileupProxy_7pileups___get__(o);
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3178
+ *                     self.tid,
+ *                     self.pos,
+ *                     self.genotype,             # <<<<<<<<<<<<<<
+ *                     self.consensus_quality,
+ *                     self.snp_quality,
+ */
+  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__genotype); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
 
-static PyMethodDef __pyx_methods_9csamtools_PileupProxy[] = {
-  {0, 0, 0, 0}
-};
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3179
+ *                     self.pos,
+ *                     self.genotype,
+ *                     self.consensus_quality,             # <<<<<<<<<<<<<<
+ *                     self.snp_quality,
+ *                     self.mapping_quality,
+ */
+  __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__consensus_quality); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
 
-static struct PyGetSetDef __pyx_getsets_9csamtools_PileupProxy[] = {
-  {(char *)"tid", __pyx_getprop_9csamtools_11PileupProxy_tid, 0, __Pyx_DOCSTR(__pyx_k_214), 0},
-  {(char *)"n", __pyx_getprop_9csamtools_11PileupProxy_n, __pyx_setprop_9csamtools_11PileupProxy_n, __Pyx_DOCSTR(__pyx_k_215), 0},
-  {(char *)"pos", __pyx_getprop_9csamtools_11PileupProxy_pos, 0, 0, 0},
-  {(char *)"pileups", __pyx_getprop_9csamtools_11PileupProxy_pileups, 0, __Pyx_DOCSTR(__pyx_k_216), 0},
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3180
+ *                     self.genotype,
+ *                     self.consensus_quality,
+ *                     self.snp_quality,             # <<<<<<<<<<<<<<
+ *                     self.mapping_quality,
+ *                     self.coverage,
+ */
+  __pyx_t_6 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__snp_quality); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_6);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3181
+ *                     self.consensus_quality,
+ *                     self.snp_quality,
+ *                     self.mapping_quality,             # <<<<<<<<<<<<<<
+ *                     self.coverage,
+ *                     self.first_allele,
+ */
+  __pyx_t_7 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__mapping_quality); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_7);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3182
+ *                     self.snp_quality,
+ *                     self.mapping_quality,
+ *                     self.coverage,             # <<<<<<<<<<<<<<
+ *                     self.first_allele,
+ *                     self.second_allele,
+ */
+  __pyx_t_8 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__coverage); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_8);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3183
+ *                     self.mapping_quality,
+ *                     self.coverage,
+ *                     self.first_allele,             # <<<<<<<<<<<<<<
+ *                     self.second_allele,
+ *                     self.reads_first,
+ */
+  __pyx_t_9 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__first_allele); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_9);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3184
+ *                     self.coverage,
+ *                     self.first_allele,
+ *                     self.second_allele,             # <<<<<<<<<<<<<<
+ *                     self.reads_first,
+ *                     self.reads_second,
+ */
+  __pyx_t_10 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__second_allele); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_10);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3185
+ *                     self.first_allele,
+ *                     self.second_allele,
+ *                     self.reads_first,             # <<<<<<<<<<<<<<
+ *                     self.reads_second,
+ *                     self.reads_diff ) ) )
+ */
+  __pyx_t_11 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__reads_first); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_11);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3186
+ *                     self.second_allele,
+ *                     self.reads_first,
+ *                     self.reads_second,             # <<<<<<<<<<<<<<
+ *                     self.reads_diff ) ) )
+ * 
+ */
+  __pyx_t_12 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__reads_second); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_12);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3187
+ *                     self.reads_first,
+ *                     self.reads_second,
+ *                     self.reads_diff ) ) )             # <<<<<<<<<<<<<<
+ * 
+ *     def __dealloc__(self ):
+ */
+  __pyx_t_13 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__reads_diff); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_13);
+  __pyx_t_14 = PyTuple_New(12); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_14);
+  PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_2);
+  PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_3);
+  __Pyx_GIVEREF(__pyx_t_3);
+  PyTuple_SET_ITEM(__pyx_t_14, 2, __pyx_t_4);
+  __Pyx_GIVEREF(__pyx_t_4);
+  PyTuple_SET_ITEM(__pyx_t_14, 3, __pyx_t_5);
+  __Pyx_GIVEREF(__pyx_t_5);
+  PyTuple_SET_ITEM(__pyx_t_14, 4, __pyx_t_6);
+  __Pyx_GIVEREF(__pyx_t_6);
+  PyTuple_SET_ITEM(__pyx_t_14, 5, __pyx_t_7);
+  __Pyx_GIVEREF(__pyx_t_7);
+  PyTuple_SET_ITEM(__pyx_t_14, 6, __pyx_t_8);
+  __Pyx_GIVEREF(__pyx_t_8);
+  PyTuple_SET_ITEM(__pyx_t_14, 7, __pyx_t_9);
+  __Pyx_GIVEREF(__pyx_t_9);
+  PyTuple_SET_ITEM(__pyx_t_14, 8, __pyx_t_10);
+  __Pyx_GIVEREF(__pyx_t_10);
+  PyTuple_SET_ITEM(__pyx_t_14, 9, __pyx_t_11);
+  __Pyx_GIVEREF(__pyx_t_11);
+  PyTuple_SET_ITEM(__pyx_t_14, 10, __pyx_t_12);
+  __Pyx_GIVEREF(__pyx_t_12);
+  PyTuple_SET_ITEM(__pyx_t_14, 11, __pyx_t_13);
+  __Pyx_GIVEREF(__pyx_t_13);
+  __pyx_t_2 = 0;
+  __pyx_t_3 = 0;
+  __pyx_t_4 = 0;
+  __pyx_t_5 = 0;
+  __pyx_t_6 = 0;
+  __pyx_t_7 = 0;
+  __pyx_t_8 = 0;
+  __pyx_t_9 = 0;
+  __pyx_t_10 = 0;
+  __pyx_t_11 = 0;
+  __pyx_t_12 = 0;
+  __pyx_t_13 = 0;
+  __pyx_t_13 = PyTuple_New(2); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_13);
+  __Pyx_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
+  PyTuple_SET_ITEM(__pyx_t_13, 0, ((PyObject *)((PyObject*)&PyString_Type)));
+  __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
+  PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_14);
+  __Pyx_GIVEREF(__pyx_t_14);
+  __pyx_t_14 = 0;
+  __pyx_t_14 = PyObject_Call(__pyx_builtin_map, __pyx_t_13, NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_14);
+  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+  __pyx_t_13 = PyTuple_New(1); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_13);
+  PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_14);
+  __Pyx_GIVEREF(__pyx_t_14);
+  __pyx_t_14 = 0;
+  __pyx_t_14 = PyObject_Call(__pyx_t_1, __pyx_t_13, NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_14);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+  __pyx_r = __pyx_t_14;
+  __pyx_t_14 = 0;
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_XDECREF(__pyx_t_10);
+  __Pyx_XDECREF(__pyx_t_11);
+  __Pyx_XDECREF(__pyx_t_12);
+  __Pyx_XDECREF(__pyx_t_13);
+  __Pyx_XDECREF(__pyx_t_14);
+  __Pyx_AddTraceback("csamtools.IndelCall.__str__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3189
+ *                     self.reads_diff ) ) )
+ * 
+ *     def __dealloc__(self ):             # <<<<<<<<<<<<<<
+ *         bam_maqindel_ret_destroy(self._r)
+ * 
+ */
+
+static void __pyx_pf_9csamtools_9IndelCall___dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_pf_9csamtools_9IndelCall___dealloc__(PyObject *__pyx_v_self) {
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__dealloc__");
+  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 3189);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3190
+ * 
+ *     def __dealloc__(self ):
+ *         bam_maqindel_ret_destroy(self._r)             # <<<<<<<<<<<<<<
+ * 
+ * cdef class IndelCallerBase:
+ */
+  bam_maqindel_ret_destroy(((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r);
+
+  __Pyx_TraceReturn(Py_None);
+  __Pyx_RefNannyFinishContext();
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3212
+ *     cdef int max_depth
+ * 
+ *     def __cinit__(self,             # <<<<<<<<<<<<<<
+ *                   IteratorColumn iterator_column,
+ *                   **kwargs ):
+ */
+
+static int __pyx_pf_9csamtools_15IndelCallerBase___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pf_9csamtools_15IndelCallerBase___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  struct __pyx_obj_9csamtools_IteratorColumn *__pyx_v_iterator_column = 0;
+  PyObject *__pyx_v_kwargs = 0;
+  int __pyx_r;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  int __pyx_t_3;
+  float __pyx_t_4;
+  int __pyx_t_5;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__iterator_column,0};
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__cinit__");
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 3212);
+  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
+  __Pyx_GOTREF(__pyx_v_kwargs);
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[1] = {0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__iterator_column);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3212; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)values[0]);
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)PyTuple_GET_ITEM(__pyx_args, 0));
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3212; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_DECREF(__pyx_v_kwargs);
+  __Pyx_AddTraceback("csamtools.IndelCallerBase.__cinit__");
+  __Pyx_RefNannyFinishContext();
+  return -1;
+  __pyx_L4_argument_unpacking_done:;
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_iterator_column), __pyx_ptype_9csamtools_IteratorColumn, 1, "iterator_column", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3217
+ * 
+ * 
+ *         self.iter = iterator_column             # <<<<<<<<<<<<<<
+ * 
+ *         assert iterator_column.hasReference(), "IndelCallerBase requires an pileup iterator with reference sequence"
+ */
+  __Pyx_INCREF(((PyObject *)__pyx_v_iterator_column));
+  __Pyx_GIVEREF(((PyObject *)__pyx_v_iterator_column));
+  __Pyx_GOTREF(((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter);
+  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter));
+  ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter = __pyx_v_iterator_column;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3219
+ *         self.iter = iterator_column
+ * 
+ *         assert iterator_column.hasReference(), "IndelCallerBase requires an pileup iterator with reference sequence"             # <<<<<<<<<<<<<<
+ * 
+ *         self.options = bam_maqindel_opt_init()
+ */
+  #ifndef PYREX_WITHOUT_ASSERTIONS
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_iterator_column), __pyx_n_s__hasReference); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (unlikely(!__pyx_t_3)) {
+    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_111));
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  #endif
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3221
+ *         assert iterator_column.hasReference(), "IndelCallerBase requires an pileup iterator with reference sequence"
+ * 
+ *         self.options = bam_maqindel_opt_init()             # <<<<<<<<<<<<<<
+ * 
+ *         # set the default parameterization according to
+ */
+  ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->options = bam_maqindel_opt_init();
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3226
+ *         # samtools
+ * 
+ *         self.options.r_indel = kwargs.get( "r_indel", 0.00015 )             # <<<<<<<<<<<<<<
+ *         self.options.q_indel = kwargs.get( "q_indel", 40 )
+ *         self.cap_mapQ = kwargs.get( "cap_mapQ", 60 )
+ */
+  if (unlikely(__pyx_v_kwargs == Py_None)) {
+    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3226; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+  }
+  __pyx_t_2 = PyFloat_FromDouble(0.00015); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_1 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__r_indel), __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_4 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_4 == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->options->r_indel = __pyx_t_4;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3227
+ * 
+ *         self.options.r_indel = kwargs.get( "r_indel", 0.00015 )
+ *         self.options.q_indel = kwargs.get( "q_indel", 40 )             # <<<<<<<<<<<<<<
+ *         self.cap_mapQ = kwargs.get( "cap_mapQ", 60 )
+ *         self.max_depth = kwargs.get( "max_depth", 1024 )
+ */
+  if (unlikely(__pyx_v_kwargs == Py_None)) {
+    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3227; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+  }
+  __pyx_t_1 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__q_indel), __pyx_int_40); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_5 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->options->q_indel = __pyx_t_5;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3228
+ *         self.options.r_indel = kwargs.get( "r_indel", 0.00015 )
+ *         self.options.q_indel = kwargs.get( "q_indel", 40 )
+ *         self.cap_mapQ = kwargs.get( "cap_mapQ", 60 )             # <<<<<<<<<<<<<<
+ *         self.max_depth = kwargs.get( "max_depth", 1024 )
+ * 
+ */
+  if (unlikely(__pyx_v_kwargs == Py_None)) {
+    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3228; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+  }
+  __pyx_t_1 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__cap_mapQ), __pyx_int_60); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_5 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->cap_mapQ = __pyx_t_5;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3229
+ *         self.options.q_indel = kwargs.get( "q_indel", 40 )
+ *         self.cap_mapQ = kwargs.get( "cap_mapQ", 60 )
+ *         self.max_depth = kwargs.get( "max_depth", 1024 )             # <<<<<<<<<<<<<<
+ * 
+ *     def __dealloc__(self):
+ */
+  if (unlikely(__pyx_v_kwargs == Py_None)) {
+    PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'get'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3229; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
+  }
+  __pyx_t_1 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__max_depth), __pyx_int_1024); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_5 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->max_depth = __pyx_t_5;
+
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("csamtools.IndelCallerBase.__cinit__");
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_kwargs);
+  __Pyx_TraceReturn(Py_None);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3231
+ *         self.max_depth = kwargs.get( "max_depth", 1024 )
+ * 
+ *     def __dealloc__(self):             # <<<<<<<<<<<<<<
+ *         free( self.options )
+ * 
+ */
+
+static void __pyx_pf_9csamtools_15IndelCallerBase___dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_pf_9csamtools_15IndelCallerBase___dealloc__(PyObject *__pyx_v_self) {
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__dealloc__");
+  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 3231);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3232
+ * 
+ *     def __dealloc__(self):
+ *         free( self.options )             # <<<<<<<<<<<<<<
+ * 
+ *     def _call( self ):
+ */
+  free(((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->options);
+
+  __Pyx_TraceReturn(Py_None);
+  __Pyx_RefNannyFinishContext();
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3234
+ *         free( self.options )
+ * 
+ *     def _call( self ):             # <<<<<<<<<<<<<<
+ * 
+ *         cdef char * seq = self.iter.getSequence()
+ */
+
+static PyObject *__pyx_pf_9csamtools_15IndelCallerBase__call(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static char __pyx_doc_9csamtools_15IndelCallerBase__call[] = "IndelCallerBase._call(self)";
+static PyObject *__pyx_pf_9csamtools_15IndelCallerBase__call(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+  char *__pyx_v_seq;
+  int __pyx_v_seq_len;
+  bam_maqindel_ret_t *__pyx_v_r;
+  int __pyx_v_m;
+  struct __pyx_obj_9csamtools_IndelCall *__pyx_v_call;
+  uint64_t __pyx_v_rms_aux;
+  int __pyx_v_i;
+  bam_pileup1_t *__pyx_v_p;
+  int __pyx_v_tmp;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  int __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  int __pyx_t_6;
+  int __pyx_t_7;
+  double __pyx_t_8;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("_call");
+  __Pyx_TraceCall("_call", __pyx_f[0], 3234);
+  __pyx_v_call = ((struct __pyx_obj_9csamtools_IndelCall *)Py_None); __Pyx_INCREF(Py_None);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3236
+ *     def _call( self ):
+ * 
+ *         cdef char * seq = self.iter.getSequence()             # <<<<<<<<<<<<<<
+ *         cdef int seq_len = self.iter.seq_len
+ * 
+ */
+  __pyx_v_seq = ((struct __pyx_vtabstruct_9csamtools_IteratorColumn *)((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->__pyx_vtab)->getSequence(((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3237
+ * 
+ *         cdef char * seq = self.iter.getSequence()
+ *         cdef int seq_len = self.iter.seq_len             # <<<<<<<<<<<<<<
+ * 
+ *         assert seq != NULL
+ */
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter), __pyx_n_s__seq_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_2 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_v_seq_len = __pyx_t_2;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3239
+ *         cdef int seq_len = self.iter.seq_len
+ * 
+ *         assert seq != NULL             # <<<<<<<<<<<<<<
+ * 
+ *         # reference base
+ */
+  #ifndef PYREX_WITHOUT_ASSERTIONS
+  if (unlikely(!(__pyx_v_seq != NULL))) {
+    PyErr_SetNone(PyExc_AssertionError);
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  #endif
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3242
+ * 
+ *         # reference base
+ *         if self.iter.pos >= seq_len:             # <<<<<<<<<<<<<<
+ *             raise ValueError( "position %i out of bounds on reference sequence (len=%i)" % (self.iter.pos, seq_len) )
+ * 
+ */
+  __pyx_t_3 = (((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->pos >= __pyx_v_seq_len);
+  if (__pyx_t_3) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3243
+ *         # reference base
+ *         if self.iter.pos >= seq_len:
+ *             raise ValueError( "position %i out of bounds on reference sequence (len=%i)" % (self.iter.pos, seq_len) )             # <<<<<<<<<<<<<<
+ * 
+ *         cdef bam_maqindel_ret_t * r
+ */
+    __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->pos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_4 = PyInt_FromLong(__pyx_v_seq_len); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
+    __Pyx_GIVEREF(__pyx_t_1);
+    PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
+    __Pyx_GIVEREF(__pyx_t_4);
+    __pyx_t_1 = 0;
+    __pyx_t_4 = 0;
+    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_108), __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_4));
+    __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
+    __pyx_t_4 = 0;
+    __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __Pyx_Raise(__pyx_t_4, 0, 0);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L5;
+  }
+  __pyx_L5:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3247
+ *         cdef bam_maqindel_ret_t * r
+ * 
+ *         cdef int m = min( self.max_depth, self.iter.n_plp )             # <<<<<<<<<<<<<<
+ * 
+ *         # printf("pysam: m=%i, q_indel=%i, r_indel=%f, r_snp=%i, mm_penalty=%i, indel_err=%i, ambi_thres=%i\n",
+ */
+  __pyx_t_2 = ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->n_plp;
+  __pyx_t_6 = ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->max_depth;
+  if ((__pyx_t_2 < __pyx_t_6)) {
+    __pyx_t_7 = __pyx_t_2;
+  } else {
+    __pyx_t_7 = __pyx_t_6;
+  }
+  __pyx_v_m = __pyx_t_7;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3259
+ *                          seq,
+ *                          0,
+ *                          NULL)             # <<<<<<<<<<<<<<
+ * 
+ *         if r == NULL: return None
+ */
+  __pyx_v_r = bam_maqindel(__pyx_v_m, ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->pos, ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->options, ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->plp, __pyx_v_seq, 0, NULL);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3261
+ *                          NULL)
+ * 
+ *         if r == NULL: return None             # <<<<<<<<<<<<<<
+ * 
+ *         cdef IndelCall call
+ */
+  __pyx_t_3 = (__pyx_v_r == NULL);
+  if (__pyx_t_3) {
+    __Pyx_XDECREF(__pyx_r);
+    __Pyx_INCREF(Py_None);
+    __pyx_r = Py_None;
+    goto __pyx_L0;
+    goto __pyx_L6;
+  }
+  __pyx_L6:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3264
+ * 
+ *         cdef IndelCall call
+ *         call = IndelCall()             # <<<<<<<<<<<<<<
+ *         call._r = r
+ *         call._tid = self.iter.tid
+ */
+  __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IndelCall)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(((PyObject *)__pyx_v_call));
+  __pyx_v_call = ((struct __pyx_obj_9csamtools_IndelCall *)__pyx_t_4);
+  __pyx_t_4 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3265
+ *         cdef IndelCall call
+ *         call = IndelCall()
+ *         call._r = r             # <<<<<<<<<<<<<<
+ *         call._tid = self.iter.tid
+ *         call._pos = self.iter.pos
+ */
+  __pyx_v_call->_r = __pyx_v_r;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3266
+ *         call = IndelCall()
+ *         call._r = r
+ *         call._tid = self.iter.tid             # <<<<<<<<<<<<<<
+ *         call._pos = self.iter.pos
+ *         call._coverage = self.iter.n_plp
+ */
+  __pyx_v_call->_tid = ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->tid;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3267
+ *         call._r = r
+ *         call._tid = self.iter.tid
+ *         call._pos = self.iter.pos             # <<<<<<<<<<<<<<
+ *         call._coverage = self.iter.n_plp
+ * 
+ */
+  __pyx_v_call->_pos = ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->pos;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3268
+ *         call._tid = self.iter.tid
+ *         call._pos = self.iter.pos
+ *         call._coverage = self.iter.n_plp             # <<<<<<<<<<<<<<
+ * 
+ *         cdef uint64_t rms_aux = 0
+ */
+  __pyx_v_call->_coverage = ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->n_plp;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3270
+ *         call._coverage = self.iter.n_plp
+ * 
+ *         cdef uint64_t rms_aux = 0             # <<<<<<<<<<<<<<
+ *         cdef int i = 0
+ *         cdef bam_pileup1_t * p
+ */
+  __pyx_v_rms_aux = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3271
+ * 
+ *         cdef uint64_t rms_aux = 0
+ *         cdef int i = 0             # <<<<<<<<<<<<<<
+ *         cdef bam_pileup1_t * p
+ *         cdef int tmp
+ */
+  __pyx_v_i = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3275
+ *         cdef int tmp
+ * 
+ *         for i from 0 <= i < self.iter.n_plp:             # <<<<<<<<<<<<<<
+ *             p = self.iter.plp + i
+ *             if p.b.core.qual < self.cap_mapQ:
+ */
+  __pyx_t_7 = ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->n_plp;
+  for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3276
+ * 
+ *         for i from 0 <= i < self.iter.n_plp:
+ *             p = self.iter.plp + i             # <<<<<<<<<<<<<<
+ *             if p.b.core.qual < self.cap_mapQ:
+ *                 tmp = p.b.core.qual
+ */
+    __pyx_v_p = (((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->plp + __pyx_v_i);
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3277
+ *         for i from 0 <= i < self.iter.n_plp:
+ *             p = self.iter.plp + i
+ *             if p.b.core.qual < self.cap_mapQ:             # <<<<<<<<<<<<<<
+ *                 tmp = p.b.core.qual
+ *             else:
+ */
+    __pyx_t_3 = (__pyx_v_p->b->core.qual < ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->cap_mapQ);
+    if (__pyx_t_3) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3278
+ *             p = self.iter.plp + i
+ *             if p.b.core.qual < self.cap_mapQ:
+ *                 tmp = p.b.core.qual             # <<<<<<<<<<<<<<
+ *             else:
+ *                 tmp = self.cap_mapQ
+ */
+      __pyx_v_tmp = __pyx_v_p->b->core.qual;
+      goto __pyx_L9;
+    }
+    /*else*/ {
+
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3280
+ *                 tmp = p.b.core.qual
+ *             else:
+ *                 tmp = self.cap_mapQ             # <<<<<<<<<<<<<<
+ *             rms_aux += tmp * tmp
+ * 
+ */
+      __pyx_v_tmp = ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->cap_mapQ;
+    }
+    __pyx_L9:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3281
+ *             else:
+ *                 tmp = self.cap_mapQ
+ *             rms_aux += tmp * tmp             # <<<<<<<<<<<<<<
+ * 
+ *         call._rms_mapping_quality = <uint64_t>(sqrt(<double>rms_aux / self.iter.n_plp) + .499)
+ */
+    __pyx_v_rms_aux += (__pyx_v_tmp * __pyx_v_tmp);
+  }
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3283
+ *             rms_aux += tmp * tmp
+ * 
+ *         call._rms_mapping_quality = <uint64_t>(sqrt(<double>rms_aux / self.iter.n_plp) + .499)             # <<<<<<<<<<<<<<
+ * 
+ *         return call
+ */
+  __pyx_t_8 = ((double)__pyx_v_rms_aux);
+  if (unlikely(((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->n_plp == 0)) {
+    PyErr_Format(PyExc_ZeroDivisionError, "float division");
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  __pyx_v_call->_rms_mapping_quality = ((uint64_t)(sqrt((__pyx_t_8 / ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->n_plp)) + .499));
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3285
+ *         call._rms_mapping_quality = <uint64_t>(sqrt(<double>rms_aux / self.iter.n_plp) + .499)
+ * 
+ *         return call             # <<<<<<<<<<<<<<
+ * 
+ * cdef class IndelCaller( IndelCallerBase ):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(((PyObject *)__pyx_v_call));
+  __pyx_r = ((PyObject *)__pyx_v_call);
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_AddTraceback("csamtools.IndelCallerBase._call");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF((PyObject *)__pyx_v_call);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3300
+ *     '''
+ * 
+ *     def __cinit__(self,             # <<<<<<<<<<<<<<
+ *                   IteratorColumn iterator_column,
+ *                   **kwargs ):
+ */
+
+static int __pyx_pf_9csamtools_11IndelCaller___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pf_9csamtools_11IndelCaller___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  struct __pyx_obj_9csamtools_IteratorColumn *__pyx_v_iterator_column = 0;
+  PyObject *__pyx_v_kwargs = 0;
+  int __pyx_r;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__iterator_column,0};
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__cinit__");
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 3300);
+  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
+  __Pyx_GOTREF(__pyx_v_kwargs);
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[1] = {0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__iterator_column);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3300; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)values[0]);
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)PyTuple_GET_ITEM(__pyx_args, 0));
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3300; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_DECREF(__pyx_v_kwargs);
+  __Pyx_AddTraceback("csamtools.IndelCaller.__cinit__");
+  __Pyx_RefNannyFinishContext();
+  return -1;
+  __pyx_L4_argument_unpacking_done:;
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_iterator_column), __pyx_ptype_9csamtools_IteratorColumn, 1, "iterator_column", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("csamtools.IndelCaller.__cinit__");
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_kwargs);
+  __Pyx_TraceReturn(Py_None);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3306
+ *         pass
+ * 
+ *     def call(self, reference, int pos ):             # <<<<<<<<<<<<<<
+ *         """call a snp on chromosome *reference*
+ *         and position *pos*.
+ */
+
+static PyObject *__pyx_pf_9csamtools_11IndelCaller_call(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_9csamtools_11IndelCaller_call[] = "IndelCaller.call(self, reference, int pos)\ncall a snp on chromosome *reference*\n        and position *pos*.\n\n        returns a :class:`SNPCall` object or None, if no indel call could be made.\n        ";
+static PyObject *__pyx_pf_9csamtools_11IndelCaller_call(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_reference = 0;
+  int __pyx_v_pos;
+  int __pyx_v_tid;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  int __pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  int __pyx_t_6;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__reference,&__pyx_n_s__pos,0};
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("call");
+  __Pyx_TraceCall("call", __pyx_f[0], 3306);
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[2] = {0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reference);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pos);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("call", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3306; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "call") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3306; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_reference = values[0];
+    __pyx_v_pos = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_pos == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3306; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_reference = PyTuple_GET_ITEM(__pyx_args, 0);
+    __pyx_v_pos = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_pos == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3306; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("call", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3306; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("csamtools.IndelCaller.call");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3313
+ *         """
+ * 
+ *         cdef int tid = self.iter.samfile.gettid( reference )             # <<<<<<<<<<<<<<
+ * 
+ *         self.iter.reset( tid, pos, pos + 1 )
+ */
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_9csamtools_IndelCaller *)__pyx_v_self)->__pyx_base.iter->samfile), __pyx_n_s__gettid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_v_reference);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_reference);
+  __Pyx_GIVEREF(__pyx_v_reference);
+  __pyx_t_3 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_v_tid = __pyx_t_4;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3315
+ *         cdef int tid = self.iter.samfile.gettid( reference )
+ * 
+ *         self.iter.reset( tid, pos, pos + 1 )             # <<<<<<<<<<<<<<
+ * 
+ *         while 1:
+ */
+  __pyx_t_3 = PyInt_FromLong(__pyx_v_tid); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_2 = PyInt_FromLong(__pyx_v_pos); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_1 = PyInt_FromLong((__pyx_v_pos + 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_5 = ((struct __pyx_vtabstruct_9csamtools_IteratorColumn *)((struct __pyx_obj_9csamtools_IndelCaller *)__pyx_v_self)->__pyx_base.iter->__pyx_vtab)->reset(((struct __pyx_obj_9csamtools_IndelCaller *)__pyx_v_self)->__pyx_base.iter, __pyx_t_3, __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3317
+ *         self.iter.reset( tid, pos, pos + 1 )
+ * 
+ *         while 1:             # <<<<<<<<<<<<<<
+ *             self.iter.cnext()
+ * 
+ */
+  while (1) {
+    if (!1) break;
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3318
+ * 
+ *         while 1:
+ *             self.iter.cnext()             # <<<<<<<<<<<<<<
+ * 
+ *             if self.iter.n_plp < 0:
+ */
+    ((struct __pyx_vtabstruct_9csamtools_IteratorColumn *)((struct __pyx_obj_9csamtools_IndelCaller *)__pyx_v_self)->__pyx_base.iter->__pyx_vtab)->cnext(((struct __pyx_obj_9csamtools_IndelCaller *)__pyx_v_self)->__pyx_base.iter);
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3320
+ *             self.iter.cnext()
+ * 
+ *             if self.iter.n_plp < 0:             # <<<<<<<<<<<<<<
+ *                 raise ValueError("error during iteration" )
+ * 
+ */
+    __pyx_t_6 = (((struct __pyx_obj_9csamtools_IndelCaller *)__pyx_v_self)->__pyx_base.iter->n_plp < 0);
+    if (__pyx_t_6) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3321
+ * 
+ *             if self.iter.n_plp < 0:
+ *                 raise ValueError("error during iteration" )             # <<<<<<<<<<<<<<
+ * 
+ *             if self.iter.plp == NULL:
+ */
+      __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_59));
+      PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_59));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_59));
+      __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_Raise(__pyx_t_1, 0, 0);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      goto __pyx_L8;
+    }
+    __pyx_L8:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3323
+ *                 raise ValueError("error during iteration" )
+ * 
+ *             if self.iter.plp == NULL:             # <<<<<<<<<<<<<<
+ *                 raise ValueError( "no reads in region - no call" )
+ * 
+ */
+    __pyx_t_6 = (((struct __pyx_obj_9csamtools_IndelCaller *)__pyx_v_self)->__pyx_base.iter->plp == NULL);
+    if (__pyx_t_6) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3324
+ * 
+ *             if self.iter.plp == NULL:
+ *                 raise ValueError( "no reads in region - no call" )             # <<<<<<<<<<<<<<
+ * 
+ *             if self.iter.pos == pos: break
+ */
+      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_109));
+      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_109));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_109));
+      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_Raise(__pyx_t_5, 0, 0);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      goto __pyx_L9;
+    }
+    __pyx_L9:;
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3326
+ *                 raise ValueError( "no reads in region - no call" )
+ * 
+ *             if self.iter.pos == pos: break             # <<<<<<<<<<<<<<
+ * 
+ *         return self._call()
+ */
+    __pyx_t_6 = (((struct __pyx_obj_9csamtools_IndelCaller *)__pyx_v_self)->__pyx_base.iter->pos == __pyx_v_pos);
+    if (__pyx_t_6) {
+      goto __pyx_L7_break;
+      goto __pyx_L10;
+    }
+    __pyx_L10:;
+  }
+  __pyx_L7_break:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3328
+ *             if self.iter.pos == pos: break
+ * 
+ *         return self._call()             # <<<<<<<<<<<<<<
+ * 
+ * cdef class IteratorIndelCalls( IndelCallerBase ):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_5 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___call); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+  __pyx_t_1 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_AddTraceback("csamtools.IndelCaller.call");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3344
+ *     """
+ * 
+ *     def __cinit__(self,             # <<<<<<<<<<<<<<
+ *                   IteratorColumn iterator_column,
+ *                   **kwargs ):
+ */
+
+static int __pyx_pf_9csamtools_18IteratorIndelCalls___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pf_9csamtools_18IteratorIndelCalls___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  struct __pyx_obj_9csamtools_IteratorColumn *__pyx_v_iterator_column = 0;
+  PyObject *__pyx_v_kwargs = 0;
+  int __pyx_r;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__iterator_column,0};
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__cinit__");
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 3344);
+  __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
+  __Pyx_GOTREF(__pyx_v_kwargs);
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[1] = {0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__iterator_column);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3344; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)values[0]);
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)PyTuple_GET_ITEM(__pyx_args, 0));
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3344; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_DECREF(__pyx_v_kwargs);
+  __Pyx_AddTraceback("csamtools.IteratorIndelCalls.__cinit__");
+  __Pyx_RefNannyFinishContext();
+  return -1;
+  __pyx_L4_argument_unpacking_done:;
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_iterator_column), __pyx_ptype_9csamtools_IteratorColumn, 1, "iterator_column", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("csamtools.IteratorIndelCalls.__cinit__");
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_kwargs);
+  __Pyx_TraceReturn(Py_None);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3350
+ * 
+ * 
+ *     def __iter__(self):             # <<<<<<<<<<<<<<
+ *         return self
+ * 
+ */
+
+static PyObject *__pyx_pf_9csamtools_18IteratorIndelCalls___iter__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_9csamtools_18IteratorIndelCalls___iter__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__iter__");
+  __Pyx_TraceCall("__iter__", __pyx_f[0], 3350);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3351
+ * 
+ *     def __iter__(self):
+ *         return self             # <<<<<<<<<<<<<<
+ * 
+ *     def __next__(self):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_v_self);
+  __pyx_r = __pyx_v_self;
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3353
+ *         return self
+ * 
+ *     def __next__(self):             # <<<<<<<<<<<<<<
+ *         """python version of next().
+ *         """
+ */
+
+static PyObject *__pyx_pf_9csamtools_18IteratorIndelCalls___next__(PyObject *__pyx_v_self); /*proto*/
+static char __pyx_doc_9csamtools_18IteratorIndelCalls___next__[] = "python version of next().\n        ";
+struct wrapperbase __pyx_wrapperbase_9csamtools_18IteratorIndelCalls___next__;
+static PyObject *__pyx_pf_9csamtools_18IteratorIndelCalls___next__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__next__");
+  __Pyx_TraceCall("__next__", __pyx_f[0], 3353);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3358
+ * 
+ *         # the following code was adapted from bam_plcmd.c:pileup_func()
+ *         self.iter.cnext()             # <<<<<<<<<<<<<<
+ * 
+ *         if self.iter.n_plp < 0:
+ */
+  ((struct __pyx_vtabstruct_9csamtools_IteratorColumn *)((struct __pyx_obj_9csamtools_IteratorIndelCalls *)__pyx_v_self)->__pyx_base.iter->__pyx_vtab)->cnext(((struct __pyx_obj_9csamtools_IteratorIndelCalls *)__pyx_v_self)->__pyx_base.iter);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3360
+ *         self.iter.cnext()
+ * 
+ *         if self.iter.n_plp < 0:             # <<<<<<<<<<<<<<
+ *             raise ValueError("error during iteration" )
+ * 
+ */
+  __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorIndelCalls *)__pyx_v_self)->__pyx_base.iter->n_plp < 0);
+  if (__pyx_t_1) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3361
+ * 
+ *         if self.iter.n_plp < 0:
+ *             raise ValueError("error during iteration" )             # <<<<<<<<<<<<<<
+ * 
+ *         if self.iter.plp == NULL:
+ */
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_59));
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_59));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_59));
+    __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_Raise(__pyx_t_3, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L5;
+  }
+  __pyx_L5:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3363
+ *             raise ValueError("error during iteration" )
+ * 
+ *         if self.iter.plp == NULL:             # <<<<<<<<<<<<<<
+ *            raise StopIteration
+ * 
+ */
+  __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorIndelCalls *)__pyx_v_self)->__pyx_base.iter->plp == NULL);
+  if (__pyx_t_1) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3364
+ * 
+ *         if self.iter.plp == NULL:
+ *            raise StopIteration             # <<<<<<<<<<<<<<
+ * 
+ *         return self._call()
+ */
+    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L6;
+  }
+  __pyx_L6:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3366
+ *            raise StopIteration
+ * 
+ *         return self._call()             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___call); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_r = __pyx_t_2;
+  __pyx_t_2 = 0;
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("csamtools.IteratorIndelCalls.__next__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3386
+ *     cdef int owns_samfile
+ * 
+ *     def __init__(self, Samfile samfile, int reopen = True ):             # <<<<<<<<<<<<<<
+ *         self.samfile = samfile
+ * 
+ */
+
+static int __pyx_pf_9csamtools_12IndexedReads___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pf_9csamtools_12IndexedReads___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  struct __pyx_obj_9csamtools_Samfile *__pyx_v_samfile = 0;
+  int __pyx_v_reopen;
+  PyObject *__pyx_v_mode;
+  PyObject *__pyx_v_store;
+  int __pyx_r;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  char *__pyx_t_3;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__samfile,&__pyx_n_s__reopen,0};
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__init__");
+  __Pyx_TraceCall("__init__", __pyx_f[0], 3386);
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[2] = {0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__samfile);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      if (kw_args > 0) {
+        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reopen);
+        if (value) { values[1] = value; kw_args--; }
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3386; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)values[0]);
+    if (values[1]) {
+      __pyx_v_reopen = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_reopen == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3386; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    } else {
+      __pyx_v_reopen = ((int)1);
+    }
+  } else {
+    __pyx_v_reopen = ((int)1);
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  2: __pyx_v_reopen = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_reopen == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3386; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      case  1: __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)PyTuple_GET_ITEM(__pyx_args, 0));
+      break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3386; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("csamtools.IndexedReads.__init__");
+  __Pyx_RefNannyFinishContext();
+  return -1;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_v_mode = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_store = Py_None; __Pyx_INCREF(Py_None);
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3387
+ * 
+ *     def __init__(self, Samfile samfile, int reopen = True ):
+ *         self.samfile = samfile             # <<<<<<<<<<<<<<
+ * 
+ *         if samfile.isbam: mode = "rb"
+ */
+  __Pyx_INCREF(((PyObject *)__pyx_v_samfile));
+  __Pyx_GIVEREF(((PyObject *)__pyx_v_samfile));
+  __Pyx_GOTREF(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->samfile);
+  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->samfile));
+  ((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->samfile = __pyx_v_samfile;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3389
+ *         self.samfile = samfile
+ * 
+ *         if samfile.isbam: mode = "rb"             # <<<<<<<<<<<<<<
+ *         else: mode = "r"
+ * 
+ */
+  if (__pyx_v_samfile->isbam) {
+    __Pyx_INCREF(((PyObject *)__pyx_n_s__rb));
+    __Pyx_DECREF(__pyx_v_mode);
+    __pyx_v_mode = ((PyObject *)__pyx_n_s__rb);
+    goto __pyx_L6;
+  }
+  /*else*/ {
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3390
+ * 
+ *         if samfile.isbam: mode = "rb"
+ *         else: mode = "r"             # <<<<<<<<<<<<<<
+ * 
+ *         # reopen the file - note that this makes the iterator
+ */
+    __Pyx_INCREF(((PyObject *)__pyx_n_s__r));
+    __Pyx_DECREF(__pyx_v_mode);
+    __pyx_v_mode = ((PyObject *)__pyx_n_s__r);
+  }
+  __pyx_L6:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3394
+ *         # reopen the file - note that this makes the iterator
+ *         # slow and causes pileup to slow down significantly.
+ *         if reopen:             # <<<<<<<<<<<<<<
+ *             store = StderrStore()
+ *             self.fp = samopen( samfile._filename, mode, NULL )
+ */
+  if (__pyx_v_reopen) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3395
+ *         # slow and causes pileup to slow down significantly.
+ *         if reopen:
+ *             store = StderrStore()             # <<<<<<<<<<<<<<
+ *             self.fp = samopen( samfile._filename, mode, NULL )
+ *             store.release()
+ */
+    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__StderrStore); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_DECREF(__pyx_v_store);
+    __pyx_v_store = __pyx_t_2;
+    __pyx_t_2 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3396
+ *         if reopen:
+ *             store = StderrStore()
+ *             self.fp = samopen( samfile._filename, mode, NULL )             # <<<<<<<<<<<<<<
+ *             store.release()
+ *             assert self.fp != NULL
+ */
+    __pyx_t_3 = PyBytes_AsString(__pyx_v_mode); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    ((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->fp = samopen(__pyx_v_samfile->_filename, __pyx_t_3, NULL);
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3397
+ *             store = StderrStore()
+ *             self.fp = samopen( samfile._filename, mode, NULL )
+ *             store.release()             # <<<<<<<<<<<<<<
+ *             assert self.fp != NULL
+ *             self.owns_samfile = True
+ */
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_store, __pyx_n_s__release); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3398
+ *             self.fp = samopen( samfile._filename, mode, NULL )
+ *             store.release()
+ *             assert self.fp != NULL             # <<<<<<<<<<<<<<
+ *             self.owns_samfile = True
+ *         else:
+ */
+    #ifndef PYREX_WITHOUT_ASSERTIONS
+    if (unlikely(!(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->fp != NULL))) {
+      PyErr_SetNone(PyExc_AssertionError);
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    }
+    #endif
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3399
+ *             store.release()
+ *             assert self.fp != NULL
+ *             self.owns_samfile = True             # <<<<<<<<<<<<<<
+ *         else:
+ *             self.fp = samfile.samfile
+ */
+    ((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->owns_samfile = 1;
+    goto __pyx_L7;
+  }
+  /*else*/ {
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3401
+ *             self.owns_samfile = True
+ *         else:
+ *             self.fp = samfile.samfile             # <<<<<<<<<<<<<<
+ *             self.owns_samfile = False
+ * 
+ */
+    ((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->fp = __pyx_v_samfile->samfile;
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3402
+ *         else:
+ *             self.fp = samfile.samfile
+ *             self.owns_samfile = False             # <<<<<<<<<<<<<<
+ * 
+ *         assert samfile.isbam, "can only IndexReads on bam files"
+ */
+    ((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->owns_samfile = 0;
+  }
+  __pyx_L7:;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3404
+ *             self.owns_samfile = False
+ * 
+ *         assert samfile.isbam, "can only IndexReads on bam files"             # <<<<<<<<<<<<<<
+ * 
+ *     def build( self ):
+ */
+  #ifndef PYREX_WITHOUT_ASSERTIONS
+  if (unlikely(!__pyx_v_samfile->isbam)) {
+    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_112));
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  #endif
+
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("csamtools.IndexedReads.__init__");
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_mode);
+  __Pyx_DECREF(__pyx_v_store);
+  __Pyx_TraceReturn(Py_None);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3406
+ *         assert samfile.isbam, "can only IndexReads on bam files"
+ * 
+ *     def build( self ):             # <<<<<<<<<<<<<<
+ *         '''build index.'''
+ * 
+ */
+
+static PyObject *__pyx_pf_9csamtools_12IndexedReads_build(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static char __pyx_doc_9csamtools_12IndexedReads_build[] = "IndexedReads.build(self)\nbuild index.";
+static PyObject *__pyx_pf_9csamtools_12IndexedReads_build(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+  int __pyx_v_ret;
+  bam1_t *__pyx_v_b;
+  uint64_t __pyx_v_pos;
+  char *__pyx_v_qname;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  int __pyx_t_4;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("build");
+  __Pyx_TraceCall("build", __pyx_f[0], 3406);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3409
+ *         '''build index.'''
+ * 
+ *         self.index = collections.defaultdict( list )             # <<<<<<<<<<<<<<
+ * 
+ *         # this method will start indexing from the current file position
+ */
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__collections); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__defaultdict); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_INCREF(((PyObject *)((PyObject*)&PyList_Type)));
+  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)&PyList_Type)));
+  __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyList_Type)));
+  __pyx_t_3 = PyObject_Call(__pyx_t_2, __pyx_t_1, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_GIVEREF(__pyx_t_3);
+  __Pyx_GOTREF(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->index);
+  __Pyx_DECREF(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->index);
+  ((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->index = __pyx_t_3;
+  __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3413
+ *         # this method will start indexing from the current file position
+ *         # if you decide
+ *         cdef int ret = 1             # <<<<<<<<<<<<<<
+ *         cdef bam1_t * b = <bam1_t*> calloc(1, sizeof( bam1_t) )
+ * 
+ */
+  __pyx_v_ret = 1;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3414
+ *         # if you decide
+ *         cdef int ret = 1
+ *         cdef bam1_t * b = <bam1_t*> calloc(1, sizeof( bam1_t) )             # <<<<<<<<<<<<<<
+ * 
+ *         cdef uint64_t pos
+ */
+  __pyx_v_b = ((bam1_t *)calloc(1, (sizeof(bam1_t))));
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3418
+ *         cdef uint64_t pos
+ * 
+ *         while ret > 0:             # <<<<<<<<<<<<<<
+ *             pos = bam_tell( self.fp.x.bam )
+ *             ret = samread( self.fp, b)
+ */
+  while (1) {
+    __pyx_t_4 = (__pyx_v_ret > 0);
+    if (!__pyx_t_4) break;
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3419
+ * 
+ *         while ret > 0:
+ *             pos = bam_tell( self.fp.x.bam )             # <<<<<<<<<<<<<<
+ *             ret = samread( self.fp, b)
+ *             if ret > 0:
+ */
+    __pyx_v_pos = bam_tell(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->fp->x.bam);
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3420
+ *         while ret > 0:
+ *             pos = bam_tell( self.fp.x.bam )
+ *             ret = samread( self.fp, b)             # <<<<<<<<<<<<<<
+ *             if ret > 0:
+ *                 qname = bam1_qname( b )
+ */
+    __pyx_v_ret = samread(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->fp, __pyx_v_b);
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3421
+ *             pos = bam_tell( self.fp.x.bam )
+ *             ret = samread( self.fp, b)
+ *             if ret > 0:             # <<<<<<<<<<<<<<
+ *                 qname = bam1_qname( b )
+ *                 self.index[qname].append( pos )
+ */
+    __pyx_t_4 = (__pyx_v_ret > 0);
+    if (__pyx_t_4) {
+
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3422
+ *             ret = samread( self.fp, b)
+ *             if ret > 0:
+ *                 qname = bam1_qname( b )             # <<<<<<<<<<<<<<
+ *                 self.index[qname].append( pos )
+ * 
+ */
+      __pyx_v_qname = bam1_qname(__pyx_v_b);
+
+      /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3423
+ *             if ret > 0:
+ *                 qname = bam1_qname( b )
+ *                 self.index[qname].append( pos )             # <<<<<<<<<<<<<<
+ * 
+ *         bam_destroy1( b )
+ */
+      __pyx_t_3 = PyBytes_FromString(__pyx_v_qname); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+      __pyx_t_1 = PyObject_GetItem(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->index, ((PyObject *)__pyx_t_3)); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+      __pyx_t_3 = __Pyx_PyInt_to_py_uint64_t(__pyx_v_pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_2 = __Pyx_PyObject_Append(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      goto __pyx_L7;
+    }
+    __pyx_L7:;
+  }
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3425
+ *                 self.index[qname].append( pos )
+ * 
+ *         bam_destroy1( b )             # <<<<<<<<<<<<<<
+ * 
+ *     def find( self, qname ):
+ */
+  bam_destroy1(__pyx_v_b);
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("csamtools.IndexedReads.build");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3427
+ *         bam_destroy1( b )
+ * 
+ *     def find( self, qname ):             # <<<<<<<<<<<<<<
+ *         if qname in self.index:
+ *             return IteratorRowSelection( self.samfile, self.index[qname], reopen = False )
+ */
+
+static PyObject *__pyx_pf_9csamtools_12IndexedReads_find(PyObject *__pyx_v_self, PyObject *__pyx_v_qname); /*proto*/
+static char __pyx_doc_9csamtools_12IndexedReads_find[] = "IndexedReads.find(self, qname)";
+static PyObject *__pyx_pf_9csamtools_12IndexedReads_find(PyObject *__pyx_v_self, PyObject *__pyx_v_qname) {
+  PyObject *__pyx_r = NULL;
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("find");
+  __Pyx_TraceCall("find", __pyx_f[0], 3427);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3428
+ * 
+ *     def find( self, qname ):
+ *         if qname in self.index:             # <<<<<<<<<<<<<<
+ *             return IteratorRowSelection( self.samfile, self.index[qname], reopen = False )
+ *         else:
+ */
+  __pyx_t_1 = ((PySequence_Contains(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->index, __pyx_v_qname))); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__pyx_t_1) {
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3429
+ *     def find( self, qname ):
+ *         if qname in self.index:
+ *             return IteratorRowSelection( self.samfile, self.index[qname], reopen = False )             # <<<<<<<<<<<<<<
+ *         else:
+ *             raise KeyError( "read %s not found" % qname )
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_2 = PyObject_GetItem(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->index, __pyx_v_qname); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_INCREF(((PyObject *)((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->samfile));
+    PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->samfile));
+    __Pyx_GIVEREF(((PyObject *)((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->samfile));
+    PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
+    __Pyx_GIVEREF(__pyx_t_2);
+    __pyx_t_2 = 0;
+    __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+    __pyx_t_4 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__reopen), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_4 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_9csamtools_IteratorRowSelection)), __pyx_t_3, ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3429; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+    __pyx_r = __pyx_t_4;
+    __pyx_t_4 = 0;
+    goto __pyx_L0;
+    goto __pyx_L5;
+  }
+  /*else*/ {
+
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3431
+ *             return IteratorRowSelection( self.samfile, self.index[qname], reopen = False )
+ *         else:
+ *             raise KeyError( "read %s not found" % qname )             # <<<<<<<<<<<<<<
+ * 
+ *     def __dealloc__(self):
+ */
+    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_113), __pyx_v_qname); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_4));
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_4));
+    __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
+    __pyx_t_4 = 0;
+    __pyx_t_4 = PyObject_Call(__pyx_builtin_KeyError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_Raise(__pyx_t_4, 0, 0);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  __pyx_L5:;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_AddTraceback("csamtools.IndexedReads.find");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3433
+ *             raise KeyError( "read %s not found" % qname )
+ * 
+ *     def __dealloc__(self):             # <<<<<<<<<<<<<<
+ *         if self.owns_samfile: samclose( self.fp )
+ * 
+ */
+
+static void __pyx_pf_9csamtools_12IndexedReads___dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_pf_9csamtools_12IndexedReads___dealloc__(PyObject *__pyx_v_self) {
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__dealloc__");
+  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 3433);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3434
+ * 
+ *     def __dealloc__(self):
+ *         if self.owns_samfile: samclose( self.fp )             # <<<<<<<<<<<<<<
+ * 
+ * __all__ = ["Samfile",
+ */
+  if (((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->owns_samfile) {
+    samclose(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->fp);
+    goto __pyx_L5;
+  }
+  __pyx_L5:;
+
+  __Pyx_TraceReturn(Py_None);
+  __Pyx_RefNannyFinishContext();
+}
+
+static PyObject *__pyx_tp_new_9csamtools_AlignedRead(PyTypeObject *t, PyObject *a, PyObject *k) {
+  PyObject *o = (*t->tp_alloc)(t, 0);
+  if (!o) return 0;
+  return o;
+}
+
+static void __pyx_tp_dealloc_9csamtools_AlignedRead(PyObject *o) {
+  {
+    PyObject *etype, *eval, *etb;
+    PyErr_Fetch(&etype, &eval, &etb);
+    ++Py_REFCNT(o);
+    __pyx_pf_9csamtools_11AlignedRead___dealloc__(o);
+    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
+    --Py_REFCNT(o);
+    PyErr_Restore(etype, eval, etb);
+  }
+  (*Py_TYPE(o)->tp_free)(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_11AlignedRead_qname(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11AlignedRead_5qname___get__(o);
+}
+
+static int __pyx_setprop_9csamtools_11AlignedRead_qname(PyObject *o, PyObject *v, void *x) {
+  if (v) {
+    return __pyx_pf_9csamtools_11AlignedRead_5qname___set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyObject *__pyx_getprop_9csamtools_11AlignedRead_cigar(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11AlignedRead_5cigar___get__(o);
+}
+
+static int __pyx_setprop_9csamtools_11AlignedRead_cigar(PyObject *o, PyObject *v, void *x) {
+  if (v) {
+    return __pyx_pf_9csamtools_11AlignedRead_5cigar___set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyObject *__pyx_getprop_9csamtools_11AlignedRead_seq(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11AlignedRead_3seq___get__(o);
+}
+
+static int __pyx_setprop_9csamtools_11AlignedRead_seq(PyObject *o, PyObject *v, void *x) {
+  if (v) {
+    return __pyx_pf_9csamtools_11AlignedRead_3seq___set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyObject *__pyx_getprop_9csamtools_11AlignedRead_qual(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11AlignedRead_4qual___get__(o);
+}
+
+static int __pyx_setprop_9csamtools_11AlignedRead_qual(PyObject *o, PyObject *v, void *x) {
+  if (v) {
+    return __pyx_pf_9csamtools_11AlignedRead_4qual___set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyObject *__pyx_getprop_9csamtools_11AlignedRead_query(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11AlignedRead_5query___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_11AlignedRead_qqual(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11AlignedRead_5qqual___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_11AlignedRead_qstart(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11AlignedRead_6qstart___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_11AlignedRead_qend(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11AlignedRead_4qend___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_11AlignedRead_qlen(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11AlignedRead_4qlen___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_11AlignedRead_tags(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11AlignedRead_4tags___get__(o);
+}
+
+static int __pyx_setprop_9csamtools_11AlignedRead_tags(PyObject *o, PyObject *v, void *x) {
+  if (v) {
+    return __pyx_pf_9csamtools_11AlignedRead_4tags___set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyObject *__pyx_getprop_9csamtools_11AlignedRead_flag(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11AlignedRead_4flag___get__(o);
+}
+
+static int __pyx_setprop_9csamtools_11AlignedRead_flag(PyObject *o, PyObject *v, void *x) {
+  if (v) {
+    return __pyx_pf_9csamtools_11AlignedRead_4flag___set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyObject *__pyx_getprop_9csamtools_11AlignedRead_rname(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11AlignedRead_5rname___get__(o);
+}
+
+static int __pyx_setprop_9csamtools_11AlignedRead_rname(PyObject *o, PyObject *v, void *x) {
+  if (v) {
+    return __pyx_pf_9csamtools_11AlignedRead_5rname___set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyObject *__pyx_getprop_9csamtools_11AlignedRead_tid(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11AlignedRead_3tid___get__(o);
+}
+
+static int __pyx_setprop_9csamtools_11AlignedRead_tid(PyObject *o, PyObject *v, void *x) {
+  if (v) {
+    return __pyx_pf_9csamtools_11AlignedRead_3tid___set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyObject *__pyx_getprop_9csamtools_11AlignedRead_pos(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11AlignedRead_3pos___get__(o);
+}
+
+static int __pyx_setprop_9csamtools_11AlignedRead_pos(PyObject *o, PyObject *v, void *x) {
+  if (v) {
+    return __pyx_pf_9csamtools_11AlignedRead_3pos___set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyObject *__pyx_getprop_9csamtools_11AlignedRead_bin(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11AlignedRead_3bin___get__(o);
+}
+
+static int __pyx_setprop_9csamtools_11AlignedRead_bin(PyObject *o, PyObject *v, void *x) {
+  if (v) {
+    return __pyx_pf_9csamtools_11AlignedRead_3bin___set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyObject *__pyx_getprop_9csamtools_11AlignedRead_rlen(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11AlignedRead_4rlen___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_11AlignedRead_aend(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11AlignedRead_4aend___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_11AlignedRead_alen(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11AlignedRead_4alen___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_11AlignedRead_mapq(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11AlignedRead_4mapq___get__(o);
+}
+
+static int __pyx_setprop_9csamtools_11AlignedRead_mapq(PyObject *o, PyObject *v, void *x) {
+  if (v) {
+    return __pyx_pf_9csamtools_11AlignedRead_4mapq___set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyObject *__pyx_getprop_9csamtools_11AlignedRead_mrnm(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11AlignedRead_4mrnm___get__(o);
+}
+
+static int __pyx_setprop_9csamtools_11AlignedRead_mrnm(PyObject *o, PyObject *v, void *x) {
+  if (v) {
+    return __pyx_pf_9csamtools_11AlignedRead_4mrnm___set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyObject *__pyx_getprop_9csamtools_11AlignedRead_mpos(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11AlignedRead_4mpos___get__(o);
+}
+
+static int __pyx_setprop_9csamtools_11AlignedRead_mpos(PyObject *o, PyObject *v, void *x) {
+  if (v) {
+    return __pyx_pf_9csamtools_11AlignedRead_4mpos___set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyObject *__pyx_getprop_9csamtools_11AlignedRead_isize(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11AlignedRead_5isize___get__(o);
+}
+
+static int __pyx_setprop_9csamtools_11AlignedRead_isize(PyObject *o, PyObject *v, void *x) {
+  if (v) {
+    return __pyx_pf_9csamtools_11AlignedRead_5isize___set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_paired(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11AlignedRead_9is_paired___get__(o);
+}
+
+static int __pyx_setprop_9csamtools_11AlignedRead_is_paired(PyObject *o, PyObject *v, void *x) {
+  if (v) {
+    return __pyx_pf_9csamtools_11AlignedRead_9is_paired___set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_proper_pair(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11AlignedRead_14is_proper_pair___get__(o);
+}
+
+static int __pyx_setprop_9csamtools_11AlignedRead_is_proper_pair(PyObject *o, PyObject *v, void *x) {
+  if (v) {
+    return __pyx_pf_9csamtools_11AlignedRead_14is_proper_pair___set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_unmapped(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11AlignedRead_11is_unmapped___get__(o);
+}
+
+static int __pyx_setprop_9csamtools_11AlignedRead_is_unmapped(PyObject *o, PyObject *v, void *x) {
+  if (v) {
+    return __pyx_pf_9csamtools_11AlignedRead_11is_unmapped___set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyObject *__pyx_getprop_9csamtools_11AlignedRead_mate_is_unmapped(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11AlignedRead_16mate_is_unmapped___get__(o);
+}
+
+static int __pyx_setprop_9csamtools_11AlignedRead_mate_is_unmapped(PyObject *o, PyObject *v, void *x) {
+  if (v) {
+    return __pyx_pf_9csamtools_11AlignedRead_16mate_is_unmapped___set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_reverse(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11AlignedRead_10is_reverse___get__(o);
+}
+
+static int __pyx_setprop_9csamtools_11AlignedRead_is_reverse(PyObject *o, PyObject *v, void *x) {
+  if (v) {
+    return __pyx_pf_9csamtools_11AlignedRead_10is_reverse___set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyObject *__pyx_getprop_9csamtools_11AlignedRead_mate_is_reverse(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11AlignedRead_15mate_is_reverse___get__(o);
+}
+
+static int __pyx_setprop_9csamtools_11AlignedRead_mate_is_reverse(PyObject *o, PyObject *v, void *x) {
+  if (v) {
+    return __pyx_pf_9csamtools_11AlignedRead_15mate_is_reverse___set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_read1(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11AlignedRead_8is_read1___get__(o);
+}
+
+static int __pyx_setprop_9csamtools_11AlignedRead_is_read1(PyObject *o, PyObject *v, void *x) {
+  if (v) {
+    return __pyx_pf_9csamtools_11AlignedRead_8is_read1___set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_read2(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11AlignedRead_8is_read2___get__(o);
+}
+
+static int __pyx_setprop_9csamtools_11AlignedRead_is_read2(PyObject *o, PyObject *v, void *x) {
+  if (v) {
+    return __pyx_pf_9csamtools_11AlignedRead_8is_read2___set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_secondary(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11AlignedRead_12is_secondary___get__(o);
+}
+
+static int __pyx_setprop_9csamtools_11AlignedRead_is_secondary(PyObject *o, PyObject *v, void *x) {
+  if (v) {
+    return __pyx_pf_9csamtools_11AlignedRead_12is_secondary___set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_qcfail(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11AlignedRead_9is_qcfail___get__(o);
+}
+
+static int __pyx_setprop_9csamtools_11AlignedRead_is_qcfail(PyObject *o, PyObject *v, void *x) {
+  if (v) {
+    return __pyx_pf_9csamtools_11AlignedRead_9is_qcfail___set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_duplicate(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11AlignedRead_12is_duplicate___get__(o);
+}
+
+static int __pyx_setprop_9csamtools_11AlignedRead_is_duplicate(PyObject *o, PyObject *v, void *x) {
+  if (v) {
+    return __pyx_pf_9csamtools_11AlignedRead_12is_duplicate___set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyObject *__pyx_getprop_9csamtools_11AlignedRead_positions(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11AlignedRead_9positions___get__(o);
+}
+
+static PyMethodDef __pyx_methods_9csamtools_AlignedRead[] = {
+  {__Pyx_NAMESTR("compare"), (PyCFunction)__pyx_pf_9csamtools_11AlignedRead_compare, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_11AlignedRead_compare)},
+  {__Pyx_NAMESTR("overlap"), (PyCFunction)__pyx_pf_9csamtools_11AlignedRead_overlap, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_11AlignedRead_overlap)},
+  {__Pyx_NAMESTR("opt"), (PyCFunction)__pyx_pf_9csamtools_11AlignedRead_opt, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_11AlignedRead_opt)},
+  {__Pyx_NAMESTR("fancy_str"), (PyCFunction)__pyx_pf_9csamtools_11AlignedRead_fancy_str, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_11AlignedRead_fancy_str)},
+  {0, 0, 0, 0}
+};
+
+static struct PyGetSetDef __pyx_getsets_9csamtools_AlignedRead[] = {
+  {(char *)"qname", __pyx_getprop_9csamtools_11AlignedRead_qname, __pyx_setprop_9csamtools_11AlignedRead_qname, __Pyx_DOCSTR(__pyx_k_114), 0},
+  {(char *)"cigar", __pyx_getprop_9csamtools_11AlignedRead_cigar, __pyx_setprop_9csamtools_11AlignedRead_cigar, __Pyx_DOCSTR(__pyx_k_115), 0},
+  {(char *)"seq", __pyx_getprop_9csamtools_11AlignedRead_seq, __pyx_setprop_9csamtools_11AlignedRead_seq, __Pyx_DOCSTR(__pyx_k_116), 0},
+  {(char *)"qual", __pyx_getprop_9csamtools_11AlignedRead_qual, __pyx_setprop_9csamtools_11AlignedRead_qual, __Pyx_DOCSTR(__pyx_k_117), 0},
+  {(char *)"query", __pyx_getprop_9csamtools_11AlignedRead_query, 0, __Pyx_DOCSTR(__pyx_k_118), 0},
+  {(char *)"qqual", __pyx_getprop_9csamtools_11AlignedRead_qqual, 0, __Pyx_DOCSTR(__pyx_k_119), 0},
+  {(char *)"qstart", __pyx_getprop_9csamtools_11AlignedRead_qstart, 0, __Pyx_DOCSTR(__pyx_k_120), 0},
+  {(char *)"qend", __pyx_getprop_9csamtools_11AlignedRead_qend, 0, __Pyx_DOCSTR(__pyx_k_121), 0},
+  {(char *)"qlen", __pyx_getprop_9csamtools_11AlignedRead_qlen, 0, __Pyx_DOCSTR(__pyx_k_122), 0},
+  {(char *)"tags", __pyx_getprop_9csamtools_11AlignedRead_tags, __pyx_setprop_9csamtools_11AlignedRead_tags, __Pyx_DOCSTR(__pyx_k_123), 0},
+  {(char *)"flag", __pyx_getprop_9csamtools_11AlignedRead_flag, __pyx_setprop_9csamtools_11AlignedRead_flag, __Pyx_DOCSTR(__pyx_k_124), 0},
+  {(char *)"rname", __pyx_getprop_9csamtools_11AlignedRead_rname, __pyx_setprop_9csamtools_11AlignedRead_rname, __Pyx_DOCSTR(__pyx_k_125), 0},
+  {(char *)"tid", __pyx_getprop_9csamtools_11AlignedRead_tid, __pyx_setprop_9csamtools_11AlignedRead_tid, __Pyx_DOCSTR(__pyx_k_126), 0},
+  {(char *)"pos", __pyx_getprop_9csamtools_11AlignedRead_pos, __pyx_setprop_9csamtools_11AlignedRead_pos, __Pyx_DOCSTR(__pyx_k_127), 0},
+  {(char *)"bin", __pyx_getprop_9csamtools_11AlignedRead_bin, __pyx_setprop_9csamtools_11AlignedRead_bin, __Pyx_DOCSTR(__pyx_k_128), 0},
+  {(char *)"rlen", __pyx_getprop_9csamtools_11AlignedRead_rlen, 0, __Pyx_DOCSTR(__pyx_k_129), 0},
+  {(char *)"aend", __pyx_getprop_9csamtools_11AlignedRead_aend, 0, __Pyx_DOCSTR(__pyx_k_130), 0},
+  {(char *)"alen", __pyx_getprop_9csamtools_11AlignedRead_alen, 0, __Pyx_DOCSTR(__pyx_k_131), 0},
+  {(char *)"mapq", __pyx_getprop_9csamtools_11AlignedRead_mapq, __pyx_setprop_9csamtools_11AlignedRead_mapq, __Pyx_DOCSTR(__pyx_k_132), 0},
+  {(char *)"mrnm", __pyx_getprop_9csamtools_11AlignedRead_mrnm, __pyx_setprop_9csamtools_11AlignedRead_mrnm, __Pyx_DOCSTR(__pyx_k_133), 0},
+  {(char *)"mpos", __pyx_getprop_9csamtools_11AlignedRead_mpos, __pyx_setprop_9csamtools_11AlignedRead_mpos, __Pyx_DOCSTR(__pyx_k_134), 0},
+  {(char *)"isize", __pyx_getprop_9csamtools_11AlignedRead_isize, __pyx_setprop_9csamtools_11AlignedRead_isize, __Pyx_DOCSTR(__pyx_k_135), 0},
+  {(char *)"is_paired", __pyx_getprop_9csamtools_11AlignedRead_is_paired, __pyx_setprop_9csamtools_11AlignedRead_is_paired, __Pyx_DOCSTR(__pyx_k_136), 0},
+  {(char *)"is_proper_pair", __pyx_getprop_9csamtools_11AlignedRead_is_proper_pair, __pyx_setprop_9csamtools_11AlignedRead_is_proper_pair, __Pyx_DOCSTR(__pyx_k_137), 0},
+  {(char *)"is_unmapped", __pyx_getprop_9csamtools_11AlignedRead_is_unmapped, __pyx_setprop_9csamtools_11AlignedRead_is_unmapped, __Pyx_DOCSTR(__pyx_k_138), 0},
+  {(char *)"mate_is_unmapped", __pyx_getprop_9csamtools_11AlignedRead_mate_is_unmapped, __pyx_setprop_9csamtools_11AlignedRead_mate_is_unmapped, __Pyx_DOCSTR(__pyx_k_139), 0},
+  {(char *)"is_reverse", __pyx_getprop_9csamtools_11AlignedRead_is_reverse, __pyx_setprop_9csamtools_11AlignedRead_is_reverse, __Pyx_DOCSTR(__pyx_k_140), 0},
+  {(char *)"mate_is_reverse", __pyx_getprop_9csamtools_11AlignedRead_mate_is_reverse, __pyx_setprop_9csamtools_11AlignedRead_mate_is_reverse, __Pyx_DOCSTR(__pyx_k_141), 0},
+  {(char *)"is_read1", __pyx_getprop_9csamtools_11AlignedRead_is_read1, __pyx_setprop_9csamtools_11AlignedRead_is_read1, __Pyx_DOCSTR(__pyx_k_142), 0},
+  {(char *)"is_read2", __pyx_getprop_9csamtools_11AlignedRead_is_read2, __pyx_setprop_9csamtools_11AlignedRead_is_read2, __Pyx_DOCSTR(__pyx_k_143), 0},
+  {(char *)"is_secondary", __pyx_getprop_9csamtools_11AlignedRead_is_secondary, __pyx_setprop_9csamtools_11AlignedRead_is_secondary, __Pyx_DOCSTR(__pyx_k_144), 0},
+  {(char *)"is_qcfail", __pyx_getprop_9csamtools_11AlignedRead_is_qcfail, __pyx_setprop_9csamtools_11AlignedRead_is_qcfail, __Pyx_DOCSTR(__pyx_k_145), 0},
+  {(char *)"is_duplicate", __pyx_getprop_9csamtools_11AlignedRead_is_duplicate, __pyx_setprop_9csamtools_11AlignedRead_is_duplicate, __Pyx_DOCSTR(__pyx_k_146), 0},
+  {(char *)"positions", __pyx_getprop_9csamtools_11AlignedRead_positions, 0, __Pyx_DOCSTR(__pyx_k_147), 0},
+  {0, 0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_AlignedRead = {
+  0, /*nb_add*/
+  0, /*nb_subtract*/
+  0, /*nb_multiply*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_divide*/
+  #endif
+  0, /*nb_remainder*/
+  0, /*nb_divmod*/
+  0, /*nb_power*/
+  0, /*nb_negative*/
+  0, /*nb_positive*/
+  0, /*nb_absolute*/
+  0, /*nb_nonzero*/
+  0, /*nb_invert*/
+  0, /*nb_lshift*/
+  0, /*nb_rshift*/
+  0, /*nb_and*/
+  0, /*nb_xor*/
+  0, /*nb_or*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_coerce*/
+  #endif
+  0, /*nb_int*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_long*/
+  #else
+  0, /*reserved*/
+  #endif
+  0, /*nb_float*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_oct*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_hex*/
+  #endif
+  0, /*nb_inplace_add*/
+  0, /*nb_inplace_subtract*/
+  0, /*nb_inplace_multiply*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_inplace_divide*/
+  #endif
+  0, /*nb_inplace_remainder*/
+  0, /*nb_inplace_power*/
+  0, /*nb_inplace_lshift*/
+  0, /*nb_inplace_rshift*/
+  0, /*nb_inplace_and*/
+  0, /*nb_inplace_xor*/
+  0, /*nb_inplace_or*/
+  0, /*nb_floor_divide*/
+  0, /*nb_true_divide*/
+  0, /*nb_inplace_floor_divide*/
+  0, /*nb_inplace_true_divide*/
+  #if PY_VERSION_HEX >= 0x02050000
+  0, /*nb_index*/
+  #endif
+};
+
+static PySequenceMethods __pyx_tp_as_sequence_AlignedRead = {
+  0, /*sq_length*/
+  0, /*sq_concat*/
+  0, /*sq_repeat*/
+  0, /*sq_item*/
+  0, /*sq_slice*/
+  0, /*sq_ass_item*/
+  0, /*sq_ass_slice*/
+  0, /*sq_contains*/
+  0, /*sq_inplace_concat*/
+  0, /*sq_inplace_repeat*/
+};
+
+static PyMappingMethods __pyx_tp_as_mapping_AlignedRead = {
+  0, /*mp_length*/
+  0, /*mp_subscript*/
+  0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_AlignedRead = {
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getreadbuffer*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getwritebuffer*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getsegcount*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getcharbuffer*/
+  #endif
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*bf_getbuffer*/
+  #endif
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*bf_releasebuffer*/
+  #endif
+};
+
+PyTypeObject __pyx_type_9csamtools_AlignedRead = {
+  PyVarObject_HEAD_INIT(0, 0)
+  __Pyx_NAMESTR("csamtools.AlignedRead"), /*tp_name*/
+  sizeof(struct __pyx_obj_9csamtools_AlignedRead), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_9csamtools_AlignedRead, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*tp_compare*/
+  #else
+  0, /*reserved*/
+  #endif
+  0, /*tp_repr*/
+  &__pyx_tp_as_number_AlignedRead, /*tp_as_number*/
+  &__pyx_tp_as_sequence_AlignedRead, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_AlignedRead, /*tp_as_mapping*/
+  __pyx_pf_9csamtools_11AlignedRead___hash__, /*tp_hash*/
+  0, /*tp_call*/
+  __pyx_pf_9csamtools_11AlignedRead___str__, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  &__pyx_tp_as_buffer_AlignedRead, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
+  __Pyx_DOCSTR("AlignedRead()\n\n    Class representing an aligned read. see SAM format specification for \n    the meaning of fields (http://samtools.sourceforge.net/).\n\n    This class stores a handle to the samtools C-structure representing\n    an aligned read. Member read access is forwarded to the C-structure\n    and converted into python objects. This implementation should be fast,\n    as only the data needed is converted.\n\n    For write access, the C-structure is updated in-place. This is\n    not the most efficient way to build BAM entries, as the variable\n    length data is concatenated and thus needs to resized if\n    a field is updated. Furthermore, the BAM entry might be\n    in an inconsistent state. The :meth:`~validate` method can\n    be used to check if an entry is consistent.\n\n    One issue to look out for is that the sequence should always\n    be set *before* the quality scores. Setting the sequence will\n    also erase any quality scores that were set previously.\n    "), /*tp_doc*/
+  0, /*tp_traverse*/
+  0, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_9csamtools_AlignedRead, /*tp_methods*/
+  0, /*tp_members*/
+  __pyx_getsets_9csamtools_AlignedRead, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  __pyx_pf_9csamtools_11AlignedRead___init__, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_9csamtools_AlignedRead, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+  0, /*tp_del*/
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*tp_version_tag*/
+  #endif
+};
+static struct __pyx_vtabstruct_9csamtools_Samfile __pyx_vtable_9csamtools_Samfile;
+
+static PyObject *__pyx_tp_new_9csamtools_Samfile(PyTypeObject *t, PyObject *a, PyObject *k) {
+  struct __pyx_obj_9csamtools_Samfile *p;
+  PyObject *o = (*t->tp_alloc)(t, 0);
+  if (!o) return 0;
+  p = ((struct __pyx_obj_9csamtools_Samfile *)o);
+  p->__pyx_vtab = __pyx_vtabptr_9csamtools_Samfile;
+  if (__pyx_pf_9csamtools_7Samfile___cinit__(o, a, k) < 0) {
+    Py_DECREF(o); o = 0;
+  }
+  return o;
+}
+
+static void __pyx_tp_dealloc_9csamtools_Samfile(PyObject *o) {
+  {
+    PyObject *etype, *eval, *etb;
+    PyErr_Fetch(&etype, &eval, &etb);
+    ++Py_REFCNT(o);
+    __pyx_pf_9csamtools_7Samfile___dealloc__(o);
+    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
+    --Py_REFCNT(o);
+    PyErr_Restore(etype, eval, etb);
+  }
+  (*Py_TYPE(o)->tp_free)(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_7Samfile_filename(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_7Samfile_8filename___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_7Samfile_nreferences(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_7Samfile_11nreferences___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_7Samfile_references(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_7Samfile_10references___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_7Samfile_lengths(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_7Samfile_7lengths___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_7Samfile_text(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_7Samfile_4text___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_7Samfile_header(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_7Samfile_6header___get__(o);
+}
+
+static PyMethodDef __pyx_methods_9csamtools_Samfile[] = {
+  {__Pyx_NAMESTR("_isOpen"), (PyCFunction)__pyx_pf_9csamtools_7Samfile__isOpen, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile__isOpen)},
+  {__Pyx_NAMESTR("_hasIndex"), (PyCFunction)__pyx_pf_9csamtools_7Samfile__hasIndex, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile__hasIndex)},
+  {__Pyx_NAMESTR("_open"), (PyCFunction)__pyx_pf_9csamtools_7Samfile__open, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile__open)},
+  {__Pyx_NAMESTR("gettid"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_gettid, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_gettid)},
+  {__Pyx_NAMESTR("getrname"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_getrname, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_getrname)},
+  {__Pyx_NAMESTR("_parseRegion"), (PyCFunction)__pyx_pf_9csamtools_7Samfile__parseRegion, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile__parseRegion)},
+  {__Pyx_NAMESTR("seek"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_seek, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_seek)},
+  {__Pyx_NAMESTR("tell"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_tell, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_tell)},
+  {__Pyx_NAMESTR("fetch"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_fetch, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_fetch)},
+  {__Pyx_NAMESTR("mate"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_mate, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_mate)},
+  {__Pyx_NAMESTR("count"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_count, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_count)},
+  {__Pyx_NAMESTR("pileup"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_pileup, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_pileup)},
+  {__Pyx_NAMESTR("close"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_close, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_close)},
+  {__Pyx_NAMESTR("write"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_write, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_write)},
+  {__Pyx_NAMESTR("__enter__"), (PyCFunction)__pyx_pf_9csamtools_7Samfile___enter__, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile___enter__)},
+  {__Pyx_NAMESTR("__exit__"), (PyCFunction)__pyx_pf_9csamtools_7Samfile___exit__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile___exit__)},
+  {__Pyx_NAMESTR("_buildLine"), (PyCFunction)__pyx_pf_9csamtools_7Samfile__buildLine, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile__buildLine)},
+  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_7Samfile___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile___next__)},
+  {0, 0, 0, 0}
+};
+
+static struct PyGetSetDef __pyx_getsets_9csamtools_Samfile[] = {
+  {(char *)"filename", __pyx_getprop_9csamtools_7Samfile_filename, 0, __Pyx_DOCSTR(__pyx_k_148), 0},
+  {(char *)"nreferences", __pyx_getprop_9csamtools_7Samfile_nreferences, 0, __Pyx_DOCSTR(__pyx_k_149), 0},
+  {(char *)"references", __pyx_getprop_9csamtools_7Samfile_references, 0, __Pyx_DOCSTR(__pyx_k_150), 0},
+  {(char *)"lengths", __pyx_getprop_9csamtools_7Samfile_lengths, 0, __Pyx_DOCSTR(__pyx_k_151), 0},
+  {(char *)"text", __pyx_getprop_9csamtools_7Samfile_text, 0, __Pyx_DOCSTR(__pyx_k_152), 0},
+  {(char *)"header", __pyx_getprop_9csamtools_7Samfile_header, 0, __Pyx_DOCSTR(__pyx_k_153), 0},
+  {0, 0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_Samfile = {
+  0, /*nb_add*/
+  0, /*nb_subtract*/
+  0, /*nb_multiply*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_divide*/
+  #endif
+  0, /*nb_remainder*/
+  0, /*nb_divmod*/
+  0, /*nb_power*/
+  0, /*nb_negative*/
+  0, /*nb_positive*/
+  0, /*nb_absolute*/
+  0, /*nb_nonzero*/
+  0, /*nb_invert*/
+  0, /*nb_lshift*/
+  0, /*nb_rshift*/
+  0, /*nb_and*/
+  0, /*nb_xor*/
+  0, /*nb_or*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_coerce*/
+  #endif
+  0, /*nb_int*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_long*/
+  #else
+  0, /*reserved*/
+  #endif
+  0, /*nb_float*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_oct*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_hex*/
+  #endif
+  0, /*nb_inplace_add*/
+  0, /*nb_inplace_subtract*/
+  0, /*nb_inplace_multiply*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_inplace_divide*/
+  #endif
+  0, /*nb_inplace_remainder*/
+  0, /*nb_inplace_power*/
+  0, /*nb_inplace_lshift*/
+  0, /*nb_inplace_rshift*/
+  0, /*nb_inplace_and*/
+  0, /*nb_inplace_xor*/
+  0, /*nb_inplace_or*/
+  0, /*nb_floor_divide*/
+  0, /*nb_true_divide*/
+  0, /*nb_inplace_floor_divide*/
+  0, /*nb_inplace_true_divide*/
+  #if PY_VERSION_HEX >= 0x02050000
+  0, /*nb_index*/
+  #endif
+};
+
+static PySequenceMethods __pyx_tp_as_sequence_Samfile = {
+  0, /*sq_length*/
+  0, /*sq_concat*/
+  0, /*sq_repeat*/
+  0, /*sq_item*/
+  0, /*sq_slice*/
+  0, /*sq_ass_item*/
+  0, /*sq_ass_slice*/
+  0, /*sq_contains*/
+  0, /*sq_inplace_concat*/
+  0, /*sq_inplace_repeat*/
+};
+
+static PyMappingMethods __pyx_tp_as_mapping_Samfile = {
+  0, /*mp_length*/
+  0, /*mp_subscript*/
+  0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_Samfile = {
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getreadbuffer*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getwritebuffer*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getsegcount*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getcharbuffer*/
+  #endif
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*bf_getbuffer*/
+  #endif
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*bf_releasebuffer*/
+  #endif
+};
+
+PyTypeObject __pyx_type_9csamtools_Samfile = {
+  PyVarObject_HEAD_INIT(0, 0)
+  __Pyx_NAMESTR("csamtools.Samfile"), /*tp_name*/
+  sizeof(struct __pyx_obj_9csamtools_Samfile), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_9csamtools_Samfile, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*tp_compare*/
+  #else
+  0, /*reserved*/
+  #endif
+  0, /*tp_repr*/
+  &__pyx_tp_as_number_Samfile, /*tp_as_number*/
+  &__pyx_tp_as_sequence_Samfile, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_Samfile, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  &__pyx_tp_as_buffer_Samfile, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
+  __Pyx_DOCSTR("*(filename, mode=None, template = None, referencenames = None, referencelengths = None, text = NULL, header = None)*\n              \n    A :term:`SAM`/:term:`BAM` formatted file. The file is automatically opened.\n    \n    *mode* should be ``r`` for reading or ``w`` for writing. The default is text mode (:term:`SAM`). For binary \n    (:term:`BAM`) I/O you should append ``b`` for compressed or ``u`` for uncompressed :term:`BAM` output. \n    Use ``h`` to output header information in text (:term:`TAM`)  mode.\n\n    If ``b`` is present, it must immediately follow ``r`` or ``w``. \n    Valid modes are ``r``, ``w``, ``wh``, ``rb``, ``wb`` and ``wbu``. For instance, to open \n    a :term:`BAM` formatted file for reading, type::\n\n        f = pysam.Samfile('ex1.bam','rb')\n\n    If mode is not specified, we will try to auto-detect in the order 'r', 'rb', thus both the following\n    should work::\n\n        f1 = pysam.Samfile('ex1.bam' )\n        f2 = pysam.Samfile('ex1.bam' )\n\n    If an index for a BAM file exists (.bai), it will be opened automatically. Without an index random\n    access to reads via :meth:`fetch` and :meth:`pileup` is disabled.\n\n    For writing, the header of a :term:`SAM` file/:term:`BAM` file can be constituted from several\n    sources (see also the samtools format specification):\n\n        1. If *template* is given, the header is copied from a another *Samfile* \n           (*template* must be of type *Samfile*).\n\n        2. If *header* is given, the header is built from a multi-level dictionary. The first level \n           are the four types ('HD', 'SQ', ...). The second level are a list of lines, with each line \n           being a list of tag-value pairs.\n\n        3. If *text* is given, new header text is copied from raw text.\n\n        4. The names (*referencenames*) and lengths (*referencelengths*) are supplied directly as lists. \n\n    "), /*tp_doc*/
+  0, /*tp_traverse*/
+  0, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  __pyx_pf_9csamtools_7Samfile___iter__, /*tp_iter*/
+  __pyx_pf_9csamtools_7Samfile___next__, /*tp_iternext*/
+  __pyx_methods_9csamtools_Samfile, /*tp_methods*/
+  0, /*tp_members*/
+  __pyx_getsets_9csamtools_Samfile, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  0, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_9csamtools_Samfile, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+  0, /*tp_del*/
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*tp_version_tag*/
+  #endif
+};
+
+static PyObject *__pyx_tp_new_9csamtools_PileupProxy(PyTypeObject *t, PyObject *a, PyObject *k) {
+  PyObject *o = (*t->tp_alloc)(t, 0);
+  if (!o) return 0;
+  return o;
+}
+
+static void __pyx_tp_dealloc_9csamtools_PileupProxy(PyObject *o) {
+  (*Py_TYPE(o)->tp_free)(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_11PileupProxy_tid(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11PileupProxy_3tid___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_11PileupProxy_n(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11PileupProxy_1n___get__(o);
+}
+
+static int __pyx_setprop_9csamtools_11PileupProxy_n(PyObject *o, PyObject *v, void *x) {
+  if (v) {
+    return __pyx_pf_9csamtools_11PileupProxy_1n___set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyObject *__pyx_getprop_9csamtools_11PileupProxy_pos(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11PileupProxy_3pos___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_11PileupProxy_pileups(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_11PileupProxy_7pileups___get__(o);
+}
+
+static PyMethodDef __pyx_methods_9csamtools_PileupProxy[] = {
+  {0, 0, 0, 0}
+};
+
+static struct PyGetSetDef __pyx_getsets_9csamtools_PileupProxy[] = {
+  {(char *)"tid", __pyx_getprop_9csamtools_11PileupProxy_tid, 0, __Pyx_DOCSTR(__pyx_k_154), 0},
+  {(char *)"n", __pyx_getprop_9csamtools_11PileupProxy_n, __pyx_setprop_9csamtools_11PileupProxy_n, __Pyx_DOCSTR(__pyx_k_155), 0},
+  {(char *)"pos", __pyx_getprop_9csamtools_11PileupProxy_pos, 0, 0, 0},
+  {(char *)"pileups", __pyx_getprop_9csamtools_11PileupProxy_pileups, 0, __Pyx_DOCSTR(__pyx_k_156), 0},
+  {0, 0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_PileupProxy = {
+  0, /*nb_add*/
+  0, /*nb_subtract*/
+  0, /*nb_multiply*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_divide*/
+  #endif
+  0, /*nb_remainder*/
+  0, /*nb_divmod*/
+  0, /*nb_power*/
+  0, /*nb_negative*/
+  0, /*nb_positive*/
+  0, /*nb_absolute*/
+  0, /*nb_nonzero*/
+  0, /*nb_invert*/
+  0, /*nb_lshift*/
+  0, /*nb_rshift*/
+  0, /*nb_and*/
+  0, /*nb_xor*/
+  0, /*nb_or*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_coerce*/
+  #endif
+  0, /*nb_int*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_long*/
+  #else
+  0, /*reserved*/
+  #endif
+  0, /*nb_float*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_oct*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_hex*/
+  #endif
+  0, /*nb_inplace_add*/
+  0, /*nb_inplace_subtract*/
+  0, /*nb_inplace_multiply*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_inplace_divide*/
+  #endif
+  0, /*nb_inplace_remainder*/
+  0, /*nb_inplace_power*/
+  0, /*nb_inplace_lshift*/
+  0, /*nb_inplace_rshift*/
+  0, /*nb_inplace_and*/
+  0, /*nb_inplace_xor*/
+  0, /*nb_inplace_or*/
+  0, /*nb_floor_divide*/
+  0, /*nb_true_divide*/
+  0, /*nb_inplace_floor_divide*/
+  0, /*nb_inplace_true_divide*/
+  #if PY_VERSION_HEX >= 0x02050000
+  0, /*nb_index*/
+  #endif
+};
+
+static PySequenceMethods __pyx_tp_as_sequence_PileupProxy = {
+  0, /*sq_length*/
+  0, /*sq_concat*/
+  0, /*sq_repeat*/
+  0, /*sq_item*/
+  0, /*sq_slice*/
+  0, /*sq_ass_item*/
+  0, /*sq_ass_slice*/
+  0, /*sq_contains*/
+  0, /*sq_inplace_concat*/
+  0, /*sq_inplace_repeat*/
+};
+
+static PyMappingMethods __pyx_tp_as_mapping_PileupProxy = {
+  0, /*mp_length*/
+  0, /*mp_subscript*/
+  0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_PileupProxy = {
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getreadbuffer*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getwritebuffer*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getsegcount*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getcharbuffer*/
+  #endif
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*bf_getbuffer*/
+  #endif
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*bf_releasebuffer*/
+  #endif
+};
+
+PyTypeObject __pyx_type_9csamtools_PileupProxy = {
+  PyVarObject_HEAD_INIT(0, 0)
+  __Pyx_NAMESTR("csamtools.PileupProxy"), /*tp_name*/
+  sizeof(struct __pyx_obj_9csamtools_PileupProxy), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_9csamtools_PileupProxy, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*tp_compare*/
+  #else
+  0, /*reserved*/
+  #endif
+  0, /*tp_repr*/
+  &__pyx_tp_as_number_PileupProxy, /*tp_as_number*/
+  &__pyx_tp_as_sequence_PileupProxy, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_PileupProxy, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  __pyx_pf_9csamtools_11PileupProxy___str__, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  &__pyx_tp_as_buffer_PileupProxy, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
+  __Pyx_DOCSTR("PileupProxy()\nA pileup column. A pileup column contains\n    all the reads that map to a certain target base.\n\n    tid\n        chromosome ID as is defined in the header\n    pos\n        the target base coordinate (0-based)\n    n\n        number of reads mapping to this column    \n    pileups\n        list of reads (:class:`pysam.PileupRead`) aligned to this column\n\n    This class is a proxy for results returned by the samtools pileup engine.\n    If the underlying engine iterator advances, the results of this column\n    will change.\n    "), /*tp_doc*/
+  0, /*tp_traverse*/
+  0, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_9csamtools_PileupProxy, /*tp_methods*/
+  0, /*tp_members*/
+  __pyx_getsets_9csamtools_PileupProxy, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  __pyx_pf_9csamtools_11PileupProxy___init__, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_9csamtools_PileupProxy, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+  0, /*tp_del*/
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*tp_version_tag*/
+  #endif
+};
+
+static PyObject *__pyx_tp_new_9csamtools_PileupRead(PyTypeObject *t, PyObject *a, PyObject *k) {
+  struct __pyx_obj_9csamtools_PileupRead *p;
+  PyObject *o = (*t->tp_alloc)(t, 0);
+  if (!o) return 0;
+  p = ((struct __pyx_obj_9csamtools_PileupRead *)o);
+  p->_alignment = ((struct __pyx_obj_9csamtools_AlignedRead *)Py_None); Py_INCREF(Py_None);
+  return o;
+}
+
+static void __pyx_tp_dealloc_9csamtools_PileupRead(PyObject *o) {
+  struct __pyx_obj_9csamtools_PileupRead *p = (struct __pyx_obj_9csamtools_PileupRead *)o;
+  Py_XDECREF(((PyObject *)p->_alignment));
+  (*Py_TYPE(o)->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_9csamtools_PileupRead(PyObject *o, visitproc v, void *a) {
+  int e;
+  struct __pyx_obj_9csamtools_PileupRead *p = (struct __pyx_obj_9csamtools_PileupRead *)o;
+  if (p->_alignment) {
+    e = (*v)(((PyObject*)p->_alignment), a); if (e) return e;
+  }
+  return 0;
+}
+
+static int __pyx_tp_clear_9csamtools_PileupRead(PyObject *o) {
+  struct __pyx_obj_9csamtools_PileupRead *p = (struct __pyx_obj_9csamtools_PileupRead *)o;
+  PyObject* tmp;
+  tmp = ((PyObject*)p->_alignment);
+  p->_alignment = ((struct __pyx_obj_9csamtools_AlignedRead *)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  return 0;
+}
+
+static PyObject *__pyx_getprop_9csamtools_10PileupRead_alignment(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_10PileupRead_9alignment___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_10PileupRead_qpos(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_10PileupRead_4qpos___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_10PileupRead_indel(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_10PileupRead_5indel___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_10PileupRead_is_del(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_10PileupRead_6is_del___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_10PileupRead_is_head(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_10PileupRead_7is_head___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_10PileupRead_is_tail(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_10PileupRead_7is_tail___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_10PileupRead_level(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_10PileupRead_5level___get__(o);
+}
+
+static PyMethodDef __pyx_methods_9csamtools_PileupRead[] = {
+  {0, 0, 0, 0}
+};
+
+static struct PyGetSetDef __pyx_getsets_9csamtools_PileupRead[] = {
+  {(char *)"alignment", __pyx_getprop_9csamtools_10PileupRead_alignment, 0, __Pyx_DOCSTR(__pyx_k_157), 0},
+  {(char *)"qpos", __pyx_getprop_9csamtools_10PileupRead_qpos, 0, __Pyx_DOCSTR(__pyx_k_158), 0},
+  {(char *)"indel", __pyx_getprop_9csamtools_10PileupRead_indel, 0, __Pyx_DOCSTR(__pyx_k_159), 0},
+  {(char *)"is_del", __pyx_getprop_9csamtools_10PileupRead_is_del, 0, __Pyx_DOCSTR(__pyx_k_160), 0},
+  {(char *)"is_head", __pyx_getprop_9csamtools_10PileupRead_is_head, 0, 0, 0},
+  {(char *)"is_tail", __pyx_getprop_9csamtools_10PileupRead_is_tail, 0, 0, 0},
+  {(char *)"level", __pyx_getprop_9csamtools_10PileupRead_level, 0, 0, 0},
+  {0, 0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_PileupRead = {
+  0, /*nb_add*/
+  0, /*nb_subtract*/
+  0, /*nb_multiply*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_divide*/
+  #endif
+  0, /*nb_remainder*/
+  0, /*nb_divmod*/
+  0, /*nb_power*/
+  0, /*nb_negative*/
+  0, /*nb_positive*/
+  0, /*nb_absolute*/
+  0, /*nb_nonzero*/
+  0, /*nb_invert*/
+  0, /*nb_lshift*/
+  0, /*nb_rshift*/
+  0, /*nb_and*/
+  0, /*nb_xor*/
+  0, /*nb_or*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_coerce*/
+  #endif
+  0, /*nb_int*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_long*/
+  #else
+  0, /*reserved*/
+  #endif
+  0, /*nb_float*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_oct*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_hex*/
+  #endif
+  0, /*nb_inplace_add*/
+  0, /*nb_inplace_subtract*/
+  0, /*nb_inplace_multiply*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_inplace_divide*/
+  #endif
+  0, /*nb_inplace_remainder*/
+  0, /*nb_inplace_power*/
+  0, /*nb_inplace_lshift*/
+  0, /*nb_inplace_rshift*/
+  0, /*nb_inplace_and*/
+  0, /*nb_inplace_xor*/
+  0, /*nb_inplace_or*/
+  0, /*nb_floor_divide*/
+  0, /*nb_true_divide*/
+  0, /*nb_inplace_floor_divide*/
+  0, /*nb_inplace_true_divide*/
+  #if PY_VERSION_HEX >= 0x02050000
+  0, /*nb_index*/
+  #endif
+};
+
+static PySequenceMethods __pyx_tp_as_sequence_PileupRead = {
+  0, /*sq_length*/
+  0, /*sq_concat*/
+  0, /*sq_repeat*/
+  0, /*sq_item*/
+  0, /*sq_slice*/
+  0, /*sq_ass_item*/
+  0, /*sq_ass_slice*/
+  0, /*sq_contains*/
+  0, /*sq_inplace_concat*/
+  0, /*sq_inplace_repeat*/
+};
+
+static PyMappingMethods __pyx_tp_as_mapping_PileupRead = {
+  0, /*mp_length*/
+  0, /*mp_subscript*/
+  0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_PileupRead = {
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getreadbuffer*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getwritebuffer*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getsegcount*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getcharbuffer*/
+  #endif
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*bf_getbuffer*/
+  #endif
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*bf_releasebuffer*/
+  #endif
+};
+
+PyTypeObject __pyx_type_9csamtools_PileupRead = {
+  PyVarObject_HEAD_INIT(0, 0)
+  __Pyx_NAMESTR("csamtools.PileupRead"), /*tp_name*/
+  sizeof(struct __pyx_obj_9csamtools_PileupRead), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_9csamtools_PileupRead, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*tp_compare*/
+  #else
+  0, /*reserved*/
+  #endif
+  0, /*tp_repr*/
+  &__pyx_tp_as_number_PileupRead, /*tp_as_number*/
+  &__pyx_tp_as_sequence_PileupRead, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_PileupRead, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  __pyx_pf_9csamtools_10PileupRead___str__, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  &__pyx_tp_as_buffer_PileupRead, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  __Pyx_DOCSTR("PileupRead()\nA read aligned to a column.\n    "), /*tp_doc*/
+  __pyx_tp_traverse_9csamtools_PileupRead, /*tp_traverse*/
+  __pyx_tp_clear_9csamtools_PileupRead, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_9csamtools_PileupRead, /*tp_methods*/
+  0, /*tp_members*/
+  __pyx_getsets_9csamtools_PileupRead, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  __pyx_pf_9csamtools_10PileupRead___init__, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_9csamtools_PileupRead, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+  0, /*tp_del*/
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*tp_version_tag*/
+  #endif
+};
+static struct __pyx_vtabstruct_9csamtools_Fastafile __pyx_vtable_9csamtools_Fastafile;
+
+static PyObject *__pyx_tp_new_9csamtools_Fastafile(PyTypeObject *t, PyObject *a, PyObject *k) {
+  struct __pyx_obj_9csamtools_Fastafile *p;
+  PyObject *o = (*t->tp_alloc)(t, 0);
+  if (!o) return 0;
+  p = ((struct __pyx_obj_9csamtools_Fastafile *)o);
+  p->__pyx_vtab = __pyx_vtabptr_9csamtools_Fastafile;
+  if (__pyx_pf_9csamtools_9Fastafile___cinit__(o, a, k) < 0) {
+    Py_DECREF(o); o = 0;
+  }
+  return o;
+}
+
+static void __pyx_tp_dealloc_9csamtools_Fastafile(PyObject *o) {
+  {
+    PyObject *etype, *eval, *etb;
+    PyErr_Fetch(&etype, &eval, &etb);
+    ++Py_REFCNT(o);
+    __pyx_pf_9csamtools_9Fastafile___dealloc__(o);
+    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
+    --Py_REFCNT(o);
+    PyErr_Restore(etype, eval, etb);
+  }
+  (*Py_TYPE(o)->tp_free)(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_9Fastafile_filename(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_9Fastafile_8filename___get__(o);
+}
+
+static PyMethodDef __pyx_methods_9csamtools_Fastafile[] = {
+  {__Pyx_NAMESTR("_isOpen"), (PyCFunction)__pyx_pf_9csamtools_9Fastafile__isOpen, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_9Fastafile__isOpen)},
+  {__Pyx_NAMESTR("_open"), (PyCFunction)__pyx_pf_9csamtools_9Fastafile__open, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_9Fastafile__open)},
+  {__Pyx_NAMESTR("close"), (PyCFunction)__pyx_pf_9csamtools_9Fastafile_close, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_9Fastafile_close)},
+  {__Pyx_NAMESTR("fetch"), (PyCFunction)__pyx_pf_9csamtools_9Fastafile_fetch, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_9Fastafile_fetch)},
+  {0, 0, 0, 0}
+};
+
+static struct PyGetSetDef __pyx_getsets_9csamtools_Fastafile[] = {
+  {(char *)"filename", __pyx_getprop_9csamtools_9Fastafile_filename, 0, __Pyx_DOCSTR(__pyx_k_148), 0},
+  {0, 0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_Fastafile = {
+  0, /*nb_add*/
+  0, /*nb_subtract*/
+  0, /*nb_multiply*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_divide*/
+  #endif
+  0, /*nb_remainder*/
+  0, /*nb_divmod*/
+  0, /*nb_power*/
+  0, /*nb_negative*/
+  0, /*nb_positive*/
+  0, /*nb_absolute*/
+  0, /*nb_nonzero*/
+  0, /*nb_invert*/
+  0, /*nb_lshift*/
+  0, /*nb_rshift*/
+  0, /*nb_and*/
+  0, /*nb_xor*/
+  0, /*nb_or*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_coerce*/
+  #endif
+  0, /*nb_int*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_long*/
+  #else
+  0, /*reserved*/
+  #endif
+  0, /*nb_float*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_oct*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_hex*/
+  #endif
+  0, /*nb_inplace_add*/
+  0, /*nb_inplace_subtract*/
+  0, /*nb_inplace_multiply*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_inplace_divide*/
+  #endif
+  0, /*nb_inplace_remainder*/
+  0, /*nb_inplace_power*/
+  0, /*nb_inplace_lshift*/
+  0, /*nb_inplace_rshift*/
+  0, /*nb_inplace_and*/
+  0, /*nb_inplace_xor*/
+  0, /*nb_inplace_or*/
+  0, /*nb_floor_divide*/
+  0, /*nb_true_divide*/
+  0, /*nb_inplace_floor_divide*/
+  0, /*nb_inplace_true_divide*/
+  #if PY_VERSION_HEX >= 0x02050000
+  0, /*nb_index*/
+  #endif
+};
+
+static PySequenceMethods __pyx_tp_as_sequence_Fastafile = {
+  __pyx_pf_9csamtools_9Fastafile___len__, /*sq_length*/
+  0, /*sq_concat*/
+  0, /*sq_repeat*/
+  0, /*sq_item*/
+  0, /*sq_slice*/
+  0, /*sq_ass_item*/
+  0, /*sq_ass_slice*/
+  0, /*sq_contains*/
+  0, /*sq_inplace_concat*/
+  0, /*sq_inplace_repeat*/
+};
+
+static PyMappingMethods __pyx_tp_as_mapping_Fastafile = {
+  __pyx_pf_9csamtools_9Fastafile___len__, /*mp_length*/
+  0, /*mp_subscript*/
+  0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_Fastafile = {
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getreadbuffer*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getwritebuffer*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getsegcount*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getcharbuffer*/
+  #endif
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*bf_getbuffer*/
+  #endif
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*bf_releasebuffer*/
+  #endif
+};
+
+PyTypeObject __pyx_type_9csamtools_Fastafile = {
+  PyVarObject_HEAD_INIT(0, 0)
+  __Pyx_NAMESTR("csamtools.Fastafile"), /*tp_name*/
+  sizeof(struct __pyx_obj_9csamtools_Fastafile), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_9csamtools_Fastafile, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*tp_compare*/
+  #else
+  0, /*reserved*/
+  #endif
+  0, /*tp_repr*/
+  &__pyx_tp_as_number_Fastafile, /*tp_as_number*/
+  &__pyx_tp_as_sequence_Fastafile, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_Fastafile, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  &__pyx_tp_as_buffer_Fastafile, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
+  __Pyx_DOCSTR("*(filename)*\n              \n    A *FASTA* file. The file is automatically opened.\n\n    The file expects an indexed fasta file.\n\n    TODO: \n        add automatic indexing.\n        add function to get sequence names.\n    "), /*tp_doc*/
+  0, /*tp_traverse*/
+  0, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_9csamtools_Fastafile, /*tp_methods*/
+  0, /*tp_members*/
+  __pyx_getsets_9csamtools_Fastafile, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  0, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_9csamtools_Fastafile, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+  0, /*tp_del*/
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*tp_version_tag*/
+  #endif
+};
+
+static PyObject *__pyx_tp_new_9csamtools_IteratorRow(PyTypeObject *t, PyObject *a, PyObject *k) {
+  PyObject *o = (*t->tp_alloc)(t, 0);
+  if (!o) return 0;
+  return o;
+}
+
+static void __pyx_tp_dealloc_9csamtools_IteratorRow(PyObject *o) {
+  (*Py_TYPE(o)->tp_free)(o);
+}
+
+static PyMethodDef __pyx_methods_9csamtools_IteratorRow[] = {
+  {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_IteratorRow = {
+  0, /*nb_add*/
+  0, /*nb_subtract*/
+  0, /*nb_multiply*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_divide*/
+  #endif
+  0, /*nb_remainder*/
+  0, /*nb_divmod*/
+  0, /*nb_power*/
+  0, /*nb_negative*/
+  0, /*nb_positive*/
+  0, /*nb_absolute*/
+  0, /*nb_nonzero*/
+  0, /*nb_invert*/
+  0, /*nb_lshift*/
+  0, /*nb_rshift*/
+  0, /*nb_and*/
+  0, /*nb_xor*/
+  0, /*nb_or*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_coerce*/
+  #endif
+  0, /*nb_int*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_long*/
+  #else
+  0, /*reserved*/
+  #endif
+  0, /*nb_float*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_oct*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_hex*/
+  #endif
+  0, /*nb_inplace_add*/
+  0, /*nb_inplace_subtract*/
+  0, /*nb_inplace_multiply*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_inplace_divide*/
+  #endif
+  0, /*nb_inplace_remainder*/
+  0, /*nb_inplace_power*/
+  0, /*nb_inplace_lshift*/
+  0, /*nb_inplace_rshift*/
+  0, /*nb_inplace_and*/
+  0, /*nb_inplace_xor*/
+  0, /*nb_inplace_or*/
+  0, /*nb_floor_divide*/
+  0, /*nb_true_divide*/
+  0, /*nb_inplace_floor_divide*/
+  0, /*nb_inplace_true_divide*/
+  #if PY_VERSION_HEX >= 0x02050000
+  0, /*nb_index*/
+  #endif
+};
+
+static PySequenceMethods __pyx_tp_as_sequence_IteratorRow = {
+  0, /*sq_length*/
+  0, /*sq_concat*/
+  0, /*sq_repeat*/
+  0, /*sq_item*/
+  0, /*sq_slice*/
+  0, /*sq_ass_item*/
+  0, /*sq_ass_slice*/
+  0, /*sq_contains*/
+  0, /*sq_inplace_concat*/
+  0, /*sq_inplace_repeat*/
+};
+
+static PyMappingMethods __pyx_tp_as_mapping_IteratorRow = {
+  0, /*mp_length*/
+  0, /*mp_subscript*/
+  0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_IteratorRow = {
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getreadbuffer*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getwritebuffer*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getsegcount*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getcharbuffer*/
+  #endif
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*bf_getbuffer*/
+  #endif
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*bf_releasebuffer*/
+  #endif
+};
+
+PyTypeObject __pyx_type_9csamtools_IteratorRow = {
+  PyVarObject_HEAD_INIT(0, 0)
+  __Pyx_NAMESTR("csamtools.IteratorRow"), /*tp_name*/
+  sizeof(struct __pyx_obj_9csamtools_IteratorRow), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_9csamtools_IteratorRow, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*tp_compare*/
+  #else
+  0, /*reserved*/
+  #endif
+  0, /*tp_repr*/
+  &__pyx_tp_as_number_IteratorRow, /*tp_as_number*/
+  &__pyx_tp_as_sequence_IteratorRow, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_IteratorRow, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  &__pyx_tp_as_buffer_IteratorRow, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
+  __Pyx_DOCSTR("abstract base class for iterators over mapped reads.\n\n    Various iterators implement different behaviours for wrapping around\n    contig boundaries. Examples include:\n\n    :class:`pysam.IteratorRowRegion`\n        iterate within a single contig and a defined region.\n\n    :class:`pysam.IteratorRowAll`\n        iterate until EOF. This iterator will also include unmapped reads.\n\n    :class:`pysam.IteratorRowAllRefs`\n        iterate over all reads in all reference sequences.\n        \n    The method :meth:`Samfile.fetch` returns an IteratorRow.\n    "), /*tp_doc*/
+  0, /*tp_traverse*/
+  0, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_9csamtools_IteratorRow, /*tp_methods*/
+  0, /*tp_members*/
+  0, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  0, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_9csamtools_IteratorRow, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+  0, /*tp_del*/
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*tp_version_tag*/
+  #endif
+};
+static struct __pyx_vtabstruct_9csamtools_IteratorRowRegion __pyx_vtable_9csamtools_IteratorRowRegion;
+
+static PyObject *__pyx_tp_new_9csamtools_IteratorRowRegion(PyTypeObject *t, PyObject *a, PyObject *k) {
+  struct __pyx_obj_9csamtools_IteratorRowRegion *p;
+  PyObject *o = __pyx_tp_new_9csamtools_IteratorRow(t, a, k);
+  if (!o) return 0;
+  p = ((struct __pyx_obj_9csamtools_IteratorRowRegion *)o);
+  p->__pyx_vtab = __pyx_vtabptr_9csamtools_IteratorRowRegion;
+  p->samfile = ((struct __pyx_obj_9csamtools_Samfile *)Py_None); Py_INCREF(Py_None);
+  if (__pyx_pf_9csamtools_17IteratorRowRegion___cinit__(o, a, k) < 0) {
+    Py_DECREF(o); o = 0;
+  }
+  return o;
+}
+
+static void __pyx_tp_dealloc_9csamtools_IteratorRowRegion(PyObject *o) {
+  struct __pyx_obj_9csamtools_IteratorRowRegion *p = (struct __pyx_obj_9csamtools_IteratorRowRegion *)o;
+  {
+    PyObject *etype, *eval, *etb;
+    PyErr_Fetch(&etype, &eval, &etb);
+    ++Py_REFCNT(o);
+    __pyx_pf_9csamtools_17IteratorRowRegion___dealloc__(o);
+    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
+    --Py_REFCNT(o);
+    PyErr_Restore(etype, eval, etb);
+  }
+  Py_XDECREF(((PyObject *)p->samfile));
+  __pyx_tp_dealloc_9csamtools_IteratorRow(o);
+}
+
+static int __pyx_tp_traverse_9csamtools_IteratorRowRegion(PyObject *o, visitproc v, void *a) {
+  int e;
+  struct __pyx_obj_9csamtools_IteratorRowRegion *p = (struct __pyx_obj_9csamtools_IteratorRowRegion *)o;
+  if (__pyx_ptype_9csamtools_IteratorRow->tp_traverse) {
+    e = __pyx_ptype_9csamtools_IteratorRow->tp_traverse(o, v, a); if (e) return e;
+  }
+  if (p->samfile) {
+    e = (*v)(((PyObject*)p->samfile), a); if (e) return e;
+  }
+  return 0;
+}
+
+static int __pyx_tp_clear_9csamtools_IteratorRowRegion(PyObject *o) {
+  struct __pyx_obj_9csamtools_IteratorRowRegion *p = (struct __pyx_obj_9csamtools_IteratorRowRegion *)o;
+  PyObject* tmp;
+  if (__pyx_ptype_9csamtools_IteratorRow->tp_clear) {
+    __pyx_ptype_9csamtools_IteratorRow->tp_clear(o);
+  }
+  tmp = ((PyObject*)p->samfile);
+  p->samfile = ((struct __pyx_obj_9csamtools_Samfile *)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  return 0;
+}
+
+static PyMethodDef __pyx_methods_9csamtools_IteratorRowRegion[] = {
+  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_17IteratorRowRegion___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_17IteratorRowRegion___next__)},
+  {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_IteratorRowRegion = {
+  0, /*nb_add*/
+  0, /*nb_subtract*/
+  0, /*nb_multiply*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_divide*/
+  #endif
+  0, /*nb_remainder*/
+  0, /*nb_divmod*/
+  0, /*nb_power*/
+  0, /*nb_negative*/
+  0, /*nb_positive*/
+  0, /*nb_absolute*/
+  0, /*nb_nonzero*/
+  0, /*nb_invert*/
+  0, /*nb_lshift*/
+  0, /*nb_rshift*/
+  0, /*nb_and*/
+  0, /*nb_xor*/
+  0, /*nb_or*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_coerce*/
+  #endif
+  0, /*nb_int*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_long*/
+  #else
+  0, /*reserved*/
+  #endif
+  0, /*nb_float*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_oct*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_hex*/
+  #endif
+  0, /*nb_inplace_add*/
+  0, /*nb_inplace_subtract*/
+  0, /*nb_inplace_multiply*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_inplace_divide*/
+  #endif
+  0, /*nb_inplace_remainder*/
+  0, /*nb_inplace_power*/
+  0, /*nb_inplace_lshift*/
+  0, /*nb_inplace_rshift*/
+  0, /*nb_inplace_and*/
+  0, /*nb_inplace_xor*/
+  0, /*nb_inplace_or*/
+  0, /*nb_floor_divide*/
+  0, /*nb_true_divide*/
+  0, /*nb_inplace_floor_divide*/
+  0, /*nb_inplace_true_divide*/
+  #if PY_VERSION_HEX >= 0x02050000
+  0, /*nb_index*/
+  #endif
+};
+
+static PySequenceMethods __pyx_tp_as_sequence_IteratorRowRegion = {
+  0, /*sq_length*/
+  0, /*sq_concat*/
+  0, /*sq_repeat*/
+  0, /*sq_item*/
+  0, /*sq_slice*/
+  0, /*sq_ass_item*/
+  0, /*sq_ass_slice*/
+  0, /*sq_contains*/
+  0, /*sq_inplace_concat*/
+  0, /*sq_inplace_repeat*/
+};
+
+static PyMappingMethods __pyx_tp_as_mapping_IteratorRowRegion = {
+  0, /*mp_length*/
+  0, /*mp_subscript*/
+  0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_IteratorRowRegion = {
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getreadbuffer*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getwritebuffer*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getsegcount*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getcharbuffer*/
+  #endif
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*bf_getbuffer*/
+  #endif
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*bf_releasebuffer*/
+  #endif
+};
+
+PyTypeObject __pyx_type_9csamtools_IteratorRowRegion = {
+  PyVarObject_HEAD_INIT(0, 0)
+  __Pyx_NAMESTR("csamtools.IteratorRowRegion"), /*tp_name*/
+  sizeof(struct __pyx_obj_9csamtools_IteratorRowRegion), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_9csamtools_IteratorRowRegion, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*tp_compare*/
+  #else
+  0, /*reserved*/
+  #endif
+  0, /*tp_repr*/
+  &__pyx_tp_as_number_IteratorRowRegion, /*tp_as_number*/
+  &__pyx_tp_as_sequence_IteratorRowRegion, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_IteratorRowRegion, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  &__pyx_tp_as_buffer_IteratorRowRegion, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  __Pyx_DOCSTR("*(Samfile samfile, int tid, int beg, int end, int reopen = True )*\n\n    iterate over mapped reads in a region.\n\n    By default, the file is re-openend to avoid conflicts between\n    multiple iterators working on the same file. Set *reopen* = False\n    to not re-open *samfile*.\n\n    The samtools iterators assume that the file\n    position between iterations do not change.\n    As a consequence, no two iterators can work\n    on the same file. To permit this, each iterator\n    creates its own file handle by re-opening the\n    file.\n\n    Note that the index will be shared between \n    samfile and the iterator.\n    "), /*tp_doc*/
+  __pyx_tp_traverse_9csamtools_IteratorRowRegion, /*tp_traverse*/
+  __pyx_tp_clear_9csamtools_IteratorRowRegion, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  __pyx_pf_9csamtools_17IteratorRowRegion___iter__, /*tp_iter*/
+  __pyx_pf_9csamtools_17IteratorRowRegion___next__, /*tp_iternext*/
+  __pyx_methods_9csamtools_IteratorRowRegion, /*tp_methods*/
+  0, /*tp_members*/
+  0, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  0, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_9csamtools_IteratorRowRegion, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+  0, /*tp_del*/
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*tp_version_tag*/
+  #endif
+};
+static struct __pyx_vtabstruct_9csamtools_IteratorRowAll __pyx_vtable_9csamtools_IteratorRowAll;
+
+static PyObject *__pyx_tp_new_9csamtools_IteratorRowAll(PyTypeObject *t, PyObject *a, PyObject *k) {
+  struct __pyx_obj_9csamtools_IteratorRowAll *p;
+  PyObject *o = __pyx_tp_new_9csamtools_IteratorRow(t, a, k);
+  if (!o) return 0;
+  p = ((struct __pyx_obj_9csamtools_IteratorRowAll *)o);
+  p->__pyx_vtab = __pyx_vtabptr_9csamtools_IteratorRowAll;
+  if (__pyx_pf_9csamtools_14IteratorRowAll___cinit__(o, a, k) < 0) {
+    Py_DECREF(o); o = 0;
+  }
+  return o;
+}
+
+static void __pyx_tp_dealloc_9csamtools_IteratorRowAll(PyObject *o) {
+  {
+    PyObject *etype, *eval, *etb;
+    PyErr_Fetch(&etype, &eval, &etb);
+    ++Py_REFCNT(o);
+    __pyx_pf_9csamtools_14IteratorRowAll___dealloc__(o);
+    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
+    --Py_REFCNT(o);
+    PyErr_Restore(etype, eval, etb);
+  }
+  __pyx_tp_dealloc_9csamtools_IteratorRow(o);
+}
+
+static PyMethodDef __pyx_methods_9csamtools_IteratorRowAll[] = {
+  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_14IteratorRowAll___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_14IteratorRowAll___next__)},
+  {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_IteratorRowAll = {
+  0, /*nb_add*/
+  0, /*nb_subtract*/
+  0, /*nb_multiply*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_divide*/
+  #endif
+  0, /*nb_remainder*/
+  0, /*nb_divmod*/
+  0, /*nb_power*/
+  0, /*nb_negative*/
+  0, /*nb_positive*/
+  0, /*nb_absolute*/
+  0, /*nb_nonzero*/
+  0, /*nb_invert*/
+  0, /*nb_lshift*/
+  0, /*nb_rshift*/
+  0, /*nb_and*/
+  0, /*nb_xor*/
+  0, /*nb_or*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_coerce*/
+  #endif
+  0, /*nb_int*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_long*/
+  #else
+  0, /*reserved*/
+  #endif
+  0, /*nb_float*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_oct*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_hex*/
+  #endif
+  0, /*nb_inplace_add*/
+  0, /*nb_inplace_subtract*/
+  0, /*nb_inplace_multiply*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_inplace_divide*/
+  #endif
+  0, /*nb_inplace_remainder*/
+  0, /*nb_inplace_power*/
+  0, /*nb_inplace_lshift*/
+  0, /*nb_inplace_rshift*/
+  0, /*nb_inplace_and*/
+  0, /*nb_inplace_xor*/
+  0, /*nb_inplace_or*/
+  0, /*nb_floor_divide*/
+  0, /*nb_true_divide*/
+  0, /*nb_inplace_floor_divide*/
+  0, /*nb_inplace_true_divide*/
+  #if PY_VERSION_HEX >= 0x02050000
+  0, /*nb_index*/
+  #endif
+};
+
+static PySequenceMethods __pyx_tp_as_sequence_IteratorRowAll = {
+  0, /*sq_length*/
+  0, /*sq_concat*/
+  0, /*sq_repeat*/
+  0, /*sq_item*/
+  0, /*sq_slice*/
+  0, /*sq_ass_item*/
+  0, /*sq_ass_slice*/
+  0, /*sq_contains*/
+  0, /*sq_inplace_concat*/
+  0, /*sq_inplace_repeat*/
+};
+
+static PyMappingMethods __pyx_tp_as_mapping_IteratorRowAll = {
+  0, /*mp_length*/
+  0, /*mp_subscript*/
+  0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_IteratorRowAll = {
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getreadbuffer*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getwritebuffer*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getsegcount*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getcharbuffer*/
+  #endif
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*bf_getbuffer*/
+  #endif
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*bf_releasebuffer*/
+  #endif
+};
+
+PyTypeObject __pyx_type_9csamtools_IteratorRowAll = {
+  PyVarObject_HEAD_INIT(0, 0)
+  __Pyx_NAMESTR("csamtools.IteratorRowAll"), /*tp_name*/
+  sizeof(struct __pyx_obj_9csamtools_IteratorRowAll), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_9csamtools_IteratorRowAll, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*tp_compare*/
+  #else
+  0, /*reserved*/
+  #endif
+  0, /*tp_repr*/
+  &__pyx_tp_as_number_IteratorRowAll, /*tp_as_number*/
+  &__pyx_tp_as_sequence_IteratorRowAll, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_IteratorRowAll, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  &__pyx_tp_as_buffer_IteratorRowAll, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
+  __Pyx_DOCSTR("*(Samfile samfile, int reopen = True)*\n\n    iterate over all reads in *samfile*\n\n    By default, the file is re-openend to avoid conflicts between\n    multiple iterators working on the same file. Set *reopen* = False\n    to not re-open *samfile*.\n    "), /*tp_doc*/
+  0, /*tp_traverse*/
+  0, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  __pyx_pf_9csamtools_14IteratorRowAll___iter__, /*tp_iter*/
+  __pyx_pf_9csamtools_14IteratorRowAll___next__, /*tp_iternext*/
+  __pyx_methods_9csamtools_IteratorRowAll, /*tp_methods*/
+  0, /*tp_members*/
+  0, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  0, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_9csamtools_IteratorRowAll, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+  0, /*tp_del*/
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*tp_version_tag*/
+  #endif
+};
+
+static PyObject *__pyx_tp_new_9csamtools_IteratorRowAllRefs(PyTypeObject *t, PyObject *a, PyObject *k) {
+  struct __pyx_obj_9csamtools_IteratorRowAllRefs *p;
+  PyObject *o = __pyx_tp_new_9csamtools_IteratorRow(t, a, k);
+  if (!o) return 0;
+  p = ((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)o);
+  p->samfile = ((struct __pyx_obj_9csamtools_Samfile *)Py_None); Py_INCREF(Py_None);
+  p->rowiter = ((struct __pyx_obj_9csamtools_IteratorRowRegion *)Py_None); Py_INCREF(Py_None);
+  if (__pyx_pf_9csamtools_18IteratorRowAllRefs___cinit__(o, a, k) < 0) {
+    Py_DECREF(o); o = 0;
+  }
+  return o;
+}
+
+static void __pyx_tp_dealloc_9csamtools_IteratorRowAllRefs(PyObject *o) {
+  struct __pyx_obj_9csamtools_IteratorRowAllRefs *p = (struct __pyx_obj_9csamtools_IteratorRowAllRefs *)o;
+  Py_XDECREF(((PyObject *)p->samfile));
+  Py_XDECREF(((PyObject *)p->rowiter));
+  __pyx_tp_dealloc_9csamtools_IteratorRow(o);
+}
+
+static int __pyx_tp_traverse_9csamtools_IteratorRowAllRefs(PyObject *o, visitproc v, void *a) {
+  int e;
+  struct __pyx_obj_9csamtools_IteratorRowAllRefs *p = (struct __pyx_obj_9csamtools_IteratorRowAllRefs *)o;
+  if (__pyx_ptype_9csamtools_IteratorRow->tp_traverse) {
+    e = __pyx_ptype_9csamtools_IteratorRow->tp_traverse(o, v, a); if (e) return e;
+  }
+  if (p->samfile) {
+    e = (*v)(((PyObject*)p->samfile), a); if (e) return e;
+  }
+  if (p->rowiter) {
+    e = (*v)(((PyObject*)p->rowiter), a); if (e) return e;
+  }
+  return 0;
+}
+
+static int __pyx_tp_clear_9csamtools_IteratorRowAllRefs(PyObject *o) {
+  struct __pyx_obj_9csamtools_IteratorRowAllRefs *p = (struct __pyx_obj_9csamtools_IteratorRowAllRefs *)o;
+  PyObject* tmp;
+  if (__pyx_ptype_9csamtools_IteratorRow->tp_clear) {
+    __pyx_ptype_9csamtools_IteratorRow->tp_clear(o);
+  }
+  tmp = ((PyObject*)p->samfile);
+  p->samfile = ((struct __pyx_obj_9csamtools_Samfile *)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->rowiter);
+  p->rowiter = ((struct __pyx_obj_9csamtools_IteratorRowRegion *)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  return 0;
+}
+
+static PyMethodDef __pyx_methods_9csamtools_IteratorRowAllRefs[] = {
+  {__Pyx_NAMESTR("nextiter"), (PyCFunction)__pyx_pf_9csamtools_18IteratorRowAllRefs_nextiter, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_18IteratorRowAllRefs_nextiter)},
+  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_18IteratorRowAllRefs___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_18IteratorRowAllRefs___next__)},
+  {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_IteratorRowAllRefs = {
+  0, /*nb_add*/
+  0, /*nb_subtract*/
+  0, /*nb_multiply*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_divide*/
+  #endif
+  0, /*nb_remainder*/
+  0, /*nb_divmod*/
+  0, /*nb_power*/
+  0, /*nb_negative*/
+  0, /*nb_positive*/
+  0, /*nb_absolute*/
+  0, /*nb_nonzero*/
+  0, /*nb_invert*/
+  0, /*nb_lshift*/
+  0, /*nb_rshift*/
+  0, /*nb_and*/
+  0, /*nb_xor*/
+  0, /*nb_or*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_coerce*/
+  #endif
+  0, /*nb_int*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_long*/
+  #else
+  0, /*reserved*/
+  #endif
+  0, /*nb_float*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_oct*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_hex*/
+  #endif
+  0, /*nb_inplace_add*/
+  0, /*nb_inplace_subtract*/
+  0, /*nb_inplace_multiply*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_inplace_divide*/
+  #endif
+  0, /*nb_inplace_remainder*/
+  0, /*nb_inplace_power*/
+  0, /*nb_inplace_lshift*/
+  0, /*nb_inplace_rshift*/
+  0, /*nb_inplace_and*/
+  0, /*nb_inplace_xor*/
+  0, /*nb_inplace_or*/
+  0, /*nb_floor_divide*/
+  0, /*nb_true_divide*/
+  0, /*nb_inplace_floor_divide*/
+  0, /*nb_inplace_true_divide*/
+  #if PY_VERSION_HEX >= 0x02050000
+  0, /*nb_index*/
+  #endif
+};
+
+static PySequenceMethods __pyx_tp_as_sequence_IteratorRowAllRefs = {
+  0, /*sq_length*/
+  0, /*sq_concat*/
+  0, /*sq_repeat*/
+  0, /*sq_item*/
+  0, /*sq_slice*/
+  0, /*sq_ass_item*/
+  0, /*sq_ass_slice*/
+  0, /*sq_contains*/
+  0, /*sq_inplace_concat*/
+  0, /*sq_inplace_repeat*/
+};
+
+static PyMappingMethods __pyx_tp_as_mapping_IteratorRowAllRefs = {
+  0, /*mp_length*/
+  0, /*mp_subscript*/
+  0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_IteratorRowAllRefs = {
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getreadbuffer*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getwritebuffer*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getsegcount*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getcharbuffer*/
+  #endif
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*bf_getbuffer*/
+  #endif
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*bf_releasebuffer*/
+  #endif
+};
+
+PyTypeObject __pyx_type_9csamtools_IteratorRowAllRefs = {
+  PyVarObject_HEAD_INIT(0, 0)
+  __Pyx_NAMESTR("csamtools.IteratorRowAllRefs"), /*tp_name*/
+  sizeof(struct __pyx_obj_9csamtools_IteratorRowAllRefs), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_9csamtools_IteratorRowAllRefs, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*tp_compare*/
+  #else
+  0, /*reserved*/
+  #endif
+  0, /*tp_repr*/
+  &__pyx_tp_as_number_IteratorRowAllRefs, /*tp_as_number*/
+  &__pyx_tp_as_sequence_IteratorRowAllRefs, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_IteratorRowAllRefs, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  &__pyx_tp_as_buffer_IteratorRowAllRefs, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  __Pyx_DOCSTR("iterates over all mapped reads by chaining iterators over each reference\n    "), /*tp_doc*/
+  __pyx_tp_traverse_9csamtools_IteratorRowAllRefs, /*tp_traverse*/
+  __pyx_tp_clear_9csamtools_IteratorRowAllRefs, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  __pyx_pf_9csamtools_18IteratorRowAllRefs___iter__, /*tp_iter*/
+  __pyx_pf_9csamtools_18IteratorRowAllRefs___next__, /*tp_iternext*/
+  __pyx_methods_9csamtools_IteratorRowAllRefs, /*tp_methods*/
+  0, /*tp_members*/
+  0, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  0, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_9csamtools_IteratorRowAllRefs, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+  0, /*tp_del*/
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*tp_version_tag*/
+  #endif
+};
+static struct __pyx_vtabstruct_9csamtools_IteratorRowSelection __pyx_vtable_9csamtools_IteratorRowSelection;
+
+static PyObject *__pyx_tp_new_9csamtools_IteratorRowSelection(PyTypeObject *t, PyObject *a, PyObject *k) {
+  struct __pyx_obj_9csamtools_IteratorRowSelection *p;
+  PyObject *o = __pyx_tp_new_9csamtools_IteratorRow(t, a, k);
+  if (!o) return 0;
+  p = ((struct __pyx_obj_9csamtools_IteratorRowSelection *)o);
+  p->__pyx_vtab = __pyx_vtabptr_9csamtools_IteratorRowSelection;
+  p->positions = Py_None; Py_INCREF(Py_None);
+  if (__pyx_pf_9csamtools_20IteratorRowSelection___cinit__(o, a, k) < 0) {
+    Py_DECREF(o); o = 0;
+  }
+  return o;
+}
+
+static void __pyx_tp_dealloc_9csamtools_IteratorRowSelection(PyObject *o) {
+  struct __pyx_obj_9csamtools_IteratorRowSelection *p = (struct __pyx_obj_9csamtools_IteratorRowSelection *)o;
+  {
+    PyObject *etype, *eval, *etb;
+    PyErr_Fetch(&etype, &eval, &etb);
+    ++Py_REFCNT(o);
+    __pyx_pf_9csamtools_20IteratorRowSelection___dealloc__(o);
+    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
+    --Py_REFCNT(o);
+    PyErr_Restore(etype, eval, etb);
+  }
+  Py_XDECREF(p->positions);
+  __pyx_tp_dealloc_9csamtools_IteratorRow(o);
+}
+
+static int __pyx_tp_traverse_9csamtools_IteratorRowSelection(PyObject *o, visitproc v, void *a) {
+  int e;
+  struct __pyx_obj_9csamtools_IteratorRowSelection *p = (struct __pyx_obj_9csamtools_IteratorRowSelection *)o;
+  if (__pyx_ptype_9csamtools_IteratorRow->tp_traverse) {
+    e = __pyx_ptype_9csamtools_IteratorRow->tp_traverse(o, v, a); if (e) return e;
+  }
+  if (p->positions) {
+    e = (*v)(p->positions, a); if (e) return e;
+  }
+  return 0;
+}
+
+static int __pyx_tp_clear_9csamtools_IteratorRowSelection(PyObject *o) {
+  struct __pyx_obj_9csamtools_IteratorRowSelection *p = (struct __pyx_obj_9csamtools_IteratorRowSelection *)o;
+  PyObject* tmp;
+  if (__pyx_ptype_9csamtools_IteratorRow->tp_clear) {
+    __pyx_ptype_9csamtools_IteratorRow->tp_clear(o);
+  }
+  tmp = ((PyObject*)p->positions);
+  p->positions = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  return 0;
+}
+
+static PyMethodDef __pyx_methods_9csamtools_IteratorRowSelection[] = {
+  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_20IteratorRowSelection___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_20IteratorRowSelection___next__)},
+  {0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_IteratorRowSelection = {
+  0, /*nb_add*/
+  0, /*nb_subtract*/
+  0, /*nb_multiply*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_divide*/
+  #endif
+  0, /*nb_remainder*/
+  0, /*nb_divmod*/
+  0, /*nb_power*/
+  0, /*nb_negative*/
+  0, /*nb_positive*/
+  0, /*nb_absolute*/
+  0, /*nb_nonzero*/
+  0, /*nb_invert*/
+  0, /*nb_lshift*/
+  0, /*nb_rshift*/
+  0, /*nb_and*/
+  0, /*nb_xor*/
+  0, /*nb_or*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_coerce*/
+  #endif
+  0, /*nb_int*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_long*/
+  #else
+  0, /*reserved*/
+  #endif
+  0, /*nb_float*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_oct*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_hex*/
+  #endif
+  0, /*nb_inplace_add*/
+  0, /*nb_inplace_subtract*/
+  0, /*nb_inplace_multiply*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_inplace_divide*/
+  #endif
+  0, /*nb_inplace_remainder*/
+  0, /*nb_inplace_power*/
+  0, /*nb_inplace_lshift*/
+  0, /*nb_inplace_rshift*/
+  0, /*nb_inplace_and*/
+  0, /*nb_inplace_xor*/
+  0, /*nb_inplace_or*/
+  0, /*nb_floor_divide*/
+  0, /*nb_true_divide*/
+  0, /*nb_inplace_floor_divide*/
+  0, /*nb_inplace_true_divide*/
+  #if PY_VERSION_HEX >= 0x02050000
+  0, /*nb_index*/
+  #endif
+};
+
+static PySequenceMethods __pyx_tp_as_sequence_IteratorRowSelection = {
+  0, /*sq_length*/
+  0, /*sq_concat*/
+  0, /*sq_repeat*/
+  0, /*sq_item*/
+  0, /*sq_slice*/
+  0, /*sq_ass_item*/
+  0, /*sq_ass_slice*/
+  0, /*sq_contains*/
+  0, /*sq_inplace_concat*/
+  0, /*sq_inplace_repeat*/
+};
+
+static PyMappingMethods __pyx_tp_as_mapping_IteratorRowSelection = {
+  0, /*mp_length*/
+  0, /*mp_subscript*/
+  0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_IteratorRowSelection = {
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getreadbuffer*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getwritebuffer*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getsegcount*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getcharbuffer*/
+  #endif
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*bf_getbuffer*/
+  #endif
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*bf_releasebuffer*/
+  #endif
+};
+
+PyTypeObject __pyx_type_9csamtools_IteratorRowSelection = {
+  PyVarObject_HEAD_INIT(0, 0)
+  __Pyx_NAMESTR("csamtools.IteratorRowSelection"), /*tp_name*/
+  sizeof(struct __pyx_obj_9csamtools_IteratorRowSelection), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_9csamtools_IteratorRowSelection, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*tp_compare*/
+  #else
+  0, /*reserved*/
+  #endif
+  0, /*tp_repr*/
+  &__pyx_tp_as_number_IteratorRowSelection, /*tp_as_number*/
+  &__pyx_tp_as_sequence_IteratorRowSelection, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_IteratorRowSelection, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  &__pyx_tp_as_buffer_IteratorRowSelection, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  __Pyx_DOCSTR("*(Samfile samfile)*\n\n    iterate over reads in *samfile* at a given list of file positions.\n    "), /*tp_doc*/
+  __pyx_tp_traverse_9csamtools_IteratorRowSelection, /*tp_traverse*/
+  __pyx_tp_clear_9csamtools_IteratorRowSelection, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  __pyx_pf_9csamtools_20IteratorRowSelection___iter__, /*tp_iter*/
+  __pyx_pf_9csamtools_20IteratorRowSelection___next__, /*tp_iternext*/
+  __pyx_methods_9csamtools_IteratorRowSelection, /*tp_methods*/
+  0, /*tp_members*/
+  0, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  0, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_9csamtools_IteratorRowSelection, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+  0, /*tp_del*/
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*tp_version_tag*/
+  #endif
+};
+static struct __pyx_vtabstruct_9csamtools_IteratorColumn __pyx_vtable_9csamtools_IteratorColumn;
+
+static PyObject *__pyx_tp_new_9csamtools_IteratorColumn(PyTypeObject *t, PyObject *a, PyObject *k) {
+  struct __pyx_obj_9csamtools_IteratorColumn *p;
+  PyObject *o = (*t->tp_alloc)(t, 0);
+  if (!o) return 0;
+  p = ((struct __pyx_obj_9csamtools_IteratorColumn *)o);
+  p->__pyx_vtab = __pyx_vtabptr_9csamtools_IteratorColumn;
+  p->iter = ((struct __pyx_obj_9csamtools_IteratorRowRegion *)Py_None); Py_INCREF(Py_None);
+  p->samfile = ((struct __pyx_obj_9csamtools_Samfile *)Py_None); Py_INCREF(Py_None);
+  p->fastafile = ((struct __pyx_obj_9csamtools_Fastafile *)Py_None); Py_INCREF(Py_None);
+  p->stepper = Py_None; Py_INCREF(Py_None);
+  if (__pyx_pf_9csamtools_14IteratorColumn___cinit__(o, a, k) < 0) {
+    Py_DECREF(o); o = 0;
+  }
+  return o;
+}
+
+static void __pyx_tp_dealloc_9csamtools_IteratorColumn(PyObject *o) {
+  struct __pyx_obj_9csamtools_IteratorColumn *p = (struct __pyx_obj_9csamtools_IteratorColumn *)o;
+  {
+    PyObject *etype, *eval, *etb;
+    PyErr_Fetch(&etype, &eval, &etb);
+    ++Py_REFCNT(o);
+    __pyx_pf_9csamtools_14IteratorColumn___dealloc__(o);
+    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
+    --Py_REFCNT(o);
+    PyErr_Restore(etype, eval, etb);
+  }
+  Py_XDECREF(((PyObject *)p->iter));
+  Py_XDECREF(((PyObject *)p->samfile));
+  Py_XDECREF(((PyObject *)p->fastafile));
+  Py_XDECREF(p->stepper);
+  (*Py_TYPE(o)->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_9csamtools_IteratorColumn(PyObject *o, visitproc v, void *a) {
+  int e;
+  struct __pyx_obj_9csamtools_IteratorColumn *p = (struct __pyx_obj_9csamtools_IteratorColumn *)o;
+  if (p->iter) {
+    e = (*v)(((PyObject*)p->iter), a); if (e) return e;
+  }
+  if (p->samfile) {
+    e = (*v)(((PyObject*)p->samfile), a); if (e) return e;
+  }
+  if (p->fastafile) {
+    e = (*v)(((PyObject*)p->fastafile), a); if (e) return e;
+  }
+  if (p->stepper) {
+    e = (*v)(p->stepper, a); if (e) return e;
+  }
+  return 0;
+}
+
+static int __pyx_tp_clear_9csamtools_IteratorColumn(PyObject *o) {
+  struct __pyx_obj_9csamtools_IteratorColumn *p = (struct __pyx_obj_9csamtools_IteratorColumn *)o;
+  PyObject* tmp;
+  tmp = ((PyObject*)p->iter);
+  p->iter = ((struct __pyx_obj_9csamtools_IteratorRowRegion *)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->samfile);
+  p->samfile = ((struct __pyx_obj_9csamtools_Samfile *)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->fastafile);
+  p->fastafile = ((struct __pyx_obj_9csamtools_Fastafile *)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->stepper);
+  p->stepper = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  return 0;
+}
+
+static PyObject *__pyx_getprop_9csamtools_14IteratorColumn_seq_len(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_14IteratorColumn_7seq_len___get__(o);
+}
+
+static PyMethodDef __pyx_methods_9csamtools_IteratorColumn[] = {
+  {__Pyx_NAMESTR("addReference"), (PyCFunction)__pyx_pf_9csamtools_14IteratorColumn_addReference, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_14IteratorColumn_addReference)},
+  {__Pyx_NAMESTR("hasReference"), (PyCFunction)__pyx_pf_9csamtools_14IteratorColumn_hasReference, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_14IteratorColumn_hasReference)},
+  {0, 0, 0, 0}
+};
+
+static struct PyGetSetDef __pyx_getsets_9csamtools_IteratorColumn[] = {
+  {(char *)"seq_len", __pyx_getprop_9csamtools_14IteratorColumn_seq_len, 0, __Pyx_DOCSTR(__pyx_k_161), 0},
   {0, 0, 0, 0, 0}
 };
 
-static PyNumberMethods __pyx_tp_as_number_PileupProxy = {
+static PyNumberMethods __pyx_tp_as_number_IteratorColumn = {
   0, /*nb_add*/
   0, /*nb_subtract*/
   0, /*nb_multiply*/
@@ -28930,7 +33384,7 @@ static PyNumberMethods __pyx_tp_as_number_PileupProxy = {
   #endif
 };
 
-static PySequenceMethods __pyx_tp_as_sequence_PileupProxy = {
+static PySequenceMethods __pyx_tp_as_sequence_IteratorColumn = {
   0, /*sq_length*/
   0, /*sq_concat*/
   0, /*sq_repeat*/
@@ -28943,13 +33397,13 @@ static PySequenceMethods __pyx_tp_as_sequence_PileupProxy = {
   0, /*sq_inplace_repeat*/
 };
 
-static PyMappingMethods __pyx_tp_as_mapping_PileupProxy = {
+static PyMappingMethods __pyx_tp_as_mapping_IteratorColumn = {
   0, /*mp_length*/
   0, /*mp_subscript*/
   0, /*mp_ass_subscript*/
 };
 
-static PyBufferProcs __pyx_tp_as_buffer_PileupProxy = {
+static PyBufferProcs __pyx_tp_as_buffer_IteratorColumn = {
   #if PY_MAJOR_VERSION < 3
   0, /*bf_getreadbuffer*/
   #endif
@@ -28970,12 +33424,12 @@ static PyBufferProcs __pyx_tp_as_buffer_PileupProxy = {
   #endif
 };
 
-static PyTypeObject __pyx_type_9csamtools_PileupProxy = {
+PyTypeObject __pyx_type_9csamtools_IteratorColumn = {
   PyVarObject_HEAD_INIT(0, 0)
-  __Pyx_NAMESTR("csamtools.PileupProxy"), /*tp_name*/
-  sizeof(struct __pyx_obj_9csamtools_PileupProxy), /*tp_basicsize*/
+  __Pyx_NAMESTR("csamtools.IteratorColumn"), /*tp_name*/
+  sizeof(struct __pyx_obj_9csamtools_IteratorColumn), /*tp_basicsize*/
   0, /*tp_itemsize*/
-  __pyx_tp_dealloc_9csamtools_PileupProxy, /*tp_dealloc*/
+  __pyx_tp_dealloc_9csamtools_IteratorColumn, /*tp_dealloc*/
   0, /*tp_print*/
   0, /*tp_getattr*/
   0, /*tp_setattr*/
@@ -28985,34 +33439,34 @@ static PyTypeObject __pyx_type_9csamtools_PileupProxy = {
   0, /*reserved*/
   #endif
   0, /*tp_repr*/
-  &__pyx_tp_as_number_PileupProxy, /*tp_as_number*/
-  &__pyx_tp_as_sequence_PileupProxy, /*tp_as_sequence*/
-  &__pyx_tp_as_mapping_PileupProxy, /*tp_as_mapping*/
+  &__pyx_tp_as_number_IteratorColumn, /*tp_as_number*/
+  &__pyx_tp_as_sequence_IteratorColumn, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_IteratorColumn, /*tp_as_mapping*/
   0, /*tp_hash*/
   0, /*tp_call*/
-  __pyx_pf_9csamtools_11PileupProxy_1__str__, /*tp_str*/
+  0, /*tp_str*/
   0, /*tp_getattro*/
   0, /*tp_setattro*/
-  &__pyx_tp_as_buffer_PileupProxy, /*tp_as_buffer*/
-  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
-  __Pyx_DOCSTR("PileupProxy()\nA pileup column. A pileup column contains\n    all the reads that map to a certain target base.\n\n    tid\n        chromosome ID as is defined in the header\n    pos\n        the target base coordinate (0-based)\n    n\n        number of reads mapping to this column    \n    pileups\n        list of reads (:class:`pysam.PileupRead`) aligned to this column\n\n    This class is a proxy for results returned by the samtools pileup engine.\n    If the underlying engine iterator advances, the results of this column\n    will change.\n    "), /*tp_doc*/
-  0, /*tp_traverse*/
-  0, /*tp_clear*/
+  &__pyx_tp_as_buffer_IteratorColumn, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  __Pyx_DOCSTR("abstract base class for iterators over columns.\n\n    IteratorColumn objects wrap the pileup functionality of samtools.\n    \n    For reasons of efficiency, the iterator points to the current \n    pileup buffer. The pileup buffer is updated at every iteration.\n    This might cause some unexpected behavious. For example,\n    consider the conversion to a list::\n    \n       f = Samfile(\"file.bam\", \"rb\")\n       result = list( f.pileup() )\n\n    Here, ``result`` will contain ``n`` objects of type :class:`PileupProxy` for ``n`` columns, \n    but each object in ``result`` will contain the same information.\n    \n    The desired behaviour can be achieved by list comprehension::\n\n       result = [ x.pileups() for x in f.pileup() ]\n\n    ``result`` will be a list of ``n`` lists of objects of type :class:`PileupRead`.\n\n    If the iterator is associated with a :class:`Fastafile` using the :meth:`addReference`\n    method, then the iterator will export the current sequence via the methods :meth:`getSequence`\n    and :meth:`seq_len`.\n\n    Optional kwargs to the iterator\n\n    stepper\n       The stepper controlls how the iterator advances. \n       Possible options for the stepper are \n       \n       all\n           use all reads for pileup.\n       samtools\n           same filter and read processing as in :term:`csamtools` pileup\n    fastafile\n       A :class:`FastaFile` object\n    mask\n       Skip all reads with bits set in mask.\n       \n    \n    "), /*tp_doc*/
+  __pyx_tp_traverse_9csamtools_IteratorColumn, /*tp_traverse*/
+  __pyx_tp_clear_9csamtools_IteratorColumn, /*tp_clear*/
   0, /*tp_richcompare*/
   0, /*tp_weaklistoffset*/
-  0, /*tp_iter*/
+  __pyx_pf_9csamtools_14IteratorColumn___iter__, /*tp_iter*/
   0, /*tp_iternext*/
-  __pyx_methods_9csamtools_PileupProxy, /*tp_methods*/
+  __pyx_methods_9csamtools_IteratorColumn, /*tp_methods*/
   0, /*tp_members*/
-  __pyx_getsets_9csamtools_PileupProxy, /*tp_getset*/
+  __pyx_getsets_9csamtools_IteratorColumn, /*tp_getset*/
   0, /*tp_base*/
   0, /*tp_dict*/
   0, /*tp_descr_get*/
   0, /*tp_descr_set*/
   0, /*tp_dictoffset*/
-  __pyx_pf_9csamtools_11PileupProxy___init__, /*tp_init*/
+  0, /*tp_init*/
   0, /*tp_alloc*/
-  __pyx_tp_new_9csamtools_PileupProxy, /*tp_new*/
+  __pyx_tp_new_9csamtools_IteratorColumn, /*tp_new*/
   0, /*tp_free*/
   0, /*tp_is_gc*/
   0, /*tp_bases*/
@@ -29025,84 +33479,198 @@ static PyTypeObject __pyx_type_9csamtools_PileupProxy = {
   0, /*tp_version_tag*/
   #endif
 };
+static struct __pyx_vtabstruct_9csamtools_IteratorColumnRegion __pyx_vtable_9csamtools_IteratorColumnRegion;
 
-static PyObject *__pyx_tp_new_9csamtools_PileupRead(PyTypeObject *t, PyObject *a, PyObject *k) {
-  struct __pyx_obj_9csamtools_PileupRead *p;
-  PyObject *o = (*t->tp_alloc)(t, 0);
+static PyObject *__pyx_tp_new_9csamtools_IteratorColumnRegion(PyTypeObject *t, PyObject *a, PyObject *k) {
+  struct __pyx_obj_9csamtools_IteratorColumnRegion *p;
+  PyObject *o = __pyx_tp_new_9csamtools_IteratorColumn(t, a, k);
   if (!o) return 0;
-  p = ((struct __pyx_obj_9csamtools_PileupRead *)o);
-  p->_alignment = ((struct __pyx_obj_9csamtools_AlignedRead *)Py_None); Py_INCREF(Py_None);
-  return o;
-}
-
-static void __pyx_tp_dealloc_9csamtools_PileupRead(PyObject *o) {
-  struct __pyx_obj_9csamtools_PileupRead *p = (struct __pyx_obj_9csamtools_PileupRead *)o;
-  Py_XDECREF(((PyObject *)p->_alignment));
-  (*Py_TYPE(o)->tp_free)(o);
-}
-
-static int __pyx_tp_traverse_9csamtools_PileupRead(PyObject *o, visitproc v, void *a) {
-  int e;
-  struct __pyx_obj_9csamtools_PileupRead *p = (struct __pyx_obj_9csamtools_PileupRead *)o;
-  if (p->_alignment) {
-    e = (*v)(((PyObject*)p->_alignment), a); if (e) return e;
+  p = ((struct __pyx_obj_9csamtools_IteratorColumnRegion *)o);
+  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_9csamtools_IteratorColumn*)__pyx_vtabptr_9csamtools_IteratorColumnRegion;
+  if (__pyx_pf_9csamtools_20IteratorColumnRegion___cinit__(o, a, k) < 0) {
+    Py_DECREF(o); o = 0;
   }
-  return 0;
-}
-
-static int __pyx_tp_clear_9csamtools_PileupRead(PyObject *o) {
-  struct __pyx_obj_9csamtools_PileupRead *p = (struct __pyx_obj_9csamtools_PileupRead *)o;
-  PyObject* tmp;
-  tmp = ((PyObject*)p->_alignment);
-  p->_alignment = ((struct __pyx_obj_9csamtools_AlignedRead *)Py_None); Py_INCREF(Py_None);
-  Py_XDECREF(tmp);
-  return 0;
+  return o;
 }
 
-static PyObject *__pyx_getprop_9csamtools_10PileupRead_alignment(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_10PileupRead_9alignment___get__(o);
-}
+static PyMethodDef __pyx_methods_9csamtools_IteratorColumnRegion[] = {
+  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_20IteratorColumnRegion___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_20IteratorColumnRegion___next__)},
+  {0, 0, 0, 0}
+};
 
-static PyObject *__pyx_getprop_9csamtools_10PileupRead_qpos(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_10PileupRead_4qpos___get__(o);
-}
+static PyNumberMethods __pyx_tp_as_number_IteratorColumnRegion = {
+  0, /*nb_add*/
+  0, /*nb_subtract*/
+  0, /*nb_multiply*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_divide*/
+  #endif
+  0, /*nb_remainder*/
+  0, /*nb_divmod*/
+  0, /*nb_power*/
+  0, /*nb_negative*/
+  0, /*nb_positive*/
+  0, /*nb_absolute*/
+  0, /*nb_nonzero*/
+  0, /*nb_invert*/
+  0, /*nb_lshift*/
+  0, /*nb_rshift*/
+  0, /*nb_and*/
+  0, /*nb_xor*/
+  0, /*nb_or*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_coerce*/
+  #endif
+  0, /*nb_int*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_long*/
+  #else
+  0, /*reserved*/
+  #endif
+  0, /*nb_float*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_oct*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_hex*/
+  #endif
+  0, /*nb_inplace_add*/
+  0, /*nb_inplace_subtract*/
+  0, /*nb_inplace_multiply*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_inplace_divide*/
+  #endif
+  0, /*nb_inplace_remainder*/
+  0, /*nb_inplace_power*/
+  0, /*nb_inplace_lshift*/
+  0, /*nb_inplace_rshift*/
+  0, /*nb_inplace_and*/
+  0, /*nb_inplace_xor*/
+  0, /*nb_inplace_or*/
+  0, /*nb_floor_divide*/
+  0, /*nb_true_divide*/
+  0, /*nb_inplace_floor_divide*/
+  0, /*nb_inplace_true_divide*/
+  #if PY_VERSION_HEX >= 0x02050000
+  0, /*nb_index*/
+  #endif
+};
 
-static PyObject *__pyx_getprop_9csamtools_10PileupRead_indel(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_10PileupRead_5indel___get__(o);
-}
+static PySequenceMethods __pyx_tp_as_sequence_IteratorColumnRegion = {
+  0, /*sq_length*/
+  0, /*sq_concat*/
+  0, /*sq_repeat*/
+  0, /*sq_item*/
+  0, /*sq_slice*/
+  0, /*sq_ass_item*/
+  0, /*sq_ass_slice*/
+  0, /*sq_contains*/
+  0, /*sq_inplace_concat*/
+  0, /*sq_inplace_repeat*/
+};
 
-static PyObject *__pyx_getprop_9csamtools_10PileupRead_is_del(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_10PileupRead_6is_del___get__(o);
-}
+static PyMappingMethods __pyx_tp_as_mapping_IteratorColumnRegion = {
+  0, /*mp_length*/
+  0, /*mp_subscript*/
+  0, /*mp_ass_subscript*/
+};
 
-static PyObject *__pyx_getprop_9csamtools_10PileupRead_is_head(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_10PileupRead_7is_head___get__(o);
-}
+static PyBufferProcs __pyx_tp_as_buffer_IteratorColumnRegion = {
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getreadbuffer*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getwritebuffer*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getsegcount*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getcharbuffer*/
+  #endif
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*bf_getbuffer*/
+  #endif
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*bf_releasebuffer*/
+  #endif
+};
 
-static PyObject *__pyx_getprop_9csamtools_10PileupRead_is_tail(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_10PileupRead_7is_tail___get__(o);
-}
+PyTypeObject __pyx_type_9csamtools_IteratorColumnRegion = {
+  PyVarObject_HEAD_INIT(0, 0)
+  __Pyx_NAMESTR("csamtools.IteratorColumnRegion"), /*tp_name*/
+  sizeof(struct __pyx_obj_9csamtools_IteratorColumnRegion), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_9csamtools_IteratorColumn, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*tp_compare*/
+  #else
+  0, /*reserved*/
+  #endif
+  0, /*tp_repr*/
+  &__pyx_tp_as_number_IteratorColumnRegion, /*tp_as_number*/
+  &__pyx_tp_as_sequence_IteratorColumnRegion, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_IteratorColumnRegion, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  &__pyx_tp_as_buffer_IteratorColumnRegion, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  __Pyx_DOCSTR("iterates over a region only.\n    "), /*tp_doc*/
+  __pyx_tp_traverse_9csamtools_IteratorColumn, /*tp_traverse*/
+  __pyx_tp_clear_9csamtools_IteratorColumn, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  __pyx_pf_9csamtools_20IteratorColumnRegion___next__, /*tp_iternext*/
+  __pyx_methods_9csamtools_IteratorColumnRegion, /*tp_methods*/
+  0, /*tp_members*/
+  0, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  0, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_9csamtools_IteratorColumnRegion, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+  0, /*tp_del*/
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*tp_version_tag*/
+  #endif
+};
+static struct __pyx_vtabstruct_9csamtools_IteratorColumnAllRefs __pyx_vtable_9csamtools_IteratorColumnAllRefs;
 
-static PyObject *__pyx_getprop_9csamtools_10PileupRead_level(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_10PileupRead_5level___get__(o);
+static PyObject *__pyx_tp_new_9csamtools_IteratorColumnAllRefs(PyTypeObject *t, PyObject *a, PyObject *k) {
+  struct __pyx_obj_9csamtools_IteratorColumnAllRefs *p;
+  PyObject *o = __pyx_tp_new_9csamtools_IteratorColumn(t, a, k);
+  if (!o) return 0;
+  p = ((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)o);
+  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_9csamtools_IteratorColumn*)__pyx_vtabptr_9csamtools_IteratorColumnAllRefs;
+  if (__pyx_pf_9csamtools_21IteratorColumnAllRefs___cinit__(o, a, k) < 0) {
+    Py_DECREF(o); o = 0;
+  }
+  return o;
 }
 
-static PyMethodDef __pyx_methods_9csamtools_PileupRead[] = {
+static PyMethodDef __pyx_methods_9csamtools_IteratorColumnAllRefs[] = {
+  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_21IteratorColumnAllRefs___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_21IteratorColumnAllRefs___next__)},
   {0, 0, 0, 0}
 };
 
-static struct PyGetSetDef __pyx_getsets_9csamtools_PileupRead[] = {
-  {(char *)"alignment", __pyx_getprop_9csamtools_10PileupRead_alignment, 0, __Pyx_DOCSTR(__pyx_k_217), 0},
-  {(char *)"qpos", __pyx_getprop_9csamtools_10PileupRead_qpos, 0, __Pyx_DOCSTR(__pyx_k_218), 0},
-  {(char *)"indel", __pyx_getprop_9csamtools_10PileupRead_indel, 0, __Pyx_DOCSTR(__pyx_k_219), 0},
-  {(char *)"is_del", __pyx_getprop_9csamtools_10PileupRead_is_del, 0, __Pyx_DOCSTR(__pyx_k_220), 0},
-  {(char *)"is_head", __pyx_getprop_9csamtools_10PileupRead_is_head, 0, 0, 0},
-  {(char *)"is_tail", __pyx_getprop_9csamtools_10PileupRead_is_tail, 0, 0, 0},
-  {(char *)"level", __pyx_getprop_9csamtools_10PileupRead_level, 0, 0, 0},
-  {0, 0, 0, 0, 0}
-};
-
-static PyNumberMethods __pyx_tp_as_number_PileupRead = {
+static PyNumberMethods __pyx_tp_as_number_IteratorColumnAllRefs = {
   0, /*nb_add*/
   0, /*nb_subtract*/
   0, /*nb_multiply*/
@@ -29160,7 +33728,7 @@ static PyNumberMethods __pyx_tp_as_number_PileupRead = {
   #endif
 };
 
-static PySequenceMethods __pyx_tp_as_sequence_PileupRead = {
+static PySequenceMethods __pyx_tp_as_sequence_IteratorColumnAllRefs = {
   0, /*sq_length*/
   0, /*sq_concat*/
   0, /*sq_repeat*/
@@ -29173,13 +33741,13 @@ static PySequenceMethods __pyx_tp_as_sequence_PileupRead = {
   0, /*sq_inplace_repeat*/
 };
 
-static PyMappingMethods __pyx_tp_as_mapping_PileupRead = {
+static PyMappingMethods __pyx_tp_as_mapping_IteratorColumnAllRefs = {
   0, /*mp_length*/
   0, /*mp_subscript*/
   0, /*mp_ass_subscript*/
 };
 
-static PyBufferProcs __pyx_tp_as_buffer_PileupRead = {
+static PyBufferProcs __pyx_tp_as_buffer_IteratorColumnAllRefs = {
   #if PY_MAJOR_VERSION < 3
   0, /*bf_getreadbuffer*/
   #endif
@@ -29200,12 +33768,12 @@ static PyBufferProcs __pyx_tp_as_buffer_PileupRead = {
   #endif
 };
 
-static PyTypeObject __pyx_type_9csamtools_PileupRead = {
+PyTypeObject __pyx_type_9csamtools_IteratorColumnAllRefs = {
   PyVarObject_HEAD_INIT(0, 0)
-  __Pyx_NAMESTR("csamtools.PileupRead"), /*tp_name*/
-  sizeof(struct __pyx_obj_9csamtools_PileupRead), /*tp_basicsize*/
+  __Pyx_NAMESTR("csamtools.IteratorColumnAllRefs"), /*tp_name*/
+  sizeof(struct __pyx_obj_9csamtools_IteratorColumnAllRefs), /*tp_basicsize*/
   0, /*tp_itemsize*/
-  __pyx_tp_dealloc_9csamtools_PileupRead, /*tp_dealloc*/
+  __pyx_tp_dealloc_9csamtools_IteratorColumn, /*tp_dealloc*/
   0, /*tp_print*/
   0, /*tp_getattr*/
   0, /*tp_setattr*/
@@ -29215,34 +33783,34 @@ static PyTypeObject __pyx_type_9csamtools_PileupRead = {
   0, /*reserved*/
   #endif
   0, /*tp_repr*/
-  &__pyx_tp_as_number_PileupRead, /*tp_as_number*/
-  &__pyx_tp_as_sequence_PileupRead, /*tp_as_sequence*/
-  &__pyx_tp_as_mapping_PileupRead, /*tp_as_mapping*/
+  &__pyx_tp_as_number_IteratorColumnAllRefs, /*tp_as_number*/
+  &__pyx_tp_as_sequence_IteratorColumnAllRefs, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_IteratorColumnAllRefs, /*tp_as_mapping*/
   0, /*tp_hash*/
   0, /*tp_call*/
-  __pyx_pf_9csamtools_10PileupRead_1__str__, /*tp_str*/
+  0, /*tp_str*/
   0, /*tp_getattro*/
   0, /*tp_setattro*/
-  &__pyx_tp_as_buffer_PileupRead, /*tp_as_buffer*/
-  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
-  __Pyx_DOCSTR("PileupRead()\nA read aligned to a column.\n    "), /*tp_doc*/
-  __pyx_tp_traverse_9csamtools_PileupRead, /*tp_traverse*/
-  __pyx_tp_clear_9csamtools_PileupRead, /*tp_clear*/
+  &__pyx_tp_as_buffer_IteratorColumnAllRefs, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  __Pyx_DOCSTR("iterates over all columns by chaining iterators over each reference\n    "), /*tp_doc*/
+  __pyx_tp_traverse_9csamtools_IteratorColumn, /*tp_traverse*/
+  __pyx_tp_clear_9csamtools_IteratorColumn, /*tp_clear*/
   0, /*tp_richcompare*/
   0, /*tp_weaklistoffset*/
   0, /*tp_iter*/
-  0, /*tp_iternext*/
-  __pyx_methods_9csamtools_PileupRead, /*tp_methods*/
+  __pyx_pf_9csamtools_21IteratorColumnAllRefs___next__, /*tp_iternext*/
+  __pyx_methods_9csamtools_IteratorColumnAllRefs, /*tp_methods*/
   0, /*tp_members*/
-  __pyx_getsets_9csamtools_PileupRead, /*tp_getset*/
+  0, /*tp_getset*/
   0, /*tp_base*/
   0, /*tp_dict*/
   0, /*tp_descr_get*/
   0, /*tp_descr_set*/
   0, /*tp_dictoffset*/
-  __pyx_pf_9csamtools_10PileupRead___init__, /*tp_init*/
+  0, /*tp_init*/
   0, /*tp_alloc*/
-  __pyx_tp_new_9csamtools_PileupRead, /*tp_new*/
+  __pyx_tp_new_9csamtools_IteratorColumnAllRefs, /*tp_new*/
   0, /*tp_free*/
   0, /*tp_is_gc*/
   0, /*tp_bases*/
@@ -29255,51 +33823,66 @@ static PyTypeObject __pyx_type_9csamtools_PileupRead = {
   0, /*tp_version_tag*/
   #endif
 };
-static struct __pyx_vtabstruct_9csamtools_Fastafile __pyx_vtable_9csamtools_Fastafile;
 
-static PyObject *__pyx_tp_new_9csamtools_Fastafile(PyTypeObject *t, PyObject *a, PyObject *k) {
-  struct __pyx_obj_9csamtools_Fastafile *p;
+static PyObject *__pyx_tp_new_9csamtools_SNPCall(PyTypeObject *t, PyObject *a, PyObject *k) {
   PyObject *o = (*t->tp_alloc)(t, 0);
   if (!o) return 0;
-  p = ((struct __pyx_obj_9csamtools_Fastafile *)o);
-  p->__pyx_vtab = __pyx_vtabptr_9csamtools_Fastafile;
-  if (__pyx_pf_9csamtools_9Fastafile___cinit__(o, a, k) < 0) {
-    Py_DECREF(o); o = 0;
-  }
   return o;
 }
 
-static void __pyx_tp_dealloc_9csamtools_Fastafile(PyObject *o) {
-  {
-    PyObject *etype, *eval, *etb;
-    PyErr_Fetch(&etype, &eval, &etb);
-    ++Py_REFCNT(o);
-    __pyx_pf_9csamtools_9Fastafile_5__dealloc__(o);
-    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
-    --Py_REFCNT(o);
-    PyErr_Restore(etype, eval, etb);
-  }
+static void __pyx_tp_dealloc_9csamtools_SNPCall(PyObject *o) {
   (*Py_TYPE(o)->tp_free)(o);
 }
 
-static PyObject *__pyx_getprop_9csamtools_9Fastafile_filename(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_9Fastafile_8filename___get__(o);
+static PyObject *__pyx_getprop_9csamtools_7SNPCall_tid(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_7SNPCall_3tid___get__(o);
 }
 
-static PyMethodDef __pyx_methods_9csamtools_Fastafile[] = {
-  {__Pyx_NAMESTR("_isOpen"), (PyCFunction)__pyx_pf_9csamtools_9Fastafile_1_isOpen, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_9Fastafile_1_isOpen)},
-  {__Pyx_NAMESTR("_open"), (PyCFunction)__pyx_pf_9csamtools_9Fastafile_3_open, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_9Fastafile_3_open)},
-  {__Pyx_NAMESTR("close"), (PyCFunction)__pyx_pf_9csamtools_9Fastafile_4close, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_9Fastafile_4close)},
-  {__Pyx_NAMESTR("fetch"), (PyCFunction)__pyx_pf_9csamtools_9Fastafile_6fetch, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_9Fastafile_6fetch)},
+static PyObject *__pyx_getprop_9csamtools_7SNPCall_pos(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_7SNPCall_3pos___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_7SNPCall_reference_base(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_7SNPCall_14reference_base___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_7SNPCall_genotype(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_7SNPCall_8genotype___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_7SNPCall_consensus_quality(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_7SNPCall_17consensus_quality___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_7SNPCall_snp_quality(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_7SNPCall_11snp_quality___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_7SNPCall_mapping_quality(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_7SNPCall_15mapping_quality___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_7SNPCall_coverage(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_7SNPCall_8coverage___get__(o);
+}
+
+static PyMethodDef __pyx_methods_9csamtools_SNPCall[] = {
   {0, 0, 0, 0}
 };
 
-static struct PyGetSetDef __pyx_getsets_9csamtools_Fastafile[] = {
-  {(char *)"filename", __pyx_getprop_9csamtools_9Fastafile_filename, 0, __Pyx_DOCSTR(__pyx_k_206), 0},
+static struct PyGetSetDef __pyx_getsets_9csamtools_SNPCall[] = {
+  {(char *)"tid", __pyx_getprop_9csamtools_7SNPCall_tid, 0, __Pyx_DOCSTR(__pyx_k_154), 0},
+  {(char *)"pos", __pyx_getprop_9csamtools_7SNPCall_pos, 0, __Pyx_DOCSTR(__pyx_k_162), 0},
+  {(char *)"reference_base", __pyx_getprop_9csamtools_7SNPCall_reference_base, 0, __Pyx_DOCSTR(__pyx_k_163), 0},
+  {(char *)"genotype", __pyx_getprop_9csamtools_7SNPCall_genotype, 0, __Pyx_DOCSTR(__pyx_k_164), 0},
+  {(char *)"consensus_quality", __pyx_getprop_9csamtools_7SNPCall_consensus_quality, 0, __Pyx_DOCSTR(__pyx_k_165), 0},
+  {(char *)"snp_quality", __pyx_getprop_9csamtools_7SNPCall_snp_quality, 0, __Pyx_DOCSTR(__pyx_k_166), 0},
+  {(char *)"mapping_quality", __pyx_getprop_9csamtools_7SNPCall_mapping_quality, 0, __Pyx_DOCSTR(__pyx_k_167), 0},
+  {(char *)"coverage", __pyx_getprop_9csamtools_7SNPCall_coverage, 0, __Pyx_DOCSTR(__pyx_k_168), 0},
   {0, 0, 0, 0, 0}
 };
 
-static PyNumberMethods __pyx_tp_as_number_Fastafile = {
+static PyNumberMethods __pyx_tp_as_number_SNPCall = {
   0, /*nb_add*/
   0, /*nb_subtract*/
   0, /*nb_multiply*/
@@ -29357,8 +33940,8 @@ static PyNumberMethods __pyx_tp_as_number_Fastafile = {
   #endif
 };
 
-static PySequenceMethods __pyx_tp_as_sequence_Fastafile = {
-  __pyx_pf_9csamtools_9Fastafile_2__len__, /*sq_length*/
+static PySequenceMethods __pyx_tp_as_sequence_SNPCall = {
+  0, /*sq_length*/
   0, /*sq_concat*/
   0, /*sq_repeat*/
   0, /*sq_item*/
@@ -29370,13 +33953,13 @@ static PySequenceMethods __pyx_tp_as_sequence_Fastafile = {
   0, /*sq_inplace_repeat*/
 };
 
-static PyMappingMethods __pyx_tp_as_mapping_Fastafile = {
-  __pyx_pf_9csamtools_9Fastafile_2__len__, /*mp_length*/
+static PyMappingMethods __pyx_tp_as_mapping_SNPCall = {
+  0, /*mp_length*/
   0, /*mp_subscript*/
   0, /*mp_ass_subscript*/
 };
 
-static PyBufferProcs __pyx_tp_as_buffer_Fastafile = {
+static PyBufferProcs __pyx_tp_as_buffer_SNPCall = {
   #if PY_MAJOR_VERSION < 3
   0, /*bf_getreadbuffer*/
   #endif
@@ -29397,12 +33980,12 @@ static PyBufferProcs __pyx_tp_as_buffer_Fastafile = {
   #endif
 };
 
-static PyTypeObject __pyx_type_9csamtools_Fastafile = {
+PyTypeObject __pyx_type_9csamtools_SNPCall = {
   PyVarObject_HEAD_INIT(0, 0)
-  __Pyx_NAMESTR("csamtools.Fastafile"), /*tp_name*/
-  sizeof(struct __pyx_obj_9csamtools_Fastafile), /*tp_basicsize*/
+  __Pyx_NAMESTR("csamtools.SNPCall"), /*tp_name*/
+  sizeof(struct __pyx_obj_9csamtools_SNPCall), /*tp_basicsize*/
   0, /*tp_itemsize*/
-  __pyx_tp_dealloc_9csamtools_Fastafile, /*tp_dealloc*/
+  __pyx_tp_dealloc_9csamtools_SNPCall, /*tp_dealloc*/
   0, /*tp_print*/
   0, /*tp_getattr*/
   0, /*tp_setattr*/
@@ -29412,26 +33995,26 @@ static PyTypeObject __pyx_type_9csamtools_Fastafile = {
   0, /*reserved*/
   #endif
   0, /*tp_repr*/
-  &__pyx_tp_as_number_Fastafile, /*tp_as_number*/
-  &__pyx_tp_as_sequence_Fastafile, /*tp_as_sequence*/
-  &__pyx_tp_as_mapping_Fastafile, /*tp_as_mapping*/
+  &__pyx_tp_as_number_SNPCall, /*tp_as_number*/
+  &__pyx_tp_as_sequence_SNPCall, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_SNPCall, /*tp_as_mapping*/
   0, /*tp_hash*/
   0, /*tp_call*/
-  0, /*tp_str*/
+  __pyx_pf_9csamtools_7SNPCall___str__, /*tp_str*/
   0, /*tp_getattro*/
   0, /*tp_setattro*/
-  &__pyx_tp_as_buffer_Fastafile, /*tp_as_buffer*/
-  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
-  __Pyx_DOCSTR("*(filename)*\n              \n    A *FASTA* file. The file is automatically opened.\n\n    The file expects an indexed fasta file.\n\n    TODO: \n        add automatic indexing.\n        add function to get sequence names.\n    "), /*tp_doc*/
+  &__pyx_tp_as_buffer_SNPCall, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
+  __Pyx_DOCSTR("the results of a SNP call."), /*tp_doc*/
   0, /*tp_traverse*/
   0, /*tp_clear*/
   0, /*tp_richcompare*/
   0, /*tp_weaklistoffset*/
   0, /*tp_iter*/
   0, /*tp_iternext*/
-  __pyx_methods_9csamtools_Fastafile, /*tp_methods*/
+  __pyx_methods_9csamtools_SNPCall, /*tp_methods*/
   0, /*tp_members*/
-  __pyx_getsets_9csamtools_Fastafile, /*tp_getset*/
+  __pyx_getsets_9csamtools_SNPCall, /*tp_getset*/
   0, /*tp_base*/
   0, /*tp_dict*/
   0, /*tp_descr_get*/
@@ -29439,7 +34022,7 @@ static PyTypeObject __pyx_type_9csamtools_Fastafile = {
   0, /*tp_dictoffset*/
   0, /*tp_init*/
   0, /*tp_alloc*/
-  __pyx_tp_new_9csamtools_Fastafile, /*tp_new*/
+  __pyx_tp_new_9csamtools_SNPCall, /*tp_new*/
   0, /*tp_free*/
   0, /*tp_is_gc*/
   0, /*tp_bases*/
@@ -29452,66 +34035,59 @@ static PyTypeObject __pyx_type_9csamtools_Fastafile = {
   0, /*tp_version_tag*/
   #endif
 };
-static struct __pyx_vtabstruct_9csamtools_IteratorRowRegion __pyx_vtable_9csamtools_IteratorRowRegion;
+static struct __pyx_vtabstruct_9csamtools_SNPCallerBase __pyx_vtable_9csamtools_SNPCallerBase;
 
-static PyObject *__pyx_tp_new_9csamtools_IteratorRowRegion(PyTypeObject *t, PyObject *a, PyObject *k) {
-  struct __pyx_obj_9csamtools_IteratorRowRegion *p;
-  PyObject *o = __pyx_tp_new_9csamtools_IteratorRow(t, a, k);
+static PyObject *__pyx_tp_new_9csamtools_SNPCallerBase(PyTypeObject *t, PyObject *a, PyObject *k) {
+  struct __pyx_obj_9csamtools_SNPCallerBase *p;
+  PyObject *o = (*t->tp_alloc)(t, 0);
   if (!o) return 0;
-  p = ((struct __pyx_obj_9csamtools_IteratorRowRegion *)o);
-  p->__pyx_vtab = __pyx_vtabptr_9csamtools_IteratorRowRegion;
-  p->samfile = ((struct __pyx_obj_9csamtools_Samfile *)Py_None); Py_INCREF(Py_None);
-  if (__pyx_pf_9csamtools_17IteratorRowRegion___cinit__(o, a, k) < 0) {
+  p = ((struct __pyx_obj_9csamtools_SNPCallerBase *)o);
+  p->__pyx_vtab = __pyx_vtabptr_9csamtools_SNPCallerBase;
+  p->iter = ((struct __pyx_obj_9csamtools_IteratorColumn *)Py_None); Py_INCREF(Py_None);
+  if (__pyx_pf_9csamtools_13SNPCallerBase___cinit__(o, a, k) < 0) {
     Py_DECREF(o); o = 0;
   }
   return o;
 }
 
-static void __pyx_tp_dealloc_9csamtools_IteratorRowRegion(PyObject *o) {
-  struct __pyx_obj_9csamtools_IteratorRowRegion *p = (struct __pyx_obj_9csamtools_IteratorRowRegion *)o;
+static void __pyx_tp_dealloc_9csamtools_SNPCallerBase(PyObject *o) {
+  struct __pyx_obj_9csamtools_SNPCallerBase *p = (struct __pyx_obj_9csamtools_SNPCallerBase *)o;
   {
     PyObject *etype, *eval, *etb;
     PyErr_Fetch(&etype, &eval, &etb);
     ++Py_REFCNT(o);
-    __pyx_pf_9csamtools_17IteratorRowRegion_3__dealloc__(o);
+    __pyx_pf_9csamtools_13SNPCallerBase___dealloc__(o);
     if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
     --Py_REFCNT(o);
     PyErr_Restore(etype, eval, etb);
   }
-  Py_XDECREF(((PyObject *)p->samfile));
-  __pyx_tp_dealloc_9csamtools_IteratorRow(o);
+  Py_XDECREF(((PyObject *)p->iter));
+  (*Py_TYPE(o)->tp_free)(o);
 }
 
-static int __pyx_tp_traverse_9csamtools_IteratorRowRegion(PyObject *o, visitproc v, void *a) {
+static int __pyx_tp_traverse_9csamtools_SNPCallerBase(PyObject *o, visitproc v, void *a) {
   int e;
-  struct __pyx_obj_9csamtools_IteratorRowRegion *p = (struct __pyx_obj_9csamtools_IteratorRowRegion *)o;
-  if (__pyx_ptype_9csamtools_IteratorRow->tp_traverse) {
-    e = __pyx_ptype_9csamtools_IteratorRow->tp_traverse(o, v, a); if (e) return e;
-  }
-  if (p->samfile) {
-    e = (*v)(((PyObject*)p->samfile), a); if (e) return e;
+  struct __pyx_obj_9csamtools_SNPCallerBase *p = (struct __pyx_obj_9csamtools_SNPCallerBase *)o;
+  if (p->iter) {
+    e = (*v)(((PyObject*)p->iter), a); if (e) return e;
   }
   return 0;
 }
 
-static int __pyx_tp_clear_9csamtools_IteratorRowRegion(PyObject *o) {
-  struct __pyx_obj_9csamtools_IteratorRowRegion *p = (struct __pyx_obj_9csamtools_IteratorRowRegion *)o;
+static int __pyx_tp_clear_9csamtools_SNPCallerBase(PyObject *o) {
+  struct __pyx_obj_9csamtools_SNPCallerBase *p = (struct __pyx_obj_9csamtools_SNPCallerBase *)o;
   PyObject* tmp;
-  if (__pyx_ptype_9csamtools_IteratorRow->tp_clear) {
-    __pyx_ptype_9csamtools_IteratorRow->tp_clear(o);
-  }
-  tmp = ((PyObject*)p->samfile);
-  p->samfile = ((struct __pyx_obj_9csamtools_Samfile *)Py_None); Py_INCREF(Py_None);
+  tmp = ((PyObject*)p->iter);
+  p->iter = ((struct __pyx_obj_9csamtools_IteratorColumn *)Py_None); Py_INCREF(Py_None);
   Py_XDECREF(tmp);
   return 0;
 }
 
-static PyMethodDef __pyx_methods_9csamtools_IteratorRowRegion[] = {
-  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_17IteratorRowRegion_2__next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_17IteratorRowRegion_2__next__)},
+static PyMethodDef __pyx_methods_9csamtools_SNPCallerBase[] = {
   {0, 0, 0, 0}
 };
 
-static PyNumberMethods __pyx_tp_as_number_IteratorRowRegion = {
+static PyNumberMethods __pyx_tp_as_number_SNPCallerBase = {
   0, /*nb_add*/
   0, /*nb_subtract*/
   0, /*nb_multiply*/
@@ -29569,7 +34145,7 @@ static PyNumberMethods __pyx_tp_as_number_IteratorRowRegion = {
   #endif
 };
 
-static PySequenceMethods __pyx_tp_as_sequence_IteratorRowRegion = {
+static PySequenceMethods __pyx_tp_as_sequence_SNPCallerBase = {
   0, /*sq_length*/
   0, /*sq_concat*/
   0, /*sq_repeat*/
@@ -29582,13 +34158,13 @@ static PySequenceMethods __pyx_tp_as_sequence_IteratorRowRegion = {
   0, /*sq_inplace_repeat*/
 };
 
-static PyMappingMethods __pyx_tp_as_mapping_IteratorRowRegion = {
+static PyMappingMethods __pyx_tp_as_mapping_SNPCallerBase = {
   0, /*mp_length*/
   0, /*mp_subscript*/
   0, /*mp_ass_subscript*/
 };
 
-static PyBufferProcs __pyx_tp_as_buffer_IteratorRowRegion = {
+static PyBufferProcs __pyx_tp_as_buffer_SNPCallerBase = {
   #if PY_MAJOR_VERSION < 3
   0, /*bf_getreadbuffer*/
   #endif
@@ -29609,12 +34185,12 @@ static PyBufferProcs __pyx_tp_as_buffer_IteratorRowRegion = {
   #endif
 };
 
-static PyTypeObject __pyx_type_9csamtools_IteratorRowRegion = {
+PyTypeObject __pyx_type_9csamtools_SNPCallerBase = {
   PyVarObject_HEAD_INIT(0, 0)
-  __Pyx_NAMESTR("csamtools.IteratorRowRegion"), /*tp_name*/
-  sizeof(struct __pyx_obj_9csamtools_IteratorRowRegion), /*tp_basicsize*/
+  __Pyx_NAMESTR("csamtools.SNPCallerBase"), /*tp_name*/
+  sizeof(struct __pyx_obj_9csamtools_SNPCallerBase), /*tp_basicsize*/
   0, /*tp_itemsize*/
-  __pyx_tp_dealloc_9csamtools_IteratorRowRegion, /*tp_dealloc*/
+  __pyx_tp_dealloc_9csamtools_SNPCallerBase, /*tp_dealloc*/
   0, /*tp_print*/
   0, /*tp_getattr*/
   0, /*tp_setattr*/
@@ -29624,24 +34200,24 @@ static PyTypeObject __pyx_type_9csamtools_IteratorRowRegion = {
   0, /*reserved*/
   #endif
   0, /*tp_repr*/
-  &__pyx_tp_as_number_IteratorRowRegion, /*tp_as_number*/
-  &__pyx_tp_as_sequence_IteratorRowRegion, /*tp_as_sequence*/
-  &__pyx_tp_as_mapping_IteratorRowRegion, /*tp_as_mapping*/
+  &__pyx_tp_as_number_SNPCallerBase, /*tp_as_number*/
+  &__pyx_tp_as_sequence_SNPCallerBase, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_SNPCallerBase, /*tp_as_mapping*/
   0, /*tp_hash*/
   0, /*tp_call*/
   0, /*tp_str*/
   0, /*tp_getattro*/
   0, /*tp_setattro*/
-  &__pyx_tp_as_buffer_IteratorRowRegion, /*tp_as_buffer*/
-  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
-  __Pyx_DOCSTR("*(Samfile samfile, int tid, int beg, int end, int reopen = True )*\n\n    iterate over mapped reads in a region.\n\n    By default, the file is re-openend to avoid conflicts between\n    multiple iterators working on the same file. Set *reopen* = False\n    to not re-open *samfile*.\n\n    The samtools iterators assume that the file\n    position between iterations do not change.\n    As a consequence, no two iterators can work\n    on the same file. To permit this, each iterator\n    creates its own file handle by re-opening the\n    file.\n\n    Note that the index will be shared between \n    samfile and the iterator.\n    "), /*tp_doc*/
-  __pyx_tp_traverse_9csamtools_IteratorRowRegion, /*tp_traverse*/
-  __pyx_tp_clear_9csamtools_IteratorRowRegion, /*tp_clear*/
+  &__pyx_tp_as_buffer_SNPCallerBase, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  __Pyx_DOCSTR("Base class for SNP callers.\n\n    *min_baseQ*\n       minimum base quality (possibly capped by BAQ)\n    *capQ_threshold*\n       coefficient for adjusting mapQ of poor mappings\n    *theta*\n       theta in maq consensus calling model\n    *n_haplotypes*\n       number of haplotypes in the sample\n    *het_rate*\n       prior of a difference between two haplotypes\n    "), /*tp_doc*/
+  __pyx_tp_traverse_9csamtools_SNPCallerBase, /*tp_traverse*/
+  __pyx_tp_clear_9csamtools_SNPCallerBase, /*tp_clear*/
   0, /*tp_richcompare*/
   0, /*tp_weaklistoffset*/
-  __pyx_pf_9csamtools_17IteratorRowRegion_1__iter__, /*tp_iter*/
-  __pyx_pf_9csamtools_17IteratorRowRegion_2__next__, /*tp_iternext*/
-  __pyx_methods_9csamtools_IteratorRowRegion, /*tp_methods*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_9csamtools_SNPCallerBase, /*tp_methods*/
   0, /*tp_members*/
   0, /*tp_getset*/
   0, /*tp_base*/
@@ -29651,7 +34227,7 @@ static PyTypeObject __pyx_type_9csamtools_IteratorRowRegion = {
   0, /*tp_dictoffset*/
   0, /*tp_init*/
   0, /*tp_alloc*/
-  __pyx_tp_new_9csamtools_IteratorRowRegion, /*tp_new*/
+  __pyx_tp_new_9csamtools_SNPCallerBase, /*tp_new*/
   0, /*tp_free*/
   0, /*tp_is_gc*/
   0, /*tp_bases*/
@@ -29664,64 +34240,26 @@ static PyTypeObject __pyx_type_9csamtools_IteratorRowRegion = {
   0, /*tp_version_tag*/
   #endif
 };
-
-static PyObject *__pyx_tp_new_9csamtools_IteratorRowAllRefs(PyTypeObject *t, PyObject *a, PyObject *k) {
-  struct __pyx_obj_9csamtools_IteratorRowAllRefs *p;
-  PyObject *o = __pyx_tp_new_9csamtools_IteratorRow(t, a, k);
-  if (!o) return 0;
-  p = ((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)o);
-  p->samfile = ((struct __pyx_obj_9csamtools_Samfile *)Py_None); Py_INCREF(Py_None);
-  p->rowiter = ((struct __pyx_obj_9csamtools_IteratorRowRegion *)Py_None); Py_INCREF(Py_None);
-  if (__pyx_pf_9csamtools_18IteratorRowAllRefs___cinit__(o, a, k) < 0) {
-    Py_DECREF(o); o = 0;
-  }
-  return o;
-}
-
-static void __pyx_tp_dealloc_9csamtools_IteratorRowAllRefs(PyObject *o) {
-  struct __pyx_obj_9csamtools_IteratorRowAllRefs *p = (struct __pyx_obj_9csamtools_IteratorRowAllRefs *)o;
-  Py_XDECREF(((PyObject *)p->samfile));
-  Py_XDECREF(((PyObject *)p->rowiter));
-  __pyx_tp_dealloc_9csamtools_IteratorRow(o);
-}
-
-static int __pyx_tp_traverse_9csamtools_IteratorRowAllRefs(PyObject *o, visitproc v, void *a) {
-  int e;
-  struct __pyx_obj_9csamtools_IteratorRowAllRefs *p = (struct __pyx_obj_9csamtools_IteratorRowAllRefs *)o;
-  if (__pyx_ptype_9csamtools_IteratorRow->tp_traverse) {
-    e = __pyx_ptype_9csamtools_IteratorRow->tp_traverse(o, v, a); if (e) return e;
-  }
-  if (p->samfile) {
-    e = (*v)(((PyObject*)p->samfile), a); if (e) return e;
-  }
-  if (p->rowiter) {
-    e = (*v)(((PyObject*)p->rowiter), a); if (e) return e;
-  }
-  return 0;
-}
-
-static int __pyx_tp_clear_9csamtools_IteratorRowAllRefs(PyObject *o) {
-  struct __pyx_obj_9csamtools_IteratorRowAllRefs *p = (struct __pyx_obj_9csamtools_IteratorRowAllRefs *)o;
-  PyObject* tmp;
-  if (__pyx_ptype_9csamtools_IteratorRow->tp_clear) {
-    __pyx_ptype_9csamtools_IteratorRow->tp_clear(o);
+static struct __pyx_vtabstruct_9csamtools_IteratorSNPCalls __pyx_vtable_9csamtools_IteratorSNPCalls;
+
+static PyObject *__pyx_tp_new_9csamtools_IteratorSNPCalls(PyTypeObject *t, PyObject *a, PyObject *k) {
+  struct __pyx_obj_9csamtools_IteratorSNPCalls *p;
+  PyObject *o = __pyx_tp_new_9csamtools_SNPCallerBase(t, a, k);
+  if (!o) return 0;
+  p = ((struct __pyx_obj_9csamtools_IteratorSNPCalls *)o);
+  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_9csamtools_SNPCallerBase*)__pyx_vtabptr_9csamtools_IteratorSNPCalls;
+  if (__pyx_pf_9csamtools_16IteratorSNPCalls___cinit__(o, a, k) < 0) {
+    Py_DECREF(o); o = 0;
   }
-  tmp = ((PyObject*)p->samfile);
-  p->samfile = ((struct __pyx_obj_9csamtools_Samfile *)Py_None); Py_INCREF(Py_None);
-  Py_XDECREF(tmp);
-  tmp = ((PyObject*)p->rowiter);
-  p->rowiter = ((struct __pyx_obj_9csamtools_IteratorRowRegion *)Py_None); Py_INCREF(Py_None);
-  Py_XDECREF(tmp);
-  return 0;
+  return o;
 }
 
-static PyMethodDef __pyx_methods_9csamtools_IteratorRowAllRefs[] = {
-  {__Pyx_NAMESTR("nextiter"), (PyCFunction)__pyx_pf_9csamtools_18IteratorRowAllRefs_1nextiter, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_18IteratorRowAllRefs_1nextiter)},
-  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_18IteratorRowAllRefs_3__next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_18IteratorRowAllRefs_3__next__)},
+static PyMethodDef __pyx_methods_9csamtools_IteratorSNPCalls[] = {
+  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_16IteratorSNPCalls___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_16IteratorSNPCalls___next__)},
   {0, 0, 0, 0}
 };
 
-static PyNumberMethods __pyx_tp_as_number_IteratorRowAllRefs = {
+static PyNumberMethods __pyx_tp_as_number_IteratorSNPCalls = {
   0, /*nb_add*/
   0, /*nb_subtract*/
   0, /*nb_multiply*/
@@ -29779,7 +34317,7 @@ static PyNumberMethods __pyx_tp_as_number_IteratorRowAllRefs = {
   #endif
 };
 
-static PySequenceMethods __pyx_tp_as_sequence_IteratorRowAllRefs = {
+static PySequenceMethods __pyx_tp_as_sequence_IteratorSNPCalls = {
   0, /*sq_length*/
   0, /*sq_concat*/
   0, /*sq_repeat*/
@@ -29792,13 +34330,13 @@ static PySequenceMethods __pyx_tp_as_sequence_IteratorRowAllRefs = {
   0, /*sq_inplace_repeat*/
 };
 
-static PyMappingMethods __pyx_tp_as_mapping_IteratorRowAllRefs = {
+static PyMappingMethods __pyx_tp_as_mapping_IteratorSNPCalls = {
   0, /*mp_length*/
   0, /*mp_subscript*/
   0, /*mp_ass_subscript*/
 };
 
-static PyBufferProcs __pyx_tp_as_buffer_IteratorRowAllRefs = {
+static PyBufferProcs __pyx_tp_as_buffer_IteratorSNPCalls = {
   #if PY_MAJOR_VERSION < 3
   0, /*bf_getreadbuffer*/
   #endif
@@ -29819,12 +34357,12 @@ static PyBufferProcs __pyx_tp_as_buffer_IteratorRowAllRefs = {
   #endif
 };
 
-static PyTypeObject __pyx_type_9csamtools_IteratorRowAllRefs = {
+PyTypeObject __pyx_type_9csamtools_IteratorSNPCalls = {
   PyVarObject_HEAD_INIT(0, 0)
-  __Pyx_NAMESTR("csamtools.IteratorRowAllRefs"), /*tp_name*/
-  sizeof(struct __pyx_obj_9csamtools_IteratorRowAllRefs), /*tp_basicsize*/
+  __Pyx_NAMESTR("csamtools.IteratorSNPCalls"), /*tp_name*/
+  sizeof(struct __pyx_obj_9csamtools_IteratorSNPCalls), /*tp_basicsize*/
   0, /*tp_itemsize*/
-  __pyx_tp_dealloc_9csamtools_IteratorRowAllRefs, /*tp_dealloc*/
+  __pyx_tp_dealloc_9csamtools_SNPCallerBase, /*tp_dealloc*/
   0, /*tp_print*/
   0, /*tp_getattr*/
   0, /*tp_setattr*/
@@ -29834,24 +34372,24 @@ static PyTypeObject __pyx_type_9csamtools_IteratorRowAllRefs = {
   0, /*reserved*/
   #endif
   0, /*tp_repr*/
-  &__pyx_tp_as_number_IteratorRowAllRefs, /*tp_as_number*/
-  &__pyx_tp_as_sequence_IteratorRowAllRefs, /*tp_as_sequence*/
-  &__pyx_tp_as_mapping_IteratorRowAllRefs, /*tp_as_mapping*/
+  &__pyx_tp_as_number_IteratorSNPCalls, /*tp_as_number*/
+  &__pyx_tp_as_sequence_IteratorSNPCalls, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_IteratorSNPCalls, /*tp_as_mapping*/
   0, /*tp_hash*/
   0, /*tp_call*/
   0, /*tp_str*/
   0, /*tp_getattro*/
   0, /*tp_setattro*/
-  &__pyx_tp_as_buffer_IteratorRowAllRefs, /*tp_as_buffer*/
-  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
-  __Pyx_DOCSTR("iterates over all mapped reads by chaining iterators over each reference\n    "), /*tp_doc*/
-  __pyx_tp_traverse_9csamtools_IteratorRowAllRefs, /*tp_traverse*/
-  __pyx_tp_clear_9csamtools_IteratorRowAllRefs, /*tp_clear*/
+  &__pyx_tp_as_buffer_IteratorSNPCalls, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  __Pyx_DOCSTR("*(IteratorColumn iterator)*\n\n    call SNPs within a region.\n\n    *iterator* is a pileup iterator. SNPs will be called\n    on all positions returned by this iterator.\n\n    This caller is fast if SNPs are called over large continuous\n    regions. It is slow, if instantiated frequently and in random\n    order as the sequence will have to be reloaded.\n\n    "), /*tp_doc*/
+  __pyx_tp_traverse_9csamtools_SNPCallerBase, /*tp_traverse*/
+  __pyx_tp_clear_9csamtools_SNPCallerBase, /*tp_clear*/
   0, /*tp_richcompare*/
   0, /*tp_weaklistoffset*/
-  __pyx_pf_9csamtools_18IteratorRowAllRefs_2__iter__, /*tp_iter*/
-  __pyx_pf_9csamtools_18IteratorRowAllRefs_3__next__, /*tp_iternext*/
-  __pyx_methods_9csamtools_IteratorRowAllRefs, /*tp_methods*/
+  __pyx_pf_9csamtools_16IteratorSNPCalls___iter__, /*tp_iter*/
+  __pyx_pf_9csamtools_16IteratorSNPCalls___next__, /*tp_iternext*/
+  __pyx_methods_9csamtools_IteratorSNPCalls, /*tp_methods*/
   0, /*tp_members*/
   0, /*tp_getset*/
   0, /*tp_base*/
@@ -29861,7 +34399,7 @@ static PyTypeObject __pyx_type_9csamtools_IteratorRowAllRefs = {
   0, /*tp_dictoffset*/
   0, /*tp_init*/
   0, /*tp_alloc*/
-  __pyx_tp_new_9csamtools_IteratorRowAllRefs, /*tp_new*/
+  __pyx_tp_new_9csamtools_IteratorSNPCalls, /*tp_new*/
   0, /*tp_free*/
   0, /*tp_is_gc*/
   0, /*tp_bases*/
@@ -29874,66 +34412,26 @@ static PyTypeObject __pyx_type_9csamtools_IteratorRowAllRefs = {
   0, /*tp_version_tag*/
   #endif
 };
-static struct __pyx_vtabstruct_9csamtools_IteratorRowSelection __pyx_vtable_9csamtools_IteratorRowSelection;
+static struct __pyx_vtabstruct_9csamtools_SNPCaller __pyx_vtable_9csamtools_SNPCaller;
 
-static PyObject *__pyx_tp_new_9csamtools_IteratorRowSelection(PyTypeObject *t, PyObject *a, PyObject *k) {
-  struct __pyx_obj_9csamtools_IteratorRowSelection *p;
-  PyObject *o = __pyx_tp_new_9csamtools_IteratorRow(t, a, k);
+static PyObject *__pyx_tp_new_9csamtools_SNPCaller(PyTypeObject *t, PyObject *a, PyObject *k) {
+  struct __pyx_obj_9csamtools_SNPCaller *p;
+  PyObject *o = __pyx_tp_new_9csamtools_SNPCallerBase(t, a, k);
   if (!o) return 0;
-  p = ((struct __pyx_obj_9csamtools_IteratorRowSelection *)o);
-  p->__pyx_vtab = __pyx_vtabptr_9csamtools_IteratorRowSelection;
-  p->positions = Py_None; Py_INCREF(Py_None);
-  if (__pyx_pf_9csamtools_20IteratorRowSelection___cinit__(o, a, k) < 0) {
+  p = ((struct __pyx_obj_9csamtools_SNPCaller *)o);
+  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_9csamtools_SNPCallerBase*)__pyx_vtabptr_9csamtools_SNPCaller;
+  if (__pyx_pf_9csamtools_9SNPCaller___cinit__(o, a, k) < 0) {
     Py_DECREF(o); o = 0;
   }
   return o;
 }
 
-static void __pyx_tp_dealloc_9csamtools_IteratorRowSelection(PyObject *o) {
-  struct __pyx_obj_9csamtools_IteratorRowSelection *p = (struct __pyx_obj_9csamtools_IteratorRowSelection *)o;
-  {
-    PyObject *etype, *eval, *etb;
-    PyErr_Fetch(&etype, &eval, &etb);
-    ++Py_REFCNT(o);
-    __pyx_pf_9csamtools_20IteratorRowSelection_3__dealloc__(o);
-    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
-    --Py_REFCNT(o);
-    PyErr_Restore(etype, eval, etb);
-  }
-  Py_XDECREF(p->positions);
-  __pyx_tp_dealloc_9csamtools_IteratorRow(o);
-}
-
-static int __pyx_tp_traverse_9csamtools_IteratorRowSelection(PyObject *o, visitproc v, void *a) {
-  int e;
-  struct __pyx_obj_9csamtools_IteratorRowSelection *p = (struct __pyx_obj_9csamtools_IteratorRowSelection *)o;
-  if (__pyx_ptype_9csamtools_IteratorRow->tp_traverse) {
-    e = __pyx_ptype_9csamtools_IteratorRow->tp_traverse(o, v, a); if (e) return e;
-  }
-  if (p->positions) {
-    e = (*v)(p->positions, a); if (e) return e;
-  }
-  return 0;
-}
-
-static int __pyx_tp_clear_9csamtools_IteratorRowSelection(PyObject *o) {
-  struct __pyx_obj_9csamtools_IteratorRowSelection *p = (struct __pyx_obj_9csamtools_IteratorRowSelection *)o;
-  PyObject* tmp;
-  if (__pyx_ptype_9csamtools_IteratorRow->tp_clear) {
-    __pyx_ptype_9csamtools_IteratorRow->tp_clear(o);
-  }
-  tmp = ((PyObject*)p->positions);
-  p->positions = Py_None; Py_INCREF(Py_None);
-  Py_XDECREF(tmp);
-  return 0;
-}
-
-static PyMethodDef __pyx_methods_9csamtools_IteratorRowSelection[] = {
-  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_20IteratorRowSelection_2__next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_20IteratorRowSelection_2__next__)},
+static PyMethodDef __pyx_methods_9csamtools_SNPCaller[] = {
+  {__Pyx_NAMESTR("call"), (PyCFunction)__pyx_pf_9csamtools_9SNPCaller_call, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_9SNPCaller_call)},
   {0, 0, 0, 0}
 };
 
-static PyNumberMethods __pyx_tp_as_number_IteratorRowSelection = {
+static PyNumberMethods __pyx_tp_as_number_SNPCaller = {
   0, /*nb_add*/
   0, /*nb_subtract*/
   0, /*nb_multiply*/
@@ -29991,7 +34489,7 @@ static PyNumberMethods __pyx_tp_as_number_IteratorRowSelection = {
   #endif
 };
 
-static PySequenceMethods __pyx_tp_as_sequence_IteratorRowSelection = {
+static PySequenceMethods __pyx_tp_as_sequence_SNPCaller = {
   0, /*sq_length*/
   0, /*sq_concat*/
   0, /*sq_repeat*/
@@ -30004,13 +34502,13 @@ static PySequenceMethods __pyx_tp_as_sequence_IteratorRowSelection = {
   0, /*sq_inplace_repeat*/
 };
 
-static PyMappingMethods __pyx_tp_as_mapping_IteratorRowSelection = {
+static PyMappingMethods __pyx_tp_as_mapping_SNPCaller = {
   0, /*mp_length*/
   0, /*mp_subscript*/
   0, /*mp_ass_subscript*/
 };
 
-static PyBufferProcs __pyx_tp_as_buffer_IteratorRowSelection = {
+static PyBufferProcs __pyx_tp_as_buffer_SNPCaller = {
   #if PY_MAJOR_VERSION < 3
   0, /*bf_getreadbuffer*/
   #endif
@@ -30031,12 +34529,12 @@ static PyBufferProcs __pyx_tp_as_buffer_IteratorRowSelection = {
   #endif
 };
 
-static PyTypeObject __pyx_type_9csamtools_IteratorRowSelection = {
+PyTypeObject __pyx_type_9csamtools_SNPCaller = {
   PyVarObject_HEAD_INIT(0, 0)
-  __Pyx_NAMESTR("csamtools.IteratorRowSelection"), /*tp_name*/
-  sizeof(struct __pyx_obj_9csamtools_IteratorRowSelection), /*tp_basicsize*/
+  __Pyx_NAMESTR("csamtools.SNPCaller"), /*tp_name*/
+  sizeof(struct __pyx_obj_9csamtools_SNPCaller), /*tp_basicsize*/
   0, /*tp_itemsize*/
-  __pyx_tp_dealloc_9csamtools_IteratorRowSelection, /*tp_dealloc*/
+  __pyx_tp_dealloc_9csamtools_SNPCallerBase, /*tp_dealloc*/
   0, /*tp_print*/
   0, /*tp_getattr*/
   0, /*tp_setattr*/
@@ -30046,24 +34544,24 @@ static PyTypeObject __pyx_type_9csamtools_IteratorRowSelection = {
   0, /*reserved*/
   #endif
   0, /*tp_repr*/
-  &__pyx_tp_as_number_IteratorRowSelection, /*tp_as_number*/
-  &__pyx_tp_as_sequence_IteratorRowSelection, /*tp_as_sequence*/
-  &__pyx_tp_as_mapping_IteratorRowSelection, /*tp_as_mapping*/
+  &__pyx_tp_as_number_SNPCaller, /*tp_as_number*/
+  &__pyx_tp_as_sequence_SNPCaller, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_SNPCaller, /*tp_as_mapping*/
   0, /*tp_hash*/
   0, /*tp_call*/
   0, /*tp_str*/
   0, /*tp_getattro*/
   0, /*tp_setattro*/
-  &__pyx_tp_as_buffer_IteratorRowSelection, /*tp_as_buffer*/
-  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
-  __Pyx_DOCSTR("*(Samfile samfile)*\n\n    iterate over reads in *samfile* at a given list of file positions.\n    "), /*tp_doc*/
-  __pyx_tp_traverse_9csamtools_IteratorRowSelection, /*tp_traverse*/
-  __pyx_tp_clear_9csamtools_IteratorRowSelection, /*tp_clear*/
+  &__pyx_tp_as_buffer_SNPCaller, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  __Pyx_DOCSTR("*(IteratorColumn iterator_column )*\n\n    The samtools SNP caller.\n\n    This object will call SNPs in *samfile* against the reference\n    sequence in *fasta*.\n\n    This caller is fast for calling few SNPs in selected regions.\n\n    It is slow, if called over large genomic regions.\n    "), /*tp_doc*/
+  __pyx_tp_traverse_9csamtools_SNPCallerBase, /*tp_traverse*/
+  __pyx_tp_clear_9csamtools_SNPCallerBase, /*tp_clear*/
   0, /*tp_richcompare*/
   0, /*tp_weaklistoffset*/
-  __pyx_pf_9csamtools_20IteratorRowSelection_1__iter__, /*tp_iter*/
-  __pyx_pf_9csamtools_20IteratorRowSelection_2__next__, /*tp_iternext*/
-  __pyx_methods_9csamtools_IteratorRowSelection, /*tp_methods*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_9csamtools_SNPCaller, /*tp_methods*/
   0, /*tp_members*/
   0, /*tp_getset*/
   0, /*tp_base*/
@@ -30073,7 +34571,7 @@ static PyTypeObject __pyx_type_9csamtools_IteratorRowSelection = {
   0, /*tp_dictoffset*/
   0, /*tp_init*/
   0, /*tp_alloc*/
-  __pyx_tp_new_9csamtools_IteratorRowSelection, /*tp_new*/
+  __pyx_tp_new_9csamtools_SNPCaller, /*tp_new*/
   0, /*tp_free*/
   0, /*tp_is_gc*/
   0, /*tp_bases*/
@@ -30086,94 +34584,98 @@ static PyTypeObject __pyx_type_9csamtools_IteratorRowSelection = {
   0, /*tp_version_tag*/
   #endif
 };
-static struct __pyx_vtabstruct_9csamtools_IteratorColumn __pyx_vtable_9csamtools_IteratorColumn;
 
-static PyObject *__pyx_tp_new_9csamtools_IteratorColumn(PyTypeObject *t, PyObject *a, PyObject *k) {
-  struct __pyx_obj_9csamtools_IteratorColumn *p;
+static PyObject *__pyx_tp_new_9csamtools_IndelCall(PyTypeObject *t, PyObject *a, PyObject *k) {
   PyObject *o = (*t->tp_alloc)(t, 0);
   if (!o) return 0;
-  p = ((struct __pyx_obj_9csamtools_IteratorColumn *)o);
-  p->__pyx_vtab = __pyx_vtabptr_9csamtools_IteratorColumn;
-  p->iter = ((struct __pyx_obj_9csamtools_IteratorRowRegion *)Py_None); Py_INCREF(Py_None);
-  p->samfile = ((struct __pyx_obj_9csamtools_Samfile *)Py_None); Py_INCREF(Py_None);
-  p->fastafile = ((struct __pyx_obj_9csamtools_Fastafile *)Py_None); Py_INCREF(Py_None);
-  p->stepper = Py_None; Py_INCREF(Py_None);
-  if (__pyx_pf_9csamtools_14IteratorColumn___cinit__(o, a, k) < 0) {
+  if (__pyx_pf_9csamtools_9IndelCall___cinit__(o, __pyx_empty_tuple, NULL) < 0) {
     Py_DECREF(o); o = 0;
   }
   return o;
 }
 
-static void __pyx_tp_dealloc_9csamtools_IteratorColumn(PyObject *o) {
-  struct __pyx_obj_9csamtools_IteratorColumn *p = (struct __pyx_obj_9csamtools_IteratorColumn *)o;
+static void __pyx_tp_dealloc_9csamtools_IndelCall(PyObject *o) {
   {
     PyObject *etype, *eval, *etb;
     PyErr_Fetch(&etype, &eval, &etb);
     ++Py_REFCNT(o);
-    __pyx_pf_9csamtools_14IteratorColumn_4__dealloc__(o);
+    __pyx_pf_9csamtools_9IndelCall___dealloc__(o);
     if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
     --Py_REFCNT(o);
     PyErr_Restore(etype, eval, etb);
   }
-  Py_XDECREF(((PyObject *)p->iter));
-  Py_XDECREF(((PyObject *)p->samfile));
-  Py_XDECREF(((PyObject *)p->fastafile));
-  Py_XDECREF(p->stepper);
   (*Py_TYPE(o)->tp_free)(o);
 }
 
-static int __pyx_tp_traverse_9csamtools_IteratorColumn(PyObject *o, visitproc v, void *a) {
-  int e;
-  struct __pyx_obj_9csamtools_IteratorColumn *p = (struct __pyx_obj_9csamtools_IteratorColumn *)o;
-  if (p->iter) {
-    e = (*v)(((PyObject*)p->iter), a); if (e) return e;
-  }
-  if (p->samfile) {
-    e = (*v)(((PyObject*)p->samfile), a); if (e) return e;
-  }
-  if (p->fastafile) {
-    e = (*v)(((PyObject*)p->fastafile), a); if (e) return e;
-  }
-  if (p->stepper) {
-    e = (*v)(p->stepper, a); if (e) return e;
-  }
-  return 0;
+static PyObject *__pyx_getprop_9csamtools_9IndelCall_tid(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_9IndelCall_3tid___get__(o);
 }
 
-static int __pyx_tp_clear_9csamtools_IteratorColumn(PyObject *o) {
-  struct __pyx_obj_9csamtools_IteratorColumn *p = (struct __pyx_obj_9csamtools_IteratorColumn *)o;
-  PyObject* tmp;
-  tmp = ((PyObject*)p->iter);
-  p->iter = ((struct __pyx_obj_9csamtools_IteratorRowRegion *)Py_None); Py_INCREF(Py_None);
-  Py_XDECREF(tmp);
-  tmp = ((PyObject*)p->samfile);
-  p->samfile = ((struct __pyx_obj_9csamtools_Samfile *)Py_None); Py_INCREF(Py_None);
-  Py_XDECREF(tmp);
-  tmp = ((PyObject*)p->fastafile);
-  p->fastafile = ((struct __pyx_obj_9csamtools_Fastafile *)Py_None); Py_INCREF(Py_None);
-  Py_XDECREF(tmp);
-  tmp = ((PyObject*)p->stepper);
-  p->stepper = Py_None; Py_INCREF(Py_None);
-  Py_XDECREF(tmp);
-  return 0;
+static PyObject *__pyx_getprop_9csamtools_9IndelCall_pos(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_9IndelCall_3pos___get__(o);
 }
 
-static PyObject *__pyx_getprop_9csamtools_14IteratorColumn_seq_len(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_14IteratorColumn_7seq_len___get__(o);
+static PyObject *__pyx_getprop_9csamtools_9IndelCall_genotype(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_9IndelCall_8genotype___get__(o);
 }
 
-static PyMethodDef __pyx_methods_9csamtools_IteratorColumn[] = {
-  {__Pyx_NAMESTR("addReference"), (PyCFunction)__pyx_pf_9csamtools_14IteratorColumn_2addReference, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_14IteratorColumn_2addReference)},
-  {__Pyx_NAMESTR("hasReference"), (PyCFunction)__pyx_pf_9csamtools_14IteratorColumn_3hasReference, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_14IteratorColumn_3hasReference)},
+static PyObject *__pyx_getprop_9csamtools_9IndelCall_consensus_quality(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_9IndelCall_17consensus_quality___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_9IndelCall_snp_quality(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_9IndelCall_11snp_quality___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_9IndelCall_mapping_quality(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_9IndelCall_15mapping_quality___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_9IndelCall_coverage(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_9IndelCall_8coverage___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_9IndelCall_first_allele(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_9IndelCall_12first_allele___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_9IndelCall_second_allele(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_9IndelCall_13second_allele___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_9IndelCall_reads_first(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_9IndelCall_11reads_first___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_9IndelCall_reads_second(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_9IndelCall_12reads_second___get__(o);
+}
+
+static PyObject *__pyx_getprop_9csamtools_9IndelCall_reads_diff(PyObject *o, void *x) {
+  return __pyx_pf_9csamtools_9IndelCall_10reads_diff___get__(o);
+}
+
+static PyMethodDef __pyx_methods_9csamtools_IndelCall[] = {
   {0, 0, 0, 0}
 };
 
-static struct PyGetSetDef __pyx_getsets_9csamtools_IteratorColumn[] = {
-  {(char *)"seq_len", __pyx_getprop_9csamtools_14IteratorColumn_seq_len, 0, __Pyx_DOCSTR(__pyx_k_221), 0},
+static struct PyGetSetDef __pyx_getsets_9csamtools_IndelCall[] = {
+  {(char *)"tid", __pyx_getprop_9csamtools_9IndelCall_tid, 0, __Pyx_DOCSTR(__pyx_k_154), 0},
+  {(char *)"pos", __pyx_getprop_9csamtools_9IndelCall_pos, 0, __Pyx_DOCSTR(__pyx_k_162), 0},
+  {(char *)"genotype", __pyx_getprop_9csamtools_9IndelCall_genotype, 0, __Pyx_DOCSTR(__pyx_k_164), 0},
+  {(char *)"consensus_quality", __pyx_getprop_9csamtools_9IndelCall_consensus_quality, 0, __Pyx_DOCSTR(__pyx_k_165), 0},
+  {(char *)"snp_quality", __pyx_getprop_9csamtools_9IndelCall_snp_quality, 0, __Pyx_DOCSTR(__pyx_k_166), 0},
+  {(char *)"mapping_quality", __pyx_getprop_9csamtools_9IndelCall_mapping_quality, 0, __Pyx_DOCSTR(__pyx_k_167), 0},
+  {(char *)"coverage", __pyx_getprop_9csamtools_9IndelCall_coverage, 0, __Pyx_DOCSTR(__pyx_k_168), 0},
+  {(char *)"first_allele", __pyx_getprop_9csamtools_9IndelCall_first_allele, 0, __Pyx_DOCSTR(__pyx_k_169), 0},
+  {(char *)"second_allele", __pyx_getprop_9csamtools_9IndelCall_second_allele, 0, __Pyx_DOCSTR(__pyx_k_170), 0},
+  {(char *)"reads_first", __pyx_getprop_9csamtools_9IndelCall_reads_first, 0, __Pyx_DOCSTR(__pyx_k_171), 0},
+  {(char *)"reads_second", __pyx_getprop_9csamtools_9IndelCall_reads_second, 0, __Pyx_DOCSTR(__pyx_k_171), 0},
+  {(char *)"reads_diff", __pyx_getprop_9csamtools_9IndelCall_reads_diff, 0, __Pyx_DOCSTR(__pyx_k_171), 0},
   {0, 0, 0, 0, 0}
 };
 
-static PyNumberMethods __pyx_tp_as_number_IteratorColumn = {
+static PyNumberMethods __pyx_tp_as_number_IndelCall = {
   0, /*nb_add*/
   0, /*nb_subtract*/
   0, /*nb_multiply*/
@@ -30231,7 +34733,7 @@ static PyNumberMethods __pyx_tp_as_number_IteratorColumn = {
   #endif
 };
 
-static PySequenceMethods __pyx_tp_as_sequence_IteratorColumn = {
+static PySequenceMethods __pyx_tp_as_sequence_IndelCall = {
   0, /*sq_length*/
   0, /*sq_concat*/
   0, /*sq_repeat*/
@@ -30244,13 +34746,13 @@ static PySequenceMethods __pyx_tp_as_sequence_IteratorColumn = {
   0, /*sq_inplace_repeat*/
 };
 
-static PyMappingMethods __pyx_tp_as_mapping_IteratorColumn = {
+static PyMappingMethods __pyx_tp_as_mapping_IndelCall = {
   0, /*mp_length*/
   0, /*mp_subscript*/
   0, /*mp_ass_subscript*/
 };
 
-static PyBufferProcs __pyx_tp_as_buffer_IteratorColumn = {
+static PyBufferProcs __pyx_tp_as_buffer_IndelCall = {
   #if PY_MAJOR_VERSION < 3
   0, /*bf_getreadbuffer*/
   #endif
@@ -30271,12 +34773,12 @@ static PyBufferProcs __pyx_tp_as_buffer_IteratorColumn = {
   #endif
 };
 
-static PyTypeObject __pyx_type_9csamtools_IteratorColumn = {
+PyTypeObject __pyx_type_9csamtools_IndelCall = {
   PyVarObject_HEAD_INIT(0, 0)
-  __Pyx_NAMESTR("csamtools.IteratorColumn"), /*tp_name*/
-  sizeof(struct __pyx_obj_9csamtools_IteratorColumn), /*tp_basicsize*/
+  __Pyx_NAMESTR("csamtools.IndelCall"), /*tp_name*/
+  sizeof(struct __pyx_obj_9csamtools_IndelCall), /*tp_basicsize*/
   0, /*tp_itemsize*/
-  __pyx_tp_dealloc_9csamtools_IteratorColumn, /*tp_dealloc*/
+  __pyx_tp_dealloc_9csamtools_IndelCall, /*tp_dealloc*/
   0, /*tp_print*/
   0, /*tp_getattr*/
   0, /*tp_setattr*/
@@ -30286,26 +34788,26 @@ static PyTypeObject __pyx_type_9csamtools_IteratorColumn = {
   0, /*reserved*/
   #endif
   0, /*tp_repr*/
-  &__pyx_tp_as_number_IteratorColumn, /*tp_as_number*/
-  &__pyx_tp_as_sequence_IteratorColumn, /*tp_as_sequence*/
-  &__pyx_tp_as_mapping_IteratorColumn, /*tp_as_mapping*/
+  &__pyx_tp_as_number_IndelCall, /*tp_as_number*/
+  &__pyx_tp_as_sequence_IndelCall, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_IndelCall, /*tp_as_mapping*/
   0, /*tp_hash*/
   0, /*tp_call*/
-  0, /*tp_str*/
+  __pyx_pf_9csamtools_9IndelCall___str__, /*tp_str*/
   0, /*tp_getattro*/
   0, /*tp_setattro*/
-  &__pyx_tp_as_buffer_IteratorColumn, /*tp_as_buffer*/
-  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
-  __Pyx_DOCSTR("abstract base class for iterators over columns.\n\n    IteratorColumn objects wrap the pileup functionality of samtools.\n    \n    For reasons of efficiency, the iterator points to the current \n    pileup buffer. The pileup buffer is updated at every iteration.\n    This might cause some unexpected behavious. For example,\n    consider the conversion to a list::\n    \n       f = Samfile(\"file.bam\", \"rb\")\n       result = list( f.pileup() )\n\n    Here, ``result`` will contain ``n`` objects of type :class:`PileupProxy` for ``n`` columns, \n    but each object in ``result`` will contain the same information.\n    \n    The desired behaviour can be achieved by list comprehension::\n\n       result = [ x.pileups() for x in f.pileup() ]\n\n    ``result`` will be a list of ``n`` lists of objects of type :class:`PileupRead`.\n\n    If the iterator is associated with a :class:`Fastafile` using the :meth:`addReference`\n    method, then the iterator will export the current sequence via the methods :meth:`getSequence`\n    and :meth:`seq_len`.\n\n    Optional kwargs to the iterator\n\n    stepper\n       The stepper controlls how the iterator advances. \n       Possible options for the stepper are \n       \n       all\n           use all reads for pileup.\n       samtools\n           same filter and read processing as in :term:`csamtools` pileup\n    fastafile\n       A :class:`FastaFile` object\n    mask\n       Skip all reads with bits set in mask.\n    max_depth\n       maximum read depth. The default is 8000.\n    "), /*tp_doc*/
-  __pyx_tp_traverse_9csamtools_IteratorColumn, /*tp_traverse*/
-  __pyx_tp_clear_9csamtools_IteratorColumn, /*tp_clear*/
+  &__pyx_tp_as_buffer_IndelCall, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
+  __Pyx_DOCSTR("the results of an indel call."), /*tp_doc*/
+  0, /*tp_traverse*/
+  0, /*tp_clear*/
   0, /*tp_richcompare*/
   0, /*tp_weaklistoffset*/
-  __pyx_pf_9csamtools_14IteratorColumn_1__iter__, /*tp_iter*/
+  0, /*tp_iter*/
   0, /*tp_iternext*/
-  __pyx_methods_9csamtools_IteratorColumn, /*tp_methods*/
+  __pyx_methods_9csamtools_IndelCall, /*tp_methods*/
   0, /*tp_members*/
-  __pyx_getsets_9csamtools_IteratorColumn, /*tp_getset*/
+  __pyx_getsets_9csamtools_IndelCall, /*tp_getset*/
   0, /*tp_base*/
   0, /*tp_dict*/
   0, /*tp_descr_get*/
@@ -30313,7 +34815,7 @@ static PyTypeObject __pyx_type_9csamtools_IteratorColumn = {
   0, /*tp_dictoffset*/
   0, /*tp_init*/
   0, /*tp_alloc*/
-  __pyx_tp_new_9csamtools_IteratorColumn, /*tp_new*/
+  __pyx_tp_new_9csamtools_IndelCall, /*tp_new*/
   0, /*tp_free*/
   0, /*tp_is_gc*/
   0, /*tp_bases*/
@@ -30326,26 +34828,58 @@ static PyTypeObject __pyx_type_9csamtools_IteratorColumn = {
   0, /*tp_version_tag*/
   #endif
 };
-static struct __pyx_vtabstruct_9csamtools_IteratorColumnRegion __pyx_vtable_9csamtools_IteratorColumnRegion;
 
-static PyObject *__pyx_tp_new_9csamtools_IteratorColumnRegion(PyTypeObject *t, PyObject *a, PyObject *k) {
-  struct __pyx_obj_9csamtools_IteratorColumnRegion *p;
-  PyObject *o = __pyx_tp_new_9csamtools_IteratorColumn(t, a, k);
+static PyObject *__pyx_tp_new_9csamtools_IndelCallerBase(PyTypeObject *t, PyObject *a, PyObject *k) {
+  struct __pyx_obj_9csamtools_IndelCallerBase *p;
+  PyObject *o = (*t->tp_alloc)(t, 0);
   if (!o) return 0;
-  p = ((struct __pyx_obj_9csamtools_IteratorColumnRegion *)o);
-  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_9csamtools_IteratorColumn*)__pyx_vtabptr_9csamtools_IteratorColumnRegion;
-  if (__pyx_pf_9csamtools_20IteratorColumnRegion___cinit__(o, a, k) < 0) {
+  p = ((struct __pyx_obj_9csamtools_IndelCallerBase *)o);
+  p->iter = ((struct __pyx_obj_9csamtools_IteratorColumn *)Py_None); Py_INCREF(Py_None);
+  if (__pyx_pf_9csamtools_15IndelCallerBase___cinit__(o, a, k) < 0) {
     Py_DECREF(o); o = 0;
   }
   return o;
 }
 
-static PyMethodDef __pyx_methods_9csamtools_IteratorColumnRegion[] = {
-  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_20IteratorColumnRegion_1__next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_20IteratorColumnRegion_1__next__)},
+static void __pyx_tp_dealloc_9csamtools_IndelCallerBase(PyObject *o) {
+  struct __pyx_obj_9csamtools_IndelCallerBase *p = (struct __pyx_obj_9csamtools_IndelCallerBase *)o;
+  {
+    PyObject *etype, *eval, *etb;
+    PyErr_Fetch(&etype, &eval, &etb);
+    ++Py_REFCNT(o);
+    __pyx_pf_9csamtools_15IndelCallerBase___dealloc__(o);
+    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
+    --Py_REFCNT(o);
+    PyErr_Restore(etype, eval, etb);
+  }
+  Py_XDECREF(((PyObject *)p->iter));
+  (*Py_TYPE(o)->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_9csamtools_IndelCallerBase(PyObject *o, visitproc v, void *a) {
+  int e;
+  struct __pyx_obj_9csamtools_IndelCallerBase *p = (struct __pyx_obj_9csamtools_IndelCallerBase *)o;
+  if (p->iter) {
+    e = (*v)(((PyObject*)p->iter), a); if (e) return e;
+  }
+  return 0;
+}
+
+static int __pyx_tp_clear_9csamtools_IndelCallerBase(PyObject *o) {
+  struct __pyx_obj_9csamtools_IndelCallerBase *p = (struct __pyx_obj_9csamtools_IndelCallerBase *)o;
+  PyObject* tmp;
+  tmp = ((PyObject*)p->iter);
+  p->iter = ((struct __pyx_obj_9csamtools_IteratorColumn *)Py_None); Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  return 0;
+}
+
+static PyMethodDef __pyx_methods_9csamtools_IndelCallerBase[] = {
+  {__Pyx_NAMESTR("_call"), (PyCFunction)__pyx_pf_9csamtools_15IndelCallerBase__call, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_15IndelCallerBase__call)},
   {0, 0, 0, 0}
 };
 
-static PyNumberMethods __pyx_tp_as_number_IteratorColumnRegion = {
+static PyNumberMethods __pyx_tp_as_number_IndelCallerBase = {
   0, /*nb_add*/
   0, /*nb_subtract*/
   0, /*nb_multiply*/
@@ -30403,7 +34937,7 @@ static PyNumberMethods __pyx_tp_as_number_IteratorColumnRegion = {
   #endif
 };
 
-static PySequenceMethods __pyx_tp_as_sequence_IteratorColumnRegion = {
+static PySequenceMethods __pyx_tp_as_sequence_IndelCallerBase = {
   0, /*sq_length*/
   0, /*sq_concat*/
   0, /*sq_repeat*/
@@ -30416,13 +34950,13 @@ static PySequenceMethods __pyx_tp_as_sequence_IteratorColumnRegion = {
   0, /*sq_inplace_repeat*/
 };
 
-static PyMappingMethods __pyx_tp_as_mapping_IteratorColumnRegion = {
+static PyMappingMethods __pyx_tp_as_mapping_IndelCallerBase = {
   0, /*mp_length*/
   0, /*mp_subscript*/
   0, /*mp_ass_subscript*/
 };
 
-static PyBufferProcs __pyx_tp_as_buffer_IteratorColumnRegion = {
+static PyBufferProcs __pyx_tp_as_buffer_IndelCallerBase = {
   #if PY_MAJOR_VERSION < 3
   0, /*bf_getreadbuffer*/
   #endif
@@ -30443,12 +34977,12 @@ static PyBufferProcs __pyx_tp_as_buffer_IteratorColumnRegion = {
   #endif
 };
 
-static PyTypeObject __pyx_type_9csamtools_IteratorColumnRegion = {
+PyTypeObject __pyx_type_9csamtools_IndelCallerBase = {
   PyVarObject_HEAD_INIT(0, 0)
-  __Pyx_NAMESTR("csamtools.IteratorColumnRegion"), /*tp_name*/
-  sizeof(struct __pyx_obj_9csamtools_IteratorColumnRegion), /*tp_basicsize*/
+  __Pyx_NAMESTR("csamtools.IndelCallerBase"), /*tp_name*/
+  sizeof(struct __pyx_obj_9csamtools_IndelCallerBase), /*tp_basicsize*/
   0, /*tp_itemsize*/
-  __pyx_tp_dealloc_9csamtools_IteratorColumn, /*tp_dealloc*/
+  __pyx_tp_dealloc_9csamtools_IndelCallerBase, /*tp_dealloc*/
   0, /*tp_print*/
   0, /*tp_getattr*/
   0, /*tp_setattr*/
@@ -30458,24 +34992,24 @@ static PyTypeObject __pyx_type_9csamtools_IteratorColumnRegion = {
   0, /*reserved*/
   #endif
   0, /*tp_repr*/
-  &__pyx_tp_as_number_IteratorColumnRegion, /*tp_as_number*/
-  &__pyx_tp_as_sequence_IteratorColumnRegion, /*tp_as_sequence*/
-  &__pyx_tp_as_mapping_IteratorColumnRegion, /*tp_as_mapping*/
+  &__pyx_tp_as_number_IndelCallerBase, /*tp_as_number*/
+  &__pyx_tp_as_sequence_IndelCallerBase, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_IndelCallerBase, /*tp_as_mapping*/
   0, /*tp_hash*/
   0, /*tp_call*/
   0, /*tp_str*/
   0, /*tp_getattro*/
   0, /*tp_setattro*/
-  &__pyx_tp_as_buffer_IteratorColumnRegion, /*tp_as_buffer*/
-  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
-  __Pyx_DOCSTR("iterates over a region only.\n    "), /*tp_doc*/
-  __pyx_tp_traverse_9csamtools_IteratorColumn, /*tp_traverse*/
-  __pyx_tp_clear_9csamtools_IteratorColumn, /*tp_clear*/
+  &__pyx_tp_as_buffer_IndelCallerBase, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  __Pyx_DOCSTR("Base class for SNP callers.\n\n    *min_baseQ*\n       minimum base quality (possibly capped by BAQ)\n    *capQ_threshold*\n       coefficient for adjusting mapQ of poor mappings\n    *theta*\n       theta in maq consensus calling model\n    *n_haplotypes*\n       number of haplotypes in the sample\n    *het_rate*\n       prior of a difference between two haplotypes\n    "), /*tp_doc*/
+  __pyx_tp_traverse_9csamtools_IndelCallerBase, /*tp_traverse*/
+  __pyx_tp_clear_9csamtools_IndelCallerBase, /*tp_clear*/
   0, /*tp_richcompare*/
   0, /*tp_weaklistoffset*/
   0, /*tp_iter*/
-  __pyx_pf_9csamtools_20IteratorColumnRegion_1__next__, /*tp_iternext*/
-  __pyx_methods_9csamtools_IteratorColumnRegion, /*tp_methods*/
+  0, /*tp_iternext*/
+  __pyx_methods_9csamtools_IndelCallerBase, /*tp_methods*/
   0, /*tp_members*/
   0, /*tp_getset*/
   0, /*tp_base*/
@@ -30485,7 +35019,7 @@ static PyTypeObject __pyx_type_9csamtools_IteratorColumnRegion = {
   0, /*tp_dictoffset*/
   0, /*tp_init*/
   0, /*tp_alloc*/
-  __pyx_tp_new_9csamtools_IteratorColumnRegion, /*tp_new*/
+  __pyx_tp_new_9csamtools_IndelCallerBase, /*tp_new*/
   0, /*tp_free*/
   0, /*tp_is_gc*/
   0, /*tp_bases*/
@@ -30498,26 +35032,22 @@ static PyTypeObject __pyx_type_9csamtools_IteratorColumnRegion = {
   0, /*tp_version_tag*/
   #endif
 };
-static struct __pyx_vtabstruct_9csamtools_IteratorColumnAllRefs __pyx_vtable_9csamtools_IteratorColumnAllRefs;
 
-static PyObject *__pyx_tp_new_9csamtools_IteratorColumnAllRefs(PyTypeObject *t, PyObject *a, PyObject *k) {
-  struct __pyx_obj_9csamtools_IteratorColumnAllRefs *p;
-  PyObject *o = __pyx_tp_new_9csamtools_IteratorColumn(t, a, k);
+static PyObject *__pyx_tp_new_9csamtools_IndelCaller(PyTypeObject *t, PyObject *a, PyObject *k) {
+  PyObject *o = __pyx_tp_new_9csamtools_IndelCallerBase(t, a, k);
   if (!o) return 0;
-  p = ((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)o);
-  p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_9csamtools_IteratorColumn*)__pyx_vtabptr_9csamtools_IteratorColumnAllRefs;
-  if (__pyx_pf_9csamtools_21IteratorColumnAllRefs___cinit__(o, a, k) < 0) {
+  if (__pyx_pf_9csamtools_11IndelCaller___cinit__(o, a, k) < 0) {
     Py_DECREF(o); o = 0;
   }
   return o;
 }
 
-static PyMethodDef __pyx_methods_9csamtools_IteratorColumnAllRefs[] = {
-  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_21IteratorColumnAllRefs_1__next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_21IteratorColumnAllRefs_1__next__)},
+static PyMethodDef __pyx_methods_9csamtools_IndelCaller[] = {
+  {__Pyx_NAMESTR("call"), (PyCFunction)__pyx_pf_9csamtools_11IndelCaller_call, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_11IndelCaller_call)},
   {0, 0, 0, 0}
 };
 
-static PyNumberMethods __pyx_tp_as_number_IteratorColumnAllRefs = {
+static PyNumberMethods __pyx_tp_as_number_IndelCaller = {
   0, /*nb_add*/
   0, /*nb_subtract*/
   0, /*nb_multiply*/
@@ -30575,7 +35105,7 @@ static PyNumberMethods __pyx_tp_as_number_IteratorColumnAllRefs = {
   #endif
 };
 
-static PySequenceMethods __pyx_tp_as_sequence_IteratorColumnAllRefs = {
+static PySequenceMethods __pyx_tp_as_sequence_IndelCaller = {
   0, /*sq_length*/
   0, /*sq_concat*/
   0, /*sq_repeat*/
@@ -30588,13 +35118,13 @@ static PySequenceMethods __pyx_tp_as_sequence_IteratorColumnAllRefs = {
   0, /*sq_inplace_repeat*/
 };
 
-static PyMappingMethods __pyx_tp_as_mapping_IteratorColumnAllRefs = {
+static PyMappingMethods __pyx_tp_as_mapping_IndelCaller = {
   0, /*mp_length*/
   0, /*mp_subscript*/
   0, /*mp_ass_subscript*/
 };
 
-static PyBufferProcs __pyx_tp_as_buffer_IteratorColumnAllRefs = {
+static PyBufferProcs __pyx_tp_as_buffer_IndelCaller = {
   #if PY_MAJOR_VERSION < 3
   0, /*bf_getreadbuffer*/
   #endif
@@ -30615,12 +35145,12 @@ static PyBufferProcs __pyx_tp_as_buffer_IteratorColumnAllRefs = {
   #endif
 };
 
-static PyTypeObject __pyx_type_9csamtools_IteratorColumnAllRefs = {
+PyTypeObject __pyx_type_9csamtools_IndelCaller = {
   PyVarObject_HEAD_INIT(0, 0)
-  __Pyx_NAMESTR("csamtools.IteratorColumnAllRefs"), /*tp_name*/
-  sizeof(struct __pyx_obj_9csamtools_IteratorColumnAllRefs), /*tp_basicsize*/
+  __Pyx_NAMESTR("csamtools.IndelCaller"), /*tp_name*/
+  sizeof(struct __pyx_obj_9csamtools_IndelCaller), /*tp_basicsize*/
   0, /*tp_itemsize*/
-  __pyx_tp_dealloc_9csamtools_IteratorColumn, /*tp_dealloc*/
+  __pyx_tp_dealloc_9csamtools_IndelCallerBase, /*tp_dealloc*/
   0, /*tp_print*/
   0, /*tp_getattr*/
   0, /*tp_setattr*/
@@ -30630,24 +35160,24 @@ static PyTypeObject __pyx_type_9csamtools_IteratorColumnAllRefs = {
   0, /*reserved*/
   #endif
   0, /*tp_repr*/
-  &__pyx_tp_as_number_IteratorColumnAllRefs, /*tp_as_number*/
-  &__pyx_tp_as_sequence_IteratorColumnAllRefs, /*tp_as_sequence*/
-  &__pyx_tp_as_mapping_IteratorColumnAllRefs, /*tp_as_mapping*/
+  &__pyx_tp_as_number_IndelCaller, /*tp_as_number*/
+  &__pyx_tp_as_sequence_IndelCaller, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_IndelCaller, /*tp_as_mapping*/
   0, /*tp_hash*/
   0, /*tp_call*/
   0, /*tp_str*/
   0, /*tp_getattro*/
   0, /*tp_setattro*/
-  &__pyx_tp_as_buffer_IteratorColumnAllRefs, /*tp_as_buffer*/
-  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
-  __Pyx_DOCSTR("iterates over all columns by chaining iterators over each reference\n    "), /*tp_doc*/
-  __pyx_tp_traverse_9csamtools_IteratorColumn, /*tp_traverse*/
-  __pyx_tp_clear_9csamtools_IteratorColumn, /*tp_clear*/
+  &__pyx_tp_as_buffer_IndelCaller, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  __Pyx_DOCSTR("*(IteratorColumn iterator_column )*\n\n    The samtools SNP caller.\n\n    This object will call SNPs in *samfile* against the reference\n    sequence in *fasta*.\n\n    This caller is fast for calling few SNPs in selected regions.\n\n    It is slow, if called over large genomic regions.\n    "), /*tp_doc*/
+  __pyx_tp_traverse_9csamtools_IndelCallerBase, /*tp_traverse*/
+  __pyx_tp_clear_9csamtools_IndelCallerBase, /*tp_clear*/
   0, /*tp_richcompare*/
   0, /*tp_weaklistoffset*/
   0, /*tp_iter*/
-  __pyx_pf_9csamtools_21IteratorColumnAllRefs_1__next__, /*tp_iternext*/
-  __pyx_methods_9csamtools_IteratorColumnAllRefs, /*tp_methods*/
+  0, /*tp_iternext*/
+  __pyx_methods_9csamtools_IndelCaller, /*tp_methods*/
   0, /*tp_members*/
   0, /*tp_getset*/
   0, /*tp_base*/
@@ -30657,7 +35187,7 @@ static PyTypeObject __pyx_type_9csamtools_IteratorColumnAllRefs = {
   0, /*tp_dictoffset*/
   0, /*tp_init*/
   0, /*tp_alloc*/
-  __pyx_tp_new_9csamtools_IteratorColumnAllRefs, /*tp_new*/
+  __pyx_tp_new_9csamtools_IndelCaller, /*tp_new*/
   0, /*tp_free*/
   0, /*tp_is_gc*/
   0, /*tp_bases*/
@@ -30671,65 +35201,21 @@ static PyTypeObject __pyx_type_9csamtools_IteratorColumnAllRefs = {
   #endif
 };
 
-static PyObject *__pyx_tp_new_9csamtools_SNPCall(PyTypeObject *t, PyObject *a, PyObject *k) {
-  PyObject *o = (*t->tp_alloc)(t, 0);
+static PyObject *__pyx_tp_new_9csamtools_IteratorIndelCalls(PyTypeObject *t, PyObject *a, PyObject *k) {
+  PyObject *o = __pyx_tp_new_9csamtools_IndelCallerBase(t, a, k);
   if (!o) return 0;
+  if (__pyx_pf_9csamtools_18IteratorIndelCalls___cinit__(o, a, k) < 0) {
+    Py_DECREF(o); o = 0;
+  }
   return o;
 }
 
-static void __pyx_tp_dealloc_9csamtools_SNPCall(PyObject *o) {
-  (*Py_TYPE(o)->tp_free)(o);
-}
-
-static PyObject *__pyx_getprop_9csamtools_7SNPCall_tid(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_7SNPCall_3tid___get__(o);
-}
-
-static PyObject *__pyx_getprop_9csamtools_7SNPCall_pos(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_7SNPCall_3pos___get__(o);
-}
-
-static PyObject *__pyx_getprop_9csamtools_7SNPCall_reference_base(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_7SNPCall_14reference_base___get__(o);
-}
-
-static PyObject *__pyx_getprop_9csamtools_7SNPCall_genotype(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_7SNPCall_8genotype___get__(o);
-}
-
-static PyObject *__pyx_getprop_9csamtools_7SNPCall_consensus_quality(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_7SNPCall_17consensus_quality___get__(o);
-}
-
-static PyObject *__pyx_getprop_9csamtools_7SNPCall_snp_quality(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_7SNPCall_11snp_quality___get__(o);
-}
-
-static PyObject *__pyx_getprop_9csamtools_7SNPCall_mapping_quality(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_7SNPCall_15mapping_quality___get__(o);
-}
-
-static PyObject *__pyx_getprop_9csamtools_7SNPCall_coverage(PyObject *o, void *x) {
-  return __pyx_pf_9csamtools_7SNPCall_8coverage___get__(o);
-}
-
-static PyMethodDef __pyx_methods_9csamtools_SNPCall[] = {
+static PyMethodDef __pyx_methods_9csamtools_IteratorIndelCalls[] = {
+  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_18IteratorIndelCalls___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_18IteratorIndelCalls___next__)},
   {0, 0, 0, 0}
 };
 
-static struct PyGetSetDef __pyx_getsets_9csamtools_SNPCall[] = {
-  {(char *)"tid", __pyx_getprop_9csamtools_7SNPCall_tid, 0, __Pyx_DOCSTR(__pyx_k_214), 0},
-  {(char *)"pos", __pyx_getprop_9csamtools_7SNPCall_pos, 0, __Pyx_DOCSTR(__pyx_k_222), 0},
-  {(char *)"reference_base", __pyx_getprop_9csamtools_7SNPCall_reference_base, 0, __Pyx_DOCSTR(__pyx_k_223), 0},
-  {(char *)"genotype", __pyx_getprop_9csamtools_7SNPCall_genotype, 0, __Pyx_DOCSTR(__pyx_k_224), 0},
-  {(char *)"consensus_quality", __pyx_getprop_9csamtools_7SNPCall_consensus_quality, 0, __Pyx_DOCSTR(__pyx_k_225), 0},
-  {(char *)"snp_quality", __pyx_getprop_9csamtools_7SNPCall_snp_quality, 0, __Pyx_DOCSTR(__pyx_k_226), 0},
-  {(char *)"mapping_quality", __pyx_getprop_9csamtools_7SNPCall_mapping_quality, 0, __Pyx_DOCSTR(__pyx_k_227), 0},
-  {(char *)"coverage", __pyx_getprop_9csamtools_7SNPCall_coverage, 0, __Pyx_DOCSTR(__pyx_k_228), 0},
-  {0, 0, 0, 0, 0}
-};
-
-static PyNumberMethods __pyx_tp_as_number_SNPCall = {
+static PyNumberMethods __pyx_tp_as_number_IteratorIndelCalls = {
   0, /*nb_add*/
   0, /*nb_subtract*/
   0, /*nb_multiply*/
@@ -30787,7 +35273,7 @@ static PyNumberMethods __pyx_tp_as_number_SNPCall = {
   #endif
 };
 
-static PySequenceMethods __pyx_tp_as_sequence_SNPCall = {
+static PySequenceMethods __pyx_tp_as_sequence_IteratorIndelCalls = {
   0, /*sq_length*/
   0, /*sq_concat*/
   0, /*sq_repeat*/
@@ -30800,13 +35286,13 @@ static PySequenceMethods __pyx_tp_as_sequence_SNPCall = {
   0, /*sq_inplace_repeat*/
 };
 
-static PyMappingMethods __pyx_tp_as_mapping_SNPCall = {
+static PyMappingMethods __pyx_tp_as_mapping_IteratorIndelCalls = {
   0, /*mp_length*/
   0, /*mp_subscript*/
   0, /*mp_ass_subscript*/
 };
 
-static PyBufferProcs __pyx_tp_as_buffer_SNPCall = {
+static PyBufferProcs __pyx_tp_as_buffer_IteratorIndelCalls = {
   #if PY_MAJOR_VERSION < 3
   0, /*bf_getreadbuffer*/
   #endif
@@ -30827,12 +35313,12 @@ static PyBufferProcs __pyx_tp_as_buffer_SNPCall = {
   #endif
 };
 
-static PyTypeObject __pyx_type_9csamtools_SNPCall = {
+PyTypeObject __pyx_type_9csamtools_IteratorIndelCalls = {
   PyVarObject_HEAD_INIT(0, 0)
-  __Pyx_NAMESTR("csamtools.SNPCall"), /*tp_name*/
-  sizeof(struct __pyx_obj_9csamtools_SNPCall), /*tp_basicsize*/
+  __Pyx_NAMESTR("csamtools.IteratorIndelCalls"), /*tp_name*/
+  sizeof(struct __pyx_obj_9csamtools_IteratorIndelCalls), /*tp_basicsize*/
   0, /*tp_itemsize*/
-  __pyx_tp_dealloc_9csamtools_SNPCall, /*tp_dealloc*/
+  __pyx_tp_dealloc_9csamtools_IndelCallerBase, /*tp_dealloc*/
   0, /*tp_print*/
   0, /*tp_getattr*/
   0, /*tp_setattr*/
@@ -30842,26 +35328,26 @@ static PyTypeObject __pyx_type_9csamtools_SNPCall = {
   0, /*reserved*/
   #endif
   0, /*tp_repr*/
-  &__pyx_tp_as_number_SNPCall, /*tp_as_number*/
-  &__pyx_tp_as_sequence_SNPCall, /*tp_as_sequence*/
-  &__pyx_tp_as_mapping_SNPCall, /*tp_as_mapping*/
+  &__pyx_tp_as_number_IteratorIndelCalls, /*tp_as_number*/
+  &__pyx_tp_as_sequence_IteratorIndelCalls, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_IteratorIndelCalls, /*tp_as_mapping*/
   0, /*tp_hash*/
   0, /*tp_call*/
-  __pyx_pf_9csamtools_7SNPCall___str__, /*tp_str*/
+  0, /*tp_str*/
   0, /*tp_getattro*/
   0, /*tp_setattro*/
-  &__pyx_tp_as_buffer_SNPCall, /*tp_as_buffer*/
-  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
-  __Pyx_DOCSTR("the results of a SNP call."), /*tp_doc*/
-  0, /*tp_traverse*/
-  0, /*tp_clear*/
+  &__pyx_tp_as_buffer_IteratorIndelCalls, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  __Pyx_DOCSTR("*(IteratorColumn iterator)*\n\n    call indels within a region.\n\n    *iterator* is a pileup iterator. SNPs will be called\n    on all positions returned by this iterator.\n\n    This caller is fast if SNPs are called over large continuous\n    regions. It is slow, if instantiated frequently and in random\n    order as the sequence will have to be reloaded.\n\n    "), /*tp_doc*/
+  __pyx_tp_traverse_9csamtools_IndelCallerBase, /*tp_traverse*/
+  __pyx_tp_clear_9csamtools_IndelCallerBase, /*tp_clear*/
   0, /*tp_richcompare*/
   0, /*tp_weaklistoffset*/
-  0, /*tp_iter*/
-  0, /*tp_iternext*/
-  __pyx_methods_9csamtools_SNPCall, /*tp_methods*/
+  __pyx_pf_9csamtools_18IteratorIndelCalls___iter__, /*tp_iter*/
+  __pyx_pf_9csamtools_18IteratorIndelCalls___next__, /*tp_iternext*/
+  __pyx_methods_9csamtools_IteratorIndelCalls, /*tp_methods*/
   0, /*tp_members*/
-  __pyx_getsets_9csamtools_SNPCall, /*tp_getset*/
+  0, /*tp_getset*/
   0, /*tp_base*/
   0, /*tp_dict*/
   0, /*tp_descr_get*/
@@ -30869,7 +35355,7 @@ static PyTypeObject __pyx_type_9csamtools_SNPCall = {
   0, /*tp_dictoffset*/
   0, /*tp_init*/
   0, /*tp_alloc*/
-  __pyx_tp_new_9csamtools_SNPCall, /*tp_new*/
+  __pyx_tp_new_9csamtools_IteratorIndelCalls, /*tp_new*/
   0, /*tp_free*/
   0, /*tp_is_gc*/
   0, /*tp_bases*/
@@ -30899,7 +35385,7 @@ static void __pyx_tp_dealloc_9csamtools_IndexedReads(PyObject *o) {
     PyObject *etype, *eval, *etb;
     PyErr_Fetch(&etype, &eval, &etb);
     ++Py_REFCNT(o);
-    __pyx_pf_9csamtools_12IndexedReads_3__dealloc__(o);
+    __pyx_pf_9csamtools_12IndexedReads___dealloc__(o);
     if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
     --Py_REFCNT(o);
     PyErr_Restore(etype, eval, etb);
@@ -30934,8 +35420,8 @@ static int __pyx_tp_clear_9csamtools_IndexedReads(PyObject *o) {
 }
 
 static PyMethodDef __pyx_methods_9csamtools_IndexedReads[] = {
-  {__Pyx_NAMESTR("build"), (PyCFunction)__pyx_pf_9csamtools_12IndexedReads_1build, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_12IndexedReads_1build)},
-  {__Pyx_NAMESTR("find"), (PyCFunction)__pyx_pf_9csamtools_12IndexedReads_2find, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_12IndexedReads_2find)},
+  {__Pyx_NAMESTR("build"), (PyCFunction)__pyx_pf_9csamtools_12IndexedReads_build, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_12IndexedReads_build)},
+  {__Pyx_NAMESTR("find"), (PyCFunction)__pyx_pf_9csamtools_12IndexedReads_find, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_12IndexedReads_find)},
   {0, 0, 0, 0}
 };
 
@@ -31037,7 +35523,7 @@ static PyBufferProcs __pyx_tp_as_buffer_IndexedReads = {
   #endif
 };
 
-static PyTypeObject __pyx_type_9csamtools_IndexedReads = {
+PyTypeObject __pyx_type_9csamtools_IndexedReads = {
   PyVarObject_HEAD_INIT(0, 0)
   __Pyx_NAMESTR("csamtools.IndexedReads"), /*tp_name*/
   sizeof(struct __pyx_obj_9csamtools_IndexedReads), /*tp_basicsize*/
@@ -31061,7 +35547,7 @@ static PyTypeObject __pyx_type_9csamtools_IndexedReads = {
   0, /*tp_getattro*/
   0, /*tp_setattro*/
   &__pyx_tp_as_buffer_IndexedReads, /*tp_as_buffer*/
-  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
   __Pyx_DOCSTR("IndexedReads(Samfile samfile, int reopen=True)\nindex a bamfile by read.\n\n    The index is kept in memory.\n\n    By default, the file is re-openend to avoid conflicts if\n    multiple operators work on the same file. Set *reopen* = False\n    to not re-open *samfile*.\n    "), /*tp_doc*/
   __pyx_tp_traverse_9csamtools_IndexedReads, /*tp_traverse*/
   __pyx_tp_clear_9csamtools_IndexedReads, /*tp_clear*/
@@ -31094,6 +35580,7 @@ static PyTypeObject __pyx_type_9csamtools_IndexedReads = {
 };
 
 static PyMethodDef __pyx_methods[] = {
+  {__Pyx_NAMESTR("_samtools_dispatch"), (PyCFunction)__pyx_pf_9csamtools__samtools_dispatch, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools__samtools_dispatch)},
   {0, 0, 0, 0}
 };
 
@@ -31113,113 +35600,159 @@ static struct PyModuleDef __pyx_moduledef = {
 
 static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0},
+  {&__pyx_kp_s_10, __pyx_k_10, sizeof(__pyx_k_10), 0, 0, 1, 0},
   {&__pyx_kp_s_100, __pyx_k_100, sizeof(__pyx_k_100), 0, 0, 1, 0},
   {&__pyx_kp_s_101, __pyx_k_101, sizeof(__pyx_k_101), 0, 0, 1, 0},
-  {&__pyx_kp_s_103, __pyx_k_103, sizeof(__pyx_k_103), 0, 0, 1, 0},
-  {&__pyx_kp_s_106, __pyx_k_106, sizeof(__pyx_k_106), 0, 0, 1, 0},
+  {&__pyx_kp_s_102, __pyx_k_102, sizeof(__pyx_k_102), 0, 0, 1, 0},
+  {&__pyx_n_s_103, __pyx_k_103, sizeof(__pyx_k_103), 0, 0, 1, 1},
+  {&__pyx_kp_s_104, __pyx_k_104, sizeof(__pyx_k_104), 0, 0, 1, 0},
+  {&__pyx_kp_s_105, __pyx_k_105, sizeof(__pyx_k_105), 0, 0, 1, 0},
+  {&__pyx_kp_s_107, __pyx_k_107, sizeof(__pyx_k_107), 0, 0, 1, 0},
+  {&__pyx_kp_s_108, __pyx_k_108, sizeof(__pyx_k_108), 0, 0, 1, 0},
+  {&__pyx_kp_s_109, __pyx_k_109, sizeof(__pyx_k_109), 0, 0, 1, 0},
   {&__pyx_kp_s_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 0, 1, 0},
+  {&__pyx_kp_s_110, __pyx_k_110, sizeof(__pyx_k_110), 0, 0, 1, 0},
+  {&__pyx_kp_s_111, __pyx_k_111, sizeof(__pyx_k_111), 0, 0, 1, 0},
   {&__pyx_kp_s_112, __pyx_k_112, sizeof(__pyx_k_112), 0, 0, 1, 0},
   {&__pyx_kp_s_113, __pyx_k_113, sizeof(__pyx_k_113), 0, 0, 1, 0},
-  {&__pyx_kp_s_114, __pyx_k_114, sizeof(__pyx_k_114), 0, 0, 1, 0},
-  {&__pyx_kp_s_116, __pyx_k_116, sizeof(__pyx_k_116), 0, 0, 1, 0},
   {&__pyx_kp_s_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 0, 1, 0},
-  {&__pyx_kp_s_120, __pyx_k_120, sizeof(__pyx_k_120), 0, 0, 1, 0},
-  {&__pyx_kp_s_121, __pyx_k_121, sizeof(__pyx_k_121), 0, 0, 1, 0},
-  {&__pyx_n_s_122, __pyx_k_122, sizeof(__pyx_k_122), 0, 0, 1, 1},
-  {&__pyx_kp_s_123, __pyx_k_123, sizeof(__pyx_k_123), 0, 0, 1, 0},
-  {&__pyx_kp_s_124, __pyx_k_124, sizeof(__pyx_k_124), 0, 0, 1, 0},
-  {&__pyx_kp_s_125, __pyx_k_125, sizeof(__pyx_k_125), 0, 0, 1, 0},
-  {&__pyx_kp_s_126, __pyx_k_126, sizeof(__pyx_k_126), 0, 0, 1, 0},
-  {&__pyx_kp_s_127, __pyx_k_127, sizeof(__pyx_k_127), 0, 0, 1, 0},
-  {&__pyx_kp_s_128, __pyx_k_128, sizeof(__pyx_k_128), 0, 0, 1, 0},
-  {&__pyx_kp_s_129, __pyx_k_129, sizeof(__pyx_k_129), 0, 0, 1, 0},
-  {&__pyx_kp_s_13, __pyx_k_13, sizeof(__pyx_k_13), 0, 0, 1, 0},
-  {&__pyx_kp_s_130, __pyx_k_130, sizeof(__pyx_k_130), 0, 0, 1, 0},
-  {&__pyx_kp_s_131, __pyx_k_131, sizeof(__pyx_k_131), 0, 0, 1, 0},
-  {&__pyx_kp_s_132, __pyx_k_132, sizeof(__pyx_k_132), 0, 0, 1, 0},
-  {&__pyx_kp_s_133, __pyx_k_133, sizeof(__pyx_k_133), 0, 0, 1, 0},
-  {&__pyx_kp_s_135, __pyx_k_135, sizeof(__pyx_k_135), 0, 0, 1, 0},
-  {&__pyx_kp_s_136, __pyx_k_136, sizeof(__pyx_k_136), 0, 0, 1, 0},
-  {&__pyx_kp_s_137, __pyx_k_137, sizeof(__pyx_k_137), 0, 0, 1, 0},
-  {&__pyx_kp_s_138, __pyx_k_138, sizeof(__pyx_k_138), 0, 0, 1, 0},
-  {&__pyx_kp_s_139, __pyx_k_139, sizeof(__pyx_k_139), 0, 0, 1, 0},
-  {&__pyx_kp_s_14, __pyx_k_14, sizeof(__pyx_k_14), 0, 0, 1, 0},
-  {&__pyx_kp_s_140, __pyx_k_140, sizeof(__pyx_k_140), 0, 0, 1, 0},
-  {&__pyx_kp_s_141, __pyx_k_141, sizeof(__pyx_k_141), 0, 0, 1, 0},
-  {&__pyx_kp_s_142, __pyx_k_142, sizeof(__pyx_k_142), 0, 0, 1, 0},
-  {&__pyx_kp_s_143, __pyx_k_143, sizeof(__pyx_k_143), 0, 0, 1, 0},
-  {&__pyx_kp_s_144, __pyx_k_144, sizeof(__pyx_k_144), 0, 0, 1, 0},
-  {&__pyx_kp_s_145, __pyx_k_145, sizeof(__pyx_k_145), 0, 0, 1, 0},
-  {&__pyx_kp_s_146, __pyx_k_146, sizeof(__pyx_k_146), 0, 0, 1, 0},
-  {&__pyx_kp_s_147, __pyx_k_147, sizeof(__pyx_k_147), 0, 0, 1, 0},
-  {&__pyx_kp_s_148, __pyx_k_148, sizeof(__pyx_k_148), 0, 0, 1, 0},
-  {&__pyx_kp_s_149, __pyx_k_149, sizeof(__pyx_k_149), 0, 0, 1, 0},
   {&__pyx_kp_s_15, __pyx_k_15, sizeof(__pyx_k_15), 0, 0, 1, 0},
-  {&__pyx_kp_s_150, __pyx_k_150, sizeof(__pyx_k_150), 0, 0, 1, 0},
-  {&__pyx_kp_s_151, __pyx_k_151, sizeof(__pyx_k_151), 0, 0, 1, 0},
-  {&__pyx_kp_s_152, __pyx_k_152, sizeof(__pyx_k_152), 0, 0, 1, 0},
-  {&__pyx_kp_s_153, __pyx_k_153, sizeof(__pyx_k_153), 0, 0, 1, 0},
-  {&__pyx_kp_s_154, __pyx_k_154, sizeof(__pyx_k_154), 0, 0, 1, 0},
-  {&__pyx_kp_s_155, __pyx_k_155, sizeof(__pyx_k_155), 0, 0, 1, 0},
-  {&__pyx_kp_s_156, __pyx_k_156, sizeof(__pyx_k_156), 0, 0, 1, 0},
-  {&__pyx_kp_s_157, __pyx_k_157, sizeof(__pyx_k_157), 0, 0, 1, 0},
-  {&__pyx_kp_s_162, __pyx_k_162, sizeof(__pyx_k_162), 0, 0, 1, 0},
-  {&__pyx_kp_s_163, __pyx_k_163, sizeof(__pyx_k_163), 0, 0, 1, 0},
-  {&__pyx_kp_s_164, __pyx_k_164, sizeof(__pyx_k_164), 0, 0, 1, 0},
-  {&__pyx_n_s_166, __pyx_k_166, sizeof(__pyx_k_166), 0, 0, 1, 1},
-  {&__pyx_kp_s_167, __pyx_k_167, sizeof(__pyx_k_167), 0, 0, 1, 0},
-  {&__pyx_kp_s_168, __pyx_k_168, sizeof(__pyx_k_168), 0, 0, 1, 0},
-  {&__pyx_kp_s_17, __pyx_k_17, sizeof(__pyx_k_17), 0, 0, 1, 0},
+  {&__pyx_kp_s_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 1, 0},
+  {&__pyx_kp_s_173, __pyx_k_173, sizeof(__pyx_k_173), 0, 0, 1, 0},
+  {&__pyx_kp_s_174, __pyx_k_174, sizeof(__pyx_k_174), 0, 0, 1, 0},
+  {&__pyx_kp_s_175, __pyx_k_175, sizeof(__pyx_k_175), 0, 0, 1, 0},
+  {&__pyx_kp_s_176, __pyx_k_176, sizeof(__pyx_k_176), 0, 0, 1, 0},
+  {&__pyx_kp_u_177, __pyx_k_177, sizeof(__pyx_k_177), 0, 1, 0, 0},
+  {&__pyx_kp_u_178, __pyx_k_178, sizeof(__pyx_k_178), 0, 1, 0, 0},
+  {&__pyx_kp_u_179, __pyx_k_179, sizeof(__pyx_k_179), 0, 1, 0, 0},
+  {&__pyx_kp_s_18, __pyx_k_18, sizeof(__pyx_k_18), 0, 0, 1, 0},
+  {&__pyx_kp_u_180, __pyx_k_180, sizeof(__pyx_k_180), 0, 1, 0, 0},
+  {&__pyx_kp_u_181, __pyx_k_181, sizeof(__pyx_k_181), 0, 1, 0, 0},
+  {&__pyx_kp_u_182, __pyx_k_182, sizeof(__pyx_k_182), 0, 1, 0, 0},
+  {&__pyx_kp_u_183, __pyx_k_183, sizeof(__pyx_k_183), 0, 1, 0, 0},
+  {&__pyx_kp_u_184, __pyx_k_184, sizeof(__pyx_k_184), 0, 1, 0, 0},
+  {&__pyx_kp_u_185, __pyx_k_185, sizeof(__pyx_k_185), 0, 1, 0, 0},
+  {&__pyx_kp_u_186, __pyx_k_186, sizeof(__pyx_k_186), 0, 1, 0, 0},
+  {&__pyx_kp_u_187, __pyx_k_187, sizeof(__pyx_k_187), 0, 1, 0, 0},
+  {&__pyx_kp_u_188, __pyx_k_188, sizeof(__pyx_k_188), 0, 1, 0, 0},
+  {&__pyx_kp_u_189, __pyx_k_189, sizeof(__pyx_k_189), 0, 1, 0, 0},
+  {&__pyx_kp_s_19, __pyx_k_19, sizeof(__pyx_k_19), 0, 0, 1, 0},
+  {&__pyx_kp_u_190, __pyx_k_190, sizeof(__pyx_k_190), 0, 1, 0, 0},
+  {&__pyx_kp_u_191, __pyx_k_191, sizeof(__pyx_k_191), 0, 1, 0, 0},
+  {&__pyx_kp_u_192, __pyx_k_192, sizeof(__pyx_k_192), 0, 1, 0, 0},
+  {&__pyx_kp_u_193, __pyx_k_193, sizeof(__pyx_k_193), 0, 1, 0, 0},
+  {&__pyx_kp_u_194, __pyx_k_194, sizeof(__pyx_k_194), 0, 1, 0, 0},
+  {&__pyx_kp_u_195, __pyx_k_195, sizeof(__pyx_k_195), 0, 1, 0, 0},
+  {&__pyx_kp_u_196, __pyx_k_196, sizeof(__pyx_k_196), 0, 1, 0, 0},
+  {&__pyx_kp_u_197, __pyx_k_197, sizeof(__pyx_k_197), 0, 1, 0, 0},
+  {&__pyx_kp_u_198, __pyx_k_198, sizeof(__pyx_k_198), 0, 1, 0, 0},
+  {&__pyx_kp_u_199, __pyx_k_199, sizeof(__pyx_k_199), 0, 1, 0, 0},
   {&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0},
+  {&__pyx_kp_s_20, __pyx_k_20, sizeof(__pyx_k_20), 0, 0, 1, 0},
+  {&__pyx_n_s_200, __pyx_k_200, sizeof(__pyx_k_200), 0, 0, 1, 1},
+  {&__pyx_kp_u_201, __pyx_k_201, sizeof(__pyx_k_201), 0, 1, 0, 0},
+  {&__pyx_kp_u_202, __pyx_k_202, sizeof(__pyx_k_202), 0, 1, 0, 0},
+  {&__pyx_kp_u_203, __pyx_k_203, sizeof(__pyx_k_203), 0, 1, 0, 0},
+  {&__pyx_n_s_204, __pyx_k_204, sizeof(__pyx_k_204), 0, 0, 1, 1},
+  {&__pyx_kp_u_205, __pyx_k_205, sizeof(__pyx_k_205), 0, 1, 0, 0},
+  {&__pyx_n_s_206, __pyx_k_206, sizeof(__pyx_k_206), 0, 0, 1, 1},
+  {&__pyx_kp_u_207, __pyx_k_207, sizeof(__pyx_k_207), 0, 1, 0, 0},
+  {&__pyx_kp_u_208, __pyx_k_208, sizeof(__pyx_k_208), 0, 1, 0, 0},
+  {&__pyx_kp_u_209, __pyx_k_209, sizeof(__pyx_k_209), 0, 1, 0, 0},
   {&__pyx_kp_s_21, __pyx_k_21, sizeof(__pyx_k_21), 0, 0, 1, 0},
+  {&__pyx_kp_u_210, __pyx_k_210, sizeof(__pyx_k_210), 0, 1, 0, 0},
+  {&__pyx_kp_u_211, __pyx_k_211, sizeof(__pyx_k_211), 0, 1, 0, 0},
+  {&__pyx_kp_u_212, __pyx_k_212, sizeof(__pyx_k_212), 0, 1, 0, 0},
+  {&__pyx_kp_u_213, __pyx_k_213, sizeof(__pyx_k_213), 0, 1, 0, 0},
+  {&__pyx_kp_u_214, __pyx_k_214, sizeof(__pyx_k_214), 0, 1, 0, 0},
+  {&__pyx_kp_u_215, __pyx_k_215, sizeof(__pyx_k_215), 0, 1, 0, 0},
+  {&__pyx_kp_u_216, __pyx_k_216, sizeof(__pyx_k_216), 0, 1, 0, 0},
+  {&__pyx_kp_u_217, __pyx_k_217, sizeof(__pyx_k_217), 0, 1, 0, 0},
+  {&__pyx_kp_u_218, __pyx_k_218, sizeof(__pyx_k_218), 0, 1, 0, 0},
+  {&__pyx_kp_u_219, __pyx_k_219, sizeof(__pyx_k_219), 0, 1, 0, 0},
   {&__pyx_kp_s_22, __pyx_k_22, sizeof(__pyx_k_22), 0, 0, 1, 0},
+  {&__pyx_kp_u_220, __pyx_k_220, sizeof(__pyx_k_220), 0, 1, 0, 0},
   {&__pyx_kp_s_23, __pyx_k_23, sizeof(__pyx_k_23), 0, 0, 1, 0},
-  {&__pyx_kp_s_230, __pyx_k_230, sizeof(__pyx_k_230), 0, 0, 1, 0},
-  {&__pyx_kp_s_231, __pyx_k_231, sizeof(__pyx_k_231), 0, 0, 1, 0},
-  {&__pyx_kp_s_232, __pyx_k_232, sizeof(__pyx_k_232), 0, 0, 1, 0},
-  {&__pyx_kp_s_238, __pyx_k_238, sizeof(__pyx_k_238), 0, 0, 1, 0},
   {&__pyx_kp_s_24, __pyx_k_24, sizeof(__pyx_k_24), 0, 0, 1, 0},
   {&__pyx_kp_s_25, __pyx_k_25, sizeof(__pyx_k_25), 0, 0, 1, 0},
   {&__pyx_kp_s_26, __pyx_k_26, sizeof(__pyx_k_26), 0, 0, 1, 0},
   {&__pyx_kp_s_27, __pyx_k_27, sizeof(__pyx_k_27), 0, 0, 1, 0},
   {&__pyx_kp_s_28, __pyx_k_28, sizeof(__pyx_k_28), 0, 0, 1, 0},
   {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0},
+  {&__pyx_kp_s_30, __pyx_k_30, sizeof(__pyx_k_30), 0, 0, 1, 0},
   {&__pyx_kp_s_31, __pyx_k_31, sizeof(__pyx_k_31), 0, 0, 1, 0},
+  {&__pyx_kp_s_32, __pyx_k_32, sizeof(__pyx_k_32), 0, 0, 1, 0},
   {&__pyx_kp_s_33, __pyx_k_33, sizeof(__pyx_k_33), 0, 0, 1, 0},
+  {&__pyx_kp_s_34, __pyx_k_34, sizeof(__pyx_k_34), 0, 0, 1, 0},
   {&__pyx_kp_s_35, __pyx_k_35, sizeof(__pyx_k_35), 0, 0, 1, 0},
   {&__pyx_kp_s_36, __pyx_k_36, sizeof(__pyx_k_36), 0, 0, 1, 0},
+  {&__pyx_kp_s_37, __pyx_k_37, sizeof(__pyx_k_37), 0, 0, 1, 0},
   {&__pyx_kp_s_38, __pyx_k_38, sizeof(__pyx_k_38), 0, 0, 1, 0},
+  {&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0},
   {&__pyx_kp_s_40, __pyx_k_40, sizeof(__pyx_k_40), 0, 0, 1, 0},
+  {&__pyx_kp_s_41, __pyx_k_41, sizeof(__pyx_k_41), 0, 0, 1, 0},
+  {&__pyx_kp_s_42, __pyx_k_42, sizeof(__pyx_k_42), 0, 0, 1, 0},
+  {&__pyx_kp_s_43, __pyx_k_43, sizeof(__pyx_k_43), 0, 0, 1, 0},
+  {&__pyx_kp_s_44, __pyx_k_44, sizeof(__pyx_k_44), 0, 0, 1, 0},
+  {&__pyx_kp_s_45, __pyx_k_45, sizeof(__pyx_k_45), 0, 0, 1, 0},
   {&__pyx_kp_s_46, __pyx_k_46, sizeof(__pyx_k_46), 0, 0, 1, 0},
+  {&__pyx_kp_s_47, __pyx_k_47, sizeof(__pyx_k_47), 0, 0, 1, 0},
   {&__pyx_kp_s_48, __pyx_k_48, sizeof(__pyx_k_48), 0, 0, 1, 0},
+  {&__pyx_kp_s_49, __pyx_k_49, sizeof(__pyx_k_49), 0, 0, 1, 0},
   {&__pyx_kp_s_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 0, 1, 0},
   {&__pyx_kp_s_50, __pyx_k_50, sizeof(__pyx_k_50), 0, 0, 1, 0},
+  {&__pyx_kp_s_51, __pyx_k_51, sizeof(__pyx_k_51), 0, 0, 1, 0},
   {&__pyx_kp_s_52, __pyx_k_52, sizeof(__pyx_k_52), 0, 0, 1, 0},
+  {&__pyx_kp_s_53, __pyx_k_53, sizeof(__pyx_k_53), 0, 0, 1, 0},
   {&__pyx_kp_s_54, __pyx_k_54, sizeof(__pyx_k_54), 0, 0, 1, 0},
+  {&__pyx_kp_s_55, __pyx_k_55, sizeof(__pyx_k_55), 0, 0, 1, 0},
   {&__pyx_kp_s_56, __pyx_k_56, sizeof(__pyx_k_56), 0, 0, 1, 0},
-  {&__pyx_kp_s_58, __pyx_k_58, sizeof(__pyx_k_58), 0, 0, 1, 0},
+  {&__pyx_kp_s_57, __pyx_k_57, sizeof(__pyx_k_57), 0, 0, 1, 0},
   {&__pyx_kp_s_59, __pyx_k_59, sizeof(__pyx_k_59), 0, 0, 1, 0},
   {&__pyx_kp_s_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 1, 0},
-  {&__pyx_kp_s_60, __pyx_k_60, sizeof(__pyx_k_60), 0, 0, 1, 0},
+  {&__pyx_kp_s_61, __pyx_k_61, sizeof(__pyx_k_61), 0, 0, 1, 0},
+  {&__pyx_kp_s_62, __pyx_k_62, sizeof(__pyx_k_62), 0, 0, 1, 0},
+  {&__pyx_n_s_63, __pyx_k_63, sizeof(__pyx_k_63), 0, 0, 1, 1},
+  {&__pyx_kp_s_64, __pyx_k_64, sizeof(__pyx_k_64), 0, 0, 1, 0},
   {&__pyx_kp_s_65, __pyx_k_65, sizeof(__pyx_k_65), 0, 0, 1, 0},
+  {&__pyx_kp_s_66, __pyx_k_66, sizeof(__pyx_k_66), 0, 0, 1, 0},
+  {&__pyx_kp_s_67, __pyx_k_67, sizeof(__pyx_k_67), 0, 0, 1, 0},
   {&__pyx_kp_s_68, __pyx_k_68, sizeof(__pyx_k_68), 0, 0, 1, 0},
+  {&__pyx_kp_s_69, __pyx_k_69, sizeof(__pyx_k_69), 0, 0, 1, 0},
+  {&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0},
+  {&__pyx_kp_s_70, __pyx_k_70, sizeof(__pyx_k_70), 0, 0, 1, 0},
   {&__pyx_kp_s_71, __pyx_k_71, sizeof(__pyx_k_71), 0, 0, 1, 0},
+  {&__pyx_kp_s_72, __pyx_k_72, sizeof(__pyx_k_72), 0, 0, 1, 0},
+  {&__pyx_kp_s_73, __pyx_k_73, sizeof(__pyx_k_73), 0, 0, 1, 0},
   {&__pyx_kp_s_74, __pyx_k_74, sizeof(__pyx_k_74), 0, 0, 1, 0},
+  {&__pyx_kp_s_75, __pyx_k_75, sizeof(__pyx_k_75), 0, 0, 1, 0},
+  {&__pyx_kp_s_76, __pyx_k_76, sizeof(__pyx_k_76), 0, 0, 1, 0},
+  {&__pyx_kp_s_77, __pyx_k_77, sizeof(__pyx_k_77), 0, 0, 1, 0},
+  {&__pyx_kp_s_78, __pyx_k_78, sizeof(__pyx_k_78), 0, 0, 1, 0},
+  {&__pyx_kp_s_79, __pyx_k_79, sizeof(__pyx_k_79), 0, 0, 1, 0},
+  {&__pyx_kp_s_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 0, 1, 0},
+  {&__pyx_kp_s_80, __pyx_k_80, sizeof(__pyx_k_80), 0, 0, 1, 0},
   {&__pyx_kp_s_81, __pyx_k_81, sizeof(__pyx_k_81), 0, 0, 1, 0},
+  {&__pyx_kp_s_82, __pyx_k_82, sizeof(__pyx_k_82), 0, 0, 1, 0},
+  {&__pyx_kp_s_83, __pyx_k_83, sizeof(__pyx_k_83), 0, 0, 1, 0},
   {&__pyx_kp_s_84, __pyx_k_84, sizeof(__pyx_k_84), 0, 0, 1, 0},
+  {&__pyx_kp_s_85, __pyx_k_85, sizeof(__pyx_k_85), 0, 0, 1, 0},
+  {&__pyx_kp_s_86, __pyx_k_86, sizeof(__pyx_k_86), 0, 0, 1, 0},
+  {&__pyx_kp_s_87, __pyx_k_87, sizeof(__pyx_k_87), 0, 0, 1, 0},
+  {&__pyx_kp_s_88, __pyx_k_88, sizeof(__pyx_k_88), 0, 0, 1, 0},
   {&__pyx_kp_s_89, __pyx_k_89, sizeof(__pyx_k_89), 0, 0, 1, 0},
   {&__pyx_kp_s_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 1, 0},
+  {&__pyx_kp_s_90, __pyx_k_90, sizeof(__pyx_k_90), 0, 0, 1, 0},
   {&__pyx_kp_s_91, __pyx_k_91, sizeof(__pyx_k_91), 0, 0, 1, 0},
+  {&__pyx_kp_s_92, __pyx_k_92, sizeof(__pyx_k_92), 0, 0, 1, 0},
   {&__pyx_kp_s_93, __pyx_k_93, sizeof(__pyx_k_93), 0, 0, 1, 0},
   {&__pyx_kp_s_94, __pyx_k_94, sizeof(__pyx_k_94), 0, 0, 1, 0},
+  {&__pyx_kp_s_95, __pyx_k_95, sizeof(__pyx_k_95), 0, 0, 1, 0},
   {&__pyx_kp_s_96, __pyx_k_96, sizeof(__pyx_k_96), 0, 0, 1, 0},
   {&__pyx_kp_s_97, __pyx_k_97, sizeof(__pyx_k_97), 0, 0, 1, 0},
-  {&__pyx_kp_s_98, __pyx_k_98, sizeof(__pyx_k_98), 0, 0, 1, 0},
-  {&__pyx_kp_s_99, __pyx_k_99, sizeof(__pyx_k_99), 0, 0, 1, 0},
   {&__pyx_n_s__A, __pyx_k__A, sizeof(__pyx_k__A), 0, 0, 1, 1},
   {&__pyx_n_s__AS, __pyx_k__AS, sizeof(__pyx_k__AS), 0, 0, 1, 1},
   {&__pyx_n_s__AlignedRead, __pyx_k__AlignedRead, sizeof(__pyx_k__AlignedRead), 0, 0, 1, 1},
-  {&__pyx_n_s__AttributeError, __pyx_k__AttributeError, sizeof(__pyx_k__AttributeError), 0, 0, 1, 1},
   {&__pyx_n_s__C, __pyx_k__C, sizeof(__pyx_k__C), 0, 0, 1, 1},
   {&__pyx_n_s__CL, __pyx_k__CL, sizeof(__pyx_k__CL), 0, 0, 1, 1},
   {&__pyx_n_s__CN, __pyx_k__CN, sizeof(__pyx_k__CN), 0, 0, 1, 1},
@@ -31236,16 +35769,21 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_n_s__I, __pyx_k__I, sizeof(__pyx_k__I), 0, 0, 1, 1},
   {&__pyx_n_s__ID, __pyx_k__ID, sizeof(__pyx_k__ID), 0, 0, 1, 1},
   {&__pyx_n_s__IOError, __pyx_k__IOError, sizeof(__pyx_k__IOError), 0, 0, 1, 1},
+  {&__pyx_n_s__IndelCaller, __pyx_k__IndelCaller, sizeof(__pyx_k__IndelCaller), 0, 0, 1, 1},
   {&__pyx_n_s__IndexedReads, __pyx_k__IndexedReads, sizeof(__pyx_k__IndexedReads), 0, 0, 1, 1},
   {&__pyx_n_s__IntType, __pyx_k__IntType, sizeof(__pyx_k__IntType), 0, 0, 1, 1},
   {&__pyx_n_s__IteratorColumn, __pyx_k__IteratorColumn, sizeof(__pyx_k__IteratorColumn), 0, 0, 1, 1},
+  {&__pyx_n_s__IteratorIndelCalls, __pyx_k__IteratorIndelCalls, sizeof(__pyx_k__IteratorIndelCalls), 0, 0, 1, 1},
   {&__pyx_n_s__IteratorRow, __pyx_k__IteratorRow, sizeof(__pyx_k__IteratorRow), 0, 0, 1, 1},
+  {&__pyx_n_s__IteratorRowAll, __pyx_k__IteratorRowAll, sizeof(__pyx_k__IteratorRowAll), 0, 0, 1, 1},
+  {&__pyx_n_s__IteratorRowAllRefs, __pyx_k__IteratorRowAllRefs, sizeof(__pyx_k__IteratorRowAllRefs), 0, 0, 1, 1},
+  {&__pyx_n_s__IteratorRowRegion, __pyx_k__IteratorRowRegion, sizeof(__pyx_k__IteratorRowRegion), 0, 0, 1, 1},
+  {&__pyx_n_s__IteratorSNPCalls, __pyx_k__IteratorSNPCalls, sizeof(__pyx_k__IteratorSNPCalls), 0, 0, 1, 1},
   {&__pyx_n_s__KeyError, __pyx_k__KeyError, sizeof(__pyx_k__KeyError), 0, 0, 1, 1},
   {&__pyx_n_s__LB, __pyx_k__LB, sizeof(__pyx_k__LB), 0, 0, 1, 1},
   {&__pyx_n_s__LN, __pyx_k__LN, sizeof(__pyx_k__LN), 0, 0, 1, 1},
   {&__pyx_n_s__M5, __pyx_k__M5, sizeof(__pyx_k__M5), 0, 0, 1, 1},
   {&__pyx_n_s__NotImplementedError, __pyx_k__NotImplementedError, sizeof(__pyx_k__NotImplementedError), 0, 0, 1, 1},
-  {&__pyx_n_s__OSError, __pyx_k__OSError, sizeof(__pyx_k__OSError), 0, 0, 1, 1},
   {&__pyx_n_s__O_CREAT, __pyx_k__O_CREAT, sizeof(__pyx_k__O_CREAT), 0, 0, 1, 1},
   {&__pyx_n_s__O_WRONLY, __pyx_k__O_WRONLY, sizeof(__pyx_k__O_WRONLY), 0, 0, 1, 1},
   {&__pyx_n_s__Outs, __pyx_k__Outs, sizeof(__pyx_k__Outs), 0, 0, 1, 1},
@@ -31262,6 +35800,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_n_s__S, __pyx_k__S, sizeof(__pyx_k__S), 0, 0, 1, 1},
   {&__pyx_n_s__SM, __pyx_k__SM, sizeof(__pyx_k__SM), 0, 0, 1, 1},
   {&__pyx_n_s__SN, __pyx_k__SN, sizeof(__pyx_k__SN), 0, 0, 1, 1},
+  {&__pyx_n_s__SNPCaller, __pyx_k__SNPCaller, sizeof(__pyx_k__SNPCaller), 0, 0, 1, 1},
   {&__pyx_n_s__SO, __pyx_k__SO, sizeof(__pyx_k__SO), 0, 0, 1, 1},
   {&__pyx_n_s__SP, __pyx_k__SP, sizeof(__pyx_k__SP), 0, 0, 1, 1},
   {&__pyx_n_s__SQ, __pyx_k__SQ, sizeof(__pyx_k__SQ), 0, 0, 1, 1},
@@ -31285,11 +35824,13 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_n_s____getattribute__, __pyx_k____getattribute__, sizeof(__pyx_k____getattribute__), 0, 0, 1, 1},
   {&__pyx_n_s____init__, __pyx_k____init__, sizeof(__pyx_k____init__), 0, 0, 1, 1},
   {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
+  {&__pyx_n_s____next__, __pyx_k____next__, sizeof(__pyx_k____next__), 0, 0, 1, 1},
   {&__pyx_n_s____str__, __pyx_k____str__, sizeof(__pyx_k____str__), 0, 0, 1, 1},
   {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
   {&__pyx_n_s___alignment, __pyx_k___alignment, sizeof(__pyx_k___alignment), 0, 0, 1, 1},
   {&__pyx_n_s___buildHeader, __pyx_k___buildHeader, sizeof(__pyx_k___buildHeader), 0, 0, 1, 1},
   {&__pyx_n_s___buildLine, __pyx_k___buildLine, sizeof(__pyx_k___buildLine), 0, 0, 1, 1},
+  {&__pyx_n_s___call, __pyx_k___call, sizeof(__pyx_k___call), 0, 0, 1, 1},
   {&__pyx_n_s___consensus_quality, __pyx_k___consensus_quality, sizeof(__pyx_k___consensus_quality), 0, 0, 1, 1},
   {&__pyx_n_s___coverage, __pyx_k___coverage, sizeof(__pyx_k___coverage), 0, 0, 1, 1},
   {&__pyx_n_s___delegate, __pyx_k___delegate, sizeof(__pyx_k___delegate), 0, 0, 1, 1},
@@ -31307,23 +35848,26 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_n_s___parseRegion, __pyx_k___parseRegion, sizeof(__pyx_k___parseRegion), 0, 0, 1, 1},
   {&__pyx_n_s___pos, __pyx_k___pos, sizeof(__pyx_k___pos), 0, 0, 1, 1},
   {&__pyx_n_s___qpos, __pyx_k___qpos, sizeof(__pyx_k___qpos), 0, 0, 1, 1},
+  {&__pyx_n_s___r, __pyx_k___r, sizeof(__pyx_k___r), 0, 0, 1, 1},
   {&__pyx_n_s___reference_base, __pyx_k___reference_base, sizeof(__pyx_k___reference_base), 0, 0, 1, 1},
   {&__pyx_n_s___samtools_dispatch, __pyx_k___samtools_dispatch, sizeof(__pyx_k___samtools_dispatch), 0, 0, 1, 1},
   {&__pyx_n_s___snp_quality, __pyx_k___snp_quality, sizeof(__pyx_k___snp_quality), 0, 0, 1, 1},
   {&__pyx_n_s___tid, __pyx_k___tid, sizeof(__pyx_k___tid), 0, 0, 1, 1},
-  {&__pyx_n_s__add_sq_text, __pyx_k__add_sq_text, sizeof(__pyx_k__add_sq_text), 0, 0, 1, 1},
+  {&__pyx_n_s__addReference, __pyx_k__addReference, sizeof(__pyx_k__addReference), 0, 0, 1, 1},
   {&__pyx_n_s__alignment, __pyx_k__alignment, sizeof(__pyx_k__alignment), 0, 0, 1, 1},
   {&__pyx_n_s__all, __pyx_k__all, sizeof(__pyx_k__all), 0, 0, 1, 1},
-  {&__pyx_n_s__append, __pyx_k__append, sizeof(__pyx_k__append), 0, 0, 1, 1},
   {&__pyx_n_s__args, __pyx_k__args, sizeof(__pyx_k__args), 0, 0, 1, 1},
   {&__pyx_n_s__b, __pyx_k__b, sizeof(__pyx_k__b), 0, 0, 1, 1},
   {&__pyx_n_s__bam, __pyx_k__bam, sizeof(__pyx_k__bam), 0, 0, 1, 1},
   {&__pyx_n_s__beg, __pyx_k__beg, sizeof(__pyx_k__beg), 0, 0, 1, 1},
   {&__pyx_n_s__bin, __pyx_k__bin, sizeof(__pyx_k__bin), 0, 0, 1, 1},
   {&__pyx_n_s__bqual, __pyx_k__bqual, sizeof(__pyx_k__bqual), 0, 0, 1, 1},
+  {&__pyx_n_s__build, __pyx_k__build, sizeof(__pyx_k__build), 0, 0, 1, 1},
   {&__pyx_n_s__c, __pyx_k__c, sizeof(__pyx_k__c), 0, 0, 1, 1},
   {&__pyx_n_s__calcsize, __pyx_k__calcsize, sizeof(__pyx_k__calcsize), 0, 0, 1, 1},
+  {&__pyx_n_s__call, __pyx_k__call, sizeof(__pyx_k__call), 0, 0, 1, 1},
   {&__pyx_n_s__callback, __pyx_k__callback, sizeof(__pyx_k__callback), 0, 0, 1, 1},
+  {&__pyx_n_s__cap_mapQ, __pyx_k__cap_mapQ, sizeof(__pyx_k__cap_mapQ), 0, 0, 1, 1},
   {&__pyx_n_s__catch_stderr, __pyx_k__catch_stderr, sizeof(__pyx_k__catch_stderr), 0, 0, 1, 1},
   {&__pyx_n_s__catch_stdout, __pyx_k__catch_stdout, sizeof(__pyx_k__catch_stdout), 0, 0, 1, 1},
   {&__pyx_n_s__chr, __pyx_k__chr, sizeof(__pyx_k__chr), 0, 0, 1, 1},
@@ -31331,11 +35875,15 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_n_s__close, __pyx_k__close, sizeof(__pyx_k__close), 0, 0, 1, 1},
   {&__pyx_n_s__cmp, __pyx_k__cmp, sizeof(__pyx_k__cmp), 0, 0, 1, 1},
   {&__pyx_n_s__cnext, __pyx_k__cnext, sizeof(__pyx_k__cnext), 0, 0, 1, 1},
+  {&__pyx_n_s__cnt1, __pyx_k__cnt1, sizeof(__pyx_k__cnt1), 0, 0, 1, 1},
+  {&__pyx_n_s__cnt2, __pyx_k__cnt2, sizeof(__pyx_k__cnt2), 0, 0, 1, 1},
+  {&__pyx_n_s__cnt_anti, __pyx_k__cnt_anti, sizeof(__pyx_k__cnt_anti), 0, 0, 1, 1},
   {&__pyx_n_s__collections, __pyx_k__collections, sizeof(__pyx_k__collections), 0, 0, 1, 1},
+  {&__pyx_n_s__compare, __pyx_k__compare, sizeof(__pyx_k__compare), 0, 0, 1, 1},
   {&__pyx_n_s__consensus_quality, __pyx_k__consensus_quality, sizeof(__pyx_k__consensus_quality), 0, 0, 1, 1},
   {&__pyx_n_s__core, __pyx_k__core, sizeof(__pyx_k__core), 0, 0, 1, 1},
+  {&__pyx_n_s__count, __pyx_k__count, sizeof(__pyx_k__count), 0, 0, 1, 1},
   {&__pyx_n_s__coverage, __pyx_k__coverage, sizeof(__pyx_k__coverage), 0, 0, 1, 1},
-  {&__pyx_n_s__csamtools, __pyx_k__csamtools, sizeof(__pyx_k__csamtools), 0, 0, 1, 1},
   {&__pyx_n_s__ctypes, __pyx_k__ctypes, sizeof(__pyx_k__ctypes), 0, 0, 1, 1},
   {&__pyx_n_s__current_pos, __pyx_k__current_pos, sizeof(__pyx_k__current_pos), 0, 0, 1, 1},
   {&__pyx_n_s__d, __pyx_k__d, sizeof(__pyx_k__d), 0, 0, 1, 1},
@@ -31346,25 +35894,35 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_n_s__dup, __pyx_k__dup, sizeof(__pyx_k__dup), 0, 0, 1, 1},
   {&__pyx_n_s__dup2, __pyx_k__dup2, sizeof(__pyx_k__dup2), 0, 0, 1, 1},
   {&__pyx_n_s__end, __pyx_k__end, sizeof(__pyx_k__end), 0, 0, 1, 1},
+  {&__pyx_n_s__errmod, __pyx_k__errmod, sizeof(__pyx_k__errmod), 0, 0, 1, 1},
   {&__pyx_n_s__exc_type, __pyx_k__exc_type, sizeof(__pyx_k__exc_type), 0, 0, 1, 1},
   {&__pyx_n_s__exc_value, __pyx_k__exc_value, sizeof(__pyx_k__exc_value), 0, 0, 1, 1},
   {&__pyx_n_s__exists, __pyx_k__exists, sizeof(__pyx_k__exists), 0, 0, 1, 1},
   {&__pyx_n_s__f, __pyx_k__f, sizeof(__pyx_k__f), 0, 0, 1, 1},
+  {&__pyx_n_s__fancy_str, __pyx_k__fancy_str, sizeof(__pyx_k__fancy_str), 0, 0, 1, 1},
   {&__pyx_n_s__fastafile, __pyx_k__fastafile, sizeof(__pyx_k__fastafile), 0, 0, 1, 1},
   {&__pyx_n_s__fd, __pyx_k__fd, sizeof(__pyx_k__fd), 0, 0, 1, 1},
+  {&__pyx_n_s__fetch, __pyx_k__fetch, sizeof(__pyx_k__fetch), 0, 0, 1, 1},
   {&__pyx_n_s__fields, __pyx_k__fields, sizeof(__pyx_k__fields), 0, 0, 1, 1},
   {&__pyx_n_s__filename, __pyx_k__filename, sizeof(__pyx_k__filename), 0, 0, 1, 1},
   {&__pyx_n_s__fileno, __pyx_k__fileno, sizeof(__pyx_k__fileno), 0, 0, 1, 1},
+  {&__pyx_n_s__first_allele, __pyx_k__first_allele, sizeof(__pyx_k__first_allele), 0, 0, 1, 1},
   {&__pyx_n_s__flag, __pyx_k__flag, sizeof(__pyx_k__flag), 0, 0, 1, 1},
   {&__pyx_n_s__flush, __pyx_k__flush, sizeof(__pyx_k__flush), 0, 0, 1, 1},
   {&__pyx_n_s__fp, __pyx_k__fp, sizeof(__pyx_k__fp), 0, 0, 1, 1},
   {&__pyx_n_s__genotype, __pyx_k__genotype, sizeof(__pyx_k__genotype), 0, 0, 1, 1},
+  {&__pyx_n_s__getSequence, __pyx_k__getSequence, sizeof(__pyx_k__getSequence), 0, 0, 1, 1},
+  {&__pyx_n_s__getrname, __pyx_k__getrname, sizeof(__pyx_k__getrname), 0, 0, 1, 1},
   {&__pyx_n_s__gettid, __pyx_k__gettid, sizeof(__pyx_k__gettid), 0, 0, 1, 1},
+  {&__pyx_n_s__hasReference, __pyx_k__hasReference, sizeof(__pyx_k__hasReference), 0, 0, 1, 1},
   {&__pyx_n_s__hash, __pyx_k__hash, sizeof(__pyx_k__hash), 0, 0, 1, 1},
   {&__pyx_n_s__header, __pyx_k__header, sizeof(__pyx_k__header), 0, 0, 1, 1},
+  {&__pyx_n_s__het_rate, __pyx_k__het_rate, sizeof(__pyx_k__het_rate), 0, 0, 1, 1},
   {&__pyx_n_s__i, __pyx_k__i, sizeof(__pyx_k__i), 0, 0, 1, 1},
   {&__pyx_n_s__id, __pyx_k__id, sizeof(__pyx_k__id), 0, 0, 1, 1},
   {&__pyx_n_s__indel, __pyx_k__indel, sizeof(__pyx_k__indel), 0, 0, 1, 1},
+  {&__pyx_n_s__indel1, __pyx_k__indel1, sizeof(__pyx_k__indel1), 0, 0, 1, 1},
+  {&__pyx_n_s__indel2, __pyx_k__indel2, sizeof(__pyx_k__indel2), 0, 0, 1, 1},
   {&__pyx_n_s__index, __pyx_k__index, sizeof(__pyx_k__index), 0, 0, 1, 1},
   {&__pyx_n_s__is_del, __pyx_k__is_del, sizeof(__pyx_k__is_del), 0, 0, 1, 1},
   {&__pyx_n_s__is_head, __pyx_k__is_head, sizeof(__pyx_k__is_head), 0, 0, 1, 1},
@@ -31372,9 +35930,9 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_n_s__isbam, __pyx_k__isbam, sizeof(__pyx_k__isbam), 0, 0, 1, 1},
   {&__pyx_n_s__isize, __pyx_k__isize, sizeof(__pyx_k__isize), 0, 0, 1, 1},
   {&__pyx_n_s__isremote, __pyx_k__isremote, sizeof(__pyx_k__isremote), 0, 0, 1, 1},
-  {&__pyx_n_s__isstream, __pyx_k__isstream, sizeof(__pyx_k__isstream), 0, 0, 1, 1},
   {&__pyx_n_s__isupper, __pyx_k__isupper, sizeof(__pyx_k__isupper), 0, 0, 1, 1},
   {&__pyx_n_s__iter, __pyx_k__iter, sizeof(__pyx_k__iter), 0, 0, 1, 1},
+  {&__pyx_n_s__iterator_column, __pyx_k__iterator_column, sizeof(__pyx_k__iterator_column), 0, 0, 1, 1},
   {&__pyx_n_s__iterdata, __pyx_k__iterdata, sizeof(__pyx_k__iterdata), 0, 0, 1, 1},
   {&__pyx_n_s__itertools, __pyx_k__itertools, sizeof(__pyx_k__itertools), 0, 0, 1, 1},
   {&__pyx_n_s__join, __pyx_k__join, sizeof(__pyx_k__join), 0, 0, 1, 1},
@@ -31391,6 +35949,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_n_s__mate, __pyx_k__mate, sizeof(__pyx_k__mate), 0, 0, 1, 1},
   {&__pyx_n_s__max_depth, __pyx_k__max_depth, sizeof(__pyx_k__max_depth), 0, 0, 1, 1},
   {&__pyx_n_s__method, __pyx_k__method, sizeof(__pyx_k__method), 0, 0, 1, 1},
+  {&__pyx_n_s__min_baseQ, __pyx_k__min_baseQ, sizeof(__pyx_k__min_baseQ), 0, 0, 1, 1},
   {&__pyx_n_s__mkstemp, __pyx_k__mkstemp, sizeof(__pyx_k__mkstemp), 0, 0, 1, 1},
   {&__pyx_n_s__mode, __pyx_k__mode, sizeof(__pyx_k__mode), 0, 0, 1, 1},
   {&__pyx_n_s__mpos, __pyx_k__mpos, sizeof(__pyx_k__mpos), 0, 0, 1, 1},
@@ -31398,6 +35957,8 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_n_s__mtid, __pyx_k__mtid, sizeof(__pyx_k__mtid), 0, 0, 1, 1},
   {&__pyx_n_s__n, __pyx_k__n, sizeof(__pyx_k__n), 0, 0, 1, 1},
   {&__pyx_n_s__n_cigar, __pyx_k__n_cigar, sizeof(__pyx_k__n_cigar), 0, 0, 1, 1},
+  {&__pyx_n_s__n_hap, __pyx_k__n_hap, sizeof(__pyx_k__n_hap), 0, 0, 1, 1},
+  {&__pyx_n_s__n_haplotypes, __pyx_k__n_haplotypes, sizeof(__pyx_k__n_haplotypes), 0, 0, 1, 1},
   {&__pyx_n_s__n_plp, __pyx_k__n_plp, sizeof(__pyx_k__n_plp), 0, 0, 1, 1},
   {&__pyx_n_s__n_pu, __pyx_k__n_pu, sizeof(__pyx_k__n_pu), 0, 0, 1, 1},
   {&__pyx_n_s__n_targets, __pyx_k__n_targets, sizeof(__pyx_k__n_targets), 0, 0, 1, 1},
@@ -31407,10 +35968,14 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_n_s__object, __pyx_k__object, sizeof(__pyx_k__object), 0, 0, 1, 1},
   {&__pyx_n_s__offset, __pyx_k__offset, sizeof(__pyx_k__offset), 0, 0, 1, 1},
   {&__pyx_n_s__open, __pyx_k__open, sizeof(__pyx_k__open), 0, 0, 1, 1},
+  {&__pyx_n_s__opt, __pyx_k__opt, sizeof(__pyx_k__opt), 0, 0, 1, 1},
+  {&__pyx_n_s__options, __pyx_k__options, sizeof(__pyx_k__options), 0, 0, 1, 1},
   {&__pyx_n_s__os, __pyx_k__os, sizeof(__pyx_k__os), 0, 0, 1, 1},
+  {&__pyx_n_s__overlap, __pyx_k__overlap, sizeof(__pyx_k__overlap), 0, 0, 1, 1},
   {&__pyx_n_s__owns_samfile, __pyx_k__owns_samfile, sizeof(__pyx_k__owns_samfile), 0, 0, 1, 1},
   {&__pyx_n_s__pack_into, __pyx_k__pack_into, sizeof(__pyx_k__pack_into), 0, 0, 1, 1},
   {&__pyx_n_s__path, __pyx_k__path, sizeof(__pyx_k__path), 0, 0, 1, 1},
+  {&__pyx_n_s__pileup, __pyx_k__pileup, sizeof(__pyx_k__pileup), 0, 0, 1, 1},
   {&__pyx_n_s__pileup_iter, __pyx_k__pileup_iter, sizeof(__pyx_k__pileup_iter), 0, 0, 1, 1},
   {&__pyx_n_s__pileups, __pyx_k__pileups, sizeof(__pyx_k__pileups), 0, 0, 1, 1},
   {&__pyx_n_s__platform, __pyx_k__platform, sizeof(__pyx_k__platform), 0, 0, 1, 1},
@@ -31418,17 +35983,25 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_n_s__port, __pyx_k__port, sizeof(__pyx_k__port), 0, 0, 1, 1},
   {&__pyx_n_s__pos, __pyx_k__pos, sizeof(__pyx_k__pos), 0, 0, 1, 1},
   {&__pyx_n_s__positions, __pyx_k__positions, sizeof(__pyx_k__positions), 0, 0, 1, 1},
+  {&__pyx_n_s__q_cns, __pyx_k__q_cns, sizeof(__pyx_k__q_cns), 0, 0, 1, 1},
+  {&__pyx_n_s__q_indel, __pyx_k__q_indel, sizeof(__pyx_k__q_indel), 0, 0, 1, 1},
+  {&__pyx_n_s__q_r, __pyx_k__q_r, sizeof(__pyx_k__q_r), 0, 0, 1, 1},
+  {&__pyx_n_s__q_ref, __pyx_k__q_ref, sizeof(__pyx_k__q_ref), 0, 0, 1, 1},
   {&__pyx_n_s__qname, __pyx_k__qname, sizeof(__pyx_k__qname), 0, 0, 1, 1},
   {&__pyx_n_s__qpos, __pyx_k__qpos, sizeof(__pyx_k__qpos), 0, 0, 1, 1},
   {&__pyx_n_s__qseq, __pyx_k__qseq, sizeof(__pyx_k__qseq), 0, 0, 1, 1},
   {&__pyx_n_s__qual, __pyx_k__qual, sizeof(__pyx_k__qual), 0, 0, 1, 1},
   {&__pyx_n_s__r, __pyx_k__r, sizeof(__pyx_k__r), 0, 0, 1, 1},
-  {&__pyx_n_s__rU, __pyx_k__rU, sizeof(__pyx_k__rU), 0, 0, 1, 1},
+  {&__pyx_n_s__r_indel, __pyx_k__r_indel, sizeof(__pyx_k__r_indel), 0, 0, 1, 1},
+  {&__pyx_n_s__range, __pyx_k__range, sizeof(__pyx_k__range), 0, 0, 1, 1},
   {&__pyx_n_s__raw, __pyx_k__raw, sizeof(__pyx_k__raw), 0, 0, 1, 1},
   {&__pyx_n_s__rb, __pyx_k__rb, sizeof(__pyx_k__rb), 0, 0, 1, 1},
   {&__pyx_n_s__re, __pyx_k__re, sizeof(__pyx_k__re), 0, 0, 1, 1},
   {&__pyx_n_s__readAndRelease, __pyx_k__readAndRelease, sizeof(__pyx_k__readAndRelease), 0, 0, 1, 1},
   {&__pyx_n_s__readlines, __pyx_k__readlines, sizeof(__pyx_k__readlines), 0, 0, 1, 1},
+  {&__pyx_n_s__reads_diff, __pyx_k__reads_diff, sizeof(__pyx_k__reads_diff), 0, 0, 1, 1},
+  {&__pyx_n_s__reads_first, __pyx_k__reads_first, sizeof(__pyx_k__reads_first), 0, 0, 1, 1},
+  {&__pyx_n_s__reads_second, __pyx_k__reads_second, sizeof(__pyx_k__reads_second), 0, 0, 1, 1},
   {&__pyx_n_s__record, __pyx_k__record, sizeof(__pyx_k__record), 0, 0, 1, 1},
   {&__pyx_n_s__reference, __pyx_k__reference, sizeof(__pyx_k__reference), 0, 0, 1, 1},
   {&__pyx_n_s__reference_base, __pyx_k__reference_base, sizeof(__pyx_k__reference_base), 0, 0, 1, 1},
@@ -31438,6 +36011,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_n_s__release, __pyx_k__release, sizeof(__pyx_k__release), 0, 0, 1, 1},
   {&__pyx_n_s__remove, __pyx_k__remove, sizeof(__pyx_k__remove), 0, 0, 1, 1},
   {&__pyx_n_s__reopen, __pyx_k__reopen, sizeof(__pyx_k__reopen), 0, 0, 1, 1},
+  {&__pyx_n_s__reset, __pyx_k__reset, sizeof(__pyx_k__reset), 0, 0, 1, 1},
   {&__pyx_n_s__restore, __pyx_k__restore, sizeof(__pyx_k__restore), 0, 0, 1, 1},
   {&__pyx_n_s__retval, __pyx_k__retval, sizeof(__pyx_k__retval), 0, 0, 1, 1},
   {&__pyx_n_s__rg2lib, __pyx_k__rg2lib, sizeof(__pyx_k__rg2lib), 0, 0, 1, 1},
@@ -31447,6 +36021,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_n_s__s, __pyx_k__s, sizeof(__pyx_k__s), 0, 0, 1, 1},
   {&__pyx_n_s__samfile, __pyx_k__samfile, sizeof(__pyx_k__samfile), 0, 0, 1, 1},
   {&__pyx_n_s__samtools, __pyx_k__samtools, sizeof(__pyx_k__samtools), 0, 0, 1, 1},
+  {&__pyx_n_s__second_allele, __pyx_k__second_allele, sizeof(__pyx_k__second_allele), 0, 0, 1, 1},
   {&__pyx_n_s__seek, __pyx_k__seek, sizeof(__pyx_k__seek), 0, 0, 1, 1},
   {&__pyx_n_s__self, __pyx_k__self, sizeof(__pyx_k__self), 0, 0, 1, 1},
   {&__pyx_n_s__seq, __pyx_k__seq, sizeof(__pyx_k__seq), 0, 0, 1, 1},
@@ -31458,7 +36033,6 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_n_s__snp_quality, __pyx_k__snp_quality, sizeof(__pyx_k__snp_quality), 0, 0, 1, 1},
   {&__pyx_n_s__split, __pyx_k__split, sizeof(__pyx_k__split), 0, 0, 1, 1},
   {&__pyx_n_s__start, __pyx_k__start, sizeof(__pyx_k__start), 0, 0, 1, 1},
-  {&__pyx_n_s__start_offset, __pyx_k__start_offset, sizeof(__pyx_k__start_offset), 0, 0, 1, 1},
   {&__pyx_n_s__startswith, __pyx_k__startswith, sizeof(__pyx_k__startswith), 0, 0, 1, 1},
   {&__pyx_n_s__stderr, __pyx_k__stderr, sizeof(__pyx_k__stderr), 0, 0, 1, 1},
   {&__pyx_n_s__stderr_f, __pyx_k__stderr_f, sizeof(__pyx_k__stderr_f), 0, 0, 1, 1},
@@ -31474,9 +36048,11 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_n_s__tags, __pyx_k__tags, sizeof(__pyx_k__tags), 0, 0, 1, 1},
   {&__pyx_n_s__target_len, __pyx_k__target_len, sizeof(__pyx_k__target_len), 0, 0, 1, 1},
   {&__pyx_n_s__target_name, __pyx_k__target_name, sizeof(__pyx_k__target_name), 0, 0, 1, 1},
+  {&__pyx_n_s__tell, __pyx_k__tell, sizeof(__pyx_k__tell), 0, 0, 1, 1},
   {&__pyx_n_s__tempfile, __pyx_k__tempfile, sizeof(__pyx_k__tempfile), 0, 0, 1, 1},
   {&__pyx_n_s__template, __pyx_k__template, sizeof(__pyx_k__template), 0, 0, 1, 1},
   {&__pyx_n_s__text, __pyx_k__text, sizeof(__pyx_k__text), 0, 0, 1, 1},
+  {&__pyx_n_s__theta, __pyx_k__theta, sizeof(__pyx_k__theta), 0, 0, 1, 1},
   {&__pyx_n_s__tid, __pyx_k__tid, sizeof(__pyx_k__tid), 0, 0, 1, 1},
   {&__pyx_n_s__traceback, __pyx_k__traceback, sizeof(__pyx_k__traceback), 0, 0, 1, 1},
   {&__pyx_n_s__types, __pyx_k__types, sizeof(__pyx_k__types), 0, 0, 1, 1},
@@ -31497,2025 +36073,1641 @@ static int __Pyx_InitCachedBuiltins(void) {
   __pyx_builtin_map = __Pyx_GetName(__pyx_b, __pyx_n_s__map); if (!__pyx_builtin_map) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_builtin_IOError = __Pyx_GetName(__pyx_b, __pyx_n_s__IOError); if (!__pyx_builtin_IOError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_builtin_OverflowError = __Pyx_GetName(__pyx_b, __pyx_n_s__OverflowError); if (!__pyx_builtin_OverflowError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_builtin_NotImplementedError = __Pyx_GetName(__pyx_b, __pyx_n_s__NotImplementedError); if (!__pyx_builtin_NotImplementedError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_builtin_OSError = __Pyx_GetName(__pyx_b, __pyx_n_s__OSError); if (!__pyx_builtin_OSError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_builtin_AttributeError = __Pyx_GetName(__pyx_b, __pyx_n_s__AttributeError); if (!__pyx_builtin_AttributeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_builtin_KeyError = __Pyx_GetName(__pyx_b, __pyx_n_s__KeyError); if (!__pyx_builtin_KeyError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_builtin_StopIteration = __Pyx_GetName(__pyx_b, __pyx_n_s__StopIteration); if (!__pyx_builtin_StopIteration) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_builtin_cmp = __Pyx_GetName(__pyx_b, __pyx_n_s__cmp); if (!__pyx_builtin_cmp) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_builtin_chr = __Pyx_GetName(__pyx_b, __pyx_n_s__chr); if (!__pyx_builtin_chr) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_builtin_TypeError = __Pyx_GetName(__pyx_b, __pyx_n_s__TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2710; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_OverflowError = __Pyx_GetName(__pyx_b, __pyx_n_s__OverflowError); if (!__pyx_builtin_OverflowError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_NotImplementedError = __Pyx_GetName(__pyx_b, __pyx_n_s__NotImplementedError); if (!__pyx_builtin_NotImplementedError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_KeyError = __Pyx_GetName(__pyx_b, __pyx_n_s__KeyError); if (!__pyx_builtin_KeyError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_StopIteration = __Pyx_GetName(__pyx_b, __pyx_n_s__StopIteration); if (!__pyx_builtin_StopIteration) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_cmp = __Pyx_GetName(__pyx_b, __pyx_n_s__cmp); if (!__pyx_builtin_cmp) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_chr = __Pyx_GetName(__pyx_b, __pyx_n_s__chr); if (!__pyx_builtin_chr) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2547; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_TypeError = __Pyx_GetName(__pyx_b, __pyx_n_s__TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_range = __Pyx_GetName(__pyx_b, __pyx_n_s__range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   return 0;
   __pyx_L1_error:;
   return -1;
 }
 
-static int __Pyx_InitCachedConstants(void) {
-  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants");
-
-  /* "csamtools.pyx":271
- *     def __len__(self):
- *         if self.fastafile == NULL:
- *             raise ValueError( "calling len() on closed file" )             # <<<<<<<<<<<<<<
- * 
- *         return faidx_fetch_nseq(self.fastafile)
- */
-  __pyx_k_tuple_4 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_4));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
-  PyTuple_SET_ITEM(__pyx_k_tuple_4, 0, ((PyObject *)__pyx_kp_s_3));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_4));
-
-  /* "csamtools.pyx":303
- *         '''number of :term:`filename` associated with this object.'''
- *         def __get__(self):
- *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
- *             return self._filename
- * 
- */
-  __pyx_k_tuple_7 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_7));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
-  PyTuple_SET_ITEM(__pyx_k_tuple_7, 0, ((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_7));
-
-  /* "csamtools.pyx":328
- * 
- *         if not self._isOpen():
- *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
- * 
- *         cdef int length
- */
-  __pyx_k_tuple_8 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_8));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
-  PyTuple_SET_ITEM(__pyx_k_tuple_8, 0, ((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_8));
-
-  /* "csamtools.pyx":334
- * 
- *         if not region:
- *             if reference is None: raise ValueError( 'no sequence/region supplied.' )             # <<<<<<<<<<<<<<
- *             if start is None: start = 0
- *             if end is None: end = max_pos -1
- */
-  __pyx_k_tuple_10 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_10));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_9));
-  PyTuple_SET_ITEM(__pyx_k_tuple_10, 0, ((PyObject *)__pyx_kp_s_9));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_9));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_10));
-
-  /* "csamtools.pyx":636
- *         returns -1 if reference is not known.
- *         '''
- *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
- *         return pysam_reference2tid( self.samfile.header, reference )
- * 
- */
-  __pyx_k_tuple_29 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_29)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_29));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
-  PyTuple_SET_ITEM(__pyx_k_tuple_29, 0, ((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_29));
-
-  /* "csamtools.pyx":642
- *         '''
- *         convert numerical :term:`tid` into :term:`reference` name.'''
- *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
- *         if not 0 <= tid < self.samfile.header.n_targets:
- *             raise ValueError( "tid %i out of range 0<=tid<%i" % (tid, self.samfile.header.n_targets ) )
- */
-  __pyx_k_tuple_30 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_30)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_30));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
-  PyTuple_SET_ITEM(__pyx_k_tuple_30, 0, ((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_30));
-
-  /* "csamtools.pyx":650
- *         '''
- *         convert numerical :term:`tid` into :term:`reference` name.'''
- *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
- *         if not 0 <= tid < self.samfile.header.n_targets:
- *             raise ValueError( "tid %i out of range 0<=tid<%i" % (tid, self.samfile.header.n_targets ) )
- */
-  __pyx_k_tuple_32 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_32)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_32));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
-  PyTuple_SET_ITEM(__pyx_k_tuple_32, 0, ((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_32));
-
-  /* "csamtools.pyx":699
- *             if len(parts) >= 3: rend = int(parts[2])
- * 
- *         if not reference: return 0, 0, 0, 0             # <<<<<<<<<<<<<<
- * 
- *         rtid = self.gettid( reference )
- */
-  __pyx_k_tuple_34 = PyTuple_New(4); if (unlikely(!__pyx_k_tuple_34)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_34));
-  __Pyx_INCREF(__pyx_int_0);
-  PyTuple_SET_ITEM(__pyx_k_tuple_34, 0, __pyx_int_0);
-  __Pyx_GIVEREF(__pyx_int_0);
-  __Pyx_INCREF(__pyx_int_0);
-  PyTuple_SET_ITEM(__pyx_k_tuple_34, 1, __pyx_int_0);
-  __Pyx_GIVEREF(__pyx_int_0);
-  __Pyx_INCREF(__pyx_int_0);
-  PyTuple_SET_ITEM(__pyx_k_tuple_34, 2, __pyx_int_0);
-  __Pyx_GIVEREF(__pyx_int_0);
-  __Pyx_INCREF(__pyx_int_0);
-  PyTuple_SET_ITEM(__pyx_k_tuple_34, 3, __pyx_int_0);
-  __Pyx_GIVEREF(__pyx_int_0);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_34));
-
-  /* "csamtools.pyx":719
- * 
- *         if not self._isOpen():
- *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
- *         if not self.isbam:
- *             raise NotImplementedError("seek only available in bam files")
- */
-  __pyx_k_tuple_37 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_37)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_37));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
-  PyTuple_SET_ITEM(__pyx_k_tuple_37, 0, ((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_37));
-
-  /* "csamtools.pyx":721
- *             raise ValueError( "I/O operation on closed file" )
- *         if not self.isbam:
- *             raise NotImplementedError("seek only available in bam files")             # <<<<<<<<<<<<<<
- *         if self.isstream:
- *             raise OSError("seek no available in streams")
- */
-  __pyx_k_tuple_39 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_39)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 721; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_39));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_38));
-  PyTuple_SET_ITEM(__pyx_k_tuple_39, 0, ((PyObject *)__pyx_kp_s_38));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_38));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_39));
-
-  /* "csamtools.pyx":723
- *             raise NotImplementedError("seek only available in bam files")
- *         if self.isstream:
- *             raise OSError("seek no available in streams")             # <<<<<<<<<<<<<<
- * 
- *         return bam_seek( self.samfile.x.bam, offset, where )
- */
-  __pyx_k_tuple_41 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_41)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_41));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_40));
-  PyTuple_SET_ITEM(__pyx_k_tuple_41, 0, ((PyObject *)__pyx_kp_s_40));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_40));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_41));
-
-  /* "csamtools.pyx":732
- *         '''
- *         if not self._isOpen():
- *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
- *         if not self.isbam:
- *             raise NotImplementedError("seek only available in bam files")
- */
-  __pyx_k_tuple_42 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_42)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 732; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_42));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
-  PyTuple_SET_ITEM(__pyx_k_tuple_42, 0, ((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_42));
-
-  /* "csamtools.pyx":734
- *             raise ValueError( "I/O operation on closed file" )
- *         if not self.isbam:
- *             raise NotImplementedError("seek only available in bam files")             # <<<<<<<<<<<<<<
- * 
- *         return bam_tell( self.samfile.x.bam )
- */
-  __pyx_k_tuple_43 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_43)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_43));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_38));
-  PyTuple_SET_ITEM(__pyx_k_tuple_43, 0, ((PyObject *)__pyx_kp_s_38));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_38));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_43));
-
-  /* "csamtools.pyx":769
- * 
- *         if not self._isOpen():
- *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
- * 
- *         has_coord, rtid, rstart, rend = self._parseRegion( reference, start, end, region )
- */
-  __pyx_k_tuple_45 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_45)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_45));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
-  PyTuple_SET_ITEM(__pyx_k_tuple_45, 0, ((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_45));
-
-  /* "csamtools.pyx":778
- *         if self.isbam:
- *             if not until_eof and not self._hasIndex() and not self.isremote:
- *                 raise ValueError( "fetch called on bamfile without index" )             # <<<<<<<<<<<<<<
- * 
- *             if callback:
- */
-  __pyx_k_tuple_47 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_47)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_47));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_46));
-  PyTuple_SET_ITEM(__pyx_k_tuple_47, 0, ((PyObject *)__pyx_kp_s_46));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_46));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_47));
-
-  /* "csamtools.pyx":781
- * 
- *             if callback:
- *                 if not has_coord: raise ValueError( "callback functionality requires a region/reference" )             # <<<<<<<<<<<<<<
- *                 if not self._hasIndex(): raise ValueError( "no index available for fetch" )
- *                 return bam_fetch(self.samfile.x.bam,
- */
-  __pyx_k_tuple_49 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_49)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_49));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_48));
-  PyTuple_SET_ITEM(__pyx_k_tuple_49, 0, ((PyObject *)__pyx_kp_s_48));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_48));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_49));
-
-  /* "csamtools.pyx":782
- *             if callback:
- *                 if not has_coord: raise ValueError( "callback functionality requires a region/reference" )
- *                 if not self._hasIndex(): raise ValueError( "no index available for fetch" )             # <<<<<<<<<<<<<<
- *                 return bam_fetch(self.samfile.x.bam,
- *                                  self.index,
- */
-  __pyx_k_tuple_51 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_51)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_51));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_50));
-  PyTuple_SET_ITEM(__pyx_k_tuple_51, 0, ((PyObject *)__pyx_kp_s_50));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_50));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_51));
-
-  /* "csamtools.pyx":803
- *             # this happens if a bamfile is opened with mode 'r'
- *             if has_coord:
- *                 raise ValueError ("fetching by region is not available for sam files" )             # <<<<<<<<<<<<<<
- * 
- *             if self.samfile.header.n_targets == 0:
- */
-  __pyx_k_tuple_53 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_53)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_53));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_52));
-  PyTuple_SET_ITEM(__pyx_k_tuple_53, 0, ((PyObject *)__pyx_kp_s_52));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_52));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_53));
-
-  /* "csamtools.pyx":806
- * 
- *             if self.samfile.header.n_targets == 0:
- *                 raise ValueError( "fetch called for samfile without header")             # <<<<<<<<<<<<<<
- * 
- *             if callback:
- */
-  __pyx_k_tuple_55 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_55)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_55));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_54));
-  PyTuple_SET_ITEM(__pyx_k_tuple_55, 0, ((PyObject *)__pyx_kp_s_54));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_54));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_55));
-
-  /* "csamtools.pyx":809
- * 
- *             if callback:
- *                 raise NotImplementedError( "callback not implemented yet" )             # <<<<<<<<<<<<<<
- *             else:
- *                 return IteratorRowAll( self, reopen=reopen )
- */
-  __pyx_k_tuple_57 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_57)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_57));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_56));
-  PyTuple_SET_ITEM(__pyx_k_tuple_57, 0, ((PyObject *)__pyx_kp_s_56));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_56));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_57));
-
-  /* "csamtools.pyx":850
- * 
- *         if mate_data.mate == NULL:
- *             raise ValueError( "mate not found" )             # <<<<<<<<<<<<<<
- * 
- *         cdef AlignedRead dest = AlignedRead.__new__(AlignedRead)
- */
-  __pyx_k_tuple_61 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_61)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_61));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_60));
-  PyTuple_SET_ITEM(__pyx_k_tuple_61, 0, ((PyObject *)__pyx_kp_s_60));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_60));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_61));
-
-  /* "csamtools.pyx":875
- * 
- *         if not self._isOpen():
- *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
- * 
- *         region, rtid, rstart, rend = self._parseRegion( reference, start, end, region )
- */
-  __pyx_k_tuple_63 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_63)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_63));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
-  PyTuple_SET_ITEM(__pyx_k_tuple_63, 0, ((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_63));
-
-  /* "csamtools.pyx":884
- *         if self.isbam:
- *             if not until_eof and not self._hasIndex() and not self.isremote:
- *                 raise ValueError( "fetch called on bamfile without index" )             # <<<<<<<<<<<<<<
- * 
- *             if not region:
- */
-  __pyx_k_tuple_64 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_64)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 884; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_64));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_46));
-  PyTuple_SET_ITEM(__pyx_k_tuple_64, 0, ((PyObject *)__pyx_kp_s_46));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_46));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_64));
-
-  /* "csamtools.pyx":887
- * 
- *             if not region:
- *                 raise ValueError( "counting functionality requires a region/reference" )             # <<<<<<<<<<<<<<
- *             if not self._hasIndex(): raise ValueError( "no index available for fetch" )
- *             bam_fetch(self.samfile.x.bam,
- */
-  __pyx_k_tuple_66 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_66)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 887; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_66));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_65));
-  PyTuple_SET_ITEM(__pyx_k_tuple_66, 0, ((PyObject *)__pyx_kp_s_65));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_65));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_66));
+static int __Pyx_InitGlobals(void) {
+  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_8 = PyInt_FromLong(8); if (unlikely(!__pyx_int_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_13 = PyInt_FromLong(13); if (unlikely(!__pyx_int_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_16 = PyInt_FromLong(16); if (unlikely(!__pyx_int_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_32 = PyInt_FromLong(32); if (unlikely(!__pyx_int_32)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_40 = PyInt_FromLong(40); if (unlikely(!__pyx_int_40)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_60 = PyInt_FromLong(60); if (unlikely(!__pyx_int_60)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_64 = PyInt_FromLong(64); if (unlikely(!__pyx_int_64)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_128 = PyInt_FromLong(128); if (unlikely(!__pyx_int_128)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_255 = PyInt_FromLong(255); if (unlikely(!__pyx_int_255)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_256 = PyInt_FromLong(256); if (unlikely(!__pyx_int_256)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_512 = PyInt_FromLong(512); if (unlikely(!__pyx_int_512)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_neg_127 = PyInt_FromLong(-127); if (unlikely(!__pyx_int_neg_127)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_0660 = PyInt_FromLong(0660); if (unlikely(!__pyx_int_0660)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_1024 = PyInt_FromLong(1024); if (unlikely(!__pyx_int_1024)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_65535 = PyInt_FromLong(65535); if (unlikely(!__pyx_int_65535)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_neg_32767 = PyInt_FromLong(-32767); if (unlikely(!__pyx_int_neg_32767)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_536870912 = PyInt_FromLong(536870912); if (unlikely(!__pyx_int_536870912)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_4294967295 = PyInt_FromString((char *)"4294967295", 0, 0); if (unlikely(!__pyx_int_4294967295)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_neg_2147483648 = PyInt_FromLong(-2147483648); if (unlikely(!__pyx_int_neg_2147483648)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  return 0;
+  __pyx_L1_error:;
+  return -1;
+}
 
-  /* "csamtools.pyx":888
- *             if not region:
- *                 raise ValueError( "counting functionality requires a region/reference" )
- *             if not self._hasIndex(): raise ValueError( "no index available for fetch" )             # <<<<<<<<<<<<<<
- *             bam_fetch(self.samfile.x.bam,
- *                              self.index,
- */
-  __pyx_k_tuple_67 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_67)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_67));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_50));
-  PyTuple_SET_ITEM(__pyx_k_tuple_67, 0, ((PyObject *)__pyx_kp_s_50));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_50));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_67));
+#if PY_MAJOR_VERSION < 3
+PyMODINIT_FUNC initcsamtools(void); /*proto*/
+PyMODINIT_FUNC initcsamtools(void)
+#else
+PyMODINIT_FUNC PyInit_csamtools(void); /*proto*/
+PyMODINIT_FUNC PyInit_csamtools(void)
+#endif
+{
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  int __pyx_t_5;
+  #if CYTHON_REFNANNY
+  void* __pyx_refnanny = NULL;
+  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
+  if (!__Pyx_RefNanny) {
+      PyErr_Clear();
+      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
+      if (!__Pyx_RefNanny)
+          Py_FatalError("failed to import 'refnanny' module");
+  }
+  __pyx_refnanny = __Pyx_RefNanny->SetupContext("PyMODINIT_FUNC PyInit_csamtools(void)", __LINE__, __FILE__);
+  #endif
+  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #ifdef __pyx_binding_PyCFunctionType_USED
+  if (__pyx_binding_PyCFunctionType_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #endif
+  /*--- Library function declarations ---*/
+  /*--- Threads initialization code ---*/
+  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
+  #ifdef WITH_THREAD /* Python build with threading support? */
+  PyEval_InitThreads();
+  #endif
+  #endif
+  /*--- Module creation code ---*/
+  #if PY_MAJOR_VERSION < 3
+  __pyx_m = Py_InitModule4(__Pyx_NAMESTR("csamtools"), __pyx_methods, 0, 0, PYTHON_API_VERSION);
+  #else
+  __pyx_m = PyModule_Create(&__pyx_moduledef);
+  #endif
+  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  #if PY_MAJOR_VERSION < 3
+  Py_INCREF(__pyx_m);
+  #endif
+  __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME));
+  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  /*--- Initialize various global constants etc. ---*/
+  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__pyx_module_is_main_csamtools) {
+    if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  }
+  /*--- Builtin init code ---*/
+  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  /*--- Global init code ---*/
+  /*--- Function export code ---*/
+  /*--- Type init code ---*/
+  __pyx_ptype_9csamtools_file = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "file", sizeof(PyFileObject), 0); if (unlikely(!__pyx_ptype_9csamtools_file)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_9csamtools_AlignedRead) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  {
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_AlignedRead, "__str__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
+      __pyx_wrapperbase_9csamtools_11AlignedRead___str__ = *((PyWrapperDescrObject *)wrapper)->d_base;
+      __pyx_wrapperbase_9csamtools_11AlignedRead___str__.doc = __pyx_doc_9csamtools_11AlignedRead___str__;
+      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_11AlignedRead___str__;
+    }
+  }
+  if (__Pyx_SetAttrString(__pyx_m, "AlignedRead", (PyObject *)&__pyx_type_9csamtools_AlignedRead) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_9csamtools_AlignedRead = &__pyx_type_9csamtools_AlignedRead;
+  __pyx_vtabptr_9csamtools_Samfile = &__pyx_vtable_9csamtools_Samfile;
+  #if PY_MAJOR_VERSION >= 3
+  __pyx_vtable_9csamtools_Samfile._buildHeader = (bam_header_t *(*)(struct __pyx_obj_9csamtools_Samfile *, PyObject *))__pyx_f_9csamtools_7Samfile__buildHeader;
+  __pyx_vtable_9csamtools_Samfile.getCurrent = (bam1_t *(*)(struct __pyx_obj_9csamtools_Samfile *))__pyx_f_9csamtools_7Samfile_getCurrent;
+  __pyx_vtable_9csamtools_Samfile.cnext = (int (*)(struct __pyx_obj_9csamtools_Samfile *))__pyx_f_9csamtools_7Samfile_cnext;
+  __pyx_vtable_9csamtools_Samfile.write = (int (*)(struct __pyx_obj_9csamtools_Samfile *, struct __pyx_obj_9csamtools_AlignedRead *, int __pyx_skip_dispatch))__pyx_f_9csamtools_7Samfile_write;
+  __pyx_vtable_9csamtools_Samfile._getrname = (char *(*)(struct __pyx_obj_9csamtools_Samfile *, int))__pyx_f_9csamtools_7Samfile__getrname;
+  #else
+  *(void(**)(void))&__pyx_vtable_9csamtools_Samfile._buildHeader = (void(*)(void))__pyx_f_9csamtools_7Samfile__buildHeader;
+  *(void(**)(void))&__pyx_vtable_9csamtools_Samfile.getCurrent = (void(*)(void))__pyx_f_9csamtools_7Samfile_getCurrent;
+  *(void(**)(void))&__pyx_vtable_9csamtools_Samfile.cnext = (void(*)(void))__pyx_f_9csamtools_7Samfile_cnext;
+  *(void(**)(void))&__pyx_vtable_9csamtools_Samfile.write = (void(*)(void))__pyx_f_9csamtools_7Samfile_write;
+  *(void(**)(void))&__pyx_vtable_9csamtools_Samfile._getrname = (void(*)(void))__pyx_f_9csamtools_7Samfile__getrname;
+  #endif
+  if (PyType_Ready(&__pyx_type_9csamtools_Samfile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  {
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_Samfile, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
+      __pyx_wrapperbase_9csamtools_7Samfile___next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
+      __pyx_wrapperbase_9csamtools_7Samfile___next__.doc = __pyx_doc_9csamtools_7Samfile___next__;
+      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_7Samfile___next__;
+    }
+  }
+  if (__Pyx_SetVtable(__pyx_type_9csamtools_Samfile.tp_dict, __pyx_vtabptr_9csamtools_Samfile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "Samfile", (PyObject *)&__pyx_type_9csamtools_Samfile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_9csamtools_Samfile = &__pyx_type_9csamtools_Samfile;
+  if (PyType_Ready(&__pyx_type_9csamtools_PileupProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "PileupProxy", (PyObject *)&__pyx_type_9csamtools_PileupProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_9csamtools_PileupProxy = &__pyx_type_9csamtools_PileupProxy;
+  if (PyType_Ready(&__pyx_type_9csamtools_PileupRead) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "PileupRead", (PyObject *)&__pyx_type_9csamtools_PileupRead) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_9csamtools_PileupRead = &__pyx_type_9csamtools_PileupRead;
+  __pyx_vtabptr_9csamtools_Fastafile = &__pyx_vtable_9csamtools_Fastafile;
+  #if PY_MAJOR_VERSION >= 3
+  __pyx_vtable_9csamtools_Fastafile._fetch = (char *(*)(struct __pyx_obj_9csamtools_Fastafile *, char *, int, int, int *))__pyx_f_9csamtools_9Fastafile__fetch;
+  #else
+  *(void(**)(void))&__pyx_vtable_9csamtools_Fastafile._fetch = (void(*)(void))__pyx_f_9csamtools_9Fastafile__fetch;
+  #endif
+  if (PyType_Ready(&__pyx_type_9csamtools_Fastafile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetVtable(__pyx_type_9csamtools_Fastafile.tp_dict, __pyx_vtabptr_9csamtools_Fastafile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "Fastafile", (PyObject *)&__pyx_type_9csamtools_Fastafile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_9csamtools_Fastafile = &__pyx_type_9csamtools_Fastafile;
+  if (PyType_Ready(&__pyx_type_9csamtools_IteratorRow) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "IteratorRow", (PyObject *)&__pyx_type_9csamtools_IteratorRow) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_9csamtools_IteratorRow = &__pyx_type_9csamtools_IteratorRow;
+  __pyx_vtabptr_9csamtools_IteratorRowRegion = &__pyx_vtable_9csamtools_IteratorRowRegion;
+  #if PY_MAJOR_VERSION >= 3
+  __pyx_vtable_9csamtools_IteratorRowRegion.getCurrent = (bam1_t *(*)(struct __pyx_obj_9csamtools_IteratorRowRegion *))__pyx_f_9csamtools_17IteratorRowRegion_getCurrent;
+  __pyx_vtable_9csamtools_IteratorRowRegion.cnext = (int (*)(struct __pyx_obj_9csamtools_IteratorRowRegion *))__pyx_f_9csamtools_17IteratorRowRegion_cnext;
+  #else
+  *(void(**)(void))&__pyx_vtable_9csamtools_IteratorRowRegion.getCurrent = (void(*)(void))__pyx_f_9csamtools_17IteratorRowRegion_getCurrent;
+  *(void(**)(void))&__pyx_vtable_9csamtools_IteratorRowRegion.cnext = (void(*)(void))__pyx_f_9csamtools_17IteratorRowRegion_cnext;
+  #endif
+  __pyx_type_9csamtools_IteratorRowRegion.tp_base = __pyx_ptype_9csamtools_IteratorRow;
+  if (PyType_Ready(&__pyx_type_9csamtools_IteratorRowRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  {
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_IteratorRowRegion, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
+      __pyx_wrapperbase_9csamtools_17IteratorRowRegion___next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
+      __pyx_wrapperbase_9csamtools_17IteratorRowRegion___next__.doc = __pyx_doc_9csamtools_17IteratorRowRegion___next__;
+      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_17IteratorRowRegion___next__;
+    }
+  }
+  if (__Pyx_SetVtable(__pyx_type_9csamtools_IteratorRowRegion.tp_dict, __pyx_vtabptr_9csamtools_IteratorRowRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "IteratorRowRegion", (PyObject *)&__pyx_type_9csamtools_IteratorRowRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_9csamtools_IteratorRowRegion = &__pyx_type_9csamtools_IteratorRowRegion;
+  __pyx_vtabptr_9csamtools_IteratorRowAll = &__pyx_vtable_9csamtools_IteratorRowAll;
+  #if PY_MAJOR_VERSION >= 3
+  __pyx_vtable_9csamtools_IteratorRowAll.getCurrent = (bam1_t *(*)(struct __pyx_obj_9csamtools_IteratorRowAll *))__pyx_f_9csamtools_14IteratorRowAll_getCurrent;
+  __pyx_vtable_9csamtools_IteratorRowAll.cnext = (int (*)(struct __pyx_obj_9csamtools_IteratorRowAll *))__pyx_f_9csamtools_14IteratorRowAll_cnext;
+  #else
+  *(void(**)(void))&__pyx_vtable_9csamtools_IteratorRowAll.getCurrent = (void(*)(void))__pyx_f_9csamtools_14IteratorRowAll_getCurrent;
+  *(void(**)(void))&__pyx_vtable_9csamtools_IteratorRowAll.cnext = (void(*)(void))__pyx_f_9csamtools_14IteratorRowAll_cnext;
+  #endif
+  __pyx_type_9csamtools_IteratorRowAll.tp_base = __pyx_ptype_9csamtools_IteratorRow;
+  if (PyType_Ready(&__pyx_type_9csamtools_IteratorRowAll) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  {
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_IteratorRowAll, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
+      __pyx_wrapperbase_9csamtools_14IteratorRowAll___next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
+      __pyx_wrapperbase_9csamtools_14IteratorRowAll___next__.doc = __pyx_doc_9csamtools_14IteratorRowAll___next__;
+      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_14IteratorRowAll___next__;
+    }
+  }
+  if (__Pyx_SetVtable(__pyx_type_9csamtools_IteratorRowAll.tp_dict, __pyx_vtabptr_9csamtools_IteratorRowAll) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "IteratorRowAll", (PyObject *)&__pyx_type_9csamtools_IteratorRowAll) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_9csamtools_IteratorRowAll = &__pyx_type_9csamtools_IteratorRowAll;
+  __pyx_type_9csamtools_IteratorRowAllRefs.tp_base = __pyx_ptype_9csamtools_IteratorRow;
+  if (PyType_Ready(&__pyx_type_9csamtools_IteratorRowAllRefs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  {
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_IteratorRowAllRefs, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
+      __pyx_wrapperbase_9csamtools_18IteratorRowAllRefs___next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
+      __pyx_wrapperbase_9csamtools_18IteratorRowAllRefs___next__.doc = __pyx_doc_9csamtools_18IteratorRowAllRefs___next__;
+      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_18IteratorRowAllRefs___next__;
+    }
+  }
+  if (__Pyx_SetAttrString(__pyx_m, "IteratorRowAllRefs", (PyObject *)&__pyx_type_9csamtools_IteratorRowAllRefs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_9csamtools_IteratorRowAllRefs = &__pyx_type_9csamtools_IteratorRowAllRefs;
+  __pyx_vtabptr_9csamtools_IteratorRowSelection = &__pyx_vtable_9csamtools_IteratorRowSelection;
+  #if PY_MAJOR_VERSION >= 3
+  __pyx_vtable_9csamtools_IteratorRowSelection.getCurrent = (bam1_t *(*)(struct __pyx_obj_9csamtools_IteratorRowSelection *))__pyx_f_9csamtools_20IteratorRowSelection_getCurrent;
+  __pyx_vtable_9csamtools_IteratorRowSelection.cnext = (int (*)(struct __pyx_obj_9csamtools_IteratorRowSelection *))__pyx_f_9csamtools_20IteratorRowSelection_cnext;
+  #else
+  *(void(**)(void))&__pyx_vtable_9csamtools_IteratorRowSelection.getCurrent = (void(*)(void))__pyx_f_9csamtools_20IteratorRowSelection_getCurrent;
+  *(void(**)(void))&__pyx_vtable_9csamtools_IteratorRowSelection.cnext = (void(*)(void))__pyx_f_9csamtools_20IteratorRowSelection_cnext;
+  #endif
+  __pyx_type_9csamtools_IteratorRowSelection.tp_base = __pyx_ptype_9csamtools_IteratorRow;
+  if (PyType_Ready(&__pyx_type_9csamtools_IteratorRowSelection) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  {
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_IteratorRowSelection, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
+      __pyx_wrapperbase_9csamtools_20IteratorRowSelection___next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
+      __pyx_wrapperbase_9csamtools_20IteratorRowSelection___next__.doc = __pyx_doc_9csamtools_20IteratorRowSelection___next__;
+      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_20IteratorRowSelection___next__;
+    }
+  }
+  if (__Pyx_SetVtable(__pyx_type_9csamtools_IteratorRowSelection.tp_dict, __pyx_vtabptr_9csamtools_IteratorRowSelection) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "IteratorRowSelection", (PyObject *)&__pyx_type_9csamtools_IteratorRowSelection) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_9csamtools_IteratorRowSelection = &__pyx_type_9csamtools_IteratorRowSelection;
+  __pyx_vtabptr_9csamtools_IteratorColumn = &__pyx_vtable_9csamtools_IteratorColumn;
+  #if PY_MAJOR_VERSION >= 3
+  __pyx_vtable_9csamtools_IteratorColumn.cnext = (int (*)(struct __pyx_obj_9csamtools_IteratorColumn *))__pyx_f_9csamtools_14IteratorColumn_cnext;
+  __pyx_vtable_9csamtools_IteratorColumn.getSequence = (char *(*)(struct __pyx_obj_9csamtools_IteratorColumn *))__pyx_f_9csamtools_14IteratorColumn_getSequence;
+  __pyx_vtable_9csamtools_IteratorColumn.setMask = (PyObject *(*)(struct __pyx_obj_9csamtools_IteratorColumn *, PyObject *))__pyx_f_9csamtools_14IteratorColumn_setMask;
+  __pyx_vtable_9csamtools_IteratorColumn.setupIteratorData = (PyObject *(*)(struct __pyx_obj_9csamtools_IteratorColumn *, int, int, int, struct __pyx_opt_args_9csamtools_14IteratorColumn_setupIteratorData *__pyx_optional_args))__pyx_f_9csamtools_14IteratorColumn_setupIteratorData;
+  __pyx_vtable_9csamtools_IteratorColumn.reset = (PyObject *(*)(struct __pyx_obj_9csamtools_IteratorColumn *, PyObject *, PyObject *, PyObject *))__pyx_f_9csamtools_14IteratorColumn_reset;
+  #else
+  *(void(**)(void))&__pyx_vtable_9csamtools_IteratorColumn.cnext = (void(*)(void))__pyx_f_9csamtools_14IteratorColumn_cnext;
+  *(void(**)(void))&__pyx_vtable_9csamtools_IteratorColumn.getSequence = (void(*)(void))__pyx_f_9csamtools_14IteratorColumn_getSequence;
+  *(void(**)(void))&__pyx_vtable_9csamtools_IteratorColumn.setMask = (void(*)(void))__pyx_f_9csamtools_14IteratorColumn_setMask;
+  *(void(**)(void))&__pyx_vtable_9csamtools_IteratorColumn.setupIteratorData = (void(*)(void))__pyx_f_9csamtools_14IteratorColumn_setupIteratorData;
+  *(void(**)(void))&__pyx_vtable_9csamtools_IteratorColumn.reset = (void(*)(void))__pyx_f_9csamtools_14IteratorColumn_reset;
+  #endif
+  if (PyType_Ready(&__pyx_type_9csamtools_IteratorColumn) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetVtable(__pyx_type_9csamtools_IteratorColumn.tp_dict, __pyx_vtabptr_9csamtools_IteratorColumn) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "IteratorColumn", (PyObject *)&__pyx_type_9csamtools_IteratorColumn) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_9csamtools_IteratorColumn = &__pyx_type_9csamtools_IteratorColumn;
+  __pyx_vtabptr_9csamtools_IteratorColumnRegion = &__pyx_vtable_9csamtools_IteratorColumnRegion;
+  __pyx_vtable_9csamtools_IteratorColumnRegion.__pyx_base = *__pyx_vtabptr_9csamtools_IteratorColumn;
+  __pyx_type_9csamtools_IteratorColumnRegion.tp_base = __pyx_ptype_9csamtools_IteratorColumn;
+  if (PyType_Ready(&__pyx_type_9csamtools_IteratorColumnRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  {
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_IteratorColumnRegion, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
+      __pyx_wrapperbase_9csamtools_20IteratorColumnRegion___next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
+      __pyx_wrapperbase_9csamtools_20IteratorColumnRegion___next__.doc = __pyx_doc_9csamtools_20IteratorColumnRegion___next__;
+      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_20IteratorColumnRegion___next__;
+    }
+  }
+  if (__Pyx_SetVtable(__pyx_type_9csamtools_IteratorColumnRegion.tp_dict, __pyx_vtabptr_9csamtools_IteratorColumnRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "IteratorColumnRegion", (PyObject *)&__pyx_type_9csamtools_IteratorColumnRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_9csamtools_IteratorColumnRegion = &__pyx_type_9csamtools_IteratorColumnRegion;
+  __pyx_vtabptr_9csamtools_IteratorColumnAllRefs = &__pyx_vtable_9csamtools_IteratorColumnAllRefs;
+  __pyx_vtable_9csamtools_IteratorColumnAllRefs.__pyx_base = *__pyx_vtabptr_9csamtools_IteratorColumn;
+  __pyx_type_9csamtools_IteratorColumnAllRefs.tp_base = __pyx_ptype_9csamtools_IteratorColumn;
+  if (PyType_Ready(&__pyx_type_9csamtools_IteratorColumnAllRefs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  {
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_IteratorColumnAllRefs, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
+      __pyx_wrapperbase_9csamtools_21IteratorColumnAllRefs___next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
+      __pyx_wrapperbase_9csamtools_21IteratorColumnAllRefs___next__.doc = __pyx_doc_9csamtools_21IteratorColumnAllRefs___next__;
+      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_21IteratorColumnAllRefs___next__;
+    }
+  }
+  if (__Pyx_SetVtable(__pyx_type_9csamtools_IteratorColumnAllRefs.tp_dict, __pyx_vtabptr_9csamtools_IteratorColumnAllRefs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "IteratorColumnAllRefs", (PyObject *)&__pyx_type_9csamtools_IteratorColumnAllRefs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_9csamtools_IteratorColumnAllRefs = &__pyx_type_9csamtools_IteratorColumnAllRefs;
+  if (PyType_Ready(&__pyx_type_9csamtools_SNPCall) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "SNPCall", (PyObject *)&__pyx_type_9csamtools_SNPCall) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_9csamtools_SNPCall = &__pyx_type_9csamtools_SNPCall;
+  __pyx_vtabptr_9csamtools_SNPCallerBase = &__pyx_vtable_9csamtools_SNPCallerBase;
+  #if PY_MAJOR_VERSION >= 3
+  __pyx_vtable_9csamtools_SNPCallerBase.__dump = (PyObject *(*)(struct __pyx_obj_9csamtools_SNPCallerBase *, glf1_t *, uint32_t, int))__pyx_f_9csamtools_13SNPCallerBase___dump;
+  #else
+  *(void(**)(void))&__pyx_vtable_9csamtools_SNPCallerBase.__dump = (void(*)(void))__pyx_f_9csamtools_13SNPCallerBase___dump;
+  #endif
+  if (PyType_Ready(&__pyx_type_9csamtools_SNPCallerBase) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetVtable(__pyx_type_9csamtools_SNPCallerBase.tp_dict, __pyx_vtabptr_9csamtools_SNPCallerBase) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "SNPCallerBase", (PyObject *)&__pyx_type_9csamtools_SNPCallerBase) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_9csamtools_SNPCallerBase = &__pyx_type_9csamtools_SNPCallerBase;
+  __pyx_vtabptr_9csamtools_IteratorSNPCalls = &__pyx_vtable_9csamtools_IteratorSNPCalls;
+  __pyx_vtable_9csamtools_IteratorSNPCalls.__pyx_base = *__pyx_vtabptr_9csamtools_SNPCallerBase;
+  __pyx_type_9csamtools_IteratorSNPCalls.tp_base = __pyx_ptype_9csamtools_SNPCallerBase;
+  if (PyType_Ready(&__pyx_type_9csamtools_IteratorSNPCalls) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  {
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_IteratorSNPCalls, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
+      __pyx_wrapperbase_9csamtools_16IteratorSNPCalls___next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
+      __pyx_wrapperbase_9csamtools_16IteratorSNPCalls___next__.doc = __pyx_doc_9csamtools_16IteratorSNPCalls___next__;
+      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_16IteratorSNPCalls___next__;
+    }
+  }
+  if (__Pyx_SetVtable(__pyx_type_9csamtools_IteratorSNPCalls.tp_dict, __pyx_vtabptr_9csamtools_IteratorSNPCalls) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "IteratorSNPCalls", (PyObject *)&__pyx_type_9csamtools_IteratorSNPCalls) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_9csamtools_IteratorSNPCalls = &__pyx_type_9csamtools_IteratorSNPCalls;
+  __pyx_vtabptr_9csamtools_SNPCaller = &__pyx_vtable_9csamtools_SNPCaller;
+  __pyx_vtable_9csamtools_SNPCaller.__pyx_base = *__pyx_vtabptr_9csamtools_SNPCallerBase;
+  __pyx_type_9csamtools_SNPCaller.tp_base = __pyx_ptype_9csamtools_SNPCallerBase;
+  if (PyType_Ready(&__pyx_type_9csamtools_SNPCaller) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetVtable(__pyx_type_9csamtools_SNPCaller.tp_dict, __pyx_vtabptr_9csamtools_SNPCaller) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "SNPCaller", (PyObject *)&__pyx_type_9csamtools_SNPCaller) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_9csamtools_SNPCaller = &__pyx_type_9csamtools_SNPCaller;
+  if (PyType_Ready(&__pyx_type_9csamtools_IndelCall) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "IndelCall", (PyObject *)&__pyx_type_9csamtools_IndelCall) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_9csamtools_IndelCall = &__pyx_type_9csamtools_IndelCall;
+  if (PyType_Ready(&__pyx_type_9csamtools_IndelCallerBase) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "IndelCallerBase", (PyObject *)&__pyx_type_9csamtools_IndelCallerBase) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_9csamtools_IndelCallerBase = &__pyx_type_9csamtools_IndelCallerBase;
+  __pyx_type_9csamtools_IndelCaller.tp_base = __pyx_ptype_9csamtools_IndelCallerBase;
+  if (PyType_Ready(&__pyx_type_9csamtools_IndelCaller) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "IndelCaller", (PyObject *)&__pyx_type_9csamtools_IndelCaller) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_9csamtools_IndelCaller = &__pyx_type_9csamtools_IndelCaller;
+  __pyx_type_9csamtools_IteratorIndelCalls.tp_base = __pyx_ptype_9csamtools_IndelCallerBase;
+  if (PyType_Ready(&__pyx_type_9csamtools_IteratorIndelCalls) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  {
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_IteratorIndelCalls, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
+      __pyx_wrapperbase_9csamtools_18IteratorIndelCalls___next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
+      __pyx_wrapperbase_9csamtools_18IteratorIndelCalls___next__.doc = __pyx_doc_9csamtools_18IteratorIndelCalls___next__;
+      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_18IteratorIndelCalls___next__;
+    }
+  }
+  if (__Pyx_SetAttrString(__pyx_m, "IteratorIndelCalls", (PyObject *)&__pyx_type_9csamtools_IteratorIndelCalls) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_9csamtools_IteratorIndelCalls = &__pyx_type_9csamtools_IteratorIndelCalls;
+  if (PyType_Ready(&__pyx_type_9csamtools_IndexedReads) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "IndexedReads", (PyObject *)&__pyx_type_9csamtools_IndexedReads) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_9csamtools_IndexedReads = &__pyx_type_9csamtools_IndexedReads;
+  /*--- Type import code ---*/
+  __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), 0); if (unlikely(!__pyx_ptype_7cpython_4bool_bool)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  /*--- Function import code ---*/
+  /*--- Execution code ---*/
 
-  /* "csamtools.pyx":898
- *             return counter
- *         else:
- *             raise ValueError ("count for a region is not available for sam files" )             # <<<<<<<<<<<<<<
- * 
- *     def pileup( self,
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":4
+ * # cython: profile=True
+ * # adds doc-strings for sphinx
+ * import tempfile             # <<<<<<<<<<<<<<
+ * import os
+ * import sys
  */
-  __pyx_k_tuple_69 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_69)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 898; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_69));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_68));
-  PyTuple_SET_ITEM(__pyx_k_tuple_69, 0, ((PyObject *)__pyx_kp_s_68));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_68));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_69));
+  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__tempfile), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__tempfile, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":952
- * 
- *         if not self._isOpen():
- *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
- * 
- *         has_coord, rtid, rstart, rend = self._parseRegion( reference, start, end, region )
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":5
+ * # adds doc-strings for sphinx
+ * import tempfile
+ * import os             # <<<<<<<<<<<<<<
+ * import sys
+ * import types
  */
-  __pyx_k_tuple_70 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_70)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_70));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
-  PyTuple_SET_ITEM(__pyx_k_tuple_70, 0, ((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_70));
+  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__os), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__os, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":957
- * 
- *         if self.isbam:
- *             if not self._hasIndex(): raise ValueError( "no index available for pileup" )             # <<<<<<<<<<<<<<
- * 
- *             if callback:
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":6
+ * import tempfile
+ * import os
+ * import sys             # <<<<<<<<<<<<<<
+ * import types
+ * import itertools
  */
-  __pyx_k_tuple_72 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_72)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_72));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_71));
-  PyTuple_SET_ITEM(__pyx_k_tuple_72, 0, ((PyObject *)__pyx_kp_s_71));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_71));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_72));
+  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__sys), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__sys, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":960
- * 
- *             if callback:
- *                 if not has_coord: raise ValueError( "callback functionality requires a region/reference" )             # <<<<<<<<<<<<<<
- * 
- *                 buf = bam_plbuf_init( <bam_pileup_f>pileup_callback, <void*>callback )
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":7
+ * import os
+ * import sys
+ * import types             # <<<<<<<<<<<<<<
+ * import itertools
+ * import struct
  */
-  __pyx_k_tuple_73 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_73)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 960; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_73));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_48));
-  PyTuple_SET_ITEM(__pyx_k_tuple_73, 0, ((PyObject *)__pyx_kp_s_48));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_48));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_73));
+  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__types), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__types, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":981
- * 
- *         else:
- *             raise NotImplementedError( "pileup of samfiles not implemented yet" )             # <<<<<<<<<<<<<<
- * 
- *     def close( self ):
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":8
+ * import sys
+ * import types
+ * import itertools             # <<<<<<<<<<<<<<
+ * import struct
+ * import ctypes
  */
-  __pyx_k_tuple_75 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_75)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 981; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_75));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_74));
-  PyTuple_SET_ITEM(__pyx_k_tuple_75, 0, ((PyObject *)__pyx_kp_s_74));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_74));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_75));
+  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__itertools), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__itertools, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":1025
- *         '''number of :term:`filename` associated with this object.'''
- *         def __get__(self):
- *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
- *             return self._filename
- * 
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":9
+ * import types
+ * import itertools
+ * import struct             # <<<<<<<<<<<<<<
+ * import ctypes
+ * import collections
  */
-  __pyx_k_tuple_76 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_76)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1025; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_76));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
-  PyTuple_SET_ITEM(__pyx_k_tuple_76, 0, ((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_76));
+  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__struct), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__struct, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":1031
- *         '''number of :term:`reference` sequences in the file.'''
- *         def __get__(self):
- *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
- *             return self.samfile.header.n_targets
- * 
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":10
+ * import itertools
+ * import struct
+ * import ctypes             # <<<<<<<<<<<<<<
+ * import collections
+ * import re
  */
-  __pyx_k_tuple_77 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_77)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_77));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
-  PyTuple_SET_ITEM(__pyx_k_tuple_77, 0, ((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_77));
+  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__ctypes), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__ctypes, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":1037
- *         """tuple with the names of :term:`reference` sequences."""
- *         def __get__(self):
- *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
- *             t = []
- *             for x from 0 <= x < self.samfile.header.n_targets:
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":11
+ * import struct
+ * import ctypes
+ * import collections             # <<<<<<<<<<<<<<
+ * import re
+ * import platform
  */
-  __pyx_k_tuple_78 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_78)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1037; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_78));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
-  PyTuple_SET_ITEM(__pyx_k_tuple_78, 0, ((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_78));
+  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__collections), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__collections, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":1048
- *         """
- *         def __get__(self):
- *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
- *             t = []
- *             for x from 0 <= x < self.samfile.header.n_targets:
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":12
+ * import ctypes
+ * import collections
+ * import re             # <<<<<<<<<<<<<<
+ * import platform
+ * from cpython cimport PyString_FromStringAndSize, PyString_AS_STRING
  */
-  __pyx_k_tuple_79 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_79)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_79));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
-  PyTuple_SET_ITEM(__pyx_k_tuple_79, 0, ((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_79));
+  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__re), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__re, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":1058
- *         """
- *         def __get__(self):
- *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
- *             if not self.isbam: raise AttributeError( "Samfile.mapped only available in bam files" )
- * 
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":13
+ * import collections
+ * import re
+ * import platform             # <<<<<<<<<<<<<<
+ * from cpython cimport PyString_FromStringAndSize, PyString_AS_STRING
+ * from cpython cimport PyErr_SetString
  */
-  __pyx_k_tuple_80 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_80)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_80));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
-  PyTuple_SET_ITEM(__pyx_k_tuple_80, 0, ((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_80));
+  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__platform), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__platform, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":1059
- *         def __get__(self):
- *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
- *             if not self.isbam: raise AttributeError( "Samfile.mapped only available in bam files" )             # <<<<<<<<<<<<<<
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":63
+ * #####################################################################
+ * # hard-coded constants
+ * cdef char * bam_nt16_rev_table = "=ACMGRSVTWYHKDBN"             # <<<<<<<<<<<<<<
+ * cdef int max_pos = 2 << 29
  * 
- *             cdef int tid
  */
-  __pyx_k_tuple_82 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_82)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_82));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_81));
-  PyTuple_SET_ITEM(__pyx_k_tuple_82, 0, ((PyObject *)__pyx_kp_s_81));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_81));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_82));
+  __pyx_v_9csamtools_bam_nt16_rev_table = __pyx_k_172;
 
-  /* "csamtools.pyx":1071
- *         """
- *         def __get__(self):
- *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
- *             if not self.isbam: raise AttributeError( "Samfile.unmapped only available in bam files" )
- *             cdef int tid
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":64
+ * # hard-coded constants
+ * cdef char * bam_nt16_rev_table = "=ACMGRSVTWYHKDBN"
+ * cdef int max_pos = 2 << 29             # <<<<<<<<<<<<<<
+ * 
+ * # redirect stderr to 0
  */
-  __pyx_k_tuple_83 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_83)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1071; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_83));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
-  PyTuple_SET_ITEM(__pyx_k_tuple_83, 0, ((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_83));
+  __pyx_v_9csamtools_max_pos = 1073741824;
 
-  /* "csamtools.pyx":1072
- *         def __get__(self):
- *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
- *             if not self.isbam: raise AttributeError( "Samfile.unmapped only available in bam files" )             # <<<<<<<<<<<<<<
- *             cdef int tid
- *             cdef uint32_t total = 0
- */
-  __pyx_k_tuple_85 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_85)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1072; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_85));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_84));
-  PyTuple_SET_ITEM(__pyx_k_tuple_85, 0, ((PyObject *)__pyx_kp_s_84));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_84));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_85));
-
-  /* "csamtools.pyx":1084
- *         '''full contents of the :term:`sam file` header as a string.'''
- *         def __get__(self):
- *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
- *             return PyString_FromStringAndSize(self.samfile.header.text, self.samfile.header.l_text)
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":67
+ * 
+ * # redirect stderr to 0
+ * _logfile = open(os.path.devnull, "w")             # <<<<<<<<<<<<<<
+ * pysam_set_stderr( PyFile_AsFile( _logfile ) )
  * 
  */
-  __pyx_k_tuple_86 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_86)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1084; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_86));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
-  PyTuple_SET_ITEM(__pyx_k_tuple_86, 0, ((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_86));
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__path); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__devnull); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
+  __Pyx_GIVEREF(__pyx_t_1);
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__w));
+  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_n_s__w));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__w));
+  __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_Call(__pyx_builtin_open, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s___logfile, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":1092
- *         '''
- *         def __get__(self):
- *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":68
+ * # redirect stderr to 0
+ * _logfile = open(os.path.devnull, "w")
+ * pysam_set_stderr( PyFile_AsFile( _logfile ) )             # <<<<<<<<<<<<<<
  * 
- *             result = {}
+ * #####################################################################
  */
-  __pyx_k_tuple_87 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_87)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1092; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_87));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
-  PyTuple_SET_ITEM(__pyx_k_tuple_87, 0, ((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_87));
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s___logfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  pysam_set_stderr(PyFile_AsFile(__pyx_t_1));
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":1099
- *                 # convert to python string (note: call self.text to create 0-terminated string)
- *                 t = self.text
- *                 for line in t.split("\n"):             # <<<<<<<<<<<<<<
- *                     if not line.strip(): continue
- *                     assert line.startswith("@"), "header line without '@': '%s'" % line
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":117
+ *     (<object>f)(a)
+ * 
+ * class PileupColumn(object):             # <<<<<<<<<<<<<<
+ *     '''A pileup column. A pileup column contains
+ *     all the reads that map to a certain target base.
  */
-  __pyx_k_tuple_88 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_88)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1099; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_88));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_2));
-  PyTuple_SET_ITEM(__pyx_k_tuple_88, 0, ((PyObject *)__pyx_kp_s_2));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_2));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_88));
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_builtin_object);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_builtin_object);
+  __Pyx_GIVEREF(__pyx_builtin_object);
+  if (PyDict_SetItemString(((PyObject *)__pyx_t_1), "__doc__", ((PyObject *)__pyx_kp_s_173)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_CreateClass(__pyx_t_2, ((PyObject *)__pyx_t_1), __pyx_n_s__PileupColumn, "csamtools"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-  /* "csamtools.pyx":1101
- *                 for line in t.split("\n"):
- *                     if not line.strip(): continue
- *                     assert line.startswith("@"), "header line without '@': '%s'" % line             # <<<<<<<<<<<<<<
- *                     fields = line[1:].split("\t")
- *                     record = fields[0]
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":130
+ *         list of reads (:class:`pysam.PileupRead`) aligned to this column
+ *     '''
+ *     def __str__(self):             # <<<<<<<<<<<<<<
+ *         return "\t".join( map(str, (self.tid, self.pos, self.n))) +\
+ *             "\n" + "\n".join( map(str, self.pileups) )
  */
-  __pyx_k_tuple_90 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_90)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_90));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_89));
-  PyTuple_SET_ITEM(__pyx_k_tuple_90, 0, ((PyObject *)__pyx_kp_s_89));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_89));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_90));
+  __pyx_t_2 = PyCFunction_New(&__pyx_mdef_9csamtools_12PileupColumn___str__, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_4 = PyMethod_New(__pyx_t_2, 0, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (PyObject_SetAttr(__pyx_t_3, __pyx_n_s____str__, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__PileupColumn, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":1102
- *                     if not line.strip(): continue
- *                     assert line.startswith("@"), "header line without '@': '%s'" % line
- *                     fields = line[1:].split("\t")             # <<<<<<<<<<<<<<
- *                     record = fields[0]
- *                     assert record in VALID_HEADER_TYPES, "header line with invalid type '%s': '%s'" % (record, line)
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":174
+ *     return 0
+ * 
+ * class StderrStore():             # <<<<<<<<<<<<<<
+ *     '''
+ *     stderr is captured.
  */
-  __pyx_k_tuple_92 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_92)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_92));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_1));
-  PyTuple_SET_ITEM(__pyx_k_tuple_92, 0, ((PyObject *)__pyx_kp_s_1));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_1));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_92));
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  if (PyDict_SetItemString(((PyObject *)__pyx_t_1), "__doc__", ((PyObject *)__pyx_kp_s_174)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_CreateClass(((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1), __pyx_n_s__StderrStore, "csamtools"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
 
-  /* "csamtools.pyx":1115
- *                     x = {}
- *                     for field in fields[1:]:
- *                         key, value = field.split(":",1)             # <<<<<<<<<<<<<<
- *                         # uppercase keys must be valid
- *                         # lowercase are permitted for user fields
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":178
+ *     stderr is captured.
+ *     '''
+ *     def __init__(self):             # <<<<<<<<<<<<<<
+ *         return
+ *         self.stderr_h, self.stderr_f = tempfile.mkstemp()
  */
-  __pyx_k_tuple_95 = PyTuple_New(2); if (unlikely(!__pyx_k_tuple_95)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_95));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_94));
-  PyTuple_SET_ITEM(__pyx_k_tuple_95, 0, ((PyObject *)__pyx_kp_s_94));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_94));
-  __Pyx_INCREF(__pyx_int_1);
-  PyTuple_SET_ITEM(__pyx_k_tuple_95, 1, __pyx_int_1);
-  __Pyx_GIVEREF(__pyx_int_1);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_95));
+  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_9csamtools_11StderrStore___init__, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_2 = PyMethod_New(__pyx_t_4, 0, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_t_3, __pyx_n_s____init__, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-  /* "csamtools.pyx":1217
- *     ###############################################################
- *     def __iter__(self):
- *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
- *         if not self.isbam and self.samfile.header.n_targets == 0:
- *                 raise NotImplementedError( "can not iterate over samfile without header")
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":184
+ *         self.stderr_save.setfd( self.stderr_h )
+ * 
+ *     def readAndRelease( self ):             # <<<<<<<<<<<<<<
+ *         return []
+ *         self.stderr_save.restore()
  */
-  __pyx_k_tuple_102 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_102)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_102));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
-  PyTuple_SET_ITEM(__pyx_k_tuple_102, 0, ((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_102));
+  __pyx_t_2 = PyCFunction_New(&__pyx_mdef_9csamtools_11StderrStore_readAndRelease, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_4 = PyMethod_New(__pyx_t_2, 0, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (PyObject_SetAttr(__pyx_t_3, __pyx_n_s__readAndRelease, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
-  /* "csamtools.pyx":1219
- *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
- *         if not self.isbam and self.samfile.header.n_targets == 0:
- *                 raise NotImplementedError( "can not iterate over samfile without header")             # <<<<<<<<<<<<<<
- *         return self
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":193
+ *         return lines
  * 
+ *     def release(self):             # <<<<<<<<<<<<<<
+ *         return
+ *         self.stderr_save.restore()
  */
-  __pyx_k_tuple_104 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_104)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_104));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_103));
-  PyTuple_SET_ITEM(__pyx_k_tuple_104, 0, ((PyObject *)__pyx_kp_s_103));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_103));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_104));
+  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_9csamtools_11StderrStore_release, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_2 = PyMethod_New(__pyx_t_4, 0, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_t_3, __pyx_n_s__release, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-  /* "csamtools.pyx":1296
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":199
+ *             os.remove( self.stderr_f )
  * 
- *         if not samfile._isOpen():
- *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
+ *     def __del__(self):             # <<<<<<<<<<<<<<
+ *         self.release()
  * 
- *         if not samfile._hasIndex():
  */
-  __pyx_k_tuple_105 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_105)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_105));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
-  PyTuple_SET_ITEM(__pyx_k_tuple_105, 0, ((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_105));
+  __pyx_t_2 = PyCFunction_New(&__pyx_mdef_9csamtools_11StderrStore___del__, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_4 = PyMethod_New(__pyx_t_2, 0, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (PyObject_SetAttr(__pyx_t_3, __pyx_n_s____del__, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__StderrStore, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":1299
- * 
- *         if not samfile._hasIndex():
- *             raise ValueError( "no index available for iteration" )             # <<<<<<<<<<<<<<
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":202
+ *         self.release()
  * 
- *         # makes sure that samfile stays alive as long as the
+ * class StderrStoreWindows():             # <<<<<<<<<<<<<<
+ *     '''does nothing. stderr can't be redirected on windows'''
+ *     def __init__(self): pass
  */
-  __pyx_k_tuple_107 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_107)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_107));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_106));
-  PyTuple_SET_ITEM(__pyx_k_tuple_107, 0, ((PyObject *)__pyx_kp_s_106));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_106));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_107));
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  if (PyDict_SetItemString(((PyObject *)__pyx_t_1), "__doc__", ((PyObject *)__pyx_kp_s_175)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_CreateClass(((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1), __pyx_n_s__StderrStoreWindows, "csamtools"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
 
-  /* "csamtools.pyx":1369
- * 
- *         if not samfile._isOpen():
- *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":204
+ * class StderrStoreWindows():
+ *     '''does nothing. stderr can't be redirected on windows'''
+ *     def __init__(self): pass             # <<<<<<<<<<<<<<
+ *     def readAndRelease(self): return []
+ *     def release(self): pass
+ */
+  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_9csamtools_18StderrStoreWindows___init__, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_2 = PyMethod_New(__pyx_t_4, 0, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_t_3, __pyx_n_s____init__, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":205
+ *     '''does nothing. stderr can't be redirected on windows'''
+ *     def __init__(self): pass
+ *     def readAndRelease(self): return []             # <<<<<<<<<<<<<<
+ *     def release(self): pass
  * 
- *         if samfile.isbam: mode = "rb"
  */
-  __pyx_k_tuple_108 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_108)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_108));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
-  PyTuple_SET_ITEM(__pyx_k_tuple_108, 0, ((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_108));
+  __pyx_t_2 = PyCFunction_New(&__pyx_mdef_9csamtools_18StderrStoreWindows_readAndRelease, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_4 = PyMethod_New(__pyx_t_2, 0, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (PyObject_SetAttr(__pyx_t_3, __pyx_n_s__readAndRelease, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
-  /* "csamtools.pyx":1424
- *     def __cinit__(self, Samfile samfile):
- *         assert samfile._isOpen()
- *         if not samfile._hasIndex(): raise ValueError("no index available for fetch")             # <<<<<<<<<<<<<<
- *         self.samfile = samfile
- *         self.tid = -1
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":206
+ *     def __init__(self): pass
+ *     def readAndRelease(self): return []
+ *     def release(self): pass             # <<<<<<<<<<<<<<
+ * 
+ * if platform.system()=='Windows':
  */
-  __pyx_k_tuple_109 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_109)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_109));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_50));
-  PyTuple_SET_ITEM(__pyx_k_tuple_109, 0, ((PyObject *)__pyx_kp_s_50));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_50));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_109));
+  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_9csamtools_18StderrStoreWindows_release, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_2 = PyMethod_New(__pyx_t_4, 0, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_t_3, __pyx_n_s__release, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__StderrStoreWindows, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":1477
- * 
- *         if not samfile._isOpen():
- *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":208
+ *     def release(self): pass
  * 
- *         if not samfile._isOpen():
+ * if platform.system()=='Windows':             # <<<<<<<<<<<<<<
+ *     del StderrStore
+ *     StderrStore = StderrStoreWindows
  */
-  __pyx_k_tuple_110 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_110)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_110));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
-  PyTuple_SET_ITEM(__pyx_k_tuple_110, 0, ((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_110));
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__platform); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__system); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)__pyx_n_s__Windows), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (__pyx_t_5) {
 
-  /* "csamtools.pyx":1480
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":209
  * 
- *         if not samfile._isOpen():
- *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
+ * if platform.system()=='Windows':
+ *     del StderrStore             # <<<<<<<<<<<<<<
+ *     StderrStore = StderrStoreWindows
  * 
- *         assert samfile.isbam, "can only use this iterator on bam files"
  */
-  __pyx_k_tuple_111 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_111)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1480; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_111));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
-  PyTuple_SET_ITEM(__pyx_k_tuple_111, 0, ((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_111));
+    if (__Pyx_DelAttrString(__pyx_m, "StderrStore") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "csamtools.pyx":1796
- *             self.cnext()
- *             if self.n_plp < 0:
- *                 raise ValueError("error during iteration" )             # <<<<<<<<<<<<<<
+    /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":210
+ * if platform.system()=='Windows':
+ *     del StderrStore
+ *     StderrStore = StderrStoreWindows             # <<<<<<<<<<<<<<
+ * 
  * 
- *             if self.plp == NULL:
  */
-  __pyx_k_tuple_117 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_117)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_117));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_116));
-  PyTuple_SET_ITEM(__pyx_k_tuple_117, 0, ((PyObject *)__pyx_kp_s_116));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_116));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_117));
+    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__StderrStoreWindows); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    if (PyObject_SetAttr(__pyx_m, __pyx_n_s__StderrStore, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    goto __pyx_L2;
+  }
+  __pyx_L2:;
 
-  /* "csamtools.pyx":1828
- * 
- *             if self.n_plp < 0:
- *                 raise ValueError("error during iteration" )             # <<<<<<<<<<<<<<
- * 
- *             # return result, if within same reference
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":217
+ * ######################################################################
+ * # valid types for sam headers
+ * VALID_HEADER_TYPES = { "HD" : dict,             # <<<<<<<<<<<<<<
+ *                        "SQ" : list,
+ *                        "RG" : list,
  */
-  __pyx_k_tuple_118 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_118)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_118));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_116));
-  PyTuple_SET_ITEM(__pyx_k_tuple_118, 0, ((PyObject *)__pyx_kp_s_116));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_116));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_118));
+  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__HD), ((PyObject *)((PyObject*)&PyDict_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "csamtools.pyx":2363
- *                     size = struct.calcsize(fmt)
- *                     if offset + size > max_size:
- *                         raise NotImplementedError("tags field too large")             # <<<<<<<<<<<<<<
- * 
- *                     struct.pack_into( fmt,
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":218
+ * # valid types for sam headers
+ * VALID_HEADER_TYPES = { "HD" : dict,
+ *                        "SQ" : list,             # <<<<<<<<<<<<<<
+ *                        "RG" : list,
+ *                        "PG" : list,
  */
-  __pyx_k_tuple_134 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_134)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_134));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_133));
-  PyTuple_SET_ITEM(__pyx_k_tuple_134, 0, ((PyObject *)__pyx_kp_s_133));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_133));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_134));
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__SQ), ((PyObject *)((PyObject*)&PyList_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "csamtools.pyx":2710
- * 
- *     def __init__(self):
- *         raise TypeError("This class cannot be instantiated from Python")             # <<<<<<<<<<<<<<
- * 
- *     def __str__(self):
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":219
+ * VALID_HEADER_TYPES = { "HD" : dict,
+ *                        "SQ" : list,
+ *                        "RG" : list,             # <<<<<<<<<<<<<<
+ *                        "PG" : list,
+ *                        "CO" : list }
  */
-  __pyx_k_tuple_158 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_158)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2710; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_158));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_157));
-  PyTuple_SET_ITEM(__pyx_k_tuple_158, 0, ((PyObject *)__pyx_kp_s_157));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_157));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_158));
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__RG), ((PyObject *)((PyObject*)&PyList_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "csamtools.pyx":2754
- * 
- *     def __init__(self):
- *         raise TypeError("This class cannot be instantiated from Python")             # <<<<<<<<<<<<<<
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":220
+ *                        "SQ" : list,
+ *                        "RG" : list,
+ *                        "PG" : list,             # <<<<<<<<<<<<<<
+ *                        "CO" : list }
  * 
- *     def __str__(self):
  */
-  __pyx_k_tuple_159 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_159)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_159));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_157));
-  PyTuple_SET_ITEM(__pyx_k_tuple_159, 0, ((PyObject *)__pyx_kp_s_157));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_157));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_159));
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__PG), ((PyObject *)((PyObject*)&PyList_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "csamtools.pyx":2867
- *         # recover. Thus redirect output to file with -o option.
- *         if method == "view":
- *             if "-o" in args: raise ValueError("option -o is forbidden in samtools view")             # <<<<<<<<<<<<<<
- *             args = ( "-o", stdout_f ) + args
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":221
+ *                        "RG" : list,
+ *                        "PG" : list,
+ *                        "CO" : list }             # <<<<<<<<<<<<<<
  * 
+ * # order of records within sam headers
  */
-  __pyx_k_tuple_165 = PyTuple_New(1); if (unlikely(!__pyx_k_tuple_165)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_165));
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_164));
-  PyTuple_SET_ITEM(__pyx_k_tuple_165, 0, ((PyObject *)__pyx_kp_s_164));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_164));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_165));
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__CO), ((PyObject *)((PyObject*)&PyList_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__VALID_HEADER_TYPES, ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
 
-  /* "csamtools.pyx":224
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":224
  * 
  * # order of records within sam headers
  * VALID_HEADERS = ("HD", "SQ", "RG", "PG", "CO" )             # <<<<<<<<<<<<<<
  * 
  * # type conversions within sam header records
  */
-  __pyx_k_tuple_233 = PyTuple_New(5); if (unlikely(!__pyx_k_tuple_233)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_233));
+  __pyx_t_3 = PyTuple_New(5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
   __Pyx_INCREF(((PyObject *)__pyx_n_s__HD));
-  PyTuple_SET_ITEM(__pyx_k_tuple_233, 0, ((PyObject *)__pyx_n_s__HD));
+  PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_n_s__HD));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__HD));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__SQ));
-  PyTuple_SET_ITEM(__pyx_k_tuple_233, 1, ((PyObject *)__pyx_n_s__SQ));
+  PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_n_s__SQ));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__SQ));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__RG));
-  PyTuple_SET_ITEM(__pyx_k_tuple_233, 2, ((PyObject *)__pyx_n_s__RG));
+  PyTuple_SET_ITEM(__pyx_t_3, 2, ((PyObject *)__pyx_n_s__RG));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__RG));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__PG));
-  PyTuple_SET_ITEM(__pyx_k_tuple_233, 3, ((PyObject *)__pyx_n_s__PG));
+  PyTuple_SET_ITEM(__pyx_t_3, 3, ((PyObject *)__pyx_n_s__PG));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PG));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__CO));
-  PyTuple_SET_ITEM(__pyx_k_tuple_233, 4, ((PyObject *)__pyx_n_s__CO));
+  PyTuple_SET_ITEM(__pyx_t_3, 4, ((PyObject *)__pyx_n_s__CO));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__CO));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_233));
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__VALID_HEADERS, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":227
+ * 
+ * # type conversions within sam header records
+ * VALID_HEADER_FIELDS = { "HD" : { "VN" : str, "SO" : str, "GO" : str },             # <<<<<<<<<<<<<<
+ *                         "SQ" : { "SN" : str, "LN" : int, "AS" : str, "M5" : str, "UR" : str, "SP" : str },
+ *                         "RG" : { "ID" : str, "SM" : str, "LB" : str, "DS" : str, "PU" : str, "PI" : str, "CN" : str, "DT" : str, "PL" : str, },
+ */
+  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__VN), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__SO), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__GO), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__HD), ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":228
+ * # type conversions within sam header records
+ * VALID_HEADER_FIELDS = { "HD" : { "VN" : str, "SO" : str, "GO" : str },
+ *                         "SQ" : { "SN" : str, "LN" : int, "AS" : str, "M5" : str, "UR" : str, "SP" : str },             # <<<<<<<<<<<<<<
+ *                         "RG" : { "ID" : str, "SM" : str, "LB" : str, "DS" : str, "PU" : str, "PI" : str, "CN" : str, "DT" : str, "PL" : str, },
+ *                         "PG" : { "PN" : str, "ID" : str, "VN" : str, "CL" : str }, }
+ */
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__SN), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__LN), ((PyObject *)((PyObject*)&PyInt_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__AS), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__M5), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__UR), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__SP), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__SQ), ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":229
+ * VALID_HEADER_FIELDS = { "HD" : { "VN" : str, "SO" : str, "GO" : str },
+ *                         "SQ" : { "SN" : str, "LN" : int, "AS" : str, "M5" : str, "UR" : str, "SP" : str },
+ *                         "RG" : { "ID" : str, "SM" : str, "LB" : str, "DS" : str, "PU" : str, "PI" : str, "CN" : str, "DT" : str, "PL" : str, },             # <<<<<<<<<<<<<<
+ *                         "PG" : { "PN" : str, "ID" : str, "VN" : str, "CL" : str }, }
+ * 
+ */
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__ID), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__SM), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__LB), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__DS), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__PU), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__PI), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__CN), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__DT), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__PL), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__RG), ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":230
+ *                         "SQ" : { "SN" : str, "LN" : int, "AS" : str, "M5" : str, "UR" : str, "SP" : str },
+ *                         "RG" : { "ID" : str, "SM" : str, "LB" : str, "DS" : str, "PU" : str, "PI" : str, "CN" : str, "DT" : str, "PL" : str, },
+ *                         "PG" : { "PN" : str, "ID" : str, "VN" : str, "CL" : str }, }             # <<<<<<<<<<<<<<
+ * 
+ * # output order of fields within records
+ */
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__PN), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__ID), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__VN), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__CL), ((PyObject *)((PyObject*)&PyString_Type))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__PG), ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__VALID_HEADER_FIELDS, ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
 
-  /* "csamtools.pyx":233
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":233
  * 
  * # output order of fields within records
  * VALID_HEADER_ORDER = { "HD" : ( "VN", "SO", "GO" ),             # <<<<<<<<<<<<<<
  *                        "SQ" : ( "SN", "LN", "AS", "M5" , "UR" , "SP" ),
  *                        "RG" : ( "ID", "SM", "LB", "DS" , "PU" , "PI" , "CN" , "DT", "PL" ),
  */
-  __pyx_k_tuple_234 = PyTuple_New(3); if (unlikely(!__pyx_k_tuple_234)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_234));
+  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
   __Pyx_INCREF(((PyObject *)__pyx_n_s__VN));
-  PyTuple_SET_ITEM(__pyx_k_tuple_234, 0, ((PyObject *)__pyx_n_s__VN));
+  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__VN));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__VN));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__SO));
-  PyTuple_SET_ITEM(__pyx_k_tuple_234, 1, ((PyObject *)__pyx_n_s__SO));
+  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__SO));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__SO));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__GO));
-  PyTuple_SET_ITEM(__pyx_k_tuple_234, 2, ((PyObject *)__pyx_n_s__GO));
+  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_n_s__GO));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__GO));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_234));
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__HD), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "csamtools.pyx":234
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":234
  * # output order of fields within records
  * VALID_HEADER_ORDER = { "HD" : ( "VN", "SO", "GO" ),
  *                        "SQ" : ( "SN", "LN", "AS", "M5" , "UR" , "SP" ),             # <<<<<<<<<<<<<<
  *                        "RG" : ( "ID", "SM", "LB", "DS" , "PU" , "PI" , "CN" , "DT", "PL" ),
  *                        "PG" : ( "PN", "ID", "VN", "CL" ), }
  */
-  __pyx_k_tuple_235 = PyTuple_New(6); if (unlikely(!__pyx_k_tuple_235)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_235));
+  __pyx_t_1 = PyTuple_New(6); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
   __Pyx_INCREF(((PyObject *)__pyx_n_s__SN));
-  PyTuple_SET_ITEM(__pyx_k_tuple_235, 0, ((PyObject *)__pyx_n_s__SN));
+  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__SN));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__SN));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__LN));
-  PyTuple_SET_ITEM(__pyx_k_tuple_235, 1, ((PyObject *)__pyx_n_s__LN));
+  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__LN));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__LN));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__AS));
-  PyTuple_SET_ITEM(__pyx_k_tuple_235, 2, ((PyObject *)__pyx_n_s__AS));
+  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_n_s__AS));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__AS));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__M5));
-  PyTuple_SET_ITEM(__pyx_k_tuple_235, 3, ((PyObject *)__pyx_n_s__M5));
+  PyTuple_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_n_s__M5));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__M5));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__UR));
-  PyTuple_SET_ITEM(__pyx_k_tuple_235, 4, ((PyObject *)__pyx_n_s__UR));
+  PyTuple_SET_ITEM(__pyx_t_1, 4, ((PyObject *)__pyx_n_s__UR));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__UR));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__SP));
-  PyTuple_SET_ITEM(__pyx_k_tuple_235, 5, ((PyObject *)__pyx_n_s__SP));
+  PyTuple_SET_ITEM(__pyx_t_1, 5, ((PyObject *)__pyx_n_s__SP));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__SP));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_235));
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__SQ), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":235
+ * VALID_HEADER_ORDER = { "HD" : ( "VN", "SO", "GO" ),
+ *                        "SQ" : ( "SN", "LN", "AS", "M5" , "UR" , "SP" ),
+ *                        "RG" : ( "ID", "SM", "LB", "DS" , "PU" , "PI" , "CN" , "DT", "PL" ),             # <<<<<<<<<<<<<<
+ *                        "PG" : ( "PN", "ID", "VN", "CL" ), }
+ * 
+ */
+  __pyx_t_1 = PyTuple_New(9); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__ID));
+  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__ID));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ID));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__SM));
+  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__SM));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__SM));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__LB));
+  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_n_s__LB));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__LB));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__DS));
+  PyTuple_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_n_s__DS));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__DS));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__PU));
+  PyTuple_SET_ITEM(__pyx_t_1, 4, ((PyObject *)__pyx_n_s__PU));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PU));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__PI));
+  PyTuple_SET_ITEM(__pyx_t_1, 5, ((PyObject *)__pyx_n_s__PI));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PI));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__CN));
+  PyTuple_SET_ITEM(__pyx_t_1, 6, ((PyObject *)__pyx_n_s__CN));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__CN));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__DT));
+  PyTuple_SET_ITEM(__pyx_t_1, 7, ((PyObject *)__pyx_n_s__DT));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__DT));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__PL));
+  PyTuple_SET_ITEM(__pyx_t_1, 8, ((PyObject *)__pyx_n_s__PL));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PL));
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__RG), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":236
+ *                        "SQ" : ( "SN", "LN", "AS", "M5" , "UR" , "SP" ),
+ *                        "RG" : ( "ID", "SM", "LB", "DS" , "PU" , "PI" , "CN" , "DT", "PL" ),
+ *                        "PG" : ( "PN", "ID", "VN", "CL" ), }             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__PN));
+  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__PN));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PN));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__ID));
+  PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__ID));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ID));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__VN));
+  PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_n_s__VN));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__VN));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__CL));
+  PyTuple_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_n_s__CL));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__CL));
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__PG), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__VALID_HEADER_ORDER, ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":719
+ *                region = None,
+ *                callback = None,
+ *                until_eof = False ):             # <<<<<<<<<<<<<<
+ *         '''
+ *         fetch aligned reads in a :term:`region` using 0-based indexing. The region is specified by
+ */
+  __pyx_t_3 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 719; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_k_29 = __pyx_t_3;
+  __Pyx_GIVEREF(__pyx_t_3);
+  __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":830
+ *                end = None,
+ *                region = None,
+ *                until_eof = False ):             # <<<<<<<<<<<<<<
+ *         '''*(reference = None, start = None, end = None, region = None, callback = None, until_eof = False)*
+ * 
+ */
+  __pyx_t_3 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_k_39 = __pyx_t_3;
+  __Pyx_GIVEREF(__pyx_t_3);
+  __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1718
+ *                   int tid = 0,
+ *                   int start = 0,
+ *                   int end = max_pos,             # <<<<<<<<<<<<<<
+ *                   **kwargs ):
+ * 
+ */
+  __pyx_k_58 = __pyx_v_9csamtools_max_pos;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2699
+ *             return self._level
+ * 
+ * class Outs:             # <<<<<<<<<<<<<<
+ *     '''http://mail.python.org/pipermail/python-list/2000-June/038406.html'''
+ *     def __init__(self, id = 1):
+ */
+  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+  if (PyDict_SetItemString(((PyObject *)__pyx_t_3), "__doc__", ((PyObject *)__pyx_kp_s_176)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_CreateClass(((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_3), __pyx_n_s__Outs, "csamtools"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2701
+ * class Outs:
+ *     '''http://mail.python.org/pipermail/python-list/2000-June/038406.html'''
+ *     def __init__(self, id = 1):             # <<<<<<<<<<<<<<
+ *         self.streams = []
+ *         self.id = id
+ */
+  __pyx_t_2 = PyCFunction_New(&__pyx_mdef_9csamtools_4Outs___init__, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2701; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_4 = PyMethod_New(__pyx_t_2, 0, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2701; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (PyObject_SetAttr(__pyx_t_1, __pyx_n_s____init__, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2701; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
-  /* "csamtools.pyx":235
- * VALID_HEADER_ORDER = { "HD" : ( "VN", "SO", "GO" ),
- *                        "SQ" : ( "SN", "LN", "AS", "M5" , "UR" , "SP" ),
- *                        "RG" : ( "ID", "SM", "LB", "DS" , "PU" , "PI" , "CN" , "DT", "PL" ),             # <<<<<<<<<<<<<<
- *                        "PG" : ( "PN", "ID", "VN", "CL" ), }
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2705
+ *         self.id = id
  * 
+ *     def setdevice(self, filename):             # <<<<<<<<<<<<<<
+ *         '''open an existing file, like "/dev/null"'''
+ *         fd = os.open(filename, os.O_WRONLY)
  */
-  __pyx_k_tuple_236 = PyTuple_New(9); if (unlikely(!__pyx_k_tuple_236)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 235; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_236));
-  __Pyx_INCREF(((PyObject *)__pyx_n_s__ID));
-  PyTuple_SET_ITEM(__pyx_k_tuple_236, 0, ((PyObject *)__pyx_n_s__ID));
-  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ID));
-  __Pyx_INCREF(((PyObject *)__pyx_n_s__SM));
-  PyTuple_SET_ITEM(__pyx_k_tuple_236, 1, ((PyObject *)__pyx_n_s__SM));
-  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__SM));
-  __Pyx_INCREF(((PyObject *)__pyx_n_s__LB));
-  PyTuple_SET_ITEM(__pyx_k_tuple_236, 2, ((PyObject *)__pyx_n_s__LB));
-  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__LB));
-  __Pyx_INCREF(((PyObject *)__pyx_n_s__DS));
-  PyTuple_SET_ITEM(__pyx_k_tuple_236, 3, ((PyObject *)__pyx_n_s__DS));
-  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__DS));
-  __Pyx_INCREF(((PyObject *)__pyx_n_s__PU));
-  PyTuple_SET_ITEM(__pyx_k_tuple_236, 4, ((PyObject *)__pyx_n_s__PU));
-  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PU));
-  __Pyx_INCREF(((PyObject *)__pyx_n_s__PI));
-  PyTuple_SET_ITEM(__pyx_k_tuple_236, 5, ((PyObject *)__pyx_n_s__PI));
-  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PI));
-  __Pyx_INCREF(((PyObject *)__pyx_n_s__CN));
-  PyTuple_SET_ITEM(__pyx_k_tuple_236, 6, ((PyObject *)__pyx_n_s__CN));
-  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__CN));
-  __Pyx_INCREF(((PyObject *)__pyx_n_s__DT));
-  PyTuple_SET_ITEM(__pyx_k_tuple_236, 7, ((PyObject *)__pyx_n_s__DT));
-  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__DT));
-  __Pyx_INCREF(((PyObject *)__pyx_n_s__PL));
-  PyTuple_SET_ITEM(__pyx_k_tuple_236, 8, ((PyObject *)__pyx_n_s__PL));
-  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PL));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_236));
+  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_9csamtools_4Outs_setdevice, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_2 = PyMethod_New(__pyx_t_4, 0, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_t_1, __pyx_n_s__setdevice, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-  /* "csamtools.pyx":236
- *                        "SQ" : ( "SN", "LN", "AS", "M5" , "UR" , "SP" ),
- *                        "RG" : ( "ID", "SM", "LB", "DS" , "PU" , "PI" , "CN" , "DT", "PL" ),
- *                        "PG" : ( "PN", "ID", "VN", "CL" ), }             # <<<<<<<<<<<<<<
- * 
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2710
+ *         self.setfd(fd)
  * 
+ *     def setfile(self, filename):             # <<<<<<<<<<<<<<
+ *         '''open a new file.'''
+ *         fd = os.open(filename, os.O_WRONLY|os.O_CREAT, 0660);
  */
-  __pyx_k_tuple_237 = PyTuple_New(4); if (unlikely(!__pyx_k_tuple_237)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_k_tuple_237));
-  __Pyx_INCREF(((PyObject *)__pyx_n_s__PN));
-  PyTuple_SET_ITEM(__pyx_k_tuple_237, 0, ((PyObject *)__pyx_n_s__PN));
-  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PN));
-  __Pyx_INCREF(((PyObject *)__pyx_n_s__ID));
-  PyTuple_SET_ITEM(__pyx_k_tuple_237, 1, ((PyObject *)__pyx_n_s__ID));
-  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ID));
-  __Pyx_INCREF(((PyObject *)__pyx_n_s__VN));
-  PyTuple_SET_ITEM(__pyx_k_tuple_237, 2, ((PyObject *)__pyx_n_s__VN));
-  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__VN));
-  __Pyx_INCREF(((PyObject *)__pyx_n_s__CL));
-  PyTuple_SET_ITEM(__pyx_k_tuple_237, 3, ((PyObject *)__pyx_n_s__CL));
-  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__CL));
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_237));
-  __Pyx_RefNannyFinishContext();
-  return 0;
-  __pyx_L1_error:;
-  __Pyx_RefNannyFinishContext();
-  return -1;
-}
+  __pyx_t_2 = PyCFunction_New(&__pyx_mdef_9csamtools_4Outs_setfile, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2710; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_4 = PyMethod_New(__pyx_t_2, 0, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2710; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (PyObject_SetAttr(__pyx_t_1, __pyx_n_s__setfile, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2710; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
-static int __Pyx_InitGlobals(void) {
-  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_8 = PyInt_FromLong(8); if (unlikely(!__pyx_int_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_16 = PyInt_FromLong(16); if (unlikely(!__pyx_int_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_32 = PyInt_FromLong(32); if (unlikely(!__pyx_int_32)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_64 = PyInt_FromLong(64); if (unlikely(!__pyx_int_64)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_128 = PyInt_FromLong(128); if (unlikely(!__pyx_int_128)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_255 = PyInt_FromLong(255); if (unlikely(!__pyx_int_255)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_256 = PyInt_FromLong(256); if (unlikely(!__pyx_int_256)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_512 = PyInt_FromLong(512); if (unlikely(!__pyx_int_512)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_neg_127 = PyInt_FromLong(-127); if (unlikely(!__pyx_int_neg_127)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_0660 = PyInt_FromLong(0660); if (unlikely(!__pyx_int_0660)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_1024 = PyInt_FromLong(1024); if (unlikely(!__pyx_int_1024)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_8000 = PyInt_FromLong(8000); if (unlikely(!__pyx_int_8000)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_65535 = PyInt_FromLong(65535); if (unlikely(!__pyx_int_65535)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_neg_32767 = PyInt_FromLong(-32767); if (unlikely(!__pyx_int_neg_32767)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_536870912 = PyInt_FromLong(536870912); if (unlikely(!__pyx_int_536870912)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_4294967295 = PyInt_FromString((char *)"4294967295", 0, 0); if (unlikely(!__pyx_int_4294967295)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  __pyx_int_neg_2147483648 = PyInt_FromLong(-2147483648); if (unlikely(!__pyx_int_neg_2147483648)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  return 0;
-  __pyx_L1_error:;
-  return -1;
-}
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2715
+ *         self.setfd(fd)
+ * 
+ *     def setfd(self, fd):             # <<<<<<<<<<<<<<
+ *         ofd = os.dup(self.id)      #  Save old stream on new unit.
+ *         self.streams.append(ofd)
+ */
+  __pyx_t_4 = PyCFunction_New(&__pyx_mdef_9csamtools_4Outs_setfd, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_2 = PyMethod_New(__pyx_t_4, 0, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_t_1, __pyx_n_s__setfd, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-#if PY_MAJOR_VERSION < 3
-PyMODINIT_FUNC initcsamtools(void); /*proto*/
-PyMODINIT_FUNC initcsamtools(void)
-#else
-PyMODINIT_FUNC PyInit_csamtools(void); /*proto*/
-PyMODINIT_FUNC PyInit_csamtools(void)
-#endif
-{
-  PyObject *__pyx_t_1 = NULL;
-  PyObject *__pyx_t_2 = NULL;
-  PyObject *__pyx_t_3 = NULL;
-  int __pyx_t_4;
-  #if CYTHON_REFNANNY
-  void* __pyx_refnanny = NULL;
-  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
-  if (!__Pyx_RefNanny) {
-      PyErr_Clear();
-      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
-      if (!__Pyx_RefNanny)
-          Py_FatalError("failed to import 'refnanny' module");
-  }
-  __pyx_refnanny = __Pyx_RefNanny->SetupContext("PyMODINIT_FUNC PyInit_csamtools(void)", __LINE__, __FILE__);
-  #endif
-  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  #ifdef __pyx_binding_PyCFunctionType_USED
-  if (__pyx_binding_PyCFunctionType_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  #endif
-  /*--- Library function declarations ---*/
-  /*--- Threads initialization code ---*/
-  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
-  #ifdef WITH_THREAD /* Python build with threading support? */
-  PyEval_InitThreads();
-  #endif
-  #endif
-  /*--- Module creation code ---*/
-  #if PY_MAJOR_VERSION < 3
-  __pyx_m = Py_InitModule4(__Pyx_NAMESTR("csamtools"), __pyx_methods, 0, 0, PYTHON_API_VERSION);
-  #else
-  __pyx_m = PyModule_Create(&__pyx_moduledef);
-  #endif
-  if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  #if PY_MAJOR_VERSION < 3
-  Py_INCREF(__pyx_m);
-  #endif
-  __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME));
-  if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  /*--- Initialize various global constants etc. ---*/
-  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__pyx_module_is_main_csamtools) {
-    if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s____main__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
-  }
-  /*--- Builtin init code ---*/
-  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  /*--- Constants init code ---*/
-  if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  /*--- Global init code ---*/
-  /*--- Function export code ---*/
-  /*--- Type init code ---*/
-  __pyx_ptype_9csamtools_file = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "file", sizeof(PyFileObject), 0); if (unlikely(!__pyx_ptype_9csamtools_file)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyType_Ready(&__pyx_type_9csamtools_AlignedRead) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  {
-    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_AlignedRead, "__str__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
-      __pyx_wrapperbase_9csamtools_11AlignedRead_2__str__ = *((PyWrapperDescrObject *)wrapper)->d_base;
-      __pyx_wrapperbase_9csamtools_11AlignedRead_2__str__.doc = __pyx_doc_9csamtools_11AlignedRead_2__str__;
-      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_11AlignedRead_2__str__;
-    }
-  }
-  if (__Pyx_SetAttrString(__pyx_m, "AlignedRead", (PyObject *)&__pyx_type_9csamtools_AlignedRead) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_ptype_9csamtools_AlignedRead = &__pyx_type_9csamtools_AlignedRead;
-  __pyx_vtabptr_9csamtools_Samfile = &__pyx_vtable_9csamtools_Samfile;
-  __pyx_vtable_9csamtools_Samfile._buildHeader = (bam_header_t *(*)(struct __pyx_obj_9csamtools_Samfile *, PyObject *))__pyx_f_9csamtools_7Samfile__buildHeader;
-  __pyx_vtable_9csamtools_Samfile.getCurrent = (bam1_t *(*)(struct __pyx_obj_9csamtools_Samfile *))__pyx_f_9csamtools_7Samfile_getCurrent;
-  __pyx_vtable_9csamtools_Samfile.cnext = (int (*)(struct __pyx_obj_9csamtools_Samfile *))__pyx_f_9csamtools_7Samfile_cnext;
-  __pyx_vtable_9csamtools_Samfile.write = (int (*)(struct __pyx_obj_9csamtools_Samfile *, struct __pyx_obj_9csamtools_AlignedRead *, int __pyx_skip_dispatch))__pyx_f_9csamtools_7Samfile_write;
-  __pyx_vtable_9csamtools_Samfile._getrname = (char *(*)(struct __pyx_obj_9csamtools_Samfile *, int))__pyx_f_9csamtools_7Samfile__getrname;
-  if (PyType_Ready(&__pyx_type_9csamtools_Samfile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  {
-    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_Samfile, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
-      __pyx_wrapperbase_9csamtools_7Samfile_21__next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
-      __pyx_wrapperbase_9csamtools_7Samfile_21__next__.doc = __pyx_doc_9csamtools_7Samfile_21__next__;
-      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_7Samfile_21__next__;
-    }
-  }
-  if (__Pyx_SetVtable(__pyx_type_9csamtools_Samfile.tp_dict, __pyx_vtabptr_9csamtools_Samfile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "Samfile", (PyObject *)&__pyx_type_9csamtools_Samfile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_ptype_9csamtools_Samfile = &__pyx_type_9csamtools_Samfile;
-  if (PyType_Ready(&__pyx_type_9csamtools_IteratorRow) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "IteratorRow", (PyObject *)&__pyx_type_9csamtools_IteratorRow) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_ptype_9csamtools_IteratorRow = &__pyx_type_9csamtools_IteratorRow;
-  __pyx_vtabptr_9csamtools_IteratorRowAll = &__pyx_vtable_9csamtools_IteratorRowAll;
-  __pyx_vtable_9csamtools_IteratorRowAll.getCurrent = (bam1_t *(*)(struct __pyx_obj_9csamtools_IteratorRowAll *))__pyx_f_9csamtools_14IteratorRowAll_getCurrent;
-  __pyx_vtable_9csamtools_IteratorRowAll.cnext = (int (*)(struct __pyx_obj_9csamtools_IteratorRowAll *))__pyx_f_9csamtools_14IteratorRowAll_cnext;
-  __pyx_type_9csamtools_IteratorRowAll.tp_base = __pyx_ptype_9csamtools_IteratorRow;
-  if (PyType_Ready(&__pyx_type_9csamtools_IteratorRowAll) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  {
-    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_IteratorRowAll, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
-      __pyx_wrapperbase_9csamtools_14IteratorRowAll_2__next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
-      __pyx_wrapperbase_9csamtools_14IteratorRowAll_2__next__.doc = __pyx_doc_9csamtools_14IteratorRowAll_2__next__;
-      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_14IteratorRowAll_2__next__;
-    }
-  }
-  if (__Pyx_SetVtable(__pyx_type_9csamtools_IteratorRowAll.tp_dict, __pyx_vtabptr_9csamtools_IteratorRowAll) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "IteratorRowAll", (PyObject *)&__pyx_type_9csamtools_IteratorRowAll) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_ptype_9csamtools_IteratorRowAll = &__pyx_type_9csamtools_IteratorRowAll;
-  if (PyType_Ready(&__pyx_type_9csamtools_PileupProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "PileupProxy", (PyObject *)&__pyx_type_9csamtools_PileupProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_ptype_9csamtools_PileupProxy = &__pyx_type_9csamtools_PileupProxy;
-  if (PyType_Ready(&__pyx_type_9csamtools_PileupRead) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "PileupRead", (PyObject *)&__pyx_type_9csamtools_PileupRead) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_ptype_9csamtools_PileupRead = &__pyx_type_9csamtools_PileupRead;
-  __pyx_vtabptr_9csamtools_Fastafile = &__pyx_vtable_9csamtools_Fastafile;
-  __pyx_vtable_9csamtools_Fastafile._fetch = (char *(*)(struct __pyx_obj_9csamtools_Fastafile *, char *, int, int, int *))__pyx_f_9csamtools_9Fastafile__fetch;
-  if (PyType_Ready(&__pyx_type_9csamtools_Fastafile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetVtable(__pyx_type_9csamtools_Fastafile.tp_dict, __pyx_vtabptr_9csamtools_Fastafile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "Fastafile", (PyObject *)&__pyx_type_9csamtools_Fastafile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_ptype_9csamtools_Fastafile = &__pyx_type_9csamtools_Fastafile;
-  __pyx_vtabptr_9csamtools_IteratorRowRegion = &__pyx_vtable_9csamtools_IteratorRowRegion;
-  __pyx_vtable_9csamtools_IteratorRowRegion.getCurrent = (bam1_t *(*)(struct __pyx_obj_9csamtools_IteratorRowRegion *))__pyx_f_9csamtools_17IteratorRowRegion_getCurrent;
-  __pyx_vtable_9csamtools_IteratorRowRegion.cnext = (int (*)(struct __pyx_obj_9csamtools_IteratorRowRegion *))__pyx_f_9csamtools_17IteratorRowRegion_cnext;
-  __pyx_type_9csamtools_IteratorRowRegion.tp_base = __pyx_ptype_9csamtools_IteratorRow;
-  if (PyType_Ready(&__pyx_type_9csamtools_IteratorRowRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  {
-    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_IteratorRowRegion, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
-      __pyx_wrapperbase_9csamtools_17IteratorRowRegion_2__next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
-      __pyx_wrapperbase_9csamtools_17IteratorRowRegion_2__next__.doc = __pyx_doc_9csamtools_17IteratorRowRegion_2__next__;
-      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_17IteratorRowRegion_2__next__;
-    }
-  }
-  if (__Pyx_SetVtable(__pyx_type_9csamtools_IteratorRowRegion.tp_dict, __pyx_vtabptr_9csamtools_IteratorRowRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "IteratorRowRegion", (PyObject *)&__pyx_type_9csamtools_IteratorRowRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_ptype_9csamtools_IteratorRowRegion = &__pyx_type_9csamtools_IteratorRowRegion;
-  __pyx_type_9csamtools_IteratorRowAllRefs.tp_base = __pyx_ptype_9csamtools_IteratorRow;
-  if (PyType_Ready(&__pyx_type_9csamtools_IteratorRowAllRefs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  {
-    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_IteratorRowAllRefs, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
-      __pyx_wrapperbase_9csamtools_18IteratorRowAllRefs_3__next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
-      __pyx_wrapperbase_9csamtools_18IteratorRowAllRefs_3__next__.doc = __pyx_doc_9csamtools_18IteratorRowAllRefs_3__next__;
-      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_18IteratorRowAllRefs_3__next__;
-    }
-  }
-  if (__Pyx_SetAttrString(__pyx_m, "IteratorRowAllRefs", (PyObject *)&__pyx_type_9csamtools_IteratorRowAllRefs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_ptype_9csamtools_IteratorRowAllRefs = &__pyx_type_9csamtools_IteratorRowAllRefs;
-  __pyx_vtabptr_9csamtools_IteratorRowSelection = &__pyx_vtable_9csamtools_IteratorRowSelection;
-  __pyx_vtable_9csamtools_IteratorRowSelection.getCurrent = (bam1_t *(*)(struct __pyx_obj_9csamtools_IteratorRowSelection *))__pyx_f_9csamtools_20IteratorRowSelection_getCurrent;
-  __pyx_vtable_9csamtools_IteratorRowSelection.cnext = (int (*)(struct __pyx_obj_9csamtools_IteratorRowSelection *))__pyx_f_9csamtools_20IteratorRowSelection_cnext;
-  __pyx_type_9csamtools_IteratorRowSelection.tp_base = __pyx_ptype_9csamtools_IteratorRow;
-  if (PyType_Ready(&__pyx_type_9csamtools_IteratorRowSelection) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  {
-    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_IteratorRowSelection, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
-      __pyx_wrapperbase_9csamtools_20IteratorRowSelection_2__next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
-      __pyx_wrapperbase_9csamtools_20IteratorRowSelection_2__next__.doc = __pyx_doc_9csamtools_20IteratorRowSelection_2__next__;
-      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_20IteratorRowSelection_2__next__;
-    }
-  }
-  if (__Pyx_SetVtable(__pyx_type_9csamtools_IteratorRowSelection.tp_dict, __pyx_vtabptr_9csamtools_IteratorRowSelection) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "IteratorRowSelection", (PyObject *)&__pyx_type_9csamtools_IteratorRowSelection) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_ptype_9csamtools_IteratorRowSelection = &__pyx_type_9csamtools_IteratorRowSelection;
-  __pyx_vtabptr_9csamtools_IteratorColumn = &__pyx_vtable_9csamtools_IteratorColumn;
-  __pyx_vtable_9csamtools_IteratorColumn.cnext = (int (*)(struct __pyx_obj_9csamtools_IteratorColumn *))__pyx_f_9csamtools_14IteratorColumn_cnext;
-  __pyx_vtable_9csamtools_IteratorColumn.getSequence = (char *(*)(struct __pyx_obj_9csamtools_IteratorColumn *))__pyx_f_9csamtools_14IteratorColumn_getSequence;
-  __pyx_vtable_9csamtools_IteratorColumn.setMask = (PyObject *(*)(struct __pyx_obj_9csamtools_IteratorColumn *, PyObject *))__pyx_f_9csamtools_14IteratorColumn_setMask;
-  __pyx_vtable_9csamtools_IteratorColumn.setupIteratorData = (PyObject *(*)(struct __pyx_obj_9csamtools_IteratorColumn *, int, int, int, struct __pyx_opt_args_9csamtools_14IteratorColumn_setupIteratorData *__pyx_optional_args))__pyx_f_9csamtools_14IteratorColumn_setupIteratorData;
-  __pyx_vtable_9csamtools_IteratorColumn.reset = (PyObject *(*)(struct __pyx_obj_9csamtools_IteratorColumn *, PyObject *, PyObject *, PyObject *))__pyx_f_9csamtools_14IteratorColumn_reset;
-  if (PyType_Ready(&__pyx_type_9csamtools_IteratorColumn) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetVtable(__pyx_type_9csamtools_IteratorColumn.tp_dict, __pyx_vtabptr_9csamtools_IteratorColumn) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "IteratorColumn", (PyObject *)&__pyx_type_9csamtools_IteratorColumn) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_ptype_9csamtools_IteratorColumn = &__pyx_type_9csamtools_IteratorColumn;
-  __pyx_vtabptr_9csamtools_IteratorColumnRegion = &__pyx_vtable_9csamtools_IteratorColumnRegion;
-  __pyx_vtable_9csamtools_IteratorColumnRegion.__pyx_base = *__pyx_vtabptr_9csamtools_IteratorColumn;
-  __pyx_type_9csamtools_IteratorColumnRegion.tp_base = __pyx_ptype_9csamtools_IteratorColumn;
-  if (PyType_Ready(&__pyx_type_9csamtools_IteratorColumnRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  {
-    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_IteratorColumnRegion, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
-      __pyx_wrapperbase_9csamtools_20IteratorColumnRegion_1__next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
-      __pyx_wrapperbase_9csamtools_20IteratorColumnRegion_1__next__.doc = __pyx_doc_9csamtools_20IteratorColumnRegion_1__next__;
-      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_20IteratorColumnRegion_1__next__;
-    }
-  }
-  if (__Pyx_SetVtable(__pyx_type_9csamtools_IteratorColumnRegion.tp_dict, __pyx_vtabptr_9csamtools_IteratorColumnRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "IteratorColumnRegion", (PyObject *)&__pyx_type_9csamtools_IteratorColumnRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_ptype_9csamtools_IteratorColumnRegion = &__pyx_type_9csamtools_IteratorColumnRegion;
-  __pyx_vtabptr_9csamtools_IteratorColumnAllRefs = &__pyx_vtable_9csamtools_IteratorColumnAllRefs;
-  __pyx_vtable_9csamtools_IteratorColumnAllRefs.__pyx_base = *__pyx_vtabptr_9csamtools_IteratorColumn;
-  __pyx_type_9csamtools_IteratorColumnAllRefs.tp_base = __pyx_ptype_9csamtools_IteratorColumn;
-  if (PyType_Ready(&__pyx_type_9csamtools_IteratorColumnAllRefs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  {
-    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_9csamtools_IteratorColumnAllRefs, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
-      __pyx_wrapperbase_9csamtools_21IteratorColumnAllRefs_1__next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
-      __pyx_wrapperbase_9csamtools_21IteratorColumnAllRefs_1__next__.doc = __pyx_doc_9csamtools_21IteratorColumnAllRefs_1__next__;
-      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_21IteratorColumnAllRefs_1__next__;
-    }
-  }
-  if (__Pyx_SetVtable(__pyx_type_9csamtools_IteratorColumnAllRefs.tp_dict, __pyx_vtabptr_9csamtools_IteratorColumnAllRefs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "IteratorColumnAllRefs", (PyObject *)&__pyx_type_9csamtools_IteratorColumnAllRefs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_ptype_9csamtools_IteratorColumnAllRefs = &__pyx_type_9csamtools_IteratorColumnAllRefs;
-  if (PyType_Ready(&__pyx_type_9csamtools_SNPCall) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "SNPCall", (PyObject *)&__pyx_type_9csamtools_SNPCall) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_ptype_9csamtools_SNPCall = &__pyx_type_9csamtools_SNPCall;
-  if (PyType_Ready(&__pyx_type_9csamtools_IndexedReads) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "IndexedReads", (PyObject *)&__pyx_type_9csamtools_IndexedReads) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_ptype_9csamtools_IndexedReads = &__pyx_type_9csamtools_IndexedReads;
-  /*--- Type import code ---*/
-  __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), 0); if (unlikely(!__pyx_ptype_7cpython_4bool_bool)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "complex", sizeof(PyComplexObject), 0); if (unlikely(!__pyx_ptype_7cpython_7complex_complex)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  /*--- Function import code ---*/
-  /*--- Execution code ---*/
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2723
+ *         os.close(fd)                #  Close other unit (look out, caller.)
+ * 
+ *     def restore(self):             # <<<<<<<<<<<<<<
+ *         '''restore previous output stream'''
+ *         if self.streams:
+ */
+  __pyx_t_2 = PyCFunction_New(&__pyx_mdef_9csamtools_4Outs_restore, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_4 = PyMethod_New(__pyx_t_2, 0, __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (PyObject_SetAttr(__pyx_t_1, __pyx_n_s__restore, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__Outs, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2736
+ * def _samtools_dispatch( method,
+ *                         args = (),
+ *                         catch_stdout = True,             # <<<<<<<<<<<<<<
+ *                         catch_stderr = False,
+ *                         ):
+ */
+  __pyx_t_3 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_k_98 = __pyx_t_3;
+  __Pyx_GIVEREF(__pyx_t_3);
+  __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2737
+ *                         args = (),
+ *                         catch_stdout = True,
+ *                         catch_stderr = False,             # <<<<<<<<<<<<<<
+ *                         ):
+ *     '''call ``method`` in samtools providing arguments in args.
+ */
+  __pyx_t_3 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2737; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_k_99 = __pyx_t_3;
+  __Pyx_GIVEREF(__pyx_t_3);
+  __pyx_t_3 = 0;
+
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3436
+ *         if self.owns_samfile: samclose( self.fp )
+ * 
+ * __all__ = ["Samfile",             # <<<<<<<<<<<<<<
+ *            "Fastafile",
+ *            "IteratorRow",
+ */
+  __pyx_t_3 = PyList_New(13); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__Samfile));
+  PyList_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_n_s__Samfile));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Samfile));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__Fastafile));
+  PyList_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_n_s__Fastafile));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Fastafile));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__IteratorRow));
+  PyList_SET_ITEM(__pyx_t_3, 2, ((PyObject *)__pyx_n_s__IteratorRow));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__IteratorRow));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__IteratorColumn));
+  PyList_SET_ITEM(__pyx_t_3, 3, ((PyObject *)__pyx_n_s__IteratorColumn));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__IteratorColumn));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__AlignedRead));
+  PyList_SET_ITEM(__pyx_t_3, 4, ((PyObject *)__pyx_n_s__AlignedRead));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__AlignedRead));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__PileupColumn));
+  PyList_SET_ITEM(__pyx_t_3, 5, ((PyObject *)__pyx_n_s__PileupColumn));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PileupColumn));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__PileupProxy));
+  PyList_SET_ITEM(__pyx_t_3, 6, ((PyObject *)__pyx_n_s__PileupProxy));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PileupProxy));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__PileupRead));
+  PyList_SET_ITEM(__pyx_t_3, 7, ((PyObject *)__pyx_n_s__PileupRead));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PileupRead));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__IteratorSNPCalls));
+  PyList_SET_ITEM(__pyx_t_3, 8, ((PyObject *)__pyx_n_s__IteratorSNPCalls));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__IteratorSNPCalls));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__SNPCaller));
+  PyList_SET_ITEM(__pyx_t_3, 9, ((PyObject *)__pyx_n_s__SNPCaller));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__SNPCaller));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__IndelCaller));
+  PyList_SET_ITEM(__pyx_t_3, 10, ((PyObject *)__pyx_n_s__IndelCaller));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__IndelCaller));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__IteratorIndelCalls));
+  PyList_SET_ITEM(__pyx_t_3, 11, ((PyObject *)__pyx_n_s__IteratorIndelCalls));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__IteratorIndelCalls));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__IndexedReads));
+  PyList_SET_ITEM(__pyx_t_3, 12, ((PyObject *)__pyx_n_s__IndexedReads));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__IndexedReads));
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____all__, ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
 
-  /* "csamtools.pyx":4
+  /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1
+ * # cython: embedsignature=True             # <<<<<<<<<<<<<<
  * # cython: profile=True
  * # adds doc-strings for sphinx
- * import tempfile             # <<<<<<<<<<<<<<
- * import os
- * import sys
  */
-  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__tempfile), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Fastafile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__tempfile, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
-  /* "csamtools.pyx":5
- * # adds doc-strings for sphinx
- * import tempfile
- * import os             # <<<<<<<<<<<<<<
- * import sys
- * import types
- */
-  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__os), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__os, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_177), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
-  /* "csamtools.pyx":6
- * import tempfile
- * import os
- * import sys             # <<<<<<<<<<<<<<
- * import types
- * import itertools
- */
-  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__sys), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Fastafile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__sys, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s___open); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
-  /* "csamtools.pyx":7
- * import os
- * import sys
- * import types             # <<<<<<<<<<<<<<
- * import itertools
- * import struct
- */
-  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__types), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__types, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_178), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
-  /* "csamtools.pyx":8
- * import sys
- * import types
- * import itertools             # <<<<<<<<<<<<<<
- * import struct
- * import ctypes
- */
-  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__itertools), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Fastafile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__fetch); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_179), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_180), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_181), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s___open); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_182), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__gettid); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_183), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__getrname); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_184), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s___parseRegion); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_185), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__seek); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_186), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__tell); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_187), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__fetch); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_188), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__mate); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_189), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__count); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_190), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__pileup); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_191), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__close); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_192), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__write); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_193), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s___buildLine); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_194), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Samfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____next__); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_195), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__IteratorRowRegion); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____next__); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_196), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__IteratorRowAll); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____next__); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_197), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__IteratorRowAllRefs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____next__); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_198), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s_200); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____next__); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_199), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__IteratorColumn); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__addReference); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_201), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__IteratorColumn); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__hasReference); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_202), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s_204); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____next__); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_203), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s_206); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____next__); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_205), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__AlignedRead); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__itertools, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____str__); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
-  /* "csamtools.pyx":9
- * import types
- * import itertools
- * import struct             # <<<<<<<<<<<<<<
- * import ctypes
- * import collections
- */
-  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__struct), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__struct, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_207), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
-  /* "csamtools.pyx":10
- * import itertools
- * import struct
- * import ctypes             # <<<<<<<<<<<<<<
- * import collections
- * import re
- */
-  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__ctypes), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__AlignedRead); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__ctypes, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__compare); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
-  /* "csamtools.pyx":11
- * import struct
- * import ctypes
- * import collections             # <<<<<<<<<<<<<<
- * import re
- * import platform
- */
-  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__collections), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__collections, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_208), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
-  /* "csamtools.pyx":12
- * import ctypes
- * import collections
- * import re             # <<<<<<<<<<<<<<
- * import platform
- * from cpython cimport PyString_FromStringAndSize, PyString_AS_STRING
- */
-  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__re), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__AlignedRead); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__re, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 12; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__overlap); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
-  /* "csamtools.pyx":13
- * import collections
- * import re
- * import platform             # <<<<<<<<<<<<<<
- * from cpython cimport PyString_FromStringAndSize, PyString_AS_STRING
- * from cpython cimport PyErr_SetString
- */
-  __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__platform), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__platform, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 13; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_209), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
-  /* "csamtools.pyx":63
- * #####################################################################
- * # hard-coded constants
- * cdef char * bam_nt16_rev_table = "=ACMGRSVTWYHKDBN"             # <<<<<<<<<<<<<<
- * cdef int max_pos = 2 << 29
- * 
- */
-  __pyx_v_9csamtools_bam_nt16_rev_table = __pyx_k_229;
-
-  /* "csamtools.pyx":64
- * # hard-coded constants
- * cdef char * bam_nt16_rev_table = "=ACMGRSVTWYHKDBN"
- * cdef int max_pos = 2 << 29             # <<<<<<<<<<<<<<
- * 
- * # redirect stderr to 0
- */
-  __pyx_v_9csamtools_max_pos = 1073741824;
-
-  /* "csamtools.pyx":67
- * 
- * # redirect stderr to 0
- * _logfile = open(os.path.devnull, "w")             # <<<<<<<<<<<<<<
- * pysam_set_stderr( PyFile_AsFile( _logfile ) )
- * 
- */
-  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__AlignedRead); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__path); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__opt); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__devnull); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
-  __Pyx_GIVEREF(__pyx_t_1);
-  __Pyx_INCREF(((PyObject *)__pyx_n_s__w));
-  PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_n_s__w));
-  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__w));
-  __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_Call(__pyx_builtin_open, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_210), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__AlignedRead); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s___logfile, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__fancy_str); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
-  /* "csamtools.pyx":68
- * # redirect stderr to 0
- * _logfile = open(os.path.devnull, "w")
- * pysam_set_stderr( PyFile_AsFile( _logfile ) )             # <<<<<<<<<<<<<<
- * 
- * #####################################################################
- */
-  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s___logfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  pysam_set_stderr(PyFile_AsFile(__pyx_t_1));
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_211), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
-  /* "csamtools.pyx":117
- *     (<object>f)(a)
- * 
- * class PileupColumn(object):             # <<<<<<<<<<<<<<
- *     '''A pileup column. A pileup column contains
- *     all the reads that map to a certain target base.
- */
-  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-
-  /* "csamtools.pyx":130
- *         list of reads (:class:`pysam.PileupRead`) aligned to this column
- *     '''
- *     def __str__(self):             # <<<<<<<<<<<<<<
- *         return "\t".join( map(str, (self.tid, self.pos, self.n))) +\
- *             "\n" + "\n".join( map(str, self.pileups) )
- */
-  __pyx_t_2 = __pyx_binding_PyCFunctionType_NewEx(&__pyx_mdef_9csamtools_12PileupColumn___str__, NULL, __pyx_n_s__csamtools); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_2);
-  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s____str__, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-
-  /* "csamtools.pyx":117
- *     (<object>f)(a)
- * 
- * class PileupColumn(object):             # <<<<<<<<<<<<<<
- *     '''A pileup column. A pileup column contains
- *     all the reads that map to a certain target base.
- */
-  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-  __Pyx_INCREF(__pyx_builtin_object);
-  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_builtin_object);
-  __Pyx_GIVEREF(__pyx_builtin_object);
-  if (PyDict_SetItemString(((PyObject *)__pyx_t_1), "__doc__", ((PyObject *)__pyx_kp_s_230)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_3 = __Pyx_CreateClass(((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_1), __pyx_n_s__PileupColumn, __pyx_n_s__csamtools); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__PileupColumn, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
-
-  /* "csamtools.pyx":174
- *     return 0
- * 
- * class StderrStore():             # <<<<<<<<<<<<<<
- *     '''
- *     stderr is captured.
- */
-  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-
-  /* "csamtools.pyx":178
- *     stderr is captured.
- *     '''
- *     def __init__(self):             # <<<<<<<<<<<<<<
- *         return
- *         self.stderr_h, self.stderr_f = tempfile.mkstemp()
- */
-  __pyx_t_3 = __pyx_binding_PyCFunctionType_NewEx(&__pyx_mdef_9csamtools_11StderrStore___init__, NULL, __pyx_n_s__csamtools); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s____init__, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
-  /* "csamtools.pyx":184
- *         self.stderr_save.setfd( self.stderr_h )
- * 
- *     def readAndRelease( self ):             # <<<<<<<<<<<<<<
- *         return []
- *         self.stderr_save.restore()
- */
-  __pyx_t_3 = __pyx_binding_PyCFunctionType_NewEx(&__pyx_mdef_9csamtools_11StderrStore_1readAndRelease, NULL, __pyx_n_s__csamtools); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s__readAndRelease, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
-  /* "csamtools.pyx":193
- *         return lines
- * 
- *     def release(self):             # <<<<<<<<<<<<<<
- *         return
- *         self.stderr_save.restore()
- */
-  __pyx_t_3 = __pyx_binding_PyCFunctionType_NewEx(&__pyx_mdef_9csamtools_11StderrStore_2release, NULL, __pyx_n_s__csamtools); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s__release, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
-  /* "csamtools.pyx":199
- *             os.remove( self.stderr_f )
- * 
- *     def __del__(self):             # <<<<<<<<<<<<<<
- *         self.release()
- * 
- */
-  __pyx_t_3 = __pyx_binding_PyCFunctionType_NewEx(&__pyx_mdef_9csamtools_11StderrStore_3__del__, NULL, __pyx_n_s__csamtools); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s____del__, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
-  /* "csamtools.pyx":174
- *     return 0
- * 
- * class StderrStore():             # <<<<<<<<<<<<<<
- *     '''
- *     stderr is captured.
- */
-  if (PyDict_SetItemString(((PyObject *)__pyx_t_1), "__doc__", ((PyObject *)__pyx_kp_s_231)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_3 = __Pyx_CreateClass(((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1), __pyx_n_s__StderrStore, __pyx_n_s__csamtools); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__StderrStore, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
-
-  /* "csamtools.pyx":202
- *         self.release()
- * 
- * class StderrStoreWindows():             # <<<<<<<<<<<<<<
- *     '''does nothing. stderr can't be redirected on windows'''
- *     def __init__(self): pass
- */
-  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-
-  /* "csamtools.pyx":204
- * class StderrStoreWindows():
- *     '''does nothing. stderr can't be redirected on windows'''
- *     def __init__(self): pass             # <<<<<<<<<<<<<<
- *     def readAndRelease(self): return []
- *     def release(self): pass
- */
-  __pyx_t_3 = __pyx_binding_PyCFunctionType_NewEx(&__pyx_mdef_9csamtools_18StderrStoreWindows___init__, NULL, __pyx_n_s__csamtools); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s____init__, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
-  /* "csamtools.pyx":205
- *     '''does nothing. stderr can't be redirected on windows'''
- *     def __init__(self): pass
- *     def readAndRelease(self): return []             # <<<<<<<<<<<<<<
- *     def release(self): pass
- * 
- */
-  __pyx_t_3 = __pyx_binding_PyCFunctionType_NewEx(&__pyx_mdef_9csamtools_18StderrStoreWindows_1readAndRelease, NULL, __pyx_n_s__csamtools); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s__readAndRelease, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
-  /* "csamtools.pyx":206
- *     def __init__(self): pass
- *     def readAndRelease(self): return []
- *     def release(self): pass             # <<<<<<<<<<<<<<
- * 
- * if platform.system()=='Windows':
- */
-  __pyx_t_3 = __pyx_binding_PyCFunctionType_NewEx(&__pyx_mdef_9csamtools_18StderrStoreWindows_2release, NULL, __pyx_n_s__csamtools); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s__release, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
-  /* "csamtools.pyx":202
- *         self.release()
- * 
- * class StderrStoreWindows():             # <<<<<<<<<<<<<<
- *     '''does nothing. stderr can't be redirected on windows'''
- *     def __init__(self): pass
- */
-  if (PyDict_SetItemString(((PyObject *)__pyx_t_1), "__doc__", ((PyObject *)__pyx_kp_s_232)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_3 = __Pyx_CreateClass(((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1), __pyx_n_s__StderrStoreWindows, __pyx_n_s__csamtools); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__StderrStoreWindows, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
-
-  /* "csamtools.pyx":208
- *     def release(self): pass
- * 
- * if platform.system()=='Windows':             # <<<<<<<<<<<<<<
- *     del StderrStore
- *     StderrStore = StderrStoreWindows
- */
-  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__platform); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Outs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__setdevice); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_212), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Outs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__system); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__setfile); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)__pyx_n_s__Windows), Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_213), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  if (__pyx_t_4) {
-
-    /* "csamtools.pyx":209
- * 
- * if platform.system()=='Windows':
- *     del StderrStore             # <<<<<<<<<<<<<<
- *     StderrStore = StderrStoreWindows
- * 
- */
-    if (__Pyx_DelAttrString(__pyx_m, "StderrStore") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-
-    /* "csamtools.pyx":210
- * if platform.system()=='Windows':
- *     del StderrStore
- *     StderrStore = StderrStoreWindows             # <<<<<<<<<<<<<<
- * 
- * 
- */
-    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__StderrStoreWindows); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_3);
-    if (PyObject_SetAttr(__pyx_m, __pyx_n_s__StderrStore, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    goto __pyx_L2;
-  }
-  __pyx_L2:;
-
-  /* "csamtools.pyx":217
- * ######################################################################
- * # valid types for sam headers
- * VALID_HEADER_TYPES = { "HD" : dict,             # <<<<<<<<<<<<<<
- *                        "SQ" : list,
- *                        "RG" : list,
- */
-  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__HD), ((PyObject *)((PyObject*)(&PyDict_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-
-  /* "csamtools.pyx":218
- * # valid types for sam headers
- * VALID_HEADER_TYPES = { "HD" : dict,
- *                        "SQ" : list,             # <<<<<<<<<<<<<<
- *                        "RG" : list,
- *                        "PG" : list,
- */
-  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__SQ), ((PyObject *)((PyObject*)(&PyList_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-
-  /* "csamtools.pyx":219
- * VALID_HEADER_TYPES = { "HD" : dict,
- *                        "SQ" : list,
- *                        "RG" : list,             # <<<<<<<<<<<<<<
- *                        "PG" : list,
- *                        "CO" : list }
- */
-  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__RG), ((PyObject *)((PyObject*)(&PyList_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-
-  /* "csamtools.pyx":220
- *                        "SQ" : list,
- *                        "RG" : list,
- *                        "PG" : list,             # <<<<<<<<<<<<<<
- *                        "CO" : list }
- * 
- */
-  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__PG), ((PyObject *)((PyObject*)(&PyList_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-
-  /* "csamtools.pyx":221
- *                        "RG" : list,
- *                        "PG" : list,
- *                        "CO" : list }             # <<<<<<<<<<<<<<
- * 
- * # order of records within sam headers
- */
-  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__CO), ((PyObject *)((PyObject*)(&PyList_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__VALID_HEADER_TYPES, ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
-
-  /* "csamtools.pyx":224
- * 
- * # order of records within sam headers
- * VALID_HEADERS = ("HD", "SQ", "RG", "PG", "CO" )             # <<<<<<<<<<<<<<
- * 
- * # type conversions within sam header records
- */
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__VALID_HEADERS, ((PyObject *)__pyx_k_tuple_233)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-
-  /* "csamtools.pyx":227
- * 
- * # type conversions within sam header records
- * VALID_HEADER_FIELDS = { "HD" : { "VN" : str, "SO" : str, "GO" : str },             # <<<<<<<<<<<<<<
- *                         "SQ" : { "SN" : str, "LN" : int, "AS" : str, "M5" : str, "UR" : str, "SP" : str },
- *                         "RG" : { "ID" : str, "SM" : str, "LB" : str, "DS" : str, "PU" : str, "PI" : str, "CN" : str, "DT" : str, "PL" : str, },
- */
-  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__VN), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__SO), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__GO), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__HD), ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
-
-  /* "csamtools.pyx":228
- * # type conversions within sam header records
- * VALID_HEADER_FIELDS = { "HD" : { "VN" : str, "SO" : str, "GO" : str },
- *                         "SQ" : { "SN" : str, "LN" : int, "AS" : str, "M5" : str, "UR" : str, "SP" : str },             # <<<<<<<<<<<<<<
- *                         "RG" : { "ID" : str, "SM" : str, "LB" : str, "DS" : str, "PU" : str, "PI" : str, "CN" : str, "DT" : str, "PL" : str, },
- *                         "PG" : { "PN" : str, "ID" : str, "VN" : str, "CL" : str }, }
- */
-  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__SN), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__LN), ((PyObject *)((PyObject*)(&PyInt_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__AS), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__M5), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__UR), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__SP), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__SQ), ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
-
-  /* "csamtools.pyx":229
- * VALID_HEADER_FIELDS = { "HD" : { "VN" : str, "SO" : str, "GO" : str },
- *                         "SQ" : { "SN" : str, "LN" : int, "AS" : str, "M5" : str, "UR" : str, "SP" : str },
- *                         "RG" : { "ID" : str, "SM" : str, "LB" : str, "DS" : str, "PU" : str, "PI" : str, "CN" : str, "DT" : str, "PL" : str, },             # <<<<<<<<<<<<<<
- *                         "PG" : { "PN" : str, "ID" : str, "VN" : str, "CL" : str }, }
- * 
- */
-  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__ID), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__SM), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__LB), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__DS), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__PU), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__PI), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__CN), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__DT), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__PL), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__RG), ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
-
-  /* "csamtools.pyx":230
- *                         "SQ" : { "SN" : str, "LN" : int, "AS" : str, "M5" : str, "UR" : str, "SP" : str },
- *                         "RG" : { "ID" : str, "SM" : str, "LB" : str, "DS" : str, "PU" : str, "PI" : str, "CN" : str, "DT" : str, "PL" : str, },
- *                         "PG" : { "PN" : str, "ID" : str, "VN" : str, "CL" : str }, }             # <<<<<<<<<<<<<<
- * 
- * # output order of fields within records
- */
-  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__PN), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__ID), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__VN), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__CL), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__PG), ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__VALID_HEADER_FIELDS, ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
-
-  /* "csamtools.pyx":233
- * 
- * # output order of fields within records
- * VALID_HEADER_ORDER = { "HD" : ( "VN", "SO", "GO" ),             # <<<<<<<<<<<<<<
- *                        "SQ" : ( "SN", "LN", "AS", "M5" , "UR" , "SP" ),
- *                        "RG" : ( "ID", "SM", "LB", "DS" , "PU" , "PI" , "CN" , "DT", "PL" ),
- */
-  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__HD), ((PyObject *)__pyx_k_tuple_234)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-
-  /* "csamtools.pyx":234
- * # output order of fields within records
- * VALID_HEADER_ORDER = { "HD" : ( "VN", "SO", "GO" ),
- *                        "SQ" : ( "SN", "LN", "AS", "M5" , "UR" , "SP" ),             # <<<<<<<<<<<<<<
- *                        "RG" : ( "ID", "SM", "LB", "DS" , "PU" , "PI" , "CN" , "DT", "PL" ),
- *                        "PG" : ( "PN", "ID", "VN", "CL" ), }
- */
-  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__SQ), ((PyObject *)__pyx_k_tuple_235)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-
-  /* "csamtools.pyx":235
- * VALID_HEADER_ORDER = { "HD" : ( "VN", "SO", "GO" ),
- *                        "SQ" : ( "SN", "LN", "AS", "M5" , "UR" , "SP" ),
- *                        "RG" : ( "ID", "SM", "LB", "DS" , "PU" , "PI" , "CN" , "DT", "PL" ),             # <<<<<<<<<<<<<<
- *                        "PG" : ( "PN", "ID", "VN", "CL" ), }
- * 
- */
-  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__RG), ((PyObject *)__pyx_k_tuple_236)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-
-  /* "csamtools.pyx":236
- *                        "SQ" : ( "SN", "LN", "AS", "M5" , "UR" , "SP" ),
- *                        "RG" : ( "ID", "SM", "LB", "DS" , "PU" , "PI" , "CN" , "DT", "PL" ),
- *                        "PG" : ( "PN", "ID", "VN", "CL" ), }             # <<<<<<<<<<<<<<
- * 
- * 
- */
-  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_n_s__PG), ((PyObject *)__pyx_k_tuple_237)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__VALID_HEADER_ORDER, ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
-
-  /* "csamtools.pyx":485
- *                header = None,
- *                port = None,
- *                add_sq_text = True,             # <<<<<<<<<<<<<<
- *               ):
- *         '''open a sam/bam file.
- */
-  __pyx_t_3 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_k_16 = __pyx_t_3;
-  __Pyx_GIVEREF(__pyx_t_3);
-  __pyx_t_3 = 0;
-
-  /* "csamtools.pyx":744
- *                region = None,
- *                callback = None,
- *                until_eof = False ):             # <<<<<<<<<<<<<<
- *         '''
- *         fetch aligned reads in a :term:`region` using 0-based indexing. The region is specified by
- */
-  __pyx_t_3 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_k_44 = __pyx_t_3;
-  __Pyx_GIVEREF(__pyx_t_3);
-  __pyx_t_3 = 0;
-
-  /* "csamtools.pyx":861
- *                end = None,
- *                region = None,
- *                until_eof = False ):             # <<<<<<<<<<<<<<
- *         '''*(reference = None, start = None, end = None, region = None, callback = None, until_eof = False)*
- * 
- */
-  __pyx_t_3 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_k_62 = __pyx_t_3;
-  __Pyx_GIVEREF(__pyx_t_3);
-  __pyx_t_3 = 0;
-
-  /* "csamtools.pyx":1783
- *                   int tid = 0,
- *                   int start = 0,
- *                   int end = max_pos,             # <<<<<<<<<<<<<<
- *                   **kwargs ):
- * 
- */
-  __pyx_k_115 = __pyx_v_9csamtools_max_pos;
-
-  /* "csamtools.pyx":2785
- *             return self._level
- * 
- * class Outs:             # <<<<<<<<<<<<<<
- *     '''http://mail.python.org/pipermail/python-list/2000-June/038406.html'''
- *     def __init__(self, id = 1):
- */
-  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-
-  /* "csamtools.pyx":2787
- * class Outs:
- *     '''http://mail.python.org/pipermail/python-list/2000-June/038406.html'''
- *     def __init__(self, id = 1):             # <<<<<<<<<<<<<<
- *         self.streams = []
- *         self.id = id
- */
-  __pyx_t_1 = __pyx_binding_PyCFunctionType_NewEx(&__pyx_mdef_9csamtools_4Outs___init__, NULL, __pyx_n_s__csamtools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Outs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetItem(__pyx_t_3, __pyx_n_s____init__, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__restore); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
-  /* "csamtools.pyx":2791
- *         self.id = id
- * 
- *     def setdevice(self, filename):             # <<<<<<<<<<<<<<
- *         '''open an existing file, like "/dev/null"'''
- *         fd = os.open(filename, os.O_WRONLY)
- */
-  __pyx_t_1 = __pyx_binding_PyCFunctionType_NewEx(&__pyx_mdef_9csamtools_4Outs_1setdevice, NULL, __pyx_n_s__csamtools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetAttrString(__pyx_t_4, "__doc__"); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetItem(__pyx_t_3, __pyx_n_s__setdevice, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_214), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
-  /* "csamtools.pyx":2796
- *         self.setfd(fd)
- * 
- *     def setfile(self, filename):             # <<<<<<<<<<<<<<
- *         '''open a new file.'''
- *         fd = os.open(filename, os.O_WRONLY|os.O_CREAT, 0660);
- */
-  __pyx_t_1 = __pyx_binding_PyCFunctionType_NewEx(&__pyx_mdef_9csamtools_4Outs_2setfile, NULL, __pyx_n_s__csamtools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_m, __pyx_n_s___samtools_dispatch); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetItem(__pyx_t_3, __pyx_n_s__setfile, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __Pyx_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
-  /* "csamtools.pyx":2801
- *         self.setfd(fd)
- * 
- *     def setfd(self, fd):             # <<<<<<<<<<<<<<
- *         ofd = os.dup(self.id)      #  Save old stream on new unit.
- *         self.streams.append(ofd)
- */
-  __pyx_t_1 = __pyx_binding_PyCFunctionType_NewEx(&__pyx_mdef_9csamtools_4Outs_3setfd, NULL, __pyx_n_s__csamtools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2801; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_215), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_4 = PyObject_GetAttr(__pyx_m, __pyx_n_s__IteratorSNPCalls); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s____next__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetItem(__pyx_t_3, __pyx_n_s__setfd, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2801; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_4 = __Pyx_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
-  /* "csamtools.pyx":2809
- *         os.close(fd)                #  Close other unit (look out, caller.)
- * 
- *     def restore(self):             # <<<<<<<<<<<<<<
- *         '''restore previous output stream'''
- *         if self.streams:
- */
-  __pyx_t_1 = __pyx_binding_PyCFunctionType_NewEx(&__pyx_mdef_9csamtools_4Outs_4restore, NULL, __pyx_n_s__csamtools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_216), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_4 = PyObject_GetAttr(__pyx_m, __pyx_n_s__SNPCaller); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__call); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_4 = __Pyx_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_217), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_4 = PyObject_GetAttr(__pyx_m, __pyx_n_s__IndelCaller); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__call); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_4 = __Pyx_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_218), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_4 = PyObject_GetAttr(__pyx_m, __pyx_n_s__IteratorIndelCalls); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s____next__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetItem(__pyx_t_3, __pyx_n_s__restore, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2809; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_4 = __Pyx_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-
-  /* "csamtools.pyx":2785
- *             return self._level
- * 
- * class Outs:             # <<<<<<<<<<<<<<
- *     '''http://mail.python.org/pipermail/python-list/2000-June/038406.html'''
- *     def __init__(self, id = 1):
- */
-  if (PyDict_SetItemString(((PyObject *)__pyx_t_3), "__doc__", ((PyObject *)__pyx_kp_s_238)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_1 = __Pyx_CreateClass(((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_3), __pyx_n_s__Outs, __pyx_n_s__csamtools); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_219), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_4 = PyObject_GetAttr(__pyx_m, __pyx_n_s__IndexedReads); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__build); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__Outs, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_4 = __Pyx_GetAttrString(__pyx_t_1, "__doc__"); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
-
-  /* "csamtools.pyx":2822
- * def _samtools_dispatch( method,
- *                         args = (),
- *                         catch_stdout = True,             # <<<<<<<<<<<<<<
- *                         catch_stderr = False,
- *                         ):
- */
-  __pyx_t_3 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_k_160 = __pyx_t_3;
-  __Pyx_GIVEREF(__pyx_t_3);
-  __pyx_t_3 = 0;
-
-  /* "csamtools.pyx":2823
- *                         args = (),
- *                         catch_stdout = True,
- *                         catch_stderr = False,             # <<<<<<<<<<<<<<
- *                         ):
- *     '''call ``method`` in samtools providing arguments in args.
- */
-  __pyx_t_3 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_k_161 = __pyx_t_3;
-  __Pyx_GIVEREF(__pyx_t_3);
-  __pyx_t_3 = 0;
-
-  /* "csamtools.pyx":2820
- *             del self.streams[-1]
- * 
- * def _samtools_dispatch( method,             # <<<<<<<<<<<<<<
- *                         args = (),
- *                         catch_stdout = True,
- */
-  __pyx_t_3 = PyCFunction_NewEx(&__pyx_mdef_9csamtools__samtools_dispatch, NULL, __pyx_n_s__csamtools); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s___samtools_dispatch, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
-  /* "csamtools.pyx":3522
- *         if self.owns_samfile: samclose( self.fp )
- * 
- * __all__ = ["Samfile",             # <<<<<<<<<<<<<<
- *            "Fastafile",
- *            "IteratorRow",
- */
-  __pyx_t_3 = PyList_New(9); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-  __Pyx_INCREF(((PyObject *)__pyx_n_s__Samfile));
-  PyList_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_n_s__Samfile));
-  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Samfile));
-  __Pyx_INCREF(((PyObject *)__pyx_n_s__Fastafile));
-  PyList_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_n_s__Fastafile));
-  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Fastafile));
-  __Pyx_INCREF(((PyObject *)__pyx_n_s__IteratorRow));
-  PyList_SET_ITEM(__pyx_t_3, 2, ((PyObject *)__pyx_n_s__IteratorRow));
-  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__IteratorRow));
-  __Pyx_INCREF(((PyObject *)__pyx_n_s__IteratorColumn));
-  PyList_SET_ITEM(__pyx_t_3, 3, ((PyObject *)__pyx_n_s__IteratorColumn));
-  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__IteratorColumn));
-  __Pyx_INCREF(((PyObject *)__pyx_n_s__AlignedRead));
-  PyList_SET_ITEM(__pyx_t_3, 4, ((PyObject *)__pyx_n_s__AlignedRead));
-  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__AlignedRead));
-  __Pyx_INCREF(((PyObject *)__pyx_n_s__PileupColumn));
-  PyList_SET_ITEM(__pyx_t_3, 5, ((PyObject *)__pyx_n_s__PileupColumn));
-  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PileupColumn));
-  __Pyx_INCREF(((PyObject *)__pyx_n_s__PileupProxy));
-  PyList_SET_ITEM(__pyx_t_3, 6, ((PyObject *)__pyx_n_s__PileupProxy));
-  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PileupProxy));
-  __Pyx_INCREF(((PyObject *)__pyx_n_s__PileupRead));
-  PyList_SET_ITEM(__pyx_t_3, 7, ((PyObject *)__pyx_n_s__PileupRead));
-  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PileupRead));
-  __Pyx_INCREF(((PyObject *)__pyx_n_s__IndexedReads));
-  PyList_SET_ITEM(__pyx_t_3, 8, ((PyObject *)__pyx_n_s__IndexedReads));
-  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__IndexedReads));
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____all__, ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3522; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
-
-  /* "csamtools.pyx":1
- * # cython: embedsignature=True             # <<<<<<<<<<<<<<
- * # cython: profile=True
- * # adds doc-strings for sphinx
- */
-  __pyx_t_3 = PyDict_New(); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+  if (PyDict_SetItem(__pyx_t_3, ((PyObject *)__pyx_kp_u_220), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_3)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
 
-  /* "cpython/type.pxd":2
+  /* "/ifs/apps/apps/python-2.7.1/lib/python2.7/site-packages/Cython-0.13-py2.7-linux-x86_64.egg/Cython/Includes/cpython/type.pxd":2
  * 
  * cdef extern from "Python.h":             # <<<<<<<<<<<<<<
  *     # The C structure of the objects used to describe built-in types.
@@ -33526,6 +37718,7 @@ PyMODINIT_FUNC PyInit_csamtools(void)
   __Pyx_XDECREF(__pyx_t_1);
   __Pyx_XDECREF(__pyx_t_2);
   __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
   if (__pyx_m) {
     __Pyx_AddTraceback("init csamtools");
     Py_DECREF(__pyx_m); __pyx_m = 0;
@@ -33612,10 +37805,10 @@ static PyCodeObject *__Pyx_createFrameCodeObject(const char *funcname, const cha
         __pyx_empty_bytes   /*PyObject *lnotab*/
     );
 
-bad:
+bad: 
     Py_XDECREF(py_srcfile);
     Py_XDECREF(py_funcname);
-
+    
     return py_code;
 }
 
@@ -33709,143 +37902,6 @@ invalid_keyword:
     return 0;
 }
 
-static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
-    PyObject *tmp_type, *tmp_value, *tmp_tb;
-    PyThreadState *tstate = PyThreadState_GET();
-
-    tmp_type = tstate->curexc_type;
-    tmp_value = tstate->curexc_value;
-    tmp_tb = tstate->curexc_traceback;
-    tstate->curexc_type = type;
-    tstate->curexc_value = value;
-    tstate->curexc_traceback = tb;
-    Py_XDECREF(tmp_type);
-    Py_XDECREF(tmp_value);
-    Py_XDECREF(tmp_tb);
-}
-
-static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
-    PyThreadState *tstate = PyThreadState_GET();
-    *type = tstate->curexc_type;
-    *value = tstate->curexc_value;
-    *tb = tstate->curexc_traceback;
-
-    tstate->curexc_type = 0;
-    tstate->curexc_value = 0;
-    tstate->curexc_traceback = 0;
-}
-
-
-#if PY_MAJOR_VERSION < 3
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
-    Py_XINCREF(type);
-    Py_XINCREF(value);
-    Py_XINCREF(tb);
-    /* First, check the traceback argument, replacing None with NULL. */
-    if (tb == Py_None) {
-        Py_DECREF(tb);
-        tb = 0;
-    }
-    else if (tb != NULL && !PyTraceBack_Check(tb)) {
-        PyErr_SetString(PyExc_TypeError,
-            "raise: arg 3 must be a traceback or None");
-        goto raise_error;
-    }
-    /* Next, replace a missing value with None */
-    if (value == NULL) {
-        value = Py_None;
-        Py_INCREF(value);
-    }
-    #if PY_VERSION_HEX < 0x02050000
-    if (!PyClass_Check(type))
-    #else
-    if (!PyType_Check(type))
-    #endif
-    {
-        /* Raising an instance.  The value should be a dummy. */
-        if (value != Py_None) {
-            PyErr_SetString(PyExc_TypeError,
-                "instance exception may not have a separate value");
-            goto raise_error;
-        }
-        /* Normalize to raise <class>, <instance> */
-        Py_DECREF(value);
-        value = type;
-        #if PY_VERSION_HEX < 0x02050000
-            if (PyInstance_Check(type)) {
-                type = (PyObject*) ((PyInstanceObject*)type)->in_class;
-                Py_INCREF(type);
-            }
-            else {
-                type = 0;
-                PyErr_SetString(PyExc_TypeError,
-                    "raise: exception must be an old-style class or instance");
-                goto raise_error;
-            }
-        #else
-            type = (PyObject*) Py_TYPE(type);
-            Py_INCREF(type);
-            if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
-                PyErr_SetString(PyExc_TypeError,
-                    "raise: exception class must be a subclass of BaseException");
-                goto raise_error;
-            }
-        #endif
-    }
-
-    __Pyx_ErrRestore(type, value, tb);
-    return;
-raise_error:
-    Py_XDECREF(value);
-    Py_XDECREF(type);
-    Py_XDECREF(tb);
-    return;
-}
-
-#else /* Python 3+ */
-
-static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
-    if (tb == Py_None) {
-        tb = 0;
-    } else if (tb && !PyTraceBack_Check(tb)) {
-        PyErr_SetString(PyExc_TypeError,
-            "raise: arg 3 must be a traceback or None");
-        goto bad;
-    }
-    if (value == Py_None)
-        value = 0;
-
-    if (PyExceptionInstance_Check(type)) {
-        if (value) {
-            PyErr_SetString(PyExc_TypeError,
-                "instance exception may not have a separate value");
-            goto bad;
-        }
-        value = type;
-        type = (PyObject*) Py_TYPE(value);
-    } else if (!PyExceptionClass_Check(type)) {
-        PyErr_SetString(PyExc_TypeError,
-            "raise: exception class must be a subclass of BaseException");
-        goto bad;
-    }
-
-    PyErr_SetObject(type, value);
-
-    if (tb) {
-        PyThreadState *tstate = PyThreadState_GET();
-        PyObject* tmp_tb = tstate->curexc_traceback;
-        if (tb != tmp_tb) {
-            Py_INCREF(tb);
-            tstate->curexc_traceback = tb;
-            Py_XDECREF(tmp_tb);
-        }
-    }
-
-bad:
-    return;
-}
-#endif
-
 static void __Pyx_RaiseDoubleKeywordsError(
     const char* func_name,
     PyObject* kw_name)
@@ -33854,9 +37910,39 @@ static void __Pyx_RaiseDoubleKeywordsError(
         #if PY_MAJOR_VERSION >= 3
         "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
         #else
-        "%s() got multiple values for keyword argument '%s'", func_name,
-        PyString_AS_STRING(kw_name));
+        "%s() got multiple values for keyword argument '%s'", func_name,
+        PyString_AS_STRING(kw_name));
+        #endif
+}
+
+static void __Pyx_RaiseArgtupleInvalid(
+    const char* func_name,
+    int exact,
+    Py_ssize_t num_min,
+    Py_ssize_t num_max,
+    Py_ssize_t num_found)
+{
+    Py_ssize_t num_expected;
+    const char *number, *more_or_less;
+
+    if (num_found < num_min) {
+        num_expected = num_min;
+        more_or_less = "at least";
+    } else {
+        num_expected = num_max;
+        more_or_less = "at most";
+    }
+    if (exact) {
+        more_or_less = "exactly";
+    }
+    number = (num_expected == 1) ? "" : "s";
+    PyErr_Format(PyExc_TypeError,
+        #if PY_VERSION_HEX < 0x02050000
+            "%s() takes %s %d positional argument%s (%d given)",
+        #else
+            "%s() takes %s %zd positional argument%s (%zd given)",
         #endif
+        func_name, more_or_less, num_expected, number, num_found);
 }
 
 static int __Pyx_ParseOptionalKeywords(
@@ -33938,36 +38024,33 @@ bad:
     return -1;
 }
 
-static void __Pyx_RaiseArgtupleInvalid(
-    const char* func_name,
-    int exact,
-    Py_ssize_t num_min,
-    Py_ssize_t num_max,
-    Py_ssize_t num_found)
-{
-    Py_ssize_t num_expected;
-    const char *number, *more_or_less;
+static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
+    PyObject *tmp_type, *tmp_value, *tmp_tb;
+    PyThreadState *tstate = PyThreadState_GET();
 
-    if (num_found < num_min) {
-        num_expected = num_min;
-        more_or_less = "at least";
-    } else {
-        num_expected = num_max;
-        more_or_less = "at most";
-    }
-    if (exact) {
-        more_or_less = "exactly";
-    }
-    number = (num_expected == 1) ? "" : "s";
-    PyErr_Format(PyExc_TypeError,
-        #if PY_VERSION_HEX < 0x02050000
-            "%s() takes %s %d positional argument%s (%d given)",
-        #else
-            "%s() takes %s %zd positional argument%s (%zd given)",
-        #endif
-        func_name, more_or_less, num_expected, number, num_found);
+    tmp_type = tstate->curexc_type;
+    tmp_value = tstate->curexc_value;
+    tmp_tb = tstate->curexc_traceback;
+    tstate->curexc_type = type;
+    tstate->curexc_value = value;
+    tstate->curexc_traceback = tb;
+    Py_XDECREF(tmp_type);
+    Py_XDECREF(tmp_value);
+    Py_XDECREF(tmp_tb);
+}
+
+static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
+    PyThreadState *tstate = PyThreadState_GET();
+    *type = tstate->curexc_type;
+    *value = tstate->curexc_value;
+    *tb = tstate->curexc_traceback;
+
+    tstate->curexc_type = 0;
+    tstate->curexc_value = 0;
+    tstate->curexc_traceback = 0;
 }
 
+
 static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
     const char *name, int exact)
 {
@@ -34035,6 +38118,10 @@ bad:
 
 
 
+static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
+    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
+}
+
 static CYTHON_INLINE void __Pyx_RaiseNoneIndexingError(void) {
     PyErr_SetString(PyExc_TypeError, "'NoneType' object is unsubscriptable");
 }
@@ -34110,92 +38197,31 @@ bad:
     return module;
 }
 
-static PyObject *__Pyx_FindPy2Metaclass(PyObject *bases) {
-    PyObject *metaclass;
-    /* Default metaclass */
-#if PY_MAJOR_VERSION < 3
-    if (PyTuple_Check(bases) && PyTuple_GET_SIZE(bases) > 0) {
-        PyObject *base = PyTuple_GET_ITEM(bases, 0);
-        metaclass = PyObject_GetAttrString(base, "__class__");
-        if (!metaclass) {
-            PyErr_Clear();
-            metaclass = (PyObject*) Py_TYPE(base);
-        }
-    } else {
-        metaclass = (PyObject *) &PyClass_Type;
-    }
-#else
-    if (PyTuple_Check(bases) && PyTuple_GET_SIZE(bases) > 0) {
-        PyObject *base = PyTuple_GET_ITEM(bases, 0);
-        metaclass = (PyObject*) Py_TYPE(base);
-    } else {
-        metaclass = (PyObject *) &PyType_Type;
-    }
-#endif
-    Py_INCREF(metaclass);
-    return metaclass;
-}
-
-static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name,
-                                   PyObject *modname) {
-    PyObject *result;
-    PyObject *metaclass;
-
-    if (PyDict_SetItemString(dict, "__module__", modname) < 0)
-        return NULL;
+static PyObject *__Pyx_CreateClass(
+    PyObject *bases, PyObject *dict, PyObject *name, const char *modname)
+{
+    PyObject *py_modname;
+    PyObject *result = 0;
 
-    /* Python2 __metaclass__ */
-    metaclass = PyDict_GetItemString(dict, "__metaclass__");
-    if (metaclass) {
-        Py_INCREF(metaclass);
-    } else {
-        metaclass = __Pyx_FindPy2Metaclass(bases);
-    }
-    result = PyObject_CallFunctionObjArgs(metaclass, name, bases, dict, NULL);
-    Py_DECREF(metaclass);
+    #if PY_MAJOR_VERSION < 3
+    py_modname = PyString_FromString(modname);
+    #else
+    py_modname = PyUnicode_FromString(modname);
+    #endif
+    if (!py_modname)
+        goto bad;
+    if (PyDict_SetItemString(dict, "__module__", py_modname) < 0)
+        goto bad;
+    #if PY_MAJOR_VERSION < 3
+    result = PyClass_New(bases, dict, name);
+    #else
+    result = PyObject_CallFunctionObjArgs((PyObject *)&PyType_Type, name, bases, dict, NULL);
+    #endif
+bad:
+    Py_XDECREF(py_modname);
     return result;
 }
 
-
-static PyObject *__pyx_binding_PyCFunctionType_NewEx(PyMethodDef *ml, PyObject *self, PyObject *module) {
-       __pyx_binding_PyCFunctionType_object *op = PyObject_GC_New(__pyx_binding_PyCFunctionType_object, __pyx_binding_PyCFunctionType);
-    if (op == NULL)
-        return NULL;
-       op->func.m_ml = ml;
-       Py_XINCREF(self);
-       op->func.m_self = self;
-       Py_XINCREF(module);
-       op->func.m_module = module;
-       PyObject_GC_Track(op);
-       return (PyObject *)op;
-}
-
-static void __pyx_binding_PyCFunctionType_dealloc(__pyx_binding_PyCFunctionType_object *m) {
-       PyObject_GC_UnTrack(m);
-       Py_XDECREF(m->func.m_self);
-       Py_XDECREF(m->func.m_module);
-    PyObject_GC_Del(m);
-}
-
-static PyObject *__pyx_binding_PyCFunctionType_descr_get(PyObject *func, PyObject *obj, PyObject *type) {
-       if (obj == Py_None)
-               obj = NULL;
-       return PyMethod_New(func, obj, type);
-}
-
-static int __pyx_binding_PyCFunctionType_init(void) {
-    __pyx_binding_PyCFunctionType_type = PyCFunction_Type;
-    __pyx_binding_PyCFunctionType_type.tp_name = __Pyx_NAMESTR("cython_binding_builtin_function_or_method");
-    __pyx_binding_PyCFunctionType_type.tp_dealloc = (destructor)__pyx_binding_PyCFunctionType_dealloc;
-    __pyx_binding_PyCFunctionType_type.tp_descr_get = __pyx_binding_PyCFunctionType_descr_get;
-    if (PyType_Ready(&__pyx_binding_PyCFunctionType_type) < 0) {
-        return -1;
-    }
-    __pyx_binding_PyCFunctionType = &__pyx_binding_PyCFunctionType_type;
-    return 0;
-
-}
-
 static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint32_t(uint32_t val) {
     const uint32_t neg_one = (uint32_t)-1, const_zero = (uint32_t)0;
     const int is_unsigned = const_zero < neg_one;
@@ -34221,6 +38247,116 @@ static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint32_t(uint32_t val) {
     }
 }
 
+#if PY_MAJOR_VERSION < 3
+static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
+    Py_XINCREF(type);
+    Py_XINCREF(value);
+    Py_XINCREF(tb);
+    /* First, check the traceback argument, replacing None with NULL. */
+    if (tb == Py_None) {
+        Py_DECREF(tb);
+        tb = 0;
+    }
+    else if (tb != NULL && !PyTraceBack_Check(tb)) {
+        PyErr_SetString(PyExc_TypeError,
+            "raise: arg 3 must be a traceback or None");
+        goto raise_error;
+    }
+    /* Next, replace a missing value with None */
+    if (value == NULL) {
+        value = Py_None;
+        Py_INCREF(value);
+    }
+    #if PY_VERSION_HEX < 0x02050000
+    if (!PyClass_Check(type))
+    #else
+    if (!PyType_Check(type))
+    #endif
+    {
+        /* Raising an instance.  The value should be a dummy. */
+        if (value != Py_None) {
+            PyErr_SetString(PyExc_TypeError,
+                "instance exception may not have a separate value");
+            goto raise_error;
+        }
+        /* Normalize to raise <class>, <instance> */
+        Py_DECREF(value);
+        value = type;
+        #if PY_VERSION_HEX < 0x02050000
+            if (PyInstance_Check(type)) {
+                type = (PyObject*) ((PyInstanceObject*)type)->in_class;
+                Py_INCREF(type);
+            }
+            else {
+                type = 0;
+                PyErr_SetString(PyExc_TypeError,
+                    "raise: exception must be an old-style class or instance");
+                goto raise_error;
+            }
+        #else
+            type = (PyObject*) Py_TYPE(type);
+            Py_INCREF(type);
+            if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
+                PyErr_SetString(PyExc_TypeError,
+                    "raise: exception class must be a subclass of BaseException");
+                goto raise_error;
+            }
+        #endif
+    }
+
+    __Pyx_ErrRestore(type, value, tb);
+    return;
+raise_error:
+    Py_XDECREF(value);
+    Py_XDECREF(type);
+    Py_XDECREF(tb);
+    return;
+}
+
+#else /* Python 3+ */
+
+static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
+    if (tb == Py_None) {
+        tb = 0;
+    } else if (tb && !PyTraceBack_Check(tb)) {
+        PyErr_SetString(PyExc_TypeError,
+            "raise: arg 3 must be a traceback or None");
+        goto bad;
+    }
+    if (value == Py_None)
+        value = 0;
+
+    if (PyExceptionInstance_Check(type)) {
+        if (value) {
+            PyErr_SetString(PyExc_TypeError,
+                "instance exception may not have a separate value");
+            goto bad;
+        }
+        value = type;
+        type = (PyObject*) Py_TYPE(value);
+    } else if (!PyExceptionClass_Check(type)) {
+        PyErr_SetString(PyExc_TypeError,
+            "raise: exception class must be a subclass of BaseException");
+        goto bad;
+    }
+
+    PyErr_SetObject(type, value);
+
+    if (tb) {
+        PyThreadState *tstate = PyThreadState_GET();
+        PyObject* tmp_tb = tstate->curexc_traceback;
+        if (tb != tmp_tb) {
+            Py_INCREF(tb);
+            tstate->curexc_traceback = tb;
+            Py_XDECREF(tmp_tb);
+        }
+    }
+
+bad:
+    return;
+}
+#endif
+
 static CYTHON_INLINE uint32_t __Pyx_PyInt_from_py_uint32_t(PyObject* x) {
     const uint32_t neg_one = (uint32_t)-1, const_zero = (uint32_t)0;
     const int is_unsigned = const_zero < neg_one;
@@ -34452,6 +38588,143 @@ static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint8_t(uint8_t val) {
     }
 }
 
+#if PY_MAJOR_VERSION < 3
+static PyObject *__Pyx_GetStdout(void) {
+    PyObject *f = PySys_GetObject((char *)"stdout");
+    if (!f) {
+        PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout");
+    }
+    return f;
+}
+
+static int __Pyx_Print(PyObject* f, PyObject *arg_tuple, int newline) {
+    PyObject* v;
+    int i;
+
+    if (!f) {
+        if (!(f = __Pyx_GetStdout()))
+            return -1;
+    }
+    for (i=0; i < PyTuple_GET_SIZE(arg_tuple); i++) {
+        if (PyFile_SoftSpace(f, 1)) {
+            if (PyFile_WriteString(" ", f) < 0)
+                return -1;
+        }
+        v = PyTuple_GET_ITEM(arg_tuple, i);
+        if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0)
+            return -1;
+        if (PyString_Check(v)) {
+            char *s = PyString_AsString(v);
+            Py_ssize_t len = PyString_Size(v);
+            if (len > 0 &&
+                isspace(Py_CHARMASK(s[len-1])) &&
+                s[len-1] != ' ')
+                    PyFile_SoftSpace(f, 0);
+        }
+    }
+    if (newline) {
+        if (PyFile_WriteString("\n", f) < 0)
+            return -1;
+        PyFile_SoftSpace(f, 0);
+    }
+    return 0;
+}
+
+#else /* Python 3 has a print function */
+
+static int __Pyx_Print(PyObject* stream, PyObject *arg_tuple, int newline) {
+    PyObject* kwargs = 0;
+    PyObject* result = 0;
+    PyObject* end_string;
+    if (unlikely(!__pyx_print)) {
+        __pyx_print = __Pyx_GetAttrString(__pyx_b, "print");
+        if (!__pyx_print)
+            return -1;
+    }
+    if (stream) {
+        kwargs = PyDict_New();
+        if (unlikely(!kwargs))
+            return -1;
+        if (unlikely(PyDict_SetItemString(kwargs, "file", stream) < 0))
+            goto bad;
+        if (!newline) {
+            end_string = PyUnicode_FromStringAndSize(" ", 1);
+            if (unlikely(!end_string))
+                goto bad;
+            if (PyDict_SetItemString(kwargs, "end", end_string) < 0) {
+                Py_DECREF(end_string);
+                goto bad;
+            }
+            Py_DECREF(end_string);
+        }
+    } else if (!newline) {
+        if (unlikely(!__pyx_print_kwargs)) {
+            __pyx_print_kwargs = PyDict_New();
+            if (unlikely(!__pyx_print_kwargs))
+                return -1;
+            end_string = PyUnicode_FromStringAndSize(" ", 1);
+            if (unlikely(!end_string))
+                return -1;
+            if (PyDict_SetItemString(__pyx_print_kwargs, "end", end_string) < 0) {
+                Py_DECREF(end_string);
+                return -1;
+            }
+            Py_DECREF(end_string);
+        }
+        kwargs = __pyx_print_kwargs;
+    }
+    result = PyObject_Call(__pyx_print, arg_tuple, kwargs);
+    if (unlikely(kwargs) && (kwargs != __pyx_print_kwargs))
+        Py_DECREF(kwargs);
+    if (!result)
+        return -1;
+    Py_DECREF(result);
+    return 0;
+bad:
+    if (kwargs != __pyx_print_kwargs)
+        Py_XDECREF(kwargs);
+    return -1;
+}
+
+#endif
+
+#if PY_MAJOR_VERSION < 3
+
+static int __Pyx_PrintOne(PyObject* f, PyObject *o) {
+    if (!f) {
+        if (!(f = __Pyx_GetStdout()))
+            return -1;
+    }
+    if (PyFile_SoftSpace(f, 0)) {
+        if (PyFile_WriteString(" ", f) < 0)
+            return -1;
+    }
+    if (PyFile_WriteObject(o, f, Py_PRINT_RAW) < 0)
+        return -1;
+    if (PyFile_WriteString("\n", f) < 0)
+        return -1;
+    return 0;
+    /* the line below is just to avoid compiler
+     * compiler warnings about unused functions */
+    return __Pyx_Print(f, NULL, 0);
+}
+
+#else /* Python 3 has a print function */
+
+static int __Pyx_PrintOne(PyObject* stream, PyObject *o) {
+    int res;
+    PyObject* arg_tuple = PyTuple_New(1);
+    if (unlikely(!arg_tuple))
+        return -1;
+    Py_INCREF(o);
+    PyTuple_SET_ITEM(arg_tuple, 0, o);
+    res = __Pyx_Print(stream, arg_tuple, 1);
+    Py_DECREF(arg_tuple);
+    return res;
+}
+
+#endif
+
 static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint64_t(uint64_t val) {
     const uint64_t neg_one = (uint64_t)-1, const_zero = (uint64_t)0;
     const int is_unsigned = const_zero < neg_one;
@@ -34923,13 +39196,13 @@ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class
     if (!result)
         goto bad;
     if (!PyType_Check(result)) {
-        PyErr_Format(PyExc_TypeError,
+        PyErr_Format(PyExc_TypeError, 
             "%s.%s is not a type object",
             module_name, class_name);
         goto bad;
     }
     if (!strict && ((PyTypeObject *)result)->tp_basicsize > size) {
-        PyOS_snprintf(warning, sizeof(warning),
+        PyOS_snprintf(warning, sizeof(warning), 
             "%s.%s size changed, may indicate binary incompatibility",
             module_name, class_name);
         #if PY_VERSION_HEX < 0x02050000
@@ -34939,7 +39212,7 @@ static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class
         #endif
     }
     else if (((PyTypeObject *)result)->tp_basicsize != size) {
-        PyErr_Format(PyExc_ValueError,
+        PyErr_Format(PyExc_ValueError, 
             "%s.%s has the wrong size, try recompiling",
             module_name, class_name);
         goto bad;