Imported Upstream version 0.5
[pysam.git] / pysam / csamtools.c
1 /* Generated by Cython 0.13 on Tue Jun  7 17:24:36 2011 */
2
3 #define PY_SSIZE_T_CLEAN
4 #include "Python.h"
5 #ifndef Py_PYTHON_H
6     #error Python headers needed to compile C extensions, please install development version of Python.
7 #else
8
9 #include <stddef.h> /* For offsetof */
10 #ifndef offsetof
11 #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
12 #endif
13
14 #if !defined(WIN32) && !defined(MS_WINDOWS)
15   #ifndef __stdcall
16     #define __stdcall
17   #endif
18   #ifndef __cdecl
19     #define __cdecl
20   #endif
21   #ifndef __fastcall
22     #define __fastcall
23   #endif
24 #endif
25
26 #ifndef DL_IMPORT
27   #define DL_IMPORT(t) t
28 #endif
29 #ifndef DL_EXPORT
30   #define DL_EXPORT(t) t
31 #endif
32
33 #ifndef PY_LONG_LONG
34   #define PY_LONG_LONG LONG_LONG
35 #endif
36
37 #if PY_VERSION_HEX < 0x02040000
38   #define METH_COEXIST 0
39   #define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type)
40   #define PyDict_Contains(d,o)   PySequence_Contains(d,o)
41 #endif
42
43 #if PY_VERSION_HEX < 0x02050000
44   typedef int Py_ssize_t;
45   #define PY_SSIZE_T_MAX INT_MAX
46   #define PY_SSIZE_T_MIN INT_MIN
47   #define PY_FORMAT_SIZE_T ""
48   #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
49   #define PyInt_AsSsize_t(o)   PyInt_AsLong(o)
50   #define PyNumber_Index(o)    PyNumber_Int(o)
51   #define PyIndex_Check(o)     PyNumber_Check(o)
52   #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
53 #endif
54
55 #if PY_VERSION_HEX < 0x02060000
56   #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
57   #define Py_TYPE(ob)   (((PyObject*)(ob))->ob_type)
58   #define Py_SIZE(ob)   (((PyVarObject*)(ob))->ob_size)
59   #define PyVarObject_HEAD_INIT(type, size) \
60           PyObject_HEAD_INIT(type) size,
61   #define PyType_Modified(t)
62
63   typedef struct {
64      void *buf;
65      PyObject *obj;
66      Py_ssize_t len;
67      Py_ssize_t itemsize;
68      int readonly;
69      int ndim;
70      char *format;
71      Py_ssize_t *shape;
72      Py_ssize_t *strides;
73      Py_ssize_t *suboffsets;
74      void *internal;
75   } Py_buffer;
76
77   #define PyBUF_SIMPLE 0
78   #define PyBUF_WRITABLE 0x0001
79   #define PyBUF_FORMAT 0x0004
80   #define PyBUF_ND 0x0008
81   #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
82   #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
83   #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
84   #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
85   #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
86
87 #endif
88
89 #if PY_MAJOR_VERSION < 3
90   #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
91 #else
92   #define __Pyx_BUILTIN_MODULE_NAME "builtins"
93 #endif
94
95 #if PY_MAJOR_VERSION >= 3
96   #define Py_TPFLAGS_CHECKTYPES 0
97   #define Py_TPFLAGS_HAVE_INDEX 0
98 #endif
99
100 #if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
101   #define Py_TPFLAGS_HAVE_NEWBUFFER 0
102 #endif
103
104 #if PY_MAJOR_VERSION >= 3
105   #define PyBaseString_Type            PyUnicode_Type
106   #define PyStringObject               PyUnicodeObject
107   #define PyString_Type                PyUnicode_Type
108   #define PyString_Check               PyUnicode_Check
109   #define PyString_CheckExact          PyUnicode_CheckExact
110 #endif
111
112 #if PY_VERSION_HEX < 0x02060000
113   #define PyBytesObject                PyStringObject
114   #define PyBytes_Type                 PyString_Type
115   #define PyBytes_Check                PyString_Check
116   #define PyBytes_CheckExact           PyString_CheckExact
117   #define PyBytes_FromString           PyString_FromString
118   #define PyBytes_FromStringAndSize    PyString_FromStringAndSize
119   #define PyBytes_FromFormat           PyString_FromFormat
120   #define PyBytes_DecodeEscape         PyString_DecodeEscape
121   #define PyBytes_AsString             PyString_AsString
122   #define PyBytes_AsStringAndSize      PyString_AsStringAndSize
123   #define PyBytes_Size                 PyString_Size
124   #define PyBytes_AS_STRING            PyString_AS_STRING
125   #define PyBytes_GET_SIZE             PyString_GET_SIZE
126   #define PyBytes_Repr                 PyString_Repr
127   #define PyBytes_Concat               PyString_Concat
128   #define PyBytes_ConcatAndDel         PyString_ConcatAndDel
129   #define PySet_Check(obj)             PyObject_TypeCheck(obj, &PySet_Type)
130   #define PyFrozenSet_Check(obj)       PyObject_TypeCheck(obj, &PyFrozenSet_Type)
131 #endif
132
133 #ifndef PySet_CheckExact
134 #  define PySet_CheckExact(obj)          (Py_TYPE(obj) == &PySet_Type)
135 #endif
136
137 #if PY_MAJOR_VERSION >= 3
138   #define PyInt_Type                   PyLong_Type
139   #define PyInt_Check(op)              PyLong_Check(op)
140   #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
141   #define PyInt_FromString             PyLong_FromString
142   #define PyInt_FromUnicode            PyLong_FromUnicode
143   #define PyInt_FromLong               PyLong_FromLong
144   #define PyInt_FromSize_t             PyLong_FromSize_t
145   #define PyInt_FromSsize_t            PyLong_FromSsize_t
146   #define PyInt_AsLong                 PyLong_AsLong
147   #define PyInt_AS_LONG                PyLong_AS_LONG
148   #define PyInt_AsSsize_t              PyLong_AsSsize_t
149   #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
150   #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
151 #endif
152
153 #if PY_MAJOR_VERSION >= 3
154   #define PyBoolObject PyLongObject
155 #endif
156
157
158 #if PY_MAJOR_VERSION >= 3
159   #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
160   #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
161 #else
162   #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
163   #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
164 #endif
165
166 #if PY_MAJOR_VERSION >= 3
167   #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
168 #endif
169
170 #if PY_VERSION_HEX < 0x02050000
171   #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),((char *)(n)))
172   #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
173   #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),((char *)(n)))
174 #else
175   #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),(n))
176   #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
177   #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),(n))
178 #endif
179
180 #if PY_VERSION_HEX < 0x02050000
181   #define __Pyx_NAMESTR(n) ((char *)(n))
182   #define __Pyx_DOCSTR(n)  ((char *)(n))
183 #else
184   #define __Pyx_NAMESTR(n) (n)
185   #define __Pyx_DOCSTR(n)  (n)
186 #endif
187
188 #ifdef __cplusplus
189 #define __PYX_EXTERN_C extern "C"
190 #else
191 #define __PYX_EXTERN_C extern
192 #endif
193
194 #if defined(WIN32) || defined(MS_WINDOWS)
195 #define _USE_MATH_DEFINES
196 #endif
197 #include <math.h>
198 #define __PYX_HAVE_API__csamtools
199 #include "string.h"
200 #include "stdlib.h"
201 #include "math.h"
202 #include "stdio.h"
203 #include "ctype.h"
204 #include "unistd.h"
205 #include "fileobject.h"
206 #include "razf.h"
207 #include "stdint.h"
208 #include "bam.h"
209 #include "sam.h"
210 #include "glf.h"
211 #include "bam_maqcns.h"
212 #include "faidx.h"
213 #include "pysam_util.h"
214 #include "pythread.h"
215
216 /* inline attribute */
217 #ifndef CYTHON_INLINE
218   #if defined(__GNUC__)
219     #define CYTHON_INLINE __inline__
220   #elif defined(_MSC_VER)
221     #define CYTHON_INLINE __inline
222   #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
223     #define CYTHON_INLINE inline
224   #else
225     #define CYTHON_INLINE 
226   #endif
227 #endif
228
229 /* unused attribute */
230 #ifndef CYTHON_UNUSED
231 # if defined(__GNUC__)
232 #   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
233 #     define CYTHON_UNUSED __attribute__ ((__unused__)) 
234 #   else
235 #     define CYTHON_UNUSED
236 #   endif
237 # elif defined(__ICC) || defined(__INTEL_COMPILER)
238 #   define CYTHON_UNUSED __attribute__ ((__unused__)) 
239 # else
240 #   define CYTHON_UNUSED 
241 # endif
242 #endif
243
244 typedef struct {PyObject **p; char *s; const long n; const char* encoding; const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/
245
246
247 /* Type Conversion Predeclarations */
248
249 #define __Pyx_PyBytes_FromUString(s) PyBytes_FromString((char*)s)
250 #define __Pyx_PyBytes_AsUString(s)   ((unsigned char*) PyBytes_AsString(s))
251
252 #define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
253 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
254 static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
255
256 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
257 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
258 static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);
259
260 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
261
262
263 #ifdef __GNUC__
264 /* Test for GCC > 2.95 */
265 #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) 
266 #define likely(x)   __builtin_expect(!!(x), 1)
267 #define unlikely(x) __builtin_expect(!!(x), 0)
268 #else /* __GNUC__ > 2 ... */
269 #define likely(x)   (x)
270 #define unlikely(x) (x)
271 #endif /* __GNUC__ > 2 ... */
272 #else /* __GNUC__ */
273 #define likely(x)   (x)
274 #define unlikely(x) (x)
275 #endif /* __GNUC__ */
276     
277 static PyObject *__pyx_m;
278 static PyObject *__pyx_b;
279 static PyObject *__pyx_empty_tuple;
280 static PyObject *__pyx_empty_bytes;
281 static int __pyx_lineno;
282 static int __pyx_clineno = 0;
283 static const char * __pyx_cfilenm= __FILE__;
284 static const char *__pyx_filename;
285
286
287 static const char *__pyx_f[] = {
288   "csamtools.pyx",
289   "csamtools.pxd",
290   "bool.pxd",
291 };
292
293 /* Type declarations */
294
295 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":388
296  *      counter[0] += 1;
297  * 
298  * ctypedef struct MateData:             # <<<<<<<<<<<<<<
299  *      char * name
300  *      bam1_t * mate
301  */
302
303 typedef struct {
304   char *name;
305   bam1_t *mate;
306   uint32_t flag;
307 } __pyx_t_9csamtools_MateData;
308
309 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1478
310  * ##-------------------------------------------------------------------
311  * ##-------------------------------------------------------------------
312  * ctypedef struct __iterdata:             # <<<<<<<<<<<<<<
313  *     samfile_t * samfile
314  *     bam_iter_t iter
315  */
316
317 typedef struct {
318   samfile_t *samfile;
319   bam_iter_t iter;
320   faidx_t *fastafile;
321   int tid;
322   char *seq;
323   int seq_len;
324 } __pyx_t_9csamtools___iterdata;
325
326 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1655
327  *         bam_plp_set_mask( self.pileup_iter, self.mask )
328  * 
329  *     cdef setupIteratorData( self,             # <<<<<<<<<<<<<<
330  *                             int tid,
331  *                             int start,
332  */
333
334 struct __pyx_opt_args_9csamtools_14IteratorColumn_setupIteratorData {
335   int __pyx_n;
336   int reopen;
337 };
338
339 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3192
340  *         bam_maqindel_ret_destroy(self._r)
341  * 
342  * cdef class IndelCallerBase:             # <<<<<<<<<<<<<<
343  *     '''Base class for SNP callers.
344  * 
345  */
346
347 struct __pyx_obj_9csamtools_IndelCallerBase {
348   PyObject_HEAD
349   bam_maqindel_opt_t *options;
350   struct __pyx_obj_9csamtools_IteratorColumn *iter;
351   int cap_mapQ;
352   int max_depth;
353 };
354
355 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3330
356  *         return self._call()
357  * 
358  * cdef class IteratorIndelCalls( IndelCallerBase ):             # <<<<<<<<<<<<<<
359  *     """*(IteratorColumn iterator)*
360  * 
361  */
362
363 struct __pyx_obj_9csamtools_IteratorIndelCalls {
364   struct __pyx_obj_9csamtools_IndelCallerBase __pyx_base;
365 };
366
367 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":244
368  * ## Public methods
369  * ######################################################################
370  * cdef class Fastafile:             # <<<<<<<<<<<<<<
371  *     '''*(filename)*
372  * 
373  */
374
375 struct __pyx_obj_9csamtools_Fastafile {
376   PyObject_HEAD
377   struct __pyx_vtabstruct_9csamtools_Fastafile *__pyx_vtab;
378   char *_filename;
379   faidx_t *fastafile;
380 };
381
382 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3103
383  *         return call
384  * 
385  * cdef class IndelCall:             # <<<<<<<<<<<<<<
386  *     '''the results of an indel call.'''
387  *     cdef int _tid
388  */
389
390 struct __pyx_obj_9csamtools_IndelCall {
391   PyObject_HEAD
392   int _tid;
393   int _pos;
394   int _coverage;
395   int _rms_mapping_quality;
396   bam_maqindel_ret_t *_r;
397 };
398
399 /* "pysam/csamtools.pxd":388
400  *     cdef bam1_t * _delegate
401  * 
402  * cdef class Samfile:             # <<<<<<<<<<<<<<
403  *     cdef char * _filename
404  *     # pointer to samfile
405  */
406
407 struct __pyx_obj_9csamtools_Samfile {
408   PyObject_HEAD
409   struct __pyx_vtabstruct_9csamtools_Samfile *__pyx_vtab;
410   char *_filename;
411   samfile_t *samfile;
412   bam_index_t *index;
413   int isbam;
414   int isremote;
415   bam1_t *b;
416   char *mode;
417 };
418
419 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3287
420  *         return call
421  * 
422  * cdef class IndelCaller( IndelCallerBase ):             # <<<<<<<<<<<<<<
423  *     '''*(IteratorColumn iterator_column )*
424  * 
425  */
426
427 struct __pyx_obj_9csamtools_IndelCaller {
428   struct __pyx_obj_9csamtools_IndelCallerBase __pyx_base;
429 };
430
431 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":91
432  *      return dest
433  * 
434  * cdef class PileupRead             # <<<<<<<<<<<<<<
435  * cdef makePileupRead( bam_pileup1_t * src ):
436  *     '''fill a  PileupRead object from a bam_pileup1_t * object.'''
437  */
438
439 struct __pyx_obj_9csamtools_PileupRead {
440   PyObject_HEAD
441   struct __pyx_obj_9csamtools_AlignedRead *_alignment;
442   int32_t _qpos;
443   int _indel;
444   int _level;
445   uint32_t _is_del;
446   uint32_t _is_head;
447   uint32_t _is_tail;
448 };
449
450 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2816
451  *     return retval, out_stderr, out_stdout
452  * 
453  * cdef class SNPCall:             # <<<<<<<<<<<<<<
454  *     '''the results of a SNP call.'''
455  *     cdef int _tid
456  */
457
458 struct __pyx_obj_9csamtools_SNPCall {
459   PyObject_HEAD
460   int _tid;
461   int _pos;
462   char _reference_base;
463   char _genotype;
464   int _consensus_quality;
465   int _snp_quality;
466   int _rms_mapping_quality;
467   int _coverage;
468 };
469
470 /* "pysam/csamtools.pxd":383
471  * 
472  * # need to declare all C fields and methods here
473  * cdef class AlignedRead:             # <<<<<<<<<<<<<<
474  * 
475  *     # object that this AlignedRead represents
476  */
477
478 struct __pyx_obj_9csamtools_AlignedRead {
479   PyObject_HEAD
480   bam1_t *_delegate;
481 };
482
483 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1542
484  *     return ret
485  * 
486  * cdef class IteratorColumn:             # <<<<<<<<<<<<<<
487  *     '''abstract base class for iterators over columns.
488  * 
489  */
490
491 struct __pyx_obj_9csamtools_IteratorColumn {
492   PyObject_HEAD
493   struct __pyx_vtabstruct_9csamtools_IteratorColumn *__pyx_vtab;
494   struct __pyx_obj_9csamtools_IteratorRowRegion *iter;
495   int tid;
496   int pos;
497   int n_plp;
498   int mask;
499   const bam_pileup1_t * plp;
500   bam_plp_t pileup_iter;
501   __pyx_t_9csamtools___iterdata iterdata;
502   struct __pyx_obj_9csamtools_Samfile *samfile;
503   struct __pyx_obj_9csamtools_Fastafile *fastafile;
504   PyObject *stepper;
505 };
506
507 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1712
508  *             self.iterdata.seq = NULL
509  * 
510  * cdef class IteratorColumnRegion(IteratorColumn):             # <<<<<<<<<<<<<<
511  *     '''iterates over a region only.
512  *     '''
513  */
514
515 struct __pyx_obj_9csamtools_IteratorColumnRegion {
516   struct __pyx_obj_9csamtools_IteratorColumn __pyx_base;
517 };
518
519 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1187
520  * ##-------------------------------------------------------------------
521  * ##-------------------------------------------------------------------
522  * cdef class IteratorRow:             # <<<<<<<<<<<<<<
523  *     '''abstract base class for iterators over mapped reads.
524  * 
525  */
526
527 struct __pyx_obj_9csamtools_IteratorRow {
528   PyObject_HEAD
529 };
530
531 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1356
532  *         if self.owns_samfile: samclose( self.fp )
533  * 
534  * cdef class IteratorRowAllRefs(IteratorRow):             # <<<<<<<<<<<<<<
535  *     """iterates over all mapped reads by chaining iterators over each reference
536  *     """
537  */
538
539 struct __pyx_obj_9csamtools_IteratorRowAllRefs {
540   struct __pyx_obj_9csamtools_IteratorRow __pyx_base;
541   struct __pyx_obj_9csamtools_Samfile *samfile;
542   int tid;
543   struct __pyx_obj_9csamtools_IteratorRowRegion *rowiter;
544 };
545
546 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1206
547  *     pass
548  * 
549  * cdef class IteratorRowRegion(IteratorRow):             # <<<<<<<<<<<<<<
550  *     """*(Samfile samfile, int tid, int beg, int end, int reopen = True )*
551  * 
552  */
553
554 struct __pyx_obj_9csamtools_IteratorRowRegion {
555   struct __pyx_obj_9csamtools_IteratorRow __pyx_base;
556   struct __pyx_vtabstruct_9csamtools_IteratorRowRegion *__pyx_vtab;
557   bam_iter_t iter;
558   bam1_t *b;
559   int retval;
560   struct __pyx_obj_9csamtools_Samfile *samfile;
561   samfile_t *fp;
562   int owns_samfile;
563 };
564
565 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1741
566  *                                      self.n_plp )
567  * 
568  * cdef class IteratorColumnAllRefs(IteratorColumn):             # <<<<<<<<<<<<<<
569  *     """iterates over all columns by chaining iterators over each reference
570  *     """
571  */
572
573 struct __pyx_obj_9csamtools_IteratorColumnAllRefs {
574   struct __pyx_obj_9csamtools_IteratorColumn __pyx_base;
575 };
576
577 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1402
578  *                 raise StopIteration
579  * 
580  * cdef class IteratorRowSelection(IteratorRow):             # <<<<<<<<<<<<<<
581  *     """*(Samfile samfile)*
582  * 
583  */
584
585 struct __pyx_obj_9csamtools_IteratorRowSelection {
586   struct __pyx_obj_9csamtools_IteratorRow __pyx_base;
587   struct __pyx_vtabstruct_9csamtools_IteratorRowSelection *__pyx_vtab;
588   bam1_t *b;
589   int current_pos;
590   samfile_t *fp;
591   PyObject *positions;
592   int owns_samfile;
593 };
594
595 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2873
596  * 
597  * 
598  * cdef class SNPCallerBase:             # <<<<<<<<<<<<<<
599  *     '''Base class for SNP callers.
600  * 
601  */
602
603 struct __pyx_obj_9csamtools_SNPCallerBase {
604   PyObject_HEAD
605   struct __pyx_vtabstruct_9csamtools_SNPCallerBase *__pyx_vtab;
606   bam_maqcns_t *c;
607   struct __pyx_obj_9csamtools_IteratorColumn *iter;
608 };
609
610 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3021
611  *         return call
612  * 
613  * cdef class SNPCaller( SNPCallerBase ):             # <<<<<<<<<<<<<<
614  *     '''*(IteratorColumn iterator_column )*
615  * 
616  */
617
618 struct __pyx_obj_9csamtools_SNPCaller {
619   struct __pyx_obj_9csamtools_SNPCallerBase __pyx_base;
620 };
621
622 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2946
623  *         sys.stdout.flush()
624  * 
625  * cdef class IteratorSNPCalls( SNPCallerBase ):             # <<<<<<<<<<<<<<
626  *     """*(IteratorColumn iterator)*
627  * 
628  */
629
630 struct __pyx_obj_9csamtools_IteratorSNPCalls {
631   struct __pyx_obj_9csamtools_SNPCallerBase __pyx_base;
632 };
633
634 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1292
635  *         if self.owns_samfile: samclose( self.fp )
636  * 
637  * cdef class IteratorRowAll(IteratorRow):             # <<<<<<<<<<<<<<
638  *     """*(Samfile samfile, int reopen = True)*
639  * 
640  */
641
642 struct __pyx_obj_9csamtools_IteratorRowAll {
643   struct __pyx_obj_9csamtools_IteratorRow __pyx_base;
644   struct __pyx_vtabstruct_9csamtools_IteratorRowAll *__pyx_vtab;
645   bam1_t *b;
646   samfile_t *fp;
647   int owns_samfile;
648 };
649
650 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3370
651  * 
652  * 
653  * cdef class IndexedReads:             # <<<<<<<<<<<<<<
654  *     """index a bamfile by read.
655  * 
656  */
657
658 struct __pyx_obj_9csamtools_IndexedReads {
659   PyObject_HEAD
660   struct __pyx_obj_9csamtools_Samfile *samfile;
661   samfile_t *fp;
662   PyObject *index;
663   int owns_samfile;
664 };
665
666 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":82
667  *     return dest
668  * 
669  * cdef class PileupProxy             # <<<<<<<<<<<<<<
670  * cdef makePileupProxy( bam_pileup1_t * plp, int tid, int pos, int n ):
671  *      cdef PileupProxy dest = PileupProxy.__new__(PileupProxy)
672  */
673
674 struct __pyx_obj_9csamtools_PileupProxy {
675   PyObject_HEAD
676   bam_pileup1_t *plp;
677   int tid;
678   int pos;
679   int n_pu;
680 };
681
682
683 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1542
684  *     return ret
685  * 
686  * cdef class IteratorColumn:             # <<<<<<<<<<<<<<
687  *     '''abstract base class for iterators over columns.
688  * 
689  */
690
691 struct __pyx_vtabstruct_9csamtools_IteratorColumn {
692   int (*cnext)(struct __pyx_obj_9csamtools_IteratorColumn *);
693   char *(*getSequence)(struct __pyx_obj_9csamtools_IteratorColumn *);
694   PyObject *(*setMask)(struct __pyx_obj_9csamtools_IteratorColumn *, PyObject *);
695   PyObject *(*setupIteratorData)(struct __pyx_obj_9csamtools_IteratorColumn *, int, int, int, struct __pyx_opt_args_9csamtools_14IteratorColumn_setupIteratorData *__pyx_optional_args);
696   PyObject *(*reset)(struct __pyx_obj_9csamtools_IteratorColumn *, PyObject *, PyObject *, PyObject *);
697 };
698 static struct __pyx_vtabstruct_9csamtools_IteratorColumn *__pyx_vtabptr_9csamtools_IteratorColumn;
699
700
701 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1712
702  *             self.iterdata.seq = NULL
703  * 
704  * cdef class IteratorColumnRegion(IteratorColumn):             # <<<<<<<<<<<<<<
705  *     '''iterates over a region only.
706  *     '''
707  */
708
709 struct __pyx_vtabstruct_9csamtools_IteratorColumnRegion {
710   struct __pyx_vtabstruct_9csamtools_IteratorColumn __pyx_base;
711 };
712 static struct __pyx_vtabstruct_9csamtools_IteratorColumnRegion *__pyx_vtabptr_9csamtools_IteratorColumnRegion;
713
714
715 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2873
716  * 
717  * 
718  * cdef class SNPCallerBase:             # <<<<<<<<<<<<<<
719  *     '''Base class for SNP callers.
720  * 
721  */
722
723 struct __pyx_vtabstruct_9csamtools_SNPCallerBase {
724   PyObject *(*__dump)(struct __pyx_obj_9csamtools_SNPCallerBase *, glf1_t *, uint32_t, int);
725 };
726 static struct __pyx_vtabstruct_9csamtools_SNPCallerBase *__pyx_vtabptr_9csamtools_SNPCallerBase;
727
728
729 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3021
730  *         return call
731  * 
732  * cdef class SNPCaller( SNPCallerBase ):             # <<<<<<<<<<<<<<
733  *     '''*(IteratorColumn iterator_column )*
734  * 
735  */
736
737 struct __pyx_vtabstruct_9csamtools_SNPCaller {
738   struct __pyx_vtabstruct_9csamtools_SNPCallerBase __pyx_base;
739 };
740 static struct __pyx_vtabstruct_9csamtools_SNPCaller *__pyx_vtabptr_9csamtools_SNPCaller;
741
742
743 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1206
744  *     pass
745  * 
746  * cdef class IteratorRowRegion(IteratorRow):             # <<<<<<<<<<<<<<
747  *     """*(Samfile samfile, int tid, int beg, int end, int reopen = True )*
748  * 
749  */
750
751 struct __pyx_vtabstruct_9csamtools_IteratorRowRegion {
752   bam1_t *(*getCurrent)(struct __pyx_obj_9csamtools_IteratorRowRegion *);
753   int (*cnext)(struct __pyx_obj_9csamtools_IteratorRowRegion *);
754 };
755 static struct __pyx_vtabstruct_9csamtools_IteratorRowRegion *__pyx_vtabptr_9csamtools_IteratorRowRegion;
756
757
758 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1402
759  *                 raise StopIteration
760  * 
761  * cdef class IteratorRowSelection(IteratorRow):             # <<<<<<<<<<<<<<
762  *     """*(Samfile samfile)*
763  * 
764  */
765
766 struct __pyx_vtabstruct_9csamtools_IteratorRowSelection {
767   bam1_t *(*getCurrent)(struct __pyx_obj_9csamtools_IteratorRowSelection *);
768   int (*cnext)(struct __pyx_obj_9csamtools_IteratorRowSelection *);
769 };
770 static struct __pyx_vtabstruct_9csamtools_IteratorRowSelection *__pyx_vtabptr_9csamtools_IteratorRowSelection;
771
772
773 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1741
774  *                                      self.n_plp )
775  * 
776  * cdef class IteratorColumnAllRefs(IteratorColumn):             # <<<<<<<<<<<<<<
777  *     """iterates over all columns by chaining iterators over each reference
778  *     """
779  */
780
781 struct __pyx_vtabstruct_9csamtools_IteratorColumnAllRefs {
782   struct __pyx_vtabstruct_9csamtools_IteratorColumn __pyx_base;
783 };
784 static struct __pyx_vtabstruct_9csamtools_IteratorColumnAllRefs *__pyx_vtabptr_9csamtools_IteratorColumnAllRefs;
785
786
787 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":415
788  * 
789  * 
790  * cdef class Samfile:             # <<<<<<<<<<<<<<
791  *     '''*(filename, mode=None, template = None, referencenames = None, referencelengths = None, text = NULL, header = None)*
792  * 
793  */
794
795 struct __pyx_vtabstruct_9csamtools_Samfile {
796   bam_header_t *(*_buildHeader)(struct __pyx_obj_9csamtools_Samfile *, PyObject *);
797   bam1_t *(*getCurrent)(struct __pyx_obj_9csamtools_Samfile *);
798   int (*cnext)(struct __pyx_obj_9csamtools_Samfile *);
799   int (*write)(struct __pyx_obj_9csamtools_Samfile *, struct __pyx_obj_9csamtools_AlignedRead *, int __pyx_skip_dispatch);
800   char *(*_getrname)(struct __pyx_obj_9csamtools_Samfile *, int);
801 };
802 static struct __pyx_vtabstruct_9csamtools_Samfile *__pyx_vtabptr_9csamtools_Samfile;
803
804
805 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":244
806  * ## Public methods
807  * ######################################################################
808  * cdef class Fastafile:             # <<<<<<<<<<<<<<
809  *     '''*(filename)*
810  * 
811  */
812
813 struct __pyx_vtabstruct_9csamtools_Fastafile {
814   char *(*_fetch)(struct __pyx_obj_9csamtools_Fastafile *, char *, int, int, int *);
815 };
816 static struct __pyx_vtabstruct_9csamtools_Fastafile *__pyx_vtabptr_9csamtools_Fastafile;
817
818
819 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1292
820  *         if self.owns_samfile: samclose( self.fp )
821  * 
822  * cdef class IteratorRowAll(IteratorRow):             # <<<<<<<<<<<<<<
823  *     """*(Samfile samfile, int reopen = True)*
824  * 
825  */
826
827 struct __pyx_vtabstruct_9csamtools_IteratorRowAll {
828   bam1_t *(*getCurrent)(struct __pyx_obj_9csamtools_IteratorRowAll *);
829   int (*cnext)(struct __pyx_obj_9csamtools_IteratorRowAll *);
830 };
831 static struct __pyx_vtabstruct_9csamtools_IteratorRowAll *__pyx_vtabptr_9csamtools_IteratorRowAll;
832
833
834 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2946
835  *         sys.stdout.flush()
836  * 
837  * cdef class IteratorSNPCalls( SNPCallerBase ):             # <<<<<<<<<<<<<<
838  *     """*(IteratorColumn iterator)*
839  * 
840  */
841
842 struct __pyx_vtabstruct_9csamtools_IteratorSNPCalls {
843   struct __pyx_vtabstruct_9csamtools_SNPCallerBase __pyx_base;
844 };
845 static struct __pyx_vtabstruct_9csamtools_IteratorSNPCalls *__pyx_vtabptr_9csamtools_IteratorSNPCalls;
846
847 #ifndef CYTHON_REFNANNY
848   #define CYTHON_REFNANNY 0
849 #endif
850
851 #if CYTHON_REFNANNY
852   typedef struct {
853     void (*INCREF)(void*, PyObject*, int);
854     void (*DECREF)(void*, PyObject*, int);
855     void (*GOTREF)(void*, PyObject*, int);
856     void (*GIVEREF)(void*, PyObject*, int);
857     void* (*SetupContext)(const char*, int, const char*);
858     void (*FinishContext)(void**);
859   } __Pyx_RefNannyAPIStruct;
860   static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
861   static __Pyx_RefNannyAPIStruct * __Pyx_RefNannyImportAPI(const char *modname) {
862     PyObject *m = NULL, *p = NULL;
863     void *r = NULL;
864     m = PyImport_ImportModule((char *)modname);
865     if (!m) goto end;
866     p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
867     if (!p) goto end;
868     r = PyLong_AsVoidPtr(p);
869   end:
870     Py_XDECREF(p);
871     Py_XDECREF(m);
872     return (__Pyx_RefNannyAPIStruct *)r;
873   }
874   #define __Pyx_RefNannySetupContext(name)           void *__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
875   #define __Pyx_RefNannyFinishContext()           __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
876   #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
877   #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
878   #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
879   #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
880   #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r);} } while(0)
881 #else
882   #define __Pyx_RefNannySetupContext(name)
883   #define __Pyx_RefNannyFinishContext()
884   #define __Pyx_INCREF(r) Py_INCREF(r)
885   #define __Pyx_DECREF(r) Py_DECREF(r)
886   #define __Pyx_GOTREF(r)
887   #define __Pyx_GIVEREF(r)
888   #define __Pyx_XDECREF(r) Py_XDECREF(r)
889 #endif /* CYTHON_REFNANNY */
890 #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);} } while(0)
891 #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r);} } while(0)
892
893 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
894
895 #ifndef CYTHON_PROFILE
896   #define CYTHON_PROFILE 1
897 #endif
898
899 #ifndef CYTHON_PROFILE_REUSE_FRAME
900   #define CYTHON_PROFILE_REUSE_FRAME 0
901 #endif
902
903 #if CYTHON_PROFILE
904
905   #include "compile.h"
906   #include "frameobject.h"
907   #include "traceback.h"
908
909   #if CYTHON_PROFILE_REUSE_FRAME
910     #define CYTHON_FRAME_MODIFIER static
911     #define CYTHON_FRAME_DEL
912   #else
913     #define CYTHON_FRAME_MODIFIER
914     #define CYTHON_FRAME_DEL Py_DECREF(__pyx_frame)
915   #endif
916
917   #define __Pyx_TraceDeclarations                                  \
918   static PyCodeObject *__pyx_frame_code = NULL;                      \
919   CYTHON_FRAME_MODIFIER PyFrameObject *__pyx_frame = NULL;           \
920   int __Pyx_use_tracing = 0;                                                         
921
922   #define __Pyx_TraceCall(funcname, srcfile, firstlineno)                            \
923   if (unlikely(PyThreadState_GET()->use_tracing && PyThreadState_GET()->c_profilefunc)) {      \
924       __Pyx_use_tracing = __Pyx_TraceSetupAndCall(&__pyx_frame_code, &__pyx_frame, funcname, srcfile, firstlineno);  \
925   }
926
927   #define __Pyx_TraceException()                                                           \
928   if (unlikely(__Pyx_use_tracing( && PyThreadState_GET()->use_tracing && PyThreadState_GET()->c_profilefunc) {  \
929       PyObject *exc_info = __Pyx_GetExceptionTuple();                                      \
930       if (exc_info) {                                                                      \
931           PyThreadState_GET()->c_profilefunc(                                              \
932               PyThreadState_GET()->c_profileobj, __pyx_frame, PyTrace_EXCEPTION, exc_info);  \
933           Py_DECREF(exc_info);                                                             \
934       }                                                                                    \
935   }
936
937   #define __Pyx_TraceReturn(result)                                                  \
938   if (unlikely(__Pyx_use_tracing) && PyThreadState_GET()->use_tracing && PyThreadState_GET()->c_profilefunc) {  \
939       PyThreadState_GET()->c_profilefunc(                                            \
940           PyThreadState_GET()->c_profileobj, __pyx_frame, PyTrace_RETURN, (PyObject*)result);     \
941       CYTHON_FRAME_DEL;                                                               \
942   }
943
944   static PyCodeObject *__Pyx_createFrameCodeObject(const char *funcname, const char *srcfile, int firstlineno); /*proto*/
945   static int __Pyx_TraceSetupAndCall(PyCodeObject** code, PyFrameObject** frame, const char *funcname, const char *srcfile, int firstlineno); /*proto*/
946
947 #else
948
949   #define __Pyx_TraceDeclarations
950   #define __Pyx_TraceCall(funcname, srcfile, firstlineno) 
951   #define __Pyx_TraceException() 
952   #define __Pyx_TraceReturn(result) 
953
954 #endif /* CYTHON_PROFILE */
955
956 static CYTHON_INLINE PyObject* __Pyx_tp_new(PyObject* type_obj) {
957     return (PyObject*) (((PyTypeObject*)(type_obj))->tp_new(
958         (PyTypeObject*)(type_obj), __pyx_empty_tuple, NULL));
959 }
960
961 static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/
962
963 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
964
965 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
966
967 static PyObject *__Pyx_UnpackItem(PyObject *, Py_ssize_t index); /*proto*/
968 static int __Pyx_EndUnpack(PyObject *, Py_ssize_t expected); /*proto*/
969
970 static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict,
971     const char* function_name, int kw_allowed); /*proto*/
972
973 static void __Pyx_RaiseDoubleKeywordsError(
974     const char* func_name, PyObject* kw_name); /*proto*/
975
976 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
977     Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/
978
979 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,     const char* function_name); /*proto*/
980
981 static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
982 static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
983
984 static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
985     const char *name, int exact); /*proto*/
986
987 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
988
989
990 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
991     PyObject *r;
992     if (!j) return NULL;
993     r = PyObject_GetItem(o, j);
994     Py_DECREF(j);
995     return r;
996 }
997
998
999 #define __Pyx_GetItemInt_List(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
1000                                                     __Pyx_GetItemInt_List_Fast(o, i) : \
1001                                                     __Pyx_GetItemInt_Generic(o, to_py_func(i)))
1002
1003 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i) {
1004     if (likely(o != Py_None)) {
1005         if (likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
1006             PyObject *r = PyList_GET_ITEM(o, i);
1007             Py_INCREF(r);
1008             return r;
1009         }
1010         else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) {
1011             PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i);
1012             Py_INCREF(r);
1013             return r;
1014         }
1015     }
1016     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
1017 }
1018
1019 #define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
1020                                                     __Pyx_GetItemInt_Tuple_Fast(o, i) : \
1021                                                     __Pyx_GetItemInt_Generic(o, to_py_func(i)))
1022
1023 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i) {
1024     if (likely(o != Py_None)) {
1025         if (likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
1026             PyObject *r = PyTuple_GET_ITEM(o, i);
1027             Py_INCREF(r);
1028             return r;
1029         }
1030         else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) {
1031             PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i);
1032             Py_INCREF(r);
1033             return r;
1034         }
1035     }
1036     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
1037 }
1038
1039
1040 #define __Pyx_GetItemInt(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
1041                                                     __Pyx_GetItemInt_Fast(o, i) : \
1042                                                     __Pyx_GetItemInt_Generic(o, to_py_func(i)))
1043
1044 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i) {
1045     PyObject *r;
1046     if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) {
1047         r = PyList_GET_ITEM(o, i);
1048         Py_INCREF(r);
1049     }
1050     else if (PyTuple_CheckExact(o) && ((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
1051         r = PyTuple_GET_ITEM(o, i);
1052         Py_INCREF(r);
1053     }
1054     else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_item && (likely(i >= 0))) {
1055         r = PySequence_GetItem(o, i);
1056     }
1057     else {
1058         r = __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
1059     }
1060     return r;
1061 }
1062
1063 static CYTHON_INLINE long __Pyx_NegateNonNeg(long b) { return unlikely(b < 0) ? b : !b; }
1064 static CYTHON_INLINE PyObject* __Pyx_PyBoolOrNull_FromLong(long b) {
1065     return unlikely(b < 0) ? NULL : __Pyx_PyBool_FromLong(b);
1066 }
1067
1068 static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);
1069
1070 static CYTHON_INLINE PyObject* __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
1071     if (likely(PyList_CheckExact(L))) {
1072         if (PyList_Append(L, x) < 0) return NULL;
1073         Py_INCREF(Py_None);
1074         return Py_None; /* this is just to have an accurate signature */
1075     }
1076     else {
1077         PyObject *r, *m;
1078         m = __Pyx_GetAttrString(L, "append");
1079         if (!m) return NULL;
1080         r = PyObject_CallFunctionObjArgs(m, x, NULL);
1081         Py_DECREF(m);
1082         return r;
1083     }
1084 }
1085
1086 static CYTHON_INLINE void __Pyx_RaiseNoneIndexingError(void);
1087
1088
1089 #if PY_MAJOR_VERSION >= 3
1090 static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
1091     PyObject *value;
1092     if (unlikely(d == Py_None)) {
1093         __Pyx_RaiseNoneIndexingError();
1094         return NULL;
1095     }
1096     value = PyDict_GetItemWithError(d, key);
1097     if (unlikely(!value)) {
1098         if (!PyErr_Occurred())
1099             PyErr_SetObject(PyExc_KeyError, key);
1100         return NULL;
1101     }
1102     Py_INCREF(value);
1103     return value;
1104 }
1105 #else
1106     #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
1107 #endif
1108
1109 static PyObject* __Pyx_PyDict_GetItemDefault(PyObject* d, PyObject* key, PyObject* default_value) {
1110     PyObject* value;
1111 #if PY_MAJOR_VERSION >= 3
1112     value = PyDict_GetItemWithError(d, key);
1113     if (unlikely(!value)) {
1114         if (unlikely(PyErr_Occurred()))
1115             return NULL;
1116         value = default_value;
1117     }
1118     Py_INCREF(value);
1119 #else
1120     if (PyString_CheckExact(key) || PyUnicode_CheckExact(key) || PyInt_CheckExact(key)) {
1121         /* these presumably have safe hash functions */
1122         value = PyDict_GetItem(d, key);
1123         if (unlikely(!value)) {
1124             value = default_value;
1125         }
1126         Py_INCREF(value);
1127     } else {
1128         PyObject *m;
1129         m = __Pyx_GetAttrString(d, "get");
1130         if (!m) return NULL;
1131         value = PyObject_CallFunctionObjArgs(m, key,
1132             (default_value == Py_None) ? NULL : default_value, NULL);
1133         Py_DECREF(m);
1134     }
1135 #endif
1136     return value;
1137 }
1138
1139 static CYTHON_INLINE long __Pyx_div_long(long, long); /* proto */
1140
1141 static CYTHON_INLINE long __Pyx_mod_long(long, long); /* proto */
1142
1143 #define __Pyx_DelItemInt(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
1144                                                     __Pyx_DelItemInt_Fast(o, i) : \
1145                                                     __Pyx_DelItem_Generic(o, to_py_func(i)))
1146
1147 static CYTHON_INLINE int __Pyx_DelItem_Generic(PyObject *o, PyObject *j) {
1148     int r;
1149     if (!j) return -1;
1150     r = PyObject_DelItem(o, j);
1151     Py_DECREF(j);
1152     return r;
1153 }
1154
1155 static CYTHON_INLINE int __Pyx_DelItemInt_Fast(PyObject *o, Py_ssize_t i) {
1156     if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_ass_item && likely(i >= 0))
1157         return PySequence_DelItem(o, i);
1158     else {
1159         PyObject *j = PyInt_FromSsize_t(i);
1160         return __Pyx_DelItem_Generic(o, j);
1161     }
1162 }
1163
1164 static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
1165 static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
1166
1167 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/
1168
1169 static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, const char *modname); /*proto*/
1170
1171 static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint32_t(uint32_t);
1172
1173 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
1174
1175 static CYTHON_INLINE uint32_t __Pyx_PyInt_from_py_uint32_t(PyObject *);
1176
1177 static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_int32_t(int32_t);
1178
1179 static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_int64_t(int64_t);
1180
1181 static CYTHON_INLINE uint64_t __Pyx_PyInt_from_py_uint64_t(PyObject *);
1182
1183 static CYTHON_INLINE int32_t __Pyx_PyInt_from_py_int32_t(PyObject *);
1184
1185 static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint8_t(uint8_t);
1186
1187 static int __Pyx_Print(PyObject*, PyObject *, int); /*proto*/
1188 #if PY_MAJOR_VERSION >= 3
1189 static PyObject* __pyx_print = 0;
1190 static PyObject* __pyx_print_kwargs = 0;
1191 #endif
1192
1193 static int __Pyx_PrintOne(PyObject* stream, PyObject *o); /*proto*/
1194
1195 static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint64_t(uint64_t);
1196
1197 static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);
1198
1199 static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);
1200
1201 static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);
1202
1203 static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *);
1204
1205 static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *);
1206
1207 static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *);
1208
1209 static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);
1210
1211 static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);
1212
1213 static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);
1214
1215 static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *);
1216
1217 static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);
1218
1219 static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);
1220
1221 static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *);
1222
1223 static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);
1224
1225 static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);
1226
1227 static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);
1228
1229 static void __Pyx_WriteUnraisable(const char *name); /*proto*/
1230
1231 static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, long size, int strict);  /*proto*/
1232
1233 static PyObject *__Pyx_ImportModule(const char *name); /*proto*/
1234
1235 static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/
1236
1237 static void __Pyx_AddTraceback(const char *funcname); /*proto*/
1238
1239 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
1240 /* Module declarations from __builtin__ */
1241
1242 /* Module declarations from cpython.version */
1243
1244 /* Module declarations from cpython.ref */
1245
1246 /* Module declarations from cpython.exc */
1247
1248 /* Module declarations from cpython.module */
1249
1250 /* Module declarations from cpython.mem */
1251
1252 /* Module declarations from cpython.tuple */
1253
1254 /* Module declarations from cpython.list */
1255
1256 /* Module declarations from libc.stdio */
1257
1258 /* Module declarations from cpython.object */
1259
1260 /* Module declarations from cpython.sequence */
1261
1262 /* Module declarations from cpython.mapping */
1263
1264 /* Module declarations from cpython.iterator */
1265
1266 /* Module declarations from cpython.type */
1267
1268 /* Module declarations from cpython.number */
1269
1270 /* Module declarations from cpython.int */
1271
1272 /* Module declarations from __builtin__ */
1273
1274 /* Module declarations from cpython.bool */
1275
1276 static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0;
1277 /* Module declarations from cpython.long */
1278
1279 /* Module declarations from cpython.float */
1280
1281 /* Module declarations from cpython.complex */
1282
1283 /* Module declarations from cpython.string */
1284
1285 /* Module declarations from cpython.unicode */
1286
1287 /* Module declarations from cpython.dict */
1288
1289 /* Module declarations from cpython.instance */
1290
1291 /* Module declarations from cpython.function */
1292
1293 /* Module declarations from cpython.method */
1294
1295 /* Module declarations from cpython.weakref */
1296
1297 /* Module declarations from cpython.getargs */
1298
1299 /* Module declarations from cpython.pythread */
1300
1301 /* Module declarations from cpython.cobject */
1302
1303 /* Module declarations from cpython.oldbuffer */
1304
1305 /* Module declarations from cpython.set */
1306
1307 /* Module declarations from cpython.buffer */
1308
1309 /* Module declarations from cpython.bytes */
1310
1311 /* Module declarations from cpython.pycapsule */
1312
1313 /* Module declarations from cpython */
1314
1315 /* Module declarations from csamtools */
1316
1317 static PyTypeObject *__pyx_ptype_9csamtools_file = 0;
1318 static PyTypeObject *__pyx_ptype_9csamtools_AlignedRead = 0;
1319 static PyTypeObject *__pyx_ptype_9csamtools_Samfile = 0;
1320 static PyTypeObject *__pyx_ptype_9csamtools_PileupProxy = 0;
1321 static PyTypeObject *__pyx_ptype_9csamtools_PileupRead = 0;
1322 static PyTypeObject *__pyx_ptype_9csamtools_Fastafile = 0;
1323 static PyTypeObject *__pyx_ptype_9csamtools_IteratorRow = 0;
1324 static PyTypeObject *__pyx_ptype_9csamtools_IteratorRowRegion = 0;
1325 static PyTypeObject *__pyx_ptype_9csamtools_IteratorRowAll = 0;
1326 static PyTypeObject *__pyx_ptype_9csamtools_IteratorRowAllRefs = 0;
1327 static PyTypeObject *__pyx_ptype_9csamtools_IteratorRowSelection = 0;
1328 static PyTypeObject *__pyx_ptype_9csamtools_IteratorColumn = 0;
1329 static PyTypeObject *__pyx_ptype_9csamtools_IteratorColumnRegion = 0;
1330 static PyTypeObject *__pyx_ptype_9csamtools_IteratorColumnAllRefs = 0;
1331 static PyTypeObject *__pyx_ptype_9csamtools_SNPCall = 0;
1332 static PyTypeObject *__pyx_ptype_9csamtools_SNPCallerBase = 0;
1333 static PyTypeObject *__pyx_ptype_9csamtools_IteratorSNPCalls = 0;
1334 static PyTypeObject *__pyx_ptype_9csamtools_SNPCaller = 0;
1335 static PyTypeObject *__pyx_ptype_9csamtools_IndelCall = 0;
1336 static PyTypeObject *__pyx_ptype_9csamtools_IndelCallerBase = 0;
1337 static PyTypeObject *__pyx_ptype_9csamtools_IndelCaller = 0;
1338 static PyTypeObject *__pyx_ptype_9csamtools_IteratorIndelCalls = 0;
1339 static PyTypeObject *__pyx_ptype_9csamtools_IndexedReads = 0;
1340 static char *__pyx_v_9csamtools_bam_nt16_rev_table;
1341 static int __pyx_v_9csamtools_max_pos;
1342 static PyObject *__pyx_f_9csamtools_makeAlignedRead(bam1_t *); /*proto*/
1343 static PyObject *__pyx_f_9csamtools_makePileupProxy(bam_pileup1_t *, int, int, int); /*proto*/
1344 static PyObject *__pyx_f_9csamtools_makePileupRead(bam_pileup1_t *); /*proto*/
1345 static int __pyx_f_9csamtools_fetch_callback(bam1_t *, void *); /*proto*/
1346 static int __pyx_f_9csamtools_pileup_callback(uint32_t, uint32_t, int, bam_pileup1_t *, void *); /*proto*/
1347 static int __pyx_f_9csamtools_pileup_fetch_callback(bam1_t *, void *); /*proto*/
1348 static int __pyx_f_9csamtools_count_callback(bam1_t *, void *); /*proto*/
1349 static int __pyx_f_9csamtools_mate_callback(bam1_t *, void *); /*proto*/
1350 static int __pyx_f_9csamtools___advance_all(void *, bam1_t *); /*proto*/
1351 static int __pyx_f_9csamtools___advance_snpcalls(void *, bam1_t *); /*proto*/
1352 static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_start(bam1_t *); /*proto*/
1353 static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_end(bam1_t *); /*proto*/
1354 static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_seq_range(bam1_t *, uint32_t, uint32_t); /*proto*/
1355 static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_qual_range(bam1_t *, uint32_t, uint32_t); /*proto*/
1356 #define __Pyx_MODULE_NAME "csamtools"
1357 int __pyx_module_is_main_csamtools = 0;
1358
1359 /* Implementation of csamtools */
1360 static PyObject *__pyx_builtin_open;
1361 static PyObject *__pyx_builtin_object;
1362 static PyObject *__pyx_builtin_map;
1363 static PyObject *__pyx_builtin_ValueError;
1364 static PyObject *__pyx_builtin_IOError;
1365 static PyObject *__pyx_builtin_OverflowError;
1366 static PyObject *__pyx_builtin_NotImplementedError;
1367 static PyObject *__pyx_builtin_KeyError;
1368 static PyObject *__pyx_builtin_StopIteration;
1369 static PyObject *__pyx_builtin_cmp;
1370 static PyObject *__pyx_builtin_chr;
1371 static PyObject *__pyx_builtin_TypeError;
1372 static PyObject *__pyx_builtin_range;
1373 static char __pyx_k_1[] = "\t";
1374 static char __pyx_k_2[] = "\n";
1375 static char __pyx_k_3[] = "calling len() on closed file";
1376 static char __pyx_k_4[] = "could not open file `%s`";
1377 static char __pyx_k_5[] = "I/O operation on closed file";
1378 static char __pyx_k_6[] = "no sequence/region supplied.";
1379 static char __pyx_k_7[] = "invalid region: start (%i) > end (%i)";
1380 static char __pyx_k_8[] = "";
1381 static char __pyx_k_9[] = "start out of range (%i)";
1382 static char __pyx_k_10[] = "end out of range (%i)";
1383 static char __pyx_k_11[] = "%s:%i-%i";
1384 static char __pyx_k_12[] = "invalid file opening mode `%s`";
1385 static char __pyx_k_13[] = "http:";
1386 static char __pyx_k_14[] = "ftp:";
1387 static char __pyx_k_15[] = "either supply options `template`, `header` or  both `referencenames` and `referencelengths` for writing";
1388 static char __pyx_k_16[] = "unequal names and lengths of reference sequences";
1389 static char __pyx_k_17[] = "-";
1390 static char __pyx_k_18[] = "file `%s` not found";
1391 static char __pyx_k_19[] = "could not open file (mode='%s') - is it SAM/BAM format?";
1392 static char __pyx_k_20[] = "file does not have valid header (mode='%s') - is it SAM/BAM format?";
1393 static char __pyx_k_21[] = "file header is empty (mode='%s') - is it SAM/BAM format?";
1394 static char __pyx_k_22[] = ".bai";
1395 static char __pyx_k_23[] = "error while opening index `%s` ";
1396 static char __pyx_k_24[] = "tid %i out of range 0<=tid<%i";
1397 static char __pyx_k_25[] = "[:-]";
1398 static char __pyx_k_26[] = "invalid reference `%s`";
1399 static char __pyx_k_27[] = "invalid coordinates: start (%i) > end (%i)";
1400 static char __pyx_k_28[] = "seek only available in bam files";
1401 static char __pyx_k_30[] = "fetch called on bamfile without index";
1402 static char __pyx_k_31[] = "callback functionality requires a region/reference";
1403 static char __pyx_k_32[] = "no index available for fetch";
1404 static char __pyx_k_33[] = "fetch called for samfile without header";
1405 static char __pyx_k_34[] = "fetch for a region is not available for sam files";
1406 static char __pyx_k_35[] = "callback not implemented yet";
1407 static char __pyx_k_36[] = "read %s: is unpaired";
1408 static char __pyx_k_37[] = "mate %s: is unmapped";
1409 static char __pyx_k_38[] = "mate not found";
1410 static char __pyx_k_40[] = "counting functionality requires a region/reference";
1411 static char __pyx_k_41[] = "count for a region is not available for sam files";
1412 static char __pyx_k_42[] = "no index available for pileup";
1413 static char __pyx_k_43[] = "pileup of samfiles not implemented yet";
1414 static char __pyx_k_44[] = "@";
1415 static char __pyx_k_45[] = "header line without '@': '%s'";
1416 static char __pyx_k_46[] = "header line with invalid type '%s': '%s'";
1417 static char __pyx_k_47[] = ":";
1418 static char __pyx_k_48[] = "unknown field code '%s' in record '%s'";
1419 static char __pyx_k_49[] = "multiple '%s' lines are not permitted";
1420 static char __pyx_k_50[] = "@%s";
1421 static char __pyx_k_51[] = "%s:%s";
1422 static char __pyx_k_52[] = "invalid type for record %s: %s, expected %s";
1423 static char __pyx_k_53[] = "incomplete sequence information in '%s'";
1424 static char __pyx_k_54[] = "no index available for iteration";
1425 static char __pyx_k_55[] = "can only use this iterator on bam files";
1426 static char __pyx_k_56[] = "reference sequence for '%s' (tid=%i) not found";
1427 static char __pyx_k_57[] = "unknown stepper option `%s` in IteratorColumn";
1428 static char __pyx_k_59[] = "error during iteration";
1429 static char __pyx_k_60[] = "Invalid clipping in CIGAR string";
1430 static char __pyx_k_61[] = "quality and sequence mismatch: %i != %i";
1431 static char __pyx_k_62[] = "%c";
1432 static char __pyx_k_63[] = "create_string_buffer";
1433 static char __pyx_k_64[] = "<cccf";
1434 static char __pyx_k_65[] = "<cccb";
1435 static char __pyx_k_66[] = "<ccch";
1436 static char __pyx_k_67[] = "integer %i out of range of BAM/SAM specification";
1437 static char __pyx_k_68[] = "<ccci";
1438 static char __pyx_k_69[] = "<cccB";
1439 static char __pyx_k_70[] = "<cccH";
1440 static char __pyx_k_71[] = "<cccI";
1441 static char __pyx_k_72[] = "<cccc";
1442 static char __pyx_k_73[] = "<ccc%is";
1443 static char __pyx_k_74[] = "tags field too large";
1444 static char __pyx_k_75[] = "tag '%s' not present";
1445 static char __pyx_k_76[] = "Contig index";
1446 static char __pyx_k_77[] = "Mapped position on contig";
1447 static char __pyx_k_78[] = "Contig index for mate pair";
1448 static char __pyx_k_79[] = "Position of mate pair";
1449 static char __pyx_k_80[] = "Insert size";
1450 static char __pyx_k_81[] = "Binary flag";
1451 static char __pyx_k_82[] = "Count of cigar entries";
1452 static char __pyx_k_83[] = "Cigar entries";
1453 static char __pyx_k_84[] = "Mapping quality";
1454 static char __pyx_k_85[] = "Bam index bin number";
1455 static char __pyx_k_86[] = "Length of query name";
1456 static char __pyx_k_87[] = "Query name";
1457 static char __pyx_k_88[] = "Length of query sequence";
1458 static char __pyx_k_89[] = "Query sequence";
1459 static char __pyx_k_90[] = "Quality scores";
1460 static char __pyx_k_91[] = "Length of auxilary data";
1461 static char __pyx_k_92[] = "Maximum data length";
1462 static char __pyx_k_93[] = "Current data length";
1463 static char __pyx_k_94[] = "%-30s %-10s= %s";
1464 static char __pyx_k_95[] = "(";
1465 static char __pyx_k_96[] = ")";
1466 static char __pyx_k_97[] = "This class cannot be instantiated from Python";
1467 static char __pyx_k__A[] = "A";
1468 static char __pyx_k__C[] = "C";
1469 static char __pyx_k__D[] = "D";
1470 static char __pyx_k__F[] = "F";
1471 static char __pyx_k__I[] = "I";
1472 static char __pyx_k__S[] = "S";
1473 static char __pyx_k__Z[] = "Z";
1474 static char __pyx_k__b[] = "b";
1475 static char __pyx_k__c[] = "c";
1476 static char __pyx_k__d[] = "d";
1477 static char __pyx_k__f[] = "f";
1478 static char __pyx_k__i[] = "i";
1479 static char __pyx_k__n[] = "n";
1480 static char __pyx_k__r[] = "r";
1481 static char __pyx_k__s[] = "s";
1482 static char __pyx_k__w[] = "w";
1483 static char __pyx_k__x[] = "x";
1484 static char __pyx_k_100[] = "No such file or directory: '%s'";
1485 static char __pyx_k_101[] = "-o";
1486 static char __pyx_k_102[] = "option -o is forbidden in samtools view";
1487 static char __pyx_k_103[] = "_rms_mapping_quality";
1488 static char __pyx_k_104[] = "--> read %i %s %i";
1489 static char __pyx_k_105[] = "pos=%i, cns=%i, q_r = %f, depth=%i, n=%i, rb=%i, cns-cq=%i %i %i %i";
1490 static char __pyx_k_106[] = "-------------------------------------\n";
1491 static char __pyx_k_107[] = "IteratorSNPCalls requires an pileup iterator with reference sequence";
1492 static char __pyx_k_108[] = "position %i out of bounds on reference sequence (len=%i)";
1493 static char __pyx_k_109[] = "no reads in region - no call";
1494 static char __pyx_k_110[] = "%s/%s";
1495 static char __pyx_k_111[] = "IndelCallerBase requires an pileup iterator with reference sequence";
1496 static char __pyx_k_112[] = "can only IndexReads on bam files";
1497 static char __pyx_k_113[] = "read %s not found";
1498 static char __pyx_k_114[] = "the query name (None if not present)";
1499 static char __pyx_k_115[] = "the :term:`cigar` alignment (None if not present).\n        ";
1500 static char __pyx_k_116[] = "read sequence bases, including :term:`soft clipped` bases (None if not present)";
1501 static char __pyx_k_117[] = "read sequence base qualities, including :term:`soft clipped` bases (None if not present)";
1502 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.";
1503 static char __pyx_k_119[] = "aligned query sequence quality values (None if not present)";
1504 static char __pyx_k_120[] = "start index of the aligned query portion of the sequence (0-based, inclusive)";
1505 static char __pyx_k_121[] = "end index of the aligned query portion of the sequence (0-based, exclusive)";
1506 static char __pyx_k_122[] = "Length of the aligned query sequence";
1507 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        ";
1508 static char __pyx_k_124[] = "properties flag";
1509 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        ";
1510 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        ";
1511 static char __pyx_k_127[] = "0-based leftmost coordinate";
1512 static char __pyx_k_128[] = "properties bin";
1513 static char __pyx_k_129[] = "length of the read (read only). Returns 0 if not given.";
1514 static char __pyx_k_130[] = "aligned end position of the read (read only).  Returns\n        None if not available.";
1515 static char __pyx_k_131[] = "aligned length of the read (read only).  Returns None if\n        not available.";
1516 static char __pyx_k_132[] = "mapping quality";
1517 static char __pyx_k_133[] = "the :term:`reference` id of the mate ";
1518 static char __pyx_k_134[] = "the position of the mate";
1519 static char __pyx_k_135[] = "the insert size";
1520 static char __pyx_k_136[] = "true if read is paired in sequencing";
1521 static char __pyx_k_137[] = "true if read is mapped in a proper pair";
1522 static char __pyx_k_138[] = "true if read itself is unmapped";
1523 static char __pyx_k_139[] = "true if the mate is unmapped";
1524 static char __pyx_k_140[] = "true if read is mapped to reverse strand";
1525 static char __pyx_k_141[] = "true is read is mapped to reverse strand";
1526 static char __pyx_k_142[] = "true if this is read1";
1527 static char __pyx_k_143[] = "true if this is read2";
1528 static char __pyx_k_144[] = "true if not primary alignment";
1529 static char __pyx_k_145[] = "true if QC failure";
1530 static char __pyx_k_146[] = "true if optical or PCR duplicate";
1531 static char __pyx_k_147[] = "a list of reference positions that this read aligns to.";
1532 static char __pyx_k_148[] = "number of :term:`filename` associated with this object.";
1533 static char __pyx_k_149[] = "number of :term:`reference` sequences in the file.";
1534 static char __pyx_k_150[] = "tuple with the names of :term:`reference` sequences.";
1535 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        ";
1536 static char __pyx_k_152[] = "full contents of the :term:`sam file` header as a string.";
1537 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        ";
1538 static char __pyx_k_154[] = "the chromosome ID as is defined in the header";
1539 static char __pyx_k_155[] = "number of reads mapping to this column.";
1540 static char __pyx_k_156[] = "list of reads (:class:`pysam.PileupRead`) aligned to this column";
1541 static char __pyx_k_157[] = "a :class:`pysam.AlignedRead` object of the aligned read";
1542 static char __pyx_k_158[] = "position of the read base at the pileup site, 0-based";
1543 static char __pyx_k_159[] = "indel length; 0 for no indel, positive for ins and negative for del";
1544 static char __pyx_k_160[] = "1 iff the base on the padded read is a deletion";
1545 static char __pyx_k_161[] = "current sequence length.";
1546 static char __pyx_k_162[] = "nucleotide position of SNP.";
1547 static char __pyx_k_163[] = "reference base at pos. ``N`` if no reference sequence supplied.";
1548 static char __pyx_k_164[] = "the genotype called.";
1549 static char __pyx_k_165[] = "the genotype quality (Phred-scaled).";
1550 static char __pyx_k_166[] = "the snp quality (Phred scaled) - probability of consensus being identical to reference sequence.";
1551 static char __pyx_k_167[] = "the root mean square (rms) of the mapping quality of all reads involved in the call.";
1552 static char __pyx_k_168[] = "coverage or read depth - the number of reads involved in the call.";
1553 static char __pyx_k_169[] = "sequence of first allele.";
1554 static char __pyx_k_170[] = "sequence of second allele.";
1555 static char __pyx_k_171[] = "reads supporting first allele.";
1556 static char __pyx_k_172[] = "=ACMGRSVTWYHKDBN";
1557 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    ";
1558 static char __pyx_k_174[] = "\n    stderr is captured. \n    ";
1559 static char __pyx_k_175[] = "does nothing. stderr can't be redirected on windows";
1560 static char __pyx_k_176[] = "http://mail.python.org/pipermail/python-list/2000-June/038406.html";
1561 static char __pyx_k_177[] = "Fastafile._isOpen (line 265)";
1562 static char __pyx_k_178[] = "Fastafile._open (line 275)";
1563 static char __pyx_k_179[] = "Fastafile.fetch (line 306)";
1564 static char __pyx_k_180[] = "Samfile._isOpen (line 464)";
1565 static char __pyx_k_181[] = "Samfile._hasIndex (line 468)";
1566 static char __pyx_k_182[] = "Samfile._open (line 472)";
1567 static char __pyx_k_183[] = "Samfile.gettid (line 612)";
1568 static char __pyx_k_184[] = "Samfile.getrname (line 621)";
1569 static char __pyx_k_185[] = "Samfile._parseRegion (line 637)";
1570 static char __pyx_k_186[] = "Samfile.seek (line 691)";
1571 static char __pyx_k_187[] = "Samfile.tell (line 702)";
1572 static char __pyx_k_188[] = "Samfile.fetch (line 713)";
1573 static char __pyx_k_189[] = "Samfile.mate (line 782)";
1574 static char __pyx_k_190[] = "Samfile.count (line 825)";
1575 static char __pyx_k_191[] = "Samfile.pileup (line 869)";
1576 static char __pyx_k_192[] = "Samfile.close (line 953)";
1577 static char __pyx_k_193[] = "Samfile.write (line 969)";
1578 static char __pyx_k_194[] = "Samfile._buildLine (line 1078)";
1579 static char __pyx_k_195[] = "Samfile.__next__ (line 1173)";
1580 static char __pyx_k_196[] = "IteratorRowRegion.__next__ (line 1281)";
1581 static char __pyx_k_197[] = "IteratorRowAll.__next__ (line 1340)";
1582 static char __pyx_k_198[] = "IteratorRowAllRefs.__next__ (line 1375)";
1583 static char __pyx_k_199[] = "IteratorRowSelection.__next__ (line 1459)";
1584 static char __pyx_k_200[] = "IteratorRowSelection";
1585 static char __pyx_k_201[] = "IteratorColumn.addReference (line 1634)";
1586 static char __pyx_k_202[] = "IteratorColumn.hasReference (line 1642)";
1587 static char __pyx_k_203[] = "IteratorColumnRegion.__next__ (line 1724)";
1588 static char __pyx_k_204[] = "IteratorColumnRegion";
1589 static char __pyx_k_205[] = "IteratorColumnAllRefs.__next__ (line 1755)";
1590 static char __pyx_k_206[] = "IteratorColumnAllRefs";
1591 static char __pyx_k_207[] = "AlignedRead.__str__ (line 1903)";
1592 static char __pyx_k_208[] = "AlignedRead.compare (line 1928)";
1593 static char __pyx_k_209[] = "AlignedRead.overlap (line 2512)";
1594 static char __pyx_k_210[] = "AlignedRead.opt (line 2541)";
1595 static char __pyx_k_211[] = "AlignedRead.fancy_str (line 2563)";
1596 static char __pyx_k_212[] = "Outs.setdevice (line 2705)";
1597 static char __pyx_k_213[] = "Outs.setfile (line 2710)";
1598 static char __pyx_k_214[] = "Outs.restore (line 2723)";
1599 static char __pyx_k_215[] = "_samtools_dispatch (line 2734)";
1600 static char __pyx_k_216[] = "IteratorSNPCalls.__next__ (line 2969)";
1601 static char __pyx_k_217[] = "SNPCaller.call (line 3041)";
1602 static char __pyx_k_218[] = "IndelCaller.call (line 3306)";
1603 static char __pyx_k_219[] = "IteratorIndelCalls.__next__ (line 3353)";
1604 static char __pyx_k_220[] = "IndexedReads.build (line 3406)";
1605 static char __pyx_k__AS[] = "AS";
1606 static char __pyx_k__CL[] = "CL";
1607 static char __pyx_k__CN[] = "CN";
1608 static char __pyx_k__CO[] = "CO";
1609 static char __pyx_k__DS[] = "DS";
1610 static char __pyx_k__DT[] = "DT";
1611 static char __pyx_k__GO[] = "GO";
1612 static char __pyx_k__HD[] = "HD";
1613 static char __pyx_k__ID[] = "ID";
1614 static char __pyx_k__LB[] = "LB";
1615 static char __pyx_k__LN[] = "LN";
1616 static char __pyx_k__M5[] = "M5";
1617 static char __pyx_k__PG[] = "PG";
1618 static char __pyx_k__PI[] = "PI";
1619 static char __pyx_k__PL[] = "PL";
1620 static char __pyx_k__PN[] = "PN";
1621 static char __pyx_k__PU[] = "PU";
1622 static char __pyx_k__RG[] = "RG";
1623 static char __pyx_k__SM[] = "SM";
1624 static char __pyx_k__SN[] = "SN";
1625 static char __pyx_k__SO[] = "SO";
1626 static char __pyx_k__SP[] = "SP";
1627 static char __pyx_k__SQ[] = "SQ";
1628 static char __pyx_k__UR[] = "UR";
1629 static char __pyx_k__VN[] = "VN";
1630 static char __pyx_k___r[] = "_r";
1631 static char __pyx_k__fd[] = "fd";
1632 static char __pyx_k__fp[] = "fp";
1633 static char __pyx_k__id[] = "id";
1634 static char __pyx_k__os[] = "os";
1635 static char __pyx_k__rb[] = "rb";
1636 static char __pyx_k__re[] = "re";
1637 static char __pyx_k__wb[] = "wb";
1638 static char __pyx_k__wh[] = "wh";
1639 static char __pyx_k__all[] = "all";
1640 static char __pyx_k__bam[] = "bam";
1641 static char __pyx_k__beg[] = "beg";
1642 static char __pyx_k__bin[] = "bin";
1643 static char __pyx_k__chr[] = "chr";
1644 static char __pyx_k__cmp[] = "cmp";
1645 static char __pyx_k__dup[] = "dup";
1646 static char __pyx_k__end[] = "end";
1647 static char __pyx_k__map[] = "map";
1648 static char __pyx_k__opt[] = "opt";
1649 static char __pyx_k__plp[] = "plp";
1650 static char __pyx_k__pos[] = "pos";
1651 static char __pyx_k__q_r[] = "q_r";
1652 static char __pyx_k__raw[] = "raw";
1653 static char __pyx_k__seq[] = "seq";
1654 static char __pyx_k__sys[] = "sys";
1655 static char __pyx_k__tid[] = "tid";
1656 static char __pyx_k__wbu[] = "wbu";
1657 static char __pyx_k__Outs[] = "Outs";
1658 static char __pyx_k___pos[] = "_pos";
1659 static char __pyx_k___tid[] = "_tid";
1660 static char __pyx_k__args[] = "args";
1661 static char __pyx_k__call[] = "call";
1662 static char __pyx_k__cnt1[] = "cnt1";
1663 static char __pyx_k__cnt2[] = "cnt2";
1664 static char __pyx_k__core[] = "core";
1665 static char __pyx_k__data[] = "data";
1666 static char __pyx_k__dup2[] = "dup2";
1667 static char __pyx_k__flag[] = "flag";
1668 static char __pyx_k__hash[] = "hash";
1669 static char __pyx_k__iter[] = "iter";
1670 static char __pyx_k__join[] = "join";
1671 static char __pyx_k__mapq[] = "mapq";
1672 static char __pyx_k__mask[] = "mask";
1673 static char __pyx_k__mate[] = "mate";
1674 static char __pyx_k__mode[] = "mode";
1675 static char __pyx_k__mpos[] = "mpos";
1676 static char __pyx_k__mrnm[] = "mrnm";
1677 static char __pyx_k__mtid[] = "mtid";
1678 static char __pyx_k__n_pu[] = "n_pu";
1679 static char __pyx_k__name[] = "name";
1680 static char __pyx_k__open[] = "open";
1681 static char __pyx_k__path[] = "path";
1682 static char __pyx_k__port[] = "port";
1683 static char __pyx_k__qpos[] = "qpos";
1684 static char __pyx_k__qseq[] = "qseq";
1685 static char __pyx_k__qual[] = "qual";
1686 static char __pyx_k__rlen[] = "rlen";
1687 static char __pyx_k__seek[] = "seek";
1688 static char __pyx_k__self[] = "self";
1689 static char __pyx_k__tags[] = "tags";
1690 static char __pyx_k__tell[] = "tell";
1691 static char __pyx_k__text[] = "text";
1692 static char __pyx_k__view[] = "view";
1693 static char __pyx_k___call[] = "_call";
1694 static char __pyx_k___open[] = "_open";
1695 static char __pyx_k___qpos[] = "_qpos";
1696 static char __pyx_k__bqual[] = "bqual";
1697 static char __pyx_k__build[] = "build";
1698 static char __pyx_k__cigar[] = "cigar";
1699 static char __pyx_k__close[] = "close";
1700 static char __pyx_k__cnext[] = "cnext";
1701 static char __pyx_k__count[] = "count";
1702 static char __pyx_k__fetch[] = "fetch";
1703 static char __pyx_k__flush[] = "flush";
1704 static char __pyx_k__indel[] = "indel";
1705 static char __pyx_k__index[] = "index";
1706 static char __pyx_k__isbam[] = "isbam";
1707 static char __pyx_k__isize[] = "isize";
1708 static char __pyx_k__l_aux[] = "l_aux";
1709 static char __pyx_k__level[] = "level";
1710 static char __pyx_k__n_hap[] = "n_hap";
1711 static char __pyx_k__n_plp[] = "n_plp";
1712 static char __pyx_k__q_cns[] = "q_cns";
1713 static char __pyx_k__q_ref[] = "q_ref";
1714 static char __pyx_k__qname[] = "qname";
1715 static char __pyx_k__range[] = "range";
1716 static char __pyx_k__reset[] = "reset";
1717 static char __pyx_k__rname[] = "rname";
1718 static char __pyx_k__setfd[] = "setfd";
1719 static char __pyx_k__split[] = "split";
1720 static char __pyx_k__start[] = "start";
1721 static char __pyx_k__strip[] = "strip";
1722 static char __pyx_k__theta[] = "theta";
1723 static char __pyx_k__types[] = "types";
1724 static char __pyx_k__where[] = "where";
1725 static char __pyx_k__write[] = "write";
1726 static char __pyx_k___indel[] = "_indel";
1727 static char __pyx_k___level[] = "_level";
1728 static char __pyx_k__ctypes[] = "ctypes";
1729 static char __pyx_k__errmod[] = "errmod";
1730 static char __pyx_k__exists[] = "exists";
1731 static char __pyx_k__fields[] = "fields";
1732 static char __pyx_k__fileno[] = "fileno";
1733 static char __pyx_k__gettid[] = "gettid";
1734 static char __pyx_k__header[] = "header";
1735 static char __pyx_k__indel1[] = "indel1";
1736 static char __pyx_k__indel2[] = "indel2";
1737 static char __pyx_k__is_del[] = "is_del";
1738 static char __pyx_k__l_qseq[] = "l_qseq";
1739 static char __pyx_k__l_text[] = "l_text";
1740 static char __pyx_k__m_data[] = "m_data";
1741 static char __pyx_k__method[] = "method";
1742 static char __pyx_k__object[] = "object";
1743 static char __pyx_k__offset[] = "offset";
1744 static char __pyx_k__pileup[] = "pileup";
1745 static char __pyx_k__record[] = "record";
1746 static char __pyx_k__region[] = "region";
1747 static char __pyx_k__remove[] = "remove";
1748 static char __pyx_k__reopen[] = "reopen";
1749 static char __pyx_k__retval[] = "retval";
1750 static char __pyx_k__rg2lib[] = "rg2lib";
1751 static char __pyx_k__stderr[] = "stderr";
1752 static char __pyx_k__stdout[] = "stdout";
1753 static char __pyx_k__struct[] = "struct";
1754 static char __pyx_k__system[] = "system";
1755 static char __pyx_k__IOError[] = "IOError";
1756 static char __pyx_k__IntType[] = "IntType";
1757 static char __pyx_k__O_CREAT[] = "O_CREAT";
1758 static char __pyx_k__Samfile[] = "Samfile";
1759 static char __pyx_k__Windows[] = "Windows";
1760 static char __pyx_k____all__[] = "__all__";
1761 static char __pyx_k____del__[] = "__del__";
1762 static char __pyx_k____str__[] = "__str__";
1763 static char __pyx_k___isOpen[] = "_isOpen";
1764 static char __pyx_k___is_del[] = "_is_del";
1765 static char __pyx_k__compare[] = "compare";
1766 static char __pyx_k__devnull[] = "devnull";
1767 static char __pyx_k__is_head[] = "is_head";
1768 static char __pyx_k__is_tail[] = "is_tail";
1769 static char __pyx_k__isupper[] = "isupper";
1770 static char __pyx_k__l_qname[] = "l_qname";
1771 static char __pyx_k__mkstemp[] = "mkstemp";
1772 static char __pyx_k__n_cigar[] = "n_cigar";
1773 static char __pyx_k__options[] = "options";
1774 static char __pyx_k__overlap[] = "overlap";
1775 static char __pyx_k__pileups[] = "pileups";
1776 static char __pyx_k__q_indel[] = "q_indel";
1777 static char __pyx_k__r_indel[] = "r_indel";
1778 static char __pyx_k__release[] = "release";
1779 static char __pyx_k__restore[] = "restore";
1780 static char __pyx_k__rowiter[] = "rowiter";
1781 static char __pyx_k__samfile[] = "samfile";
1782 static char __pyx_k__seq_len[] = "seq_len";
1783 static char __pyx_k__setfile[] = "setfile";
1784 static char __pyx_k__stepper[] = "stepper";
1785 static char __pyx_k__streams[] = "streams";
1786 static char __pyx_k__DictType[] = "DictType";
1787 static char __pyx_k__KeyError[] = "KeyError";
1788 static char __pyx_k__O_WRONLY[] = "O_WRONLY";
1789 static char __pyx_k____dict__[] = "__dict__";
1790 static char __pyx_k____init__[] = "__init__";
1791 static char __pyx_k____main__[] = "__main__";
1792 static char __pyx_k____next__[] = "__next__";
1793 static char __pyx_k____test__[] = "__test__";
1794 static char __pyx_k___is_head[] = "_is_head";
1795 static char __pyx_k___is_tail[] = "_is_tail";
1796 static char __pyx_k___logfile[] = "_logfile";
1797 static char __pyx_k__calcsize[] = "calcsize";
1798 static char __pyx_k__callback[] = "callback";
1799 static char __pyx_k__cap_mapQ[] = "cap_mapQ";
1800 static char __pyx_k__cnt_anti[] = "cnt_anti";
1801 static char __pyx_k__coverage[] = "coverage";
1802 static char __pyx_k__data_len[] = "data_len";
1803 static char __pyx_k__exc_type[] = "exc_type";
1804 static char __pyx_k__filename[] = "filename";
1805 static char __pyx_k__genotype[] = "genotype";
1806 static char __pyx_k__getrname[] = "getrname";
1807 static char __pyx_k__het_rate[] = "het_rate";
1808 static char __pyx_k__isremote[] = "isremote";
1809 static char __pyx_k__iterdata[] = "iterdata";
1810 static char __pyx_k__nextiter[] = "nextiter";
1811 static char __pyx_k__platform[] = "platform";
1812 static char __pyx_k__samtools[] = "samtools";
1813 static char __pyx_k__stderr_f[] = "stderr_f";
1814 static char __pyx_k__stderr_h[] = "stderr_h";
1815 static char __pyx_k__tempfile[] = "tempfile";
1816 static char __pyx_k__template[] = "template";
1817 static char __pyx_k__Fastafile[] = "Fastafile";
1818 static char __pyx_k__FloatType[] = "FloatType";
1819 static char __pyx_k__SNPCaller[] = "SNPCaller";
1820 static char __pyx_k__TypeError[] = "TypeError";
1821 static char __pyx_k___coverage[] = "_coverage";
1822 static char __pyx_k___delegate[] = "_delegate";
1823 static char __pyx_k___filename[] = "_filename";
1824 static char __pyx_k___genotype[] = "_genotype";
1825 static char __pyx_k___hasIndex[] = "_hasIndex";
1826 static char __pyx_k__alignment[] = "alignment";
1827 static char __pyx_k__exc_value[] = "exc_value";
1828 static char __pyx_k__fancy_str[] = "fancy_str";
1829 static char __pyx_k__fastafile[] = "fastafile";
1830 static char __pyx_k__itertools[] = "itertools";
1831 static char __pyx_k__max_depth[] = "max_depth";
1832 static char __pyx_k__min_baseQ[] = "min_baseQ";
1833 static char __pyx_k__n_targets[] = "n_targets";
1834 static char __pyx_k__pack_into[] = "pack_into";
1835 static char __pyx_k__positions[] = "positions";
1836 static char __pyx_k__readlines[] = "readlines";
1837 static char __pyx_k__reference[] = "reference";
1838 static char __pyx_k__setdevice[] = "setdevice";
1839 static char __pyx_k__traceback[] = "traceback";
1840 static char __pyx_k__until_eof[] = "until_eof";
1841 static char __pyx_k__PileupRead[] = "PileupRead";
1842 static char __pyx_k__ValueError[] = "ValueError";
1843 static char __pyx_k___alignment[] = "_alignment";
1844 static char __pyx_k___buildLine[] = "_buildLine";
1845 static char __pyx_k__reads_diff[] = "reads_diff";
1846 static char __pyx_k__startswith[] = "startswith";
1847 static char __pyx_k__target_len[] = "target_len";
1848 static char __pyx_k__AlignedRead[] = "AlignedRead";
1849 static char __pyx_k__IndelCaller[] = "IndelCaller";
1850 static char __pyx_k__IteratorRow[] = "IteratorRow";
1851 static char __pyx_k__PileupProxy[] = "PileupProxy";
1852 static char __pyx_k__StderrStore[] = "StderrStore";
1853 static char __pyx_k__collections[] = "collections";
1854 static char __pyx_k__current_pos[] = "current_pos";
1855 static char __pyx_k__defaultdict[] = "defaultdict";
1856 static char __pyx_k__getSequence[] = "getSequence";
1857 static char __pyx_k__nreferences[] = "nreferences";
1858 static char __pyx_k__pileup_iter[] = "pileup_iter";
1859 static char __pyx_k__reads_first[] = "reads_first";
1860 static char __pyx_k__snp_quality[] = "snp_quality";
1861 static char __pyx_k__stderr_save[] = "stderr_save";
1862 static char __pyx_k__target_name[] = "target_name";
1863 static char __pyx_k__IndexedReads[] = "IndexedReads";
1864 static char __pyx_k__PileupColumn[] = "PileupColumn";
1865 static char __pyx_k___buildHeader[] = "_buildHeader";
1866 static char __pyx_k___parseRegion[] = "_parseRegion";
1867 static char __pyx_k___snp_quality[] = "_snp_quality";
1868 static char __pyx_k__addReference[] = "addReference";
1869 static char __pyx_k__catch_stderr[] = "catch_stderr";
1870 static char __pyx_k__catch_stdout[] = "catch_stdout";
1871 static char __pyx_k__first_allele[] = "first_allele";
1872 static char __pyx_k__hasReference[] = "hasReference";
1873 static char __pyx_k__n_haplotypes[] = "n_haplotypes";
1874 static char __pyx_k__owns_samfile[] = "owns_samfile";
1875 static char __pyx_k__reads_second[] = "reads_second";
1876 static char __pyx_k__OverflowError[] = "OverflowError";
1877 static char __pyx_k__StopIteration[] = "StopIteration";
1878 static char __pyx_k__VALID_HEADERS[] = "VALID_HEADERS";
1879 static char __pyx_k__second_allele[] = "second_allele";
1880 static char __pyx_k__IteratorColumn[] = "IteratorColumn";
1881 static char __pyx_k__IteratorRowAll[] = "IteratorRowAll";
1882 static char __pyx_k__readAndRelease[] = "readAndRelease";
1883 static char __pyx_k__reference_base[] = "reference_base";
1884 static char __pyx_k__referencenames[] = "referencenames";
1885 static char __pyx_k___reference_base[] = "_reference_base";
1886 static char __pyx_k__iterator_column[] = "iterator_column";
1887 static char __pyx_k__mapping_quality[] = "mapping_quality";
1888 static char __pyx_k__IteratorSNPCalls[] = "IteratorSNPCalls";
1889 static char __pyx_k____getattribute__[] = "__getattribute__";
1890 static char __pyx_k__referencelengths[] = "referencelengths";
1891 static char __pyx_k__IteratorRowRegion[] = "IteratorRowRegion";
1892 static char __pyx_k__consensus_quality[] = "consensus_quality";
1893 static char __pyx_k__setupIteratorData[] = "setupIteratorData";
1894 static char __pyx_k__IteratorIndelCalls[] = "IteratorIndelCalls";
1895 static char __pyx_k__IteratorRowAllRefs[] = "IteratorRowAllRefs";
1896 static char __pyx_k__StderrStoreWindows[] = "StderrStoreWindows";
1897 static char __pyx_k__VALID_HEADER_ORDER[] = "VALID_HEADER_ORDER";
1898 static char __pyx_k__VALID_HEADER_TYPES[] = "VALID_HEADER_TYPES";
1899 static char __pyx_k___consensus_quality[] = "_consensus_quality";
1900 static char __pyx_k___samtools_dispatch[] = "_samtools_dispatch";
1901 static char __pyx_k__NotImplementedError[] = "NotImplementedError";
1902 static char __pyx_k__VALID_HEADER_FIELDS[] = "VALID_HEADER_FIELDS";
1903 static PyObject *__pyx_kp_s_1;
1904 static PyObject *__pyx_kp_s_10;
1905 static PyObject *__pyx_kp_s_100;
1906 static PyObject *__pyx_kp_s_101;
1907 static PyObject *__pyx_kp_s_102;
1908 static PyObject *__pyx_n_s_103;
1909 static PyObject *__pyx_kp_s_104;
1910 static PyObject *__pyx_kp_s_105;
1911 static PyObject *__pyx_kp_s_107;
1912 static PyObject *__pyx_kp_s_108;
1913 static PyObject *__pyx_kp_s_109;
1914 static PyObject *__pyx_kp_s_11;
1915 static PyObject *__pyx_kp_s_110;
1916 static PyObject *__pyx_kp_s_111;
1917 static PyObject *__pyx_kp_s_112;
1918 static PyObject *__pyx_kp_s_113;
1919 static PyObject *__pyx_kp_s_12;
1920 static PyObject *__pyx_kp_s_15;
1921 static PyObject *__pyx_kp_s_16;
1922 static PyObject *__pyx_kp_s_173;
1923 static PyObject *__pyx_kp_s_174;
1924 static PyObject *__pyx_kp_s_175;
1925 static PyObject *__pyx_kp_s_176;
1926 static PyObject *__pyx_kp_u_177;
1927 static PyObject *__pyx_kp_u_178;
1928 static PyObject *__pyx_kp_u_179;
1929 static PyObject *__pyx_kp_s_18;
1930 static PyObject *__pyx_kp_u_180;
1931 static PyObject *__pyx_kp_u_181;
1932 static PyObject *__pyx_kp_u_182;
1933 static PyObject *__pyx_kp_u_183;
1934 static PyObject *__pyx_kp_u_184;
1935 static PyObject *__pyx_kp_u_185;
1936 static PyObject *__pyx_kp_u_186;
1937 static PyObject *__pyx_kp_u_187;
1938 static PyObject *__pyx_kp_u_188;
1939 static PyObject *__pyx_kp_u_189;
1940 static PyObject *__pyx_kp_s_19;
1941 static PyObject *__pyx_kp_u_190;
1942 static PyObject *__pyx_kp_u_191;
1943 static PyObject *__pyx_kp_u_192;
1944 static PyObject *__pyx_kp_u_193;
1945 static PyObject *__pyx_kp_u_194;
1946 static PyObject *__pyx_kp_u_195;
1947 static PyObject *__pyx_kp_u_196;
1948 static PyObject *__pyx_kp_u_197;
1949 static PyObject *__pyx_kp_u_198;
1950 static PyObject *__pyx_kp_u_199;
1951 static PyObject *__pyx_kp_s_2;
1952 static PyObject *__pyx_kp_s_20;
1953 static PyObject *__pyx_n_s_200;
1954 static PyObject *__pyx_kp_u_201;
1955 static PyObject *__pyx_kp_u_202;
1956 static PyObject *__pyx_kp_u_203;
1957 static PyObject *__pyx_n_s_204;
1958 static PyObject *__pyx_kp_u_205;
1959 static PyObject *__pyx_n_s_206;
1960 static PyObject *__pyx_kp_u_207;
1961 static PyObject *__pyx_kp_u_208;
1962 static PyObject *__pyx_kp_u_209;
1963 static PyObject *__pyx_kp_s_21;
1964 static PyObject *__pyx_kp_u_210;
1965 static PyObject *__pyx_kp_u_211;
1966 static PyObject *__pyx_kp_u_212;
1967 static PyObject *__pyx_kp_u_213;
1968 static PyObject *__pyx_kp_u_214;
1969 static PyObject *__pyx_kp_u_215;
1970 static PyObject *__pyx_kp_u_216;
1971 static PyObject *__pyx_kp_u_217;
1972 static PyObject *__pyx_kp_u_218;
1973 static PyObject *__pyx_kp_u_219;
1974 static PyObject *__pyx_kp_s_22;
1975 static PyObject *__pyx_kp_u_220;
1976 static PyObject *__pyx_kp_s_23;
1977 static PyObject *__pyx_kp_s_24;
1978 static PyObject *__pyx_kp_s_25;
1979 static PyObject *__pyx_kp_s_26;
1980 static PyObject *__pyx_kp_s_27;
1981 static PyObject *__pyx_kp_s_28;
1982 static PyObject *__pyx_kp_s_3;
1983 static PyObject *__pyx_kp_s_30;
1984 static PyObject *__pyx_kp_s_31;
1985 static PyObject *__pyx_kp_s_32;
1986 static PyObject *__pyx_kp_s_33;
1987 static PyObject *__pyx_kp_s_34;
1988 static PyObject *__pyx_kp_s_35;
1989 static PyObject *__pyx_kp_s_36;
1990 static PyObject *__pyx_kp_s_37;
1991 static PyObject *__pyx_kp_s_38;
1992 static PyObject *__pyx_kp_s_4;
1993 static PyObject *__pyx_kp_s_40;
1994 static PyObject *__pyx_kp_s_41;
1995 static PyObject *__pyx_kp_s_42;
1996 static PyObject *__pyx_kp_s_43;
1997 static PyObject *__pyx_kp_s_44;
1998 static PyObject *__pyx_kp_s_45;
1999 static PyObject *__pyx_kp_s_46;
2000 static PyObject *__pyx_kp_s_47;
2001 static PyObject *__pyx_kp_s_48;
2002 static PyObject *__pyx_kp_s_49;
2003 static PyObject *__pyx_kp_s_5;
2004 static PyObject *__pyx_kp_s_50;
2005 static PyObject *__pyx_kp_s_51;
2006 static PyObject *__pyx_kp_s_52;
2007 static PyObject *__pyx_kp_s_53;
2008 static PyObject *__pyx_kp_s_54;
2009 static PyObject *__pyx_kp_s_55;
2010 static PyObject *__pyx_kp_s_56;
2011 static PyObject *__pyx_kp_s_57;
2012 static PyObject *__pyx_kp_s_59;
2013 static PyObject *__pyx_kp_s_6;
2014 static PyObject *__pyx_kp_s_61;
2015 static PyObject *__pyx_kp_s_62;
2016 static PyObject *__pyx_n_s_63;
2017 static PyObject *__pyx_kp_s_64;
2018 static PyObject *__pyx_kp_s_65;
2019 static PyObject *__pyx_kp_s_66;
2020 static PyObject *__pyx_kp_s_67;
2021 static PyObject *__pyx_kp_s_68;
2022 static PyObject *__pyx_kp_s_69;
2023 static PyObject *__pyx_kp_s_7;
2024 static PyObject *__pyx_kp_s_70;
2025 static PyObject *__pyx_kp_s_71;
2026 static PyObject *__pyx_kp_s_72;
2027 static PyObject *__pyx_kp_s_73;
2028 static PyObject *__pyx_kp_s_74;
2029 static PyObject *__pyx_kp_s_75;
2030 static PyObject *__pyx_kp_s_76;
2031 static PyObject *__pyx_kp_s_77;
2032 static PyObject *__pyx_kp_s_78;
2033 static PyObject *__pyx_kp_s_79;
2034 static PyObject *__pyx_kp_s_8;
2035 static PyObject *__pyx_kp_s_80;
2036 static PyObject *__pyx_kp_s_81;
2037 static PyObject *__pyx_kp_s_82;
2038 static PyObject *__pyx_kp_s_83;
2039 static PyObject *__pyx_kp_s_84;
2040 static PyObject *__pyx_kp_s_85;
2041 static PyObject *__pyx_kp_s_86;
2042 static PyObject *__pyx_kp_s_87;
2043 static PyObject *__pyx_kp_s_88;
2044 static PyObject *__pyx_kp_s_89;
2045 static PyObject *__pyx_kp_s_9;
2046 static PyObject *__pyx_kp_s_90;
2047 static PyObject *__pyx_kp_s_91;
2048 static PyObject *__pyx_kp_s_92;
2049 static PyObject *__pyx_kp_s_93;
2050 static PyObject *__pyx_kp_s_94;
2051 static PyObject *__pyx_kp_s_95;
2052 static PyObject *__pyx_kp_s_96;
2053 static PyObject *__pyx_kp_s_97;
2054 static PyObject *__pyx_n_s__A;
2055 static PyObject *__pyx_n_s__AS;
2056 static PyObject *__pyx_n_s__AlignedRead;
2057 static PyObject *__pyx_n_s__C;
2058 static PyObject *__pyx_n_s__CL;
2059 static PyObject *__pyx_n_s__CN;
2060 static PyObject *__pyx_n_s__CO;
2061 static PyObject *__pyx_n_s__D;
2062 static PyObject *__pyx_n_s__DS;
2063 static PyObject *__pyx_n_s__DT;
2064 static PyObject *__pyx_n_s__DictType;
2065 static PyObject *__pyx_n_s__F;
2066 static PyObject *__pyx_n_s__Fastafile;
2067 static PyObject *__pyx_n_s__FloatType;
2068 static PyObject *__pyx_n_s__GO;
2069 static PyObject *__pyx_n_s__HD;
2070 static PyObject *__pyx_n_s__I;
2071 static PyObject *__pyx_n_s__ID;
2072 static PyObject *__pyx_n_s__IOError;
2073 static PyObject *__pyx_n_s__IndelCaller;
2074 static PyObject *__pyx_n_s__IndexedReads;
2075 static PyObject *__pyx_n_s__IntType;
2076 static PyObject *__pyx_n_s__IteratorColumn;
2077 static PyObject *__pyx_n_s__IteratorIndelCalls;
2078 static PyObject *__pyx_n_s__IteratorRow;
2079 static PyObject *__pyx_n_s__IteratorRowAll;
2080 static PyObject *__pyx_n_s__IteratorRowAllRefs;
2081 static PyObject *__pyx_n_s__IteratorRowRegion;
2082 static PyObject *__pyx_n_s__IteratorSNPCalls;
2083 static PyObject *__pyx_n_s__KeyError;
2084 static PyObject *__pyx_n_s__LB;
2085 static PyObject *__pyx_n_s__LN;
2086 static PyObject *__pyx_n_s__M5;
2087 static PyObject *__pyx_n_s__NotImplementedError;
2088 static PyObject *__pyx_n_s__O_CREAT;
2089 static PyObject *__pyx_n_s__O_WRONLY;
2090 static PyObject *__pyx_n_s__Outs;
2091 static PyObject *__pyx_n_s__OverflowError;
2092 static PyObject *__pyx_n_s__PG;
2093 static PyObject *__pyx_n_s__PI;
2094 static PyObject *__pyx_n_s__PL;
2095 static PyObject *__pyx_n_s__PN;
2096 static PyObject *__pyx_n_s__PU;
2097 static PyObject *__pyx_n_s__PileupColumn;
2098 static PyObject *__pyx_n_s__PileupProxy;
2099 static PyObject *__pyx_n_s__PileupRead;
2100 static PyObject *__pyx_n_s__RG;
2101 static PyObject *__pyx_n_s__S;
2102 static PyObject *__pyx_n_s__SM;
2103 static PyObject *__pyx_n_s__SN;
2104 static PyObject *__pyx_n_s__SNPCaller;
2105 static PyObject *__pyx_n_s__SO;
2106 static PyObject *__pyx_n_s__SP;
2107 static PyObject *__pyx_n_s__SQ;
2108 static PyObject *__pyx_n_s__Samfile;
2109 static PyObject *__pyx_n_s__StderrStore;
2110 static PyObject *__pyx_n_s__StderrStoreWindows;
2111 static PyObject *__pyx_n_s__StopIteration;
2112 static PyObject *__pyx_n_s__TypeError;
2113 static PyObject *__pyx_n_s__UR;
2114 static PyObject *__pyx_n_s__VALID_HEADERS;
2115 static PyObject *__pyx_n_s__VALID_HEADER_FIELDS;
2116 static PyObject *__pyx_n_s__VALID_HEADER_ORDER;
2117 static PyObject *__pyx_n_s__VALID_HEADER_TYPES;
2118 static PyObject *__pyx_n_s__VN;
2119 static PyObject *__pyx_n_s__ValueError;
2120 static PyObject *__pyx_n_s__Windows;
2121 static PyObject *__pyx_n_s__Z;
2122 static PyObject *__pyx_n_s____all__;
2123 static PyObject *__pyx_n_s____del__;
2124 static PyObject *__pyx_n_s____dict__;
2125 static PyObject *__pyx_n_s____getattribute__;
2126 static PyObject *__pyx_n_s____init__;
2127 static PyObject *__pyx_n_s____main__;
2128 static PyObject *__pyx_n_s____next__;
2129 static PyObject *__pyx_n_s____str__;
2130 static PyObject *__pyx_n_s____test__;
2131 static PyObject *__pyx_n_s___alignment;
2132 static PyObject *__pyx_n_s___buildHeader;
2133 static PyObject *__pyx_n_s___buildLine;
2134 static PyObject *__pyx_n_s___call;
2135 static PyObject *__pyx_n_s___consensus_quality;
2136 static PyObject *__pyx_n_s___coverage;
2137 static PyObject *__pyx_n_s___delegate;
2138 static PyObject *__pyx_n_s___filename;
2139 static PyObject *__pyx_n_s___genotype;
2140 static PyObject *__pyx_n_s___hasIndex;
2141 static PyObject *__pyx_n_s___indel;
2142 static PyObject *__pyx_n_s___isOpen;
2143 static PyObject *__pyx_n_s___is_del;
2144 static PyObject *__pyx_n_s___is_head;
2145 static PyObject *__pyx_n_s___is_tail;
2146 static PyObject *__pyx_n_s___level;
2147 static PyObject *__pyx_n_s___logfile;
2148 static PyObject *__pyx_n_s___open;
2149 static PyObject *__pyx_n_s___parseRegion;
2150 static PyObject *__pyx_n_s___pos;
2151 static PyObject *__pyx_n_s___qpos;
2152 static PyObject *__pyx_n_s___r;
2153 static PyObject *__pyx_n_s___reference_base;
2154 static PyObject *__pyx_n_s___samtools_dispatch;
2155 static PyObject *__pyx_n_s___snp_quality;
2156 static PyObject *__pyx_n_s___tid;
2157 static PyObject *__pyx_n_s__addReference;
2158 static PyObject *__pyx_n_s__alignment;
2159 static PyObject *__pyx_n_s__all;
2160 static PyObject *__pyx_n_s__args;
2161 static PyObject *__pyx_n_s__b;
2162 static PyObject *__pyx_n_s__bam;
2163 static PyObject *__pyx_n_s__beg;
2164 static PyObject *__pyx_n_s__bin;
2165 static PyObject *__pyx_n_s__bqual;
2166 static PyObject *__pyx_n_s__build;
2167 static PyObject *__pyx_n_s__c;
2168 static PyObject *__pyx_n_s__calcsize;
2169 static PyObject *__pyx_n_s__call;
2170 static PyObject *__pyx_n_s__callback;
2171 static PyObject *__pyx_n_s__cap_mapQ;
2172 static PyObject *__pyx_n_s__catch_stderr;
2173 static PyObject *__pyx_n_s__catch_stdout;
2174 static PyObject *__pyx_n_s__chr;
2175 static PyObject *__pyx_n_s__cigar;
2176 static PyObject *__pyx_n_s__close;
2177 static PyObject *__pyx_n_s__cmp;
2178 static PyObject *__pyx_n_s__cnext;
2179 static PyObject *__pyx_n_s__cnt1;
2180 static PyObject *__pyx_n_s__cnt2;
2181 static PyObject *__pyx_n_s__cnt_anti;
2182 static PyObject *__pyx_n_s__collections;
2183 static PyObject *__pyx_n_s__compare;
2184 static PyObject *__pyx_n_s__consensus_quality;
2185 static PyObject *__pyx_n_s__core;
2186 static PyObject *__pyx_n_s__count;
2187 static PyObject *__pyx_n_s__coverage;
2188 static PyObject *__pyx_n_s__ctypes;
2189 static PyObject *__pyx_n_s__current_pos;
2190 static PyObject *__pyx_n_s__d;
2191 static PyObject *__pyx_n_s__data;
2192 static PyObject *__pyx_n_s__data_len;
2193 static PyObject *__pyx_n_s__defaultdict;
2194 static PyObject *__pyx_n_s__devnull;
2195 static PyObject *__pyx_n_s__dup;
2196 static PyObject *__pyx_n_s__dup2;
2197 static PyObject *__pyx_n_s__end;
2198 static PyObject *__pyx_n_s__errmod;
2199 static PyObject *__pyx_n_s__exc_type;
2200 static PyObject *__pyx_n_s__exc_value;
2201 static PyObject *__pyx_n_s__exists;
2202 static PyObject *__pyx_n_s__f;
2203 static PyObject *__pyx_n_s__fancy_str;
2204 static PyObject *__pyx_n_s__fastafile;
2205 static PyObject *__pyx_n_s__fd;
2206 static PyObject *__pyx_n_s__fetch;
2207 static PyObject *__pyx_n_s__fields;
2208 static PyObject *__pyx_n_s__filename;
2209 static PyObject *__pyx_n_s__fileno;
2210 static PyObject *__pyx_n_s__first_allele;
2211 static PyObject *__pyx_n_s__flag;
2212 static PyObject *__pyx_n_s__flush;
2213 static PyObject *__pyx_n_s__fp;
2214 static PyObject *__pyx_n_s__genotype;
2215 static PyObject *__pyx_n_s__getSequence;
2216 static PyObject *__pyx_n_s__getrname;
2217 static PyObject *__pyx_n_s__gettid;
2218 static PyObject *__pyx_n_s__hasReference;
2219 static PyObject *__pyx_n_s__hash;
2220 static PyObject *__pyx_n_s__header;
2221 static PyObject *__pyx_n_s__het_rate;
2222 static PyObject *__pyx_n_s__i;
2223 static PyObject *__pyx_n_s__id;
2224 static PyObject *__pyx_n_s__indel;
2225 static PyObject *__pyx_n_s__indel1;
2226 static PyObject *__pyx_n_s__indel2;
2227 static PyObject *__pyx_n_s__index;
2228 static PyObject *__pyx_n_s__is_del;
2229 static PyObject *__pyx_n_s__is_head;
2230 static PyObject *__pyx_n_s__is_tail;
2231 static PyObject *__pyx_n_s__isbam;
2232 static PyObject *__pyx_n_s__isize;
2233 static PyObject *__pyx_n_s__isremote;
2234 static PyObject *__pyx_n_s__isupper;
2235 static PyObject *__pyx_n_s__iter;
2236 static PyObject *__pyx_n_s__iterator_column;
2237 static PyObject *__pyx_n_s__iterdata;
2238 static PyObject *__pyx_n_s__itertools;
2239 static PyObject *__pyx_n_s__join;
2240 static PyObject *__pyx_n_s__l_aux;
2241 static PyObject *__pyx_n_s__l_qname;
2242 static PyObject *__pyx_n_s__l_qseq;
2243 static PyObject *__pyx_n_s__l_text;
2244 static PyObject *__pyx_n_s__level;
2245 static PyObject *__pyx_n_s__m_data;
2246 static PyObject *__pyx_n_s__map;
2247 static PyObject *__pyx_n_s__mapping_quality;
2248 static PyObject *__pyx_n_s__mapq;
2249 static PyObject *__pyx_n_s__mask;
2250 static PyObject *__pyx_n_s__mate;
2251 static PyObject *__pyx_n_s__max_depth;
2252 static PyObject *__pyx_n_s__method;
2253 static PyObject *__pyx_n_s__min_baseQ;
2254 static PyObject *__pyx_n_s__mkstemp;
2255 static PyObject *__pyx_n_s__mode;
2256 static PyObject *__pyx_n_s__mpos;
2257 static PyObject *__pyx_n_s__mrnm;
2258 static PyObject *__pyx_n_s__mtid;
2259 static PyObject *__pyx_n_s__n;
2260 static PyObject *__pyx_n_s__n_cigar;
2261 static PyObject *__pyx_n_s__n_hap;
2262 static PyObject *__pyx_n_s__n_haplotypes;
2263 static PyObject *__pyx_n_s__n_plp;
2264 static PyObject *__pyx_n_s__n_pu;
2265 static PyObject *__pyx_n_s__n_targets;
2266 static PyObject *__pyx_n_s__name;
2267 static PyObject *__pyx_n_s__nextiter;
2268 static PyObject *__pyx_n_s__nreferences;
2269 static PyObject *__pyx_n_s__object;
2270 static PyObject *__pyx_n_s__offset;
2271 static PyObject *__pyx_n_s__open;
2272 static PyObject *__pyx_n_s__opt;
2273 static PyObject *__pyx_n_s__options;
2274 static PyObject *__pyx_n_s__os;
2275 static PyObject *__pyx_n_s__overlap;
2276 static PyObject *__pyx_n_s__owns_samfile;
2277 static PyObject *__pyx_n_s__pack_into;
2278 static PyObject *__pyx_n_s__path;
2279 static PyObject *__pyx_n_s__pileup;
2280 static PyObject *__pyx_n_s__pileup_iter;
2281 static PyObject *__pyx_n_s__pileups;
2282 static PyObject *__pyx_n_s__platform;
2283 static PyObject *__pyx_n_s__plp;
2284 static PyObject *__pyx_n_s__port;
2285 static PyObject *__pyx_n_s__pos;
2286 static PyObject *__pyx_n_s__positions;
2287 static PyObject *__pyx_n_s__q_cns;
2288 static PyObject *__pyx_n_s__q_indel;
2289 static PyObject *__pyx_n_s__q_r;
2290 static PyObject *__pyx_n_s__q_ref;
2291 static PyObject *__pyx_n_s__qname;
2292 static PyObject *__pyx_n_s__qpos;
2293 static PyObject *__pyx_n_s__qseq;
2294 static PyObject *__pyx_n_s__qual;
2295 static PyObject *__pyx_n_s__r;
2296 static PyObject *__pyx_n_s__r_indel;
2297 static PyObject *__pyx_n_s__range;
2298 static PyObject *__pyx_n_s__raw;
2299 static PyObject *__pyx_n_s__rb;
2300 static PyObject *__pyx_n_s__re;
2301 static PyObject *__pyx_n_s__readAndRelease;
2302 static PyObject *__pyx_n_s__readlines;
2303 static PyObject *__pyx_n_s__reads_diff;
2304 static PyObject *__pyx_n_s__reads_first;
2305 static PyObject *__pyx_n_s__reads_second;
2306 static PyObject *__pyx_n_s__record;
2307 static PyObject *__pyx_n_s__reference;
2308 static PyObject *__pyx_n_s__reference_base;
2309 static PyObject *__pyx_n_s__referencelengths;
2310 static PyObject *__pyx_n_s__referencenames;
2311 static PyObject *__pyx_n_s__region;
2312 static PyObject *__pyx_n_s__release;
2313 static PyObject *__pyx_n_s__remove;
2314 static PyObject *__pyx_n_s__reopen;
2315 static PyObject *__pyx_n_s__reset;
2316 static PyObject *__pyx_n_s__restore;
2317 static PyObject *__pyx_n_s__retval;
2318 static PyObject *__pyx_n_s__rg2lib;
2319 static PyObject *__pyx_n_s__rlen;
2320 static PyObject *__pyx_n_s__rname;
2321 static PyObject *__pyx_n_s__rowiter;
2322 static PyObject *__pyx_n_s__s;
2323 static PyObject *__pyx_n_s__samfile;
2324 static PyObject *__pyx_n_s__samtools;
2325 static PyObject *__pyx_n_s__second_allele;
2326 static PyObject *__pyx_n_s__seek;
2327 static PyObject *__pyx_n_s__self;
2328 static PyObject *__pyx_n_s__seq;
2329 static PyObject *__pyx_n_s__seq_len;
2330 static PyObject *__pyx_n_s__setdevice;
2331 static PyObject *__pyx_n_s__setfd;
2332 static PyObject *__pyx_n_s__setfile;
2333 static PyObject *__pyx_n_s__setupIteratorData;
2334 static PyObject *__pyx_n_s__snp_quality;
2335 static PyObject *__pyx_n_s__split;
2336 static PyObject *__pyx_n_s__start;
2337 static PyObject *__pyx_n_s__startswith;
2338 static PyObject *__pyx_n_s__stderr;
2339 static PyObject *__pyx_n_s__stderr_f;
2340 static PyObject *__pyx_n_s__stderr_h;
2341 static PyObject *__pyx_n_s__stderr_save;
2342 static PyObject *__pyx_n_s__stdout;
2343 static PyObject *__pyx_n_s__stepper;
2344 static PyObject *__pyx_n_s__streams;
2345 static PyObject *__pyx_n_s__strip;
2346 static PyObject *__pyx_n_s__struct;
2347 static PyObject *__pyx_n_s__sys;
2348 static PyObject *__pyx_n_s__system;
2349 static PyObject *__pyx_n_s__tags;
2350 static PyObject *__pyx_n_s__target_len;
2351 static PyObject *__pyx_n_s__target_name;
2352 static PyObject *__pyx_n_s__tell;
2353 static PyObject *__pyx_n_s__tempfile;
2354 static PyObject *__pyx_n_s__template;
2355 static PyObject *__pyx_n_s__text;
2356 static PyObject *__pyx_n_s__theta;
2357 static PyObject *__pyx_n_s__tid;
2358 static PyObject *__pyx_n_s__traceback;
2359 static PyObject *__pyx_n_s__types;
2360 static PyObject *__pyx_n_s__until_eof;
2361 static PyObject *__pyx_n_s__view;
2362 static PyObject *__pyx_n_s__w;
2363 static PyObject *__pyx_n_s__wb;
2364 static PyObject *__pyx_n_s__wbu;
2365 static PyObject *__pyx_n_s__wh;
2366 static PyObject *__pyx_n_s__where;
2367 static PyObject *__pyx_n_s__write;
2368 static PyObject *__pyx_n_s__x;
2369 static PyObject *__pyx_int_0;
2370 static PyObject *__pyx_int_1;
2371 static PyObject *__pyx_int_2;
2372 static PyObject *__pyx_int_4;
2373 static PyObject *__pyx_int_8;
2374 static PyObject *__pyx_int_13;
2375 static PyObject *__pyx_int_16;
2376 static PyObject *__pyx_int_32;
2377 static PyObject *__pyx_int_40;
2378 static PyObject *__pyx_int_60;
2379 static PyObject *__pyx_int_64;
2380 static PyObject *__pyx_int_128;
2381 static PyObject *__pyx_int_255;
2382 static PyObject *__pyx_int_256;
2383 static PyObject *__pyx_int_512;
2384 static PyObject *__pyx_int_neg_127;
2385 static PyObject *__pyx_int_0660;
2386 static PyObject *__pyx_int_1024;
2387 static PyObject *__pyx_int_65535;
2388 static PyObject *__pyx_int_neg_32767;
2389 static PyObject *__pyx_int_536870912;
2390 static PyObject *__pyx_int_4294967295;
2391 static PyObject *__pyx_int_neg_2147483648;
2392 static PyObject *__pyx_k_29;
2393 static PyObject *__pyx_k_39;
2394 static int __pyx_k_58;
2395 static PyObject *__pyx_k_98;
2396 static PyObject *__pyx_k_99;
2397
2398 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":76
2399  * #####################################################################
2400  * cdef class AlignedRead
2401  * cdef makeAlignedRead(bam1_t * src):             # <<<<<<<<<<<<<<
2402  *     '''enter src into AlignedRead.'''
2403  *     cdef AlignedRead dest = AlignedRead.__new__(AlignedRead)
2404  */
2405
2406 static  PyObject *__pyx_f_9csamtools_makeAlignedRead(bam1_t *__pyx_v_src) {
2407   struct __pyx_obj_9csamtools_AlignedRead *__pyx_v_dest = 0;
2408   PyObject *__pyx_r = NULL;
2409   PyObject *__pyx_t_1 = NULL;
2410   __Pyx_TraceDeclarations
2411   __Pyx_RefNannySetupContext("makeAlignedRead");
2412   __Pyx_TraceCall("makeAlignedRead", __pyx_f[0], 76);
2413
2414   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":78
2415  * cdef makeAlignedRead(bam1_t * src):
2416  *     '''enter src into AlignedRead.'''
2417  *     cdef AlignedRead dest = AlignedRead.__new__(AlignedRead)             # <<<<<<<<<<<<<<
2418  *     dest._delegate = bam_dup1(src)
2419  *     return dest
2420  */
2421   __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_9csamtools_AlignedRead)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2422   __Pyx_GOTREF(__pyx_t_1);
2423   if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_9csamtools_AlignedRead)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2424   __pyx_v_dest = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_t_1);
2425   __pyx_t_1 = 0;
2426
2427   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":79
2428  *     '''enter src into AlignedRead.'''
2429  *     cdef AlignedRead dest = AlignedRead.__new__(AlignedRead)
2430  *     dest._delegate = bam_dup1(src)             # <<<<<<<<<<<<<<
2431  *     return dest
2432  * 
2433  */
2434   __pyx_v_dest->_delegate = bam_dup1(__pyx_v_src);
2435
2436   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":80
2437  *     cdef AlignedRead dest = AlignedRead.__new__(AlignedRead)
2438  *     dest._delegate = bam_dup1(src)
2439  *     return dest             # <<<<<<<<<<<<<<
2440  * 
2441  * cdef class PileupProxy
2442  */
2443   __Pyx_XDECREF(__pyx_r);
2444   __Pyx_INCREF(((PyObject *)__pyx_v_dest));
2445   __pyx_r = ((PyObject *)__pyx_v_dest);
2446   goto __pyx_L0;
2447
2448   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2449   goto __pyx_L0;
2450   __pyx_L1_error:;
2451   __Pyx_XDECREF(__pyx_t_1);
2452   __Pyx_AddTraceback("csamtools.makeAlignedRead");
2453   __pyx_r = 0;
2454   __pyx_L0:;
2455   __Pyx_XDECREF((PyObject *)__pyx_v_dest);
2456   __Pyx_XGIVEREF(__pyx_r);
2457   __Pyx_TraceReturn(__pyx_r);
2458   __Pyx_RefNannyFinishContext();
2459   return __pyx_r;
2460 }
2461
2462 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":83
2463  * 
2464  * cdef class PileupProxy
2465  * cdef makePileupProxy( bam_pileup1_t * plp, int tid, int pos, int n ):             # <<<<<<<<<<<<<<
2466  *      cdef PileupProxy dest = PileupProxy.__new__(PileupProxy)
2467  *      dest.plp = plp
2468  */
2469
2470 static  PyObject *__pyx_f_9csamtools_makePileupProxy(bam_pileup1_t *__pyx_v_plp, int __pyx_v_tid, int __pyx_v_pos, int __pyx_v_n) {
2471   struct __pyx_obj_9csamtools_PileupProxy *__pyx_v_dest = 0;
2472   PyObject *__pyx_r = NULL;
2473   PyObject *__pyx_t_1 = NULL;
2474   __Pyx_TraceDeclarations
2475   __Pyx_RefNannySetupContext("makePileupProxy");
2476   __Pyx_TraceCall("makePileupProxy", __pyx_f[0], 83);
2477
2478   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":84
2479  * cdef class PileupProxy
2480  * cdef makePileupProxy( bam_pileup1_t * plp, int tid, int pos, int n ):
2481  *      cdef PileupProxy dest = PileupProxy.__new__(PileupProxy)             # <<<<<<<<<<<<<<
2482  *      dest.plp = plp
2483  *      dest.tid = tid
2484  */
2485   __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_9csamtools_PileupProxy)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2486   __Pyx_GOTREF(__pyx_t_1);
2487   if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_9csamtools_PileupProxy)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2488   __pyx_v_dest = ((struct __pyx_obj_9csamtools_PileupProxy *)__pyx_t_1);
2489   __pyx_t_1 = 0;
2490
2491   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":85
2492  * cdef makePileupProxy( bam_pileup1_t * plp, int tid, int pos, int n ):
2493  *      cdef PileupProxy dest = PileupProxy.__new__(PileupProxy)
2494  *      dest.plp = plp             # <<<<<<<<<<<<<<
2495  *      dest.tid = tid
2496  *      dest.pos = pos
2497  */
2498   __pyx_v_dest->plp = __pyx_v_plp;
2499
2500   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":86
2501  *      cdef PileupProxy dest = PileupProxy.__new__(PileupProxy)
2502  *      dest.plp = plp
2503  *      dest.tid = tid             # <<<<<<<<<<<<<<
2504  *      dest.pos = pos
2505  *      dest.n = n
2506  */
2507   __pyx_v_dest->tid = __pyx_v_tid;
2508
2509   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":87
2510  *      dest.plp = plp
2511  *      dest.tid = tid
2512  *      dest.pos = pos             # <<<<<<<<<<<<<<
2513  *      dest.n = n
2514  *      return dest
2515  */
2516   __pyx_v_dest->pos = __pyx_v_pos;
2517
2518   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":88
2519  *      dest.tid = tid
2520  *      dest.pos = pos
2521  *      dest.n = n             # <<<<<<<<<<<<<<
2522  *      return dest
2523  * 
2524  */
2525   __pyx_t_1 = PyInt_FromLong(__pyx_v_n); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2526   __Pyx_GOTREF(__pyx_t_1);
2527   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;}
2528   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2529
2530   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":89
2531  *      dest.pos = pos
2532  *      dest.n = n
2533  *      return dest             # <<<<<<<<<<<<<<
2534  * 
2535  * cdef class PileupRead
2536  */
2537   __Pyx_XDECREF(__pyx_r);
2538   __Pyx_INCREF(((PyObject *)__pyx_v_dest));
2539   __pyx_r = ((PyObject *)__pyx_v_dest);
2540   goto __pyx_L0;
2541
2542   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2543   goto __pyx_L0;
2544   __pyx_L1_error:;
2545   __Pyx_XDECREF(__pyx_t_1);
2546   __Pyx_AddTraceback("csamtools.makePileupProxy");
2547   __pyx_r = 0;
2548   __pyx_L0:;
2549   __Pyx_XDECREF((PyObject *)__pyx_v_dest);
2550   __Pyx_XGIVEREF(__pyx_r);
2551   __Pyx_TraceReturn(__pyx_r);
2552   __Pyx_RefNannyFinishContext();
2553   return __pyx_r;
2554 }
2555
2556 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":92
2557  * 
2558  * cdef class PileupRead
2559  * cdef makePileupRead( bam_pileup1_t * src ):             # <<<<<<<<<<<<<<
2560  *     '''fill a  PileupRead object from a bam_pileup1_t * object.'''
2561  *     cdef PileupRead dest = PileupRead.__new__(PileupRead)
2562  */
2563
2564 static  PyObject *__pyx_f_9csamtools_makePileupRead(bam_pileup1_t *__pyx_v_src) {
2565   struct __pyx_obj_9csamtools_PileupRead *__pyx_v_dest = 0;
2566   PyObject *__pyx_r = NULL;
2567   PyObject *__pyx_t_1 = NULL;
2568   __Pyx_TraceDeclarations
2569   __Pyx_RefNannySetupContext("makePileupRead");
2570   __Pyx_TraceCall("makePileupRead", __pyx_f[0], 92);
2571
2572   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":94
2573  * cdef makePileupRead( bam_pileup1_t * src ):
2574  *     '''fill a  PileupRead object from a bam_pileup1_t * object.'''
2575  *     cdef PileupRead dest = PileupRead.__new__(PileupRead)             # <<<<<<<<<<<<<<
2576  *     dest._alignment = makeAlignedRead( src.b )
2577  *     dest._qpos = src.qpos
2578  */
2579   __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_9csamtools_PileupRead)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2580   __Pyx_GOTREF(__pyx_t_1);
2581   if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_9csamtools_PileupRead)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2582   __pyx_v_dest = ((struct __pyx_obj_9csamtools_PileupRead *)__pyx_t_1);
2583   __pyx_t_1 = 0;
2584
2585   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":95
2586  *     '''fill a  PileupRead object from a bam_pileup1_t * object.'''
2587  *     cdef PileupRead dest = PileupRead.__new__(PileupRead)
2588  *     dest._alignment = makeAlignedRead( src.b )             # <<<<<<<<<<<<<<
2589  *     dest._qpos = src.qpos
2590  *     dest._indel = src.indel
2591  */
2592   __pyx_t_1 = __pyx_f_9csamtools_makeAlignedRead(__pyx_v_src->b); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2593   __Pyx_GOTREF(__pyx_t_1);
2594   if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_9csamtools_AlignedRead))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2595   __Pyx_GIVEREF(__pyx_t_1);
2596   __Pyx_GOTREF(__pyx_v_dest->_alignment);
2597   __Pyx_DECREF(((PyObject *)__pyx_v_dest->_alignment));
2598   __pyx_v_dest->_alignment = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_t_1);
2599   __pyx_t_1 = 0;
2600
2601   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":96
2602  *     cdef PileupRead dest = PileupRead.__new__(PileupRead)
2603  *     dest._alignment = makeAlignedRead( src.b )
2604  *     dest._qpos = src.qpos             # <<<<<<<<<<<<<<
2605  *     dest._indel = src.indel
2606  *     dest._level = src.level
2607  */
2608   __pyx_v_dest->_qpos = __pyx_v_src->qpos;
2609
2610   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":97
2611  *     dest._alignment = makeAlignedRead( src.b )
2612  *     dest._qpos = src.qpos
2613  *     dest._indel = src.indel             # <<<<<<<<<<<<<<
2614  *     dest._level = src.level
2615  *     dest._is_del = src.is_del
2616  */
2617   __pyx_v_dest->_indel = __pyx_v_src->indel;
2618
2619   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":98
2620  *     dest._qpos = src.qpos
2621  *     dest._indel = src.indel
2622  *     dest._level = src.level             # <<<<<<<<<<<<<<
2623  *     dest._is_del = src.is_del
2624  *     dest._is_head = src.is_head
2625  */
2626   __pyx_v_dest->_level = __pyx_v_src->level;
2627
2628   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":99
2629  *     dest._indel = src.indel
2630  *     dest._level = src.level
2631  *     dest._is_del = src.is_del             # <<<<<<<<<<<<<<
2632  *     dest._is_head = src.is_head
2633  *     dest._is_tail = src.is_tail
2634  */
2635   __pyx_v_dest->_is_del = __pyx_v_src->is_del;
2636
2637   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":100
2638  *     dest._level = src.level
2639  *     dest._is_del = src.is_del
2640  *     dest._is_head = src.is_head             # <<<<<<<<<<<<<<
2641  *     dest._is_tail = src.is_tail
2642  *     return dest
2643  */
2644   __pyx_v_dest->_is_head = __pyx_v_src->is_head;
2645
2646   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":101
2647  *     dest._is_del = src.is_del
2648  *     dest._is_head = src.is_head
2649  *     dest._is_tail = src.is_tail             # <<<<<<<<<<<<<<
2650  *     return dest
2651  * 
2652  */
2653   __pyx_v_dest->_is_tail = __pyx_v_src->is_tail;
2654
2655   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":102
2656  *     dest._is_head = src.is_head
2657  *     dest._is_tail = src.is_tail
2658  *     return dest             # <<<<<<<<<<<<<<
2659  * 
2660  * #####################################################################
2661  */
2662   __Pyx_XDECREF(__pyx_r);
2663   __Pyx_INCREF(((PyObject *)__pyx_v_dest));
2664   __pyx_r = ((PyObject *)__pyx_v_dest);
2665   goto __pyx_L0;
2666
2667   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2668   goto __pyx_L0;
2669   __pyx_L1_error:;
2670   __Pyx_XDECREF(__pyx_t_1);
2671   __Pyx_AddTraceback("csamtools.makePileupRead");
2672   __pyx_r = 0;
2673   __pyx_L0:;
2674   __Pyx_XDECREF((PyObject *)__pyx_v_dest);
2675   __Pyx_XGIVEREF(__pyx_r);
2676   __Pyx_TraceReturn(__pyx_r);
2677   __Pyx_RefNannyFinishContext();
2678   return __pyx_r;
2679 }
2680
2681 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":109
2682  * ## Generic callbacks for inserting python callbacks.
2683  * #####################################################################
2684  * cdef int fetch_callback( bam1_t *alignment, void *f):             # <<<<<<<<<<<<<<
2685  *     '''callback for bam_fetch.
2686  * 
2687  */
2688
2689 static  int __pyx_f_9csamtools_fetch_callback(bam1_t *__pyx_v_alignment, void *__pyx_v_f) {
2690   PyObject *__pyx_v_a;
2691   int __pyx_r;
2692   PyObject *__pyx_t_1 = NULL;
2693   PyObject *__pyx_t_2 = NULL;
2694   __Pyx_TraceDeclarations
2695   __Pyx_RefNannySetupContext("fetch_callback");
2696   __Pyx_TraceCall("fetch_callback", __pyx_f[0], 109);
2697   __pyx_v_a = Py_None; __Pyx_INCREF(Py_None);
2698
2699   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":114
2700  *     calls function in *f* with a new :class:`AlignedRead` object as parameter.
2701  *     '''
2702  *     a = makeAlignedRead( alignment )             # <<<<<<<<<<<<<<
2703  *     (<object>f)(a)
2704  * 
2705  */
2706   __pyx_t_1 = __pyx_f_9csamtools_makeAlignedRead(__pyx_v_alignment); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2707   __Pyx_GOTREF(__pyx_t_1);
2708   __Pyx_DECREF(__pyx_v_a);
2709   __pyx_v_a = __pyx_t_1;
2710   __pyx_t_1 = 0;
2711
2712   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":115
2713  *     '''
2714  *     a = makeAlignedRead( alignment )
2715  *     (<object>f)(a)             # <<<<<<<<<<<<<<
2716  * 
2717  * class PileupColumn(object):
2718  */
2719   __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;}
2720   __Pyx_GOTREF(__pyx_t_1);
2721   __Pyx_INCREF(__pyx_v_a);
2722   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_a);
2723   __Pyx_GIVEREF(__pyx_v_a);
2724   __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;}
2725   __Pyx_GOTREF(__pyx_t_2);
2726   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2727   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2728
2729   __pyx_r = 0;
2730   goto __pyx_L0;
2731   __pyx_L1_error:;
2732   __Pyx_XDECREF(__pyx_t_1);
2733   __Pyx_XDECREF(__pyx_t_2);
2734   __Pyx_WriteUnraisable("csamtools.fetch_callback");
2735   __pyx_r = 0;
2736   __pyx_L0:;
2737   __Pyx_DECREF(__pyx_v_a);
2738   __Pyx_TraceReturn(Py_None);
2739   __Pyx_RefNannyFinishContext();
2740   return __pyx_r;
2741 }
2742
2743 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":130
2744  *         list of reads (:class:`pysam.PileupRead`) aligned to this column
2745  *     '''
2746  *     def __str__(self):             # <<<<<<<<<<<<<<
2747  *         return "\t".join( map(str, (self.tid, self.pos, self.n))) +\
2748  *             "\n" + "\n".join( map(str, self.pileups) )
2749  */
2750
2751 static PyObject *__pyx_pf_9csamtools_12PileupColumn___str__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
2752 static char __pyx_doc_9csamtools_12PileupColumn___str__[] = "PileupColumn.__str__(self)";
2753 static PyMethodDef __pyx_mdef_9csamtools_12PileupColumn___str__ = {__Pyx_NAMESTR("__str__"), (PyCFunction)__pyx_pf_9csamtools_12PileupColumn___str__, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_12PileupColumn___str__)};
2754 static PyObject *__pyx_pf_9csamtools_12PileupColumn___str__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
2755   PyObject *__pyx_r = NULL;
2756   PyObject *__pyx_t_1 = NULL;
2757   PyObject *__pyx_t_2 = NULL;
2758   PyObject *__pyx_t_3 = NULL;
2759   PyObject *__pyx_t_4 = NULL;
2760   PyObject *__pyx_t_5 = NULL;
2761   __Pyx_TraceDeclarations
2762   __Pyx_RefNannySetupContext("__str__");
2763   __Pyx_TraceCall("__str__", __pyx_f[0], 130);
2764   __pyx_self = __pyx_self;
2765
2766   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":131
2767  *     '''
2768  *     def __str__(self):
2769  *         return "\t".join( map(str, (self.tid, self.pos, self.n))) +\             # <<<<<<<<<<<<<<
2770  *             "\n" + "\n".join( map(str, self.pileups) )
2771  * 
2772  */
2773   __Pyx_XDECREF(__pyx_r);
2774
2775   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":132
2776  *     def __str__(self):
2777  *         return "\t".join( map(str, (self.tid, self.pos, self.n))) +\
2778  *             "\n" + "\n".join( map(str, self.pileups) )             # <<<<<<<<<<<<<<
2779  * 
2780  * cdef int pileup_callback( uint32_t tid, uint32_t pos, int n, bam_pileup1_t *pl, void *f):
2781  */
2782   __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;}
2783   __Pyx_GOTREF(__pyx_t_1);
2784
2785   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":131
2786  *     '''
2787  *     def __str__(self):
2788  *         return "\t".join( map(str, (self.tid, self.pos, self.n))) +\             # <<<<<<<<<<<<<<
2789  *             "\n" + "\n".join( map(str, self.pileups) )
2790  * 
2791  */
2792   __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__tid); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2793   __Pyx_GOTREF(__pyx_t_2);
2794   __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2795   __Pyx_GOTREF(__pyx_t_3);
2796   __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;}
2797   __Pyx_GOTREF(__pyx_t_4);
2798   __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;}
2799   __Pyx_GOTREF(__pyx_t_5);
2800   PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
2801   __Pyx_GIVEREF(__pyx_t_2);
2802   PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
2803   __Pyx_GIVEREF(__pyx_t_3);
2804   PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
2805   __Pyx_GIVEREF(__pyx_t_4);
2806   __pyx_t_2 = 0;
2807   __pyx_t_3 = 0;
2808   __pyx_t_4 = 0;
2809   __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;}
2810   __Pyx_GOTREF(__pyx_t_4);
2811   __Pyx_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
2812   PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)((PyObject*)&PyString_Type)));
2813   __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
2814   PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5);
2815   __Pyx_GIVEREF(__pyx_t_5);
2816   __pyx_t_5 = 0;
2817   __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;}
2818   __Pyx_GOTREF(__pyx_t_5);
2819   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2820   __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;}
2821   __Pyx_GOTREF(__pyx_t_4);
2822   PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
2823   __Pyx_GIVEREF(__pyx_t_5);
2824   __pyx_t_5 = 0;
2825   __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;}
2826   __Pyx_GOTREF(__pyx_t_5);
2827   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2828   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2829   __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;}
2830   __Pyx_GOTREF(__pyx_t_4);
2831   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2832
2833   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":132
2834  *     def __str__(self):
2835  *         return "\t".join( map(str, (self.tid, self.pos, self.n))) +\
2836  *             "\n" + "\n".join( map(str, self.pileups) )             # <<<<<<<<<<<<<<
2837  * 
2838  * cdef int pileup_callback( uint32_t tid, uint32_t pos, int n, bam_pileup1_t *pl, void *f):
2839  */
2840   __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 = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2841   __Pyx_GOTREF(__pyx_t_5);
2842   __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;}
2843   __Pyx_GOTREF(__pyx_t_1);
2844   __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;}
2845   __Pyx_GOTREF(__pyx_t_3);
2846   __Pyx_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
2847   PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)((PyObject*)&PyString_Type)));
2848   __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
2849   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
2850   __Pyx_GIVEREF(__pyx_t_1);
2851   __pyx_t_1 = 0;
2852   __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;}
2853   __Pyx_GOTREF(__pyx_t_1);
2854   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2855   __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;}
2856   __Pyx_GOTREF(__pyx_t_3);
2857   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
2858   __Pyx_GIVEREF(__pyx_t_1);
2859   __pyx_t_1 = 0;
2860   __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;}
2861   __Pyx_GOTREF(__pyx_t_1);
2862   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2863   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2864   __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;}
2865   __Pyx_GOTREF(__pyx_t_3);
2866   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2867   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2868   __pyx_r = __pyx_t_3;
2869   __pyx_t_3 = 0;
2870   goto __pyx_L0;
2871
2872   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2873   goto __pyx_L0;
2874   __pyx_L1_error:;
2875   __Pyx_XDECREF(__pyx_t_1);
2876   __Pyx_XDECREF(__pyx_t_2);
2877   __Pyx_XDECREF(__pyx_t_3);
2878   __Pyx_XDECREF(__pyx_t_4);
2879   __Pyx_XDECREF(__pyx_t_5);
2880   __Pyx_AddTraceback("csamtools.PileupColumn.__str__");
2881   __pyx_r = NULL;
2882   __pyx_L0:;
2883   __Pyx_XGIVEREF(__pyx_r);
2884   __Pyx_TraceReturn(__pyx_r);
2885   __Pyx_RefNannyFinishContext();
2886   return __pyx_r;
2887 }
2888
2889 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":134
2890  *             "\n" + "\n".join( map(str, self.pileups) )
2891  * 
2892  * cdef int pileup_callback( uint32_t tid, uint32_t pos, int n, bam_pileup1_t *pl, void *f):             # <<<<<<<<<<<<<<
2893  *     '''callback for pileup.
2894  * 
2895  */
2896
2897 static  int __pyx_f_9csamtools_pileup_callback(uint32_t __pyx_v_tid, uint32_t __pyx_v_pos, int __pyx_v_n, bam_pileup1_t *__pyx_v_pl, void *__pyx_v_f) {
2898   PyObject *__pyx_v_p;
2899   PyObject *__pyx_v_pileups;
2900   int __pyx_v_x;
2901   int __pyx_r;
2902   PyObject *__pyx_t_1 = NULL;
2903   PyObject *__pyx_t_2 = NULL;
2904   int __pyx_t_3;
2905   int __pyx_t_4;
2906   __Pyx_TraceDeclarations
2907   __Pyx_RefNannySetupContext("pileup_callback");
2908   __Pyx_TraceCall("pileup_callback", __pyx_f[0], 134);
2909   __pyx_v_p = Py_None; __Pyx_INCREF(Py_None);
2910   __pyx_v_pileups = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
2911
2912   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":151
2913  *     '''
2914  * 
2915  *     p = PileupColumn()             # <<<<<<<<<<<<<<
2916  *     p.tid = tid
2917  *     p.pos = pos
2918  */
2919   __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__PileupColumn); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2920   __Pyx_GOTREF(__pyx_t_1);
2921   __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 = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2922   __Pyx_GOTREF(__pyx_t_2);
2923   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2924   __Pyx_DECREF(__pyx_v_p);
2925   __pyx_v_p = __pyx_t_2;
2926   __pyx_t_2 = 0;
2927
2928   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":152
2929  * 
2930  *     p = PileupColumn()
2931  *     p.tid = tid             # <<<<<<<<<<<<<<
2932  *     p.pos = pos
2933  *     p.n = n
2934  */
2935   __pyx_t_2 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_tid); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2936   __Pyx_GOTREF(__pyx_t_2);
2937   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;}
2938   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2939
2940   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":153
2941  *     p = PileupColumn()
2942  *     p.tid = tid
2943  *     p.pos = pos             # <<<<<<<<<<<<<<
2944  *     p.n = n
2945  *     pileups = []
2946  */
2947   __pyx_t_2 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_pos); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2948   __Pyx_GOTREF(__pyx_t_2);
2949   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;}
2950   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2951
2952   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":154
2953  *     p.tid = tid
2954  *     p.pos = pos
2955  *     p.n = n             # <<<<<<<<<<<<<<
2956  *     pileups = []
2957  * 
2958  */
2959   __pyx_t_2 = PyInt_FromLong(__pyx_v_n); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2960   __Pyx_GOTREF(__pyx_t_2);
2961   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;}
2962   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2963
2964   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":155
2965  *     p.pos = pos
2966  *     p.n = n
2967  *     pileups = []             # <<<<<<<<<<<<<<
2968  * 
2969  *     cdef int x
2970  */
2971   __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2972   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
2973   __Pyx_DECREF(((PyObject *)__pyx_v_pileups));
2974   __pyx_v_pileups = __pyx_t_2;
2975   __pyx_t_2 = 0;
2976
2977   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":158
2978  * 
2979  *     cdef int x
2980  *     for x from 0 <= x < n:             # <<<<<<<<<<<<<<
2981  *         pileups.append( makePileupRead( &(pl[x]) ) )
2982  *     p.pileups = pileups
2983  */
2984   __pyx_t_3 = __pyx_v_n;
2985   for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_3; __pyx_v_x++) {
2986
2987     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":159
2988  *     cdef int x
2989  *     for x from 0 <= x < n:
2990  *         pileups.append( makePileupRead( &(pl[x]) ) )             # <<<<<<<<<<<<<<
2991  *     p.pileups = pileups
2992  * 
2993  */
2994     if (unlikely(__pyx_v_pileups == Py_None)) {
2995       PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
2996     }
2997     __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;}
2998     __Pyx_GOTREF(__pyx_t_2);
2999     __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;}
3000     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3001   }
3002
3003   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":160
3004  *     for x from 0 <= x < n:
3005  *         pileups.append( makePileupRead( &(pl[x]) ) )
3006  *     p.pileups = pileups             # <<<<<<<<<<<<<<
3007  * 
3008  *     (<object>f)(p)
3009  */
3010   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;}
3011
3012   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":162
3013  *     p.pileups = pileups
3014  * 
3015  *     (<object>f)(p)             # <<<<<<<<<<<<<<
3016  * 
3017  * cdef int pileup_fetch_callback( bam1_t *b, void *data):
3018  */
3019   __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;}
3020   __Pyx_GOTREF(__pyx_t_2);
3021   __Pyx_INCREF(__pyx_v_p);
3022   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_p);
3023   __Pyx_GIVEREF(__pyx_v_p);
3024   __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;}
3025   __Pyx_GOTREF(__pyx_t_1);
3026   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3027   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3028
3029   __pyx_r = 0;
3030   goto __pyx_L0;
3031   __pyx_L1_error:;
3032   __Pyx_XDECREF(__pyx_t_1);
3033   __Pyx_XDECREF(__pyx_t_2);
3034   __Pyx_WriteUnraisable("csamtools.pileup_callback");
3035   __pyx_r = 0;
3036   __pyx_L0:;
3037   __Pyx_DECREF(__pyx_v_p);
3038   __Pyx_DECREF(__pyx_v_pileups);
3039   __Pyx_TraceReturn(Py_None);
3040   __Pyx_RefNannyFinishContext();
3041   return __pyx_r;
3042 }
3043
3044 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":164
3045  *     (<object>f)(p)
3046  * 
3047  * cdef int pileup_fetch_callback( bam1_t *b, void *data):             # <<<<<<<<<<<<<<
3048  *     '''callback for bam_fetch.
3049  * 
3050  */
3051
3052 static  int __pyx_f_9csamtools_pileup_fetch_callback(bam1_t *__pyx_v_b, void *__pyx_v_data) {
3053   bam_plbuf_t *__pyx_v_buf;
3054   int __pyx_r;
3055   __Pyx_TraceDeclarations
3056   __Pyx_RefNannySetupContext("pileup_fetch_callback");
3057   __Pyx_TraceCall("pileup_fetch_callback", __pyx_f[0], 164);
3058
3059   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":170
3060  *     '''
3061  *     cdef bam_plbuf_t * buf
3062  *     buf = <bam_plbuf_t*>data             # <<<<<<<<<<<<<<
3063  *     bam_plbuf_push(b, buf)
3064  *     return 0
3065  */
3066   __pyx_v_buf = ((bam_plbuf_t *)__pyx_v_data);
3067
3068   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":171
3069  *     cdef bam_plbuf_t * buf
3070  *     buf = <bam_plbuf_t*>data
3071  *     bam_plbuf_push(b, buf)             # <<<<<<<<<<<<<<
3072  *     return 0
3073  * 
3074  */
3075   bam_plbuf_push(__pyx_v_b, __pyx_v_buf);
3076
3077   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":172
3078  *     buf = <bam_plbuf_t*>data
3079  *     bam_plbuf_push(b, buf)
3080  *     return 0             # <<<<<<<<<<<<<<
3081  * 
3082  * class StderrStore():
3083  */
3084   __pyx_r = 0;
3085   goto __pyx_L0;
3086
3087   __pyx_r = 0;
3088   __pyx_L0:;
3089   __Pyx_TraceReturn(Py_None);
3090   __Pyx_RefNannyFinishContext();
3091   return __pyx_r;
3092 }
3093
3094 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":178
3095  *     stderr is captured.
3096  *     '''
3097  *     def __init__(self):             # <<<<<<<<<<<<<<
3098  *         return
3099  *         self.stderr_h, self.stderr_f = tempfile.mkstemp()
3100  */
3101
3102 static PyObject *__pyx_pf_9csamtools_11StderrStore___init__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
3103 static char __pyx_doc_9csamtools_11StderrStore___init__[] = "StderrStore.__init__(self)";
3104 static PyMethodDef __pyx_mdef_9csamtools_11StderrStore___init__ = {__Pyx_NAMESTR("__init__"), (PyCFunction)__pyx_pf_9csamtools_11StderrStore___init__, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_11StderrStore___init__)};
3105 static PyObject *__pyx_pf_9csamtools_11StderrStore___init__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
3106   PyObject *__pyx_r = NULL;
3107   PyObject *__pyx_t_1 = NULL;
3108   PyObject *__pyx_t_2 = NULL;
3109   PyObject *__pyx_t_3 = NULL;
3110   PyObject *__pyx_t_4 = NULL;
3111   __Pyx_TraceDeclarations
3112   __Pyx_RefNannySetupContext("__init__");
3113   __Pyx_TraceCall("__init__", __pyx_f[0], 178);
3114   __pyx_self = __pyx_self;
3115
3116   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":179
3117  *     '''
3118  *     def __init__(self):
3119  *         return             # <<<<<<<<<<<<<<
3120  *         self.stderr_h, self.stderr_f = tempfile.mkstemp()
3121  *         self.stderr_save = Outs( sys.stderr.fileno() )
3122  */
3123   __Pyx_XDECREF(__pyx_r);
3124   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3125   goto __pyx_L0;
3126
3127   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":180
3128  *     def __init__(self):
3129  *         return
3130  *         self.stderr_h, self.stderr_f = tempfile.mkstemp()             # <<<<<<<<<<<<<<
3131  *         self.stderr_save = Outs( sys.stderr.fileno() )
3132  *         self.stderr_save.setfd( self.stderr_h )
3133  */
3134   __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__tempfile); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3135   __Pyx_GOTREF(__pyx_t_1);
3136   __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__mkstemp); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3137   __Pyx_GOTREF(__pyx_t_2);
3138   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3139   __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 = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3140   __Pyx_GOTREF(__pyx_t_1);
3141   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3142   if (PyTuple_CheckExact(__pyx_t_1) && likely(PyTuple_GET_SIZE(__pyx_t_1) == 2)) {
3143     PyObject* tuple = __pyx_t_1;
3144     __pyx_t_2 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_2);
3145     __pyx_t_3 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_3);
3146     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3147     if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__stderr_h, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3148     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3149     if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__stderr_f, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3150     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3151   } else {
3152     __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3153     __Pyx_GOTREF(__pyx_t_4);
3154     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3155     __pyx_t_2 = __Pyx_UnpackItem(__pyx_t_4, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3156     __Pyx_GOTREF(__pyx_t_2);
3157     __pyx_t_3 = __Pyx_UnpackItem(__pyx_t_4, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3158     __Pyx_GOTREF(__pyx_t_3);
3159     if (__Pyx_EndUnpack(__pyx_t_4, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3160     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3161     if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__stderr_h, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3162     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3163     if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__stderr_f, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3164     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3165   }
3166
3167   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":181
3168  *         return
3169  *         self.stderr_h, self.stderr_f = tempfile.mkstemp()
3170  *         self.stderr_save = Outs( sys.stderr.fileno() )             # <<<<<<<<<<<<<<
3171  *         self.stderr_save.setfd( self.stderr_h )
3172  * 
3173  */
3174   __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__Outs); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3175   __Pyx_GOTREF(__pyx_t_1);
3176   __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3177   __Pyx_GOTREF(__pyx_t_3);
3178   __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__stderr); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3179   __Pyx_GOTREF(__pyx_t_2);
3180   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3181   __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__fileno); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3182   __Pyx_GOTREF(__pyx_t_3);
3183   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3184   __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 = 181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3185   __Pyx_GOTREF(__pyx_t_2);
3186   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3187   __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;}
3188   __Pyx_GOTREF(__pyx_t_3);
3189   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
3190   __Pyx_GIVEREF(__pyx_t_2);
3191   __pyx_t_2 = 0;
3192   __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;}
3193   __Pyx_GOTREF(__pyx_t_2);
3194   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3195   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3196   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;}
3197   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3198
3199   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":182
3200  *         self.stderr_h, self.stderr_f = tempfile.mkstemp()
3201  *         self.stderr_save = Outs( sys.stderr.fileno() )
3202  *         self.stderr_save.setfd( self.stderr_h )             # <<<<<<<<<<<<<<
3203  * 
3204  *     def readAndRelease( self ):
3205  */
3206   __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__stderr_save); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3207   __Pyx_GOTREF(__pyx_t_2);
3208   __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__setfd); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3209   __Pyx_GOTREF(__pyx_t_3);
3210   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3211   __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;}
3212   __Pyx_GOTREF(__pyx_t_2);
3213   __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;}
3214   __Pyx_GOTREF(__pyx_t_1);
3215   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
3216   __Pyx_GIVEREF(__pyx_t_2);
3217   __pyx_t_2 = 0;
3218   __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;}
3219   __Pyx_GOTREF(__pyx_t_2);
3220   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3221   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3222   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3223
3224   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3225   goto __pyx_L0;
3226   __pyx_L1_error:;
3227   __Pyx_XDECREF(__pyx_t_1);
3228   __Pyx_XDECREF(__pyx_t_2);
3229   __Pyx_XDECREF(__pyx_t_3);
3230   __Pyx_XDECREF(__pyx_t_4);
3231   __Pyx_AddTraceback("csamtools.StderrStore.__init__");
3232   __pyx_r = NULL;
3233   __pyx_L0:;
3234   __Pyx_XGIVEREF(__pyx_r);
3235   __Pyx_TraceReturn(__pyx_r);
3236   __Pyx_RefNannyFinishContext();
3237   return __pyx_r;
3238 }
3239
3240 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":184
3241  *         self.stderr_save.setfd( self.stderr_h )
3242  * 
3243  *     def readAndRelease( self ):             # <<<<<<<<<<<<<<
3244  *         return []
3245  *         self.stderr_save.restore()
3246  */
3247
3248 static PyObject *__pyx_pf_9csamtools_11StderrStore_readAndRelease(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
3249 static char __pyx_doc_9csamtools_11StderrStore_readAndRelease[] = "StderrStore.readAndRelease(self)";
3250 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)};
3251 static PyObject *__pyx_pf_9csamtools_11StderrStore_readAndRelease(PyObject *__pyx_self, PyObject *__pyx_v_self) {
3252   PyObject *__pyx_v_lines;
3253   PyObject *__pyx_r = NULL;
3254   PyObject *__pyx_t_1 = NULL;
3255   PyObject *__pyx_t_2 = NULL;
3256   PyObject *__pyx_t_3 = NULL;
3257   int __pyx_t_4;
3258   __Pyx_TraceDeclarations
3259   __Pyx_RefNannySetupContext("readAndRelease");
3260   __Pyx_TraceCall("readAndRelease", __pyx_f[0], 184);
3261   __pyx_self = __pyx_self;
3262   __pyx_v_lines = Py_None; __Pyx_INCREF(Py_None);
3263
3264   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":185
3265  * 
3266  *     def readAndRelease( self ):
3267  *         return []             # <<<<<<<<<<<<<<
3268  *         self.stderr_save.restore()
3269  *         lines = []
3270  */
3271   __Pyx_XDECREF(__pyx_r);
3272   __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3273   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
3274   __pyx_r = ((PyObject *)__pyx_t_1);
3275   __pyx_t_1 = 0;
3276   goto __pyx_L0;
3277
3278   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":186
3279  *     def readAndRelease( self ):
3280  *         return []
3281  *         self.stderr_save.restore()             # <<<<<<<<<<<<<<
3282  *         lines = []
3283  *         if os.path.exists(self.stderr_f):
3284  */
3285   __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__stderr_save); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3286   __Pyx_GOTREF(__pyx_t_1);
3287   __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__restore); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3288   __Pyx_GOTREF(__pyx_t_2);
3289   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3290   __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 = 186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3291   __Pyx_GOTREF(__pyx_t_1);
3292   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3293   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3294
3295   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":187
3296  *         return []
3297  *         self.stderr_save.restore()
3298  *         lines = []             # <<<<<<<<<<<<<<
3299  *         if os.path.exists(self.stderr_f):
3300  *             lines = open( self.stderr_f, "r" ).readlines()
3301  */
3302   __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3303   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
3304   __Pyx_DECREF(__pyx_v_lines);
3305   __pyx_v_lines = ((PyObject *)__pyx_t_1);
3306   __pyx_t_1 = 0;
3307
3308   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":188
3309  *         self.stderr_save.restore()
3310  *         lines = []
3311  *         if os.path.exists(self.stderr_f):             # <<<<<<<<<<<<<<
3312  *             lines = open( self.stderr_f, "r" ).readlines()
3313  *             os.remove( self.stderr_f )
3314  */
3315   __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3316   __Pyx_GOTREF(__pyx_t_1);
3317   __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__path); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3318   __Pyx_GOTREF(__pyx_t_2);
3319   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3320   __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__exists); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3321   __Pyx_GOTREF(__pyx_t_1);
3322   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3323   __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;}
3324   __Pyx_GOTREF(__pyx_t_2);
3325   __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;}
3326   __Pyx_GOTREF(__pyx_t_3);
3327   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
3328   __Pyx_GIVEREF(__pyx_t_2);
3329   __pyx_t_2 = 0;
3330   __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;}
3331   __Pyx_GOTREF(__pyx_t_2);
3332   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3333   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3334   __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;}
3335   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3336   if (__pyx_t_4) {
3337
3338     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":189
3339  *         lines = []
3340  *         if os.path.exists(self.stderr_f):
3341  *             lines = open( self.stderr_f, "r" ).readlines()             # <<<<<<<<<<<<<<
3342  *             os.remove( self.stderr_f )
3343  *         return lines
3344  */
3345     __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;}
3346     __Pyx_GOTREF(__pyx_t_2);
3347     __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;}
3348     __Pyx_GOTREF(__pyx_t_3);
3349     PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
3350     __Pyx_GIVEREF(__pyx_t_2);
3351     __Pyx_INCREF(((PyObject *)__pyx_n_s__r));
3352     PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_n_s__r));
3353     __Pyx_GIVEREF(((PyObject *)__pyx_n_s__r));
3354     __pyx_t_2 = 0;
3355     __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;}
3356     __Pyx_GOTREF(__pyx_t_2);
3357     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3358     __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;}
3359     __Pyx_GOTREF(__pyx_t_3);
3360     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3361     __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 = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3362     __Pyx_GOTREF(__pyx_t_2);
3363     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3364     __Pyx_DECREF(__pyx_v_lines);
3365     __pyx_v_lines = __pyx_t_2;
3366     __pyx_t_2 = 0;
3367
3368     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":190
3369  *         if os.path.exists(self.stderr_f):
3370  *             lines = open( self.stderr_f, "r" ).readlines()
3371  *             os.remove( self.stderr_f )             # <<<<<<<<<<<<<<
3372  *         return lines
3373  * 
3374  */
3375     __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3376     __Pyx_GOTREF(__pyx_t_2);
3377     __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__remove); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3378     __Pyx_GOTREF(__pyx_t_3);
3379     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3380     __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;}
3381     __Pyx_GOTREF(__pyx_t_2);
3382     __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;}
3383     __Pyx_GOTREF(__pyx_t_1);
3384     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
3385     __Pyx_GIVEREF(__pyx_t_2);
3386     __pyx_t_2 = 0;
3387     __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;}
3388     __Pyx_GOTREF(__pyx_t_2);
3389     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3390     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3391     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3392     goto __pyx_L5;
3393   }
3394   __pyx_L5:;
3395
3396   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":191
3397  *             lines = open( self.stderr_f, "r" ).readlines()
3398  *             os.remove( self.stderr_f )
3399  *         return lines             # <<<<<<<<<<<<<<
3400  * 
3401  *     def release(self):
3402  */
3403   __Pyx_XDECREF(__pyx_r);
3404   __Pyx_INCREF(__pyx_v_lines);
3405   __pyx_r = __pyx_v_lines;
3406   goto __pyx_L0;
3407
3408   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3409   goto __pyx_L0;
3410   __pyx_L1_error:;
3411   __Pyx_XDECREF(__pyx_t_1);
3412   __Pyx_XDECREF(__pyx_t_2);
3413   __Pyx_XDECREF(__pyx_t_3);
3414   __Pyx_AddTraceback("csamtools.StderrStore.readAndRelease");
3415   __pyx_r = NULL;
3416   __pyx_L0:;
3417   __Pyx_DECREF(__pyx_v_lines);
3418   __Pyx_XGIVEREF(__pyx_r);
3419   __Pyx_TraceReturn(__pyx_r);
3420   __Pyx_RefNannyFinishContext();
3421   return __pyx_r;
3422 }
3423
3424 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":193
3425  *         return lines
3426  * 
3427  *     def release(self):             # <<<<<<<<<<<<<<
3428  *         return
3429  *         self.stderr_save.restore()
3430  */
3431
3432 static PyObject *__pyx_pf_9csamtools_11StderrStore_release(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
3433 static char __pyx_doc_9csamtools_11StderrStore_release[] = "StderrStore.release(self)";
3434 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)};
3435 static PyObject *__pyx_pf_9csamtools_11StderrStore_release(PyObject *__pyx_self, PyObject *__pyx_v_self) {
3436   PyObject *__pyx_r = NULL;
3437   PyObject *__pyx_t_1 = NULL;
3438   PyObject *__pyx_t_2 = NULL;
3439   PyObject *__pyx_t_3 = NULL;
3440   int __pyx_t_4;
3441   __Pyx_TraceDeclarations
3442   __Pyx_RefNannySetupContext("release");
3443   __Pyx_TraceCall("release", __pyx_f[0], 193);
3444   __pyx_self = __pyx_self;
3445
3446   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":194
3447  * 
3448  *     def release(self):
3449  *         return             # <<<<<<<<<<<<<<
3450  *         self.stderr_save.restore()
3451  *         if os.path.exists(self.stderr_f):
3452  */
3453   __Pyx_XDECREF(__pyx_r);
3454   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3455   goto __pyx_L0;
3456
3457   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":195
3458  *     def release(self):
3459  *         return
3460  *         self.stderr_save.restore()             # <<<<<<<<<<<<<<
3461  *         if os.path.exists(self.stderr_f):
3462  *             os.remove( self.stderr_f )
3463  */
3464   __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__stderr_save); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3465   __Pyx_GOTREF(__pyx_t_1);
3466   __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__restore); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3467   __Pyx_GOTREF(__pyx_t_2);
3468   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3469   __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 = 195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3470   __Pyx_GOTREF(__pyx_t_1);
3471   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3472   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3473
3474   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":196
3475  *         return
3476  *         self.stderr_save.restore()
3477  *         if os.path.exists(self.stderr_f):             # <<<<<<<<<<<<<<
3478  *             os.remove( self.stderr_f )
3479  * 
3480  */
3481   __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3482   __Pyx_GOTREF(__pyx_t_1);
3483   __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__path); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3484   __Pyx_GOTREF(__pyx_t_2);
3485   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3486   __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__exists); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 196; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3487   __Pyx_GOTREF(__pyx_t_1);
3488   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3489   __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;}
3490   __Pyx_GOTREF(__pyx_t_2);
3491   __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;}
3492   __Pyx_GOTREF(__pyx_t_3);
3493   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
3494   __Pyx_GIVEREF(__pyx_t_2);
3495   __pyx_t_2 = 0;
3496   __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;}
3497   __Pyx_GOTREF(__pyx_t_2);
3498   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3499   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3500   __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;}
3501   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3502   if (__pyx_t_4) {
3503
3504     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":197
3505  *         self.stderr_save.restore()
3506  *         if os.path.exists(self.stderr_f):
3507  *             os.remove( self.stderr_f )             # <<<<<<<<<<<<<<
3508  * 
3509  *     def __del__(self):
3510  */
3511     __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3512     __Pyx_GOTREF(__pyx_t_2);
3513     __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__remove); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3514     __Pyx_GOTREF(__pyx_t_3);
3515     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3516     __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;}
3517     __Pyx_GOTREF(__pyx_t_2);
3518     __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;}
3519     __Pyx_GOTREF(__pyx_t_1);
3520     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
3521     __Pyx_GIVEREF(__pyx_t_2);
3522     __pyx_t_2 = 0;
3523     __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;}
3524     __Pyx_GOTREF(__pyx_t_2);
3525     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3526     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3527     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3528     goto __pyx_L5;
3529   }
3530   __pyx_L5:;
3531
3532   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3533   goto __pyx_L0;
3534   __pyx_L1_error:;
3535   __Pyx_XDECREF(__pyx_t_1);
3536   __Pyx_XDECREF(__pyx_t_2);
3537   __Pyx_XDECREF(__pyx_t_3);
3538   __Pyx_AddTraceback("csamtools.StderrStore.release");
3539   __pyx_r = NULL;
3540   __pyx_L0:;
3541   __Pyx_XGIVEREF(__pyx_r);
3542   __Pyx_TraceReturn(__pyx_r);
3543   __Pyx_RefNannyFinishContext();
3544   return __pyx_r;
3545 }
3546
3547 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":199
3548  *             os.remove( self.stderr_f )
3549  * 
3550  *     def __del__(self):             # <<<<<<<<<<<<<<
3551  *         self.release()
3552  * 
3553  */
3554
3555 static PyObject *__pyx_pf_9csamtools_11StderrStore___del__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
3556 static char __pyx_doc_9csamtools_11StderrStore___del__[] = "StderrStore.__del__(self)";
3557 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__)};
3558 static PyObject *__pyx_pf_9csamtools_11StderrStore___del__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
3559   PyObject *__pyx_r = NULL;
3560   PyObject *__pyx_t_1 = NULL;
3561   PyObject *__pyx_t_2 = NULL;
3562   __Pyx_TraceDeclarations
3563   __Pyx_RefNannySetupContext("__del__");
3564   __Pyx_TraceCall("__del__", __pyx_f[0], 199);
3565   __pyx_self = __pyx_self;
3566
3567   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":200
3568  * 
3569  *     def __del__(self):
3570  *         self.release()             # <<<<<<<<<<<<<<
3571  * 
3572  * class StderrStoreWindows():
3573  */
3574   __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__release); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3575   __Pyx_GOTREF(__pyx_t_1);
3576   __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 = 200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3577   __Pyx_GOTREF(__pyx_t_2);
3578   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3579   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3580
3581   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3582   goto __pyx_L0;
3583   __pyx_L1_error:;
3584   __Pyx_XDECREF(__pyx_t_1);
3585   __Pyx_XDECREF(__pyx_t_2);
3586   __Pyx_AddTraceback("csamtools.StderrStore.__del__");
3587   __pyx_r = NULL;
3588   __pyx_L0:;
3589   __Pyx_XGIVEREF(__pyx_r);
3590   __Pyx_TraceReturn(__pyx_r);
3591   __Pyx_RefNannyFinishContext();
3592   return __pyx_r;
3593 }
3594
3595 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":204
3596  * class StderrStoreWindows():
3597  *     '''does nothing. stderr can't be redirected on windows'''
3598  *     def __init__(self): pass             # <<<<<<<<<<<<<<
3599  *     def readAndRelease(self): return []
3600  *     def release(self): pass
3601  */
3602
3603 static PyObject *__pyx_pf_9csamtools_18StderrStoreWindows___init__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
3604 static char __pyx_doc_9csamtools_18StderrStoreWindows___init__[] = "StderrStoreWindows.__init__(self)";
3605 static PyMethodDef __pyx_mdef_9csamtools_18StderrStoreWindows___init__ = {__Pyx_NAMESTR("__init__"), (PyCFunction)__pyx_pf_9csamtools_18StderrStoreWindows___init__, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_18StderrStoreWindows___init__)};
3606 static PyObject *__pyx_pf_9csamtools_18StderrStoreWindows___init__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
3607   PyObject *__pyx_r = NULL;
3608   __Pyx_TraceDeclarations
3609   __Pyx_RefNannySetupContext("__init__");
3610   __Pyx_TraceCall("__init__", __pyx_f[0], 204);
3611   __pyx_self = __pyx_self;
3612
3613   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3614   __Pyx_XGIVEREF(__pyx_r);
3615   __Pyx_TraceReturn(__pyx_r);
3616   __Pyx_RefNannyFinishContext();
3617   return __pyx_r;
3618 }
3619
3620 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":205
3621  *     '''does nothing. stderr can't be redirected on windows'''
3622  *     def __init__(self): pass
3623  *     def readAndRelease(self): return []             # <<<<<<<<<<<<<<
3624  *     def release(self): pass
3625  * 
3626  */
3627
3628 static PyObject *__pyx_pf_9csamtools_18StderrStoreWindows_readAndRelease(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
3629 static char __pyx_doc_9csamtools_18StderrStoreWindows_readAndRelease[] = "StderrStoreWindows.readAndRelease(self)";
3630 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)};
3631 static PyObject *__pyx_pf_9csamtools_18StderrStoreWindows_readAndRelease(PyObject *__pyx_self, PyObject *__pyx_v_self) {
3632   PyObject *__pyx_r = NULL;
3633   PyObject *__pyx_t_1 = NULL;
3634   __Pyx_TraceDeclarations
3635   __Pyx_RefNannySetupContext("readAndRelease");
3636   __Pyx_TraceCall("readAndRelease", __pyx_f[0], 205);
3637   __pyx_self = __pyx_self;
3638   __Pyx_XDECREF(__pyx_r);
3639   __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3640   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
3641   __pyx_r = ((PyObject *)__pyx_t_1);
3642   __pyx_t_1 = 0;
3643   goto __pyx_L0;
3644
3645   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3646   goto __pyx_L0;
3647   __pyx_L1_error:;
3648   __Pyx_XDECREF(__pyx_t_1);
3649   __Pyx_AddTraceback("csamtools.StderrStoreWindows.readAndRelease");
3650   __pyx_r = NULL;
3651   __pyx_L0:;
3652   __Pyx_XGIVEREF(__pyx_r);
3653   __Pyx_TraceReturn(__pyx_r);
3654   __Pyx_RefNannyFinishContext();
3655   return __pyx_r;
3656 }
3657
3658 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":206
3659  *     def __init__(self): pass
3660  *     def readAndRelease(self): return []
3661  *     def release(self): pass             # <<<<<<<<<<<<<<
3662  * 
3663  * if platform.system()=='Windows':
3664  */
3665
3666 static PyObject *__pyx_pf_9csamtools_18StderrStoreWindows_release(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
3667 static char __pyx_doc_9csamtools_18StderrStoreWindows_release[] = "StderrStoreWindows.release(self)";
3668 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)};
3669 static PyObject *__pyx_pf_9csamtools_18StderrStoreWindows_release(PyObject *__pyx_self, PyObject *__pyx_v_self) {
3670   PyObject *__pyx_r = NULL;
3671   __Pyx_TraceDeclarations
3672   __Pyx_RefNannySetupContext("release");
3673   __Pyx_TraceCall("release", __pyx_f[0], 206);
3674   __pyx_self = __pyx_self;
3675
3676   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3677   __Pyx_XGIVEREF(__pyx_r);
3678   __Pyx_TraceReturn(__pyx_r);
3679   __Pyx_RefNannyFinishContext();
3680   return __pyx_r;
3681 }
3682
3683 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":260
3684  *     cdef faidx_t * fastafile
3685  * 
3686  *     def __cinit__(self, *args, **kwargs ):             # <<<<<<<<<<<<<<
3687  *         self.fastafile = NULL
3688  *         self._filename = NULL
3689  */
3690
3691 static int __pyx_pf_9csamtools_9Fastafile___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3692 static int __pyx_pf_9csamtools_9Fastafile___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3693   PyObject *__pyx_v_args = 0;
3694   PyObject *__pyx_v_kwargs = 0;
3695   int __pyx_r;
3696   PyObject *__pyx_t_1 = NULL;
3697   PyObject *__pyx_t_2 = NULL;
3698   PyObject *__pyx_t_3 = NULL;
3699   __Pyx_TraceDeclarations
3700   __Pyx_RefNannySetupContext("__cinit__");
3701   __Pyx_TraceCall("__cinit__", __pyx_f[0], 260);
3702   if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 1))) return -1;
3703   __pyx_v_kwargs = (__pyx_kwds) ? PyDict_Copy(__pyx_kwds) : PyDict_New();
3704   if (unlikely(!__pyx_v_kwargs)) return -1;
3705   __Pyx_GOTREF(__pyx_v_kwargs);
3706   __Pyx_INCREF(__pyx_args);
3707   __pyx_v_args = __pyx_args;
3708
3709   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":261
3710  * 
3711  *     def __cinit__(self, *args, **kwargs ):
3712  *         self.fastafile = NULL             # <<<<<<<<<<<<<<
3713  *         self._filename = NULL
3714  *         self._open( *args, **kwargs )
3715  */
3716   ((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile = NULL;
3717
3718   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":262
3719  *     def __cinit__(self, *args, **kwargs ):
3720  *         self.fastafile = NULL
3721  *         self._filename = NULL             # <<<<<<<<<<<<<<
3722  *         self._open( *args, **kwargs )
3723  * 
3724  */
3725   ((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->_filename = NULL;
3726
3727   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":263
3728  *         self.fastafile = NULL
3729  *         self._filename = NULL
3730  *         self._open( *args, **kwargs )             # <<<<<<<<<<<<<<
3731  * 
3732  *     def _isOpen( self ):
3733  */
3734   __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___open); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3735   __Pyx_GOTREF(__pyx_t_1);
3736   __pyx_t_2 = PySequence_Tuple(((PyObject *)__pyx_v_args)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3737   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
3738   __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 = 263; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3739   __Pyx_GOTREF(__pyx_t_3);
3740   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3741   __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
3742   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3743
3744   __pyx_r = 0;
3745   goto __pyx_L0;
3746   __pyx_L1_error:;
3747   __Pyx_XDECREF(__pyx_t_1);
3748   __Pyx_XDECREF(__pyx_t_2);
3749   __Pyx_XDECREF(__pyx_t_3);
3750   __Pyx_AddTraceback("csamtools.Fastafile.__cinit__");
3751   __pyx_r = -1;
3752   __pyx_L0:;
3753   __Pyx_DECREF(__pyx_v_args);
3754   __Pyx_DECREF(__pyx_v_kwargs);
3755   __Pyx_TraceReturn(Py_None);
3756   __Pyx_RefNannyFinishContext();
3757   return __pyx_r;
3758 }
3759
3760 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":265
3761  *         self._open( *args, **kwargs )
3762  * 
3763  *     def _isOpen( self ):             # <<<<<<<<<<<<<<
3764  *         '''return true if samfile has been opened.'''
3765  *         return self.fastafile != NULL
3766  */
3767
3768 static PyObject *__pyx_pf_9csamtools_9Fastafile__isOpen(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
3769 static char __pyx_doc_9csamtools_9Fastafile__isOpen[] = "Fastafile._isOpen(self)\nreturn true if samfile has been opened.";
3770 static PyObject *__pyx_pf_9csamtools_9Fastafile__isOpen(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
3771   PyObject *__pyx_r = NULL;
3772   PyObject *__pyx_t_1 = NULL;
3773   __Pyx_TraceDeclarations
3774   __Pyx_RefNannySetupContext("_isOpen");
3775   __Pyx_TraceCall("_isOpen", __pyx_f[0], 265);
3776
3777   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":267
3778  *     def _isOpen( self ):
3779  *         '''return true if samfile has been opened.'''
3780  *         return self.fastafile != NULL             # <<<<<<<<<<<<<<
3781  * 
3782  *     def __len__(self):
3783  */
3784   __Pyx_XDECREF(__pyx_r);
3785   __pyx_t_1 = __Pyx_PyBool_FromLong((((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile != NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3786   __Pyx_GOTREF(__pyx_t_1);
3787   __pyx_r = __pyx_t_1;
3788   __pyx_t_1 = 0;
3789   goto __pyx_L0;
3790
3791   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3792   goto __pyx_L0;
3793   __pyx_L1_error:;
3794   __Pyx_XDECREF(__pyx_t_1);
3795   __Pyx_AddTraceback("csamtools.Fastafile._isOpen");
3796   __pyx_r = NULL;
3797   __pyx_L0:;
3798   __Pyx_XGIVEREF(__pyx_r);
3799   __Pyx_TraceReturn(__pyx_r);
3800   __Pyx_RefNannyFinishContext();
3801   return __pyx_r;
3802 }
3803
3804 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":269
3805  *         return self.fastafile != NULL
3806  * 
3807  *     def __len__(self):             # <<<<<<<<<<<<<<
3808  *         if self.fastafile == NULL:
3809  *             raise ValueError( "calling len() on closed file" )
3810  */
3811
3812 static Py_ssize_t __pyx_pf_9csamtools_9Fastafile___len__(PyObject *__pyx_v_self); /*proto*/
3813 static Py_ssize_t __pyx_pf_9csamtools_9Fastafile___len__(PyObject *__pyx_v_self) {
3814   Py_ssize_t __pyx_r;
3815   int __pyx_t_1;
3816   PyObject *__pyx_t_2 = NULL;
3817   PyObject *__pyx_t_3 = NULL;
3818   __Pyx_TraceDeclarations
3819   __Pyx_RefNannySetupContext("__len__");
3820   __Pyx_TraceCall("__len__", __pyx_f[0], 269);
3821
3822   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":270
3823  * 
3824  *     def __len__(self):
3825  *         if self.fastafile == NULL:             # <<<<<<<<<<<<<<
3826  *             raise ValueError( "calling len() on closed file" )
3827  * 
3828  */
3829   __pyx_t_1 = (((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile == NULL);
3830   if (__pyx_t_1) {
3831
3832     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":271
3833  *     def __len__(self):
3834  *         if self.fastafile == NULL:
3835  *             raise ValueError( "calling len() on closed file" )             # <<<<<<<<<<<<<<
3836  * 
3837  *         return faidx_fetch_nseq(self.fastafile)
3838  */
3839     __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;}
3840     __Pyx_GOTREF(__pyx_t_2);
3841     __Pyx_INCREF(((PyObject *)__pyx_kp_s_3));
3842     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_3));
3843     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_3));
3844     __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;}
3845     __Pyx_GOTREF(__pyx_t_3);
3846     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3847     __Pyx_Raise(__pyx_t_3, 0, 0);
3848     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3849     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3850     goto __pyx_L5;
3851   }
3852   __pyx_L5:;
3853
3854   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":273
3855  *             raise ValueError( "calling len() on closed file" )
3856  * 
3857  *         return faidx_fetch_nseq(self.fastafile)             # <<<<<<<<<<<<<<
3858  * 
3859  *     def _open( self,
3860  */
3861   __pyx_r = faidx_fetch_nseq(((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile);
3862   goto __pyx_L0;
3863
3864   __pyx_r = 0;
3865   goto __pyx_L0;
3866   __pyx_L1_error:;
3867   __Pyx_XDECREF(__pyx_t_2);
3868   __Pyx_XDECREF(__pyx_t_3);
3869   __Pyx_AddTraceback("csamtools.Fastafile.__len__");
3870   __pyx_r = -1;
3871   __pyx_L0:;
3872   __Pyx_TraceReturn(Py_None);
3873   __Pyx_RefNannyFinishContext();
3874   return __pyx_r;
3875 }
3876
3877 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":275
3878  *         return faidx_fetch_nseq(self.fastafile)
3879  * 
3880  *     def _open( self,             # <<<<<<<<<<<<<<
3881  *                char * filename ):
3882  *         '''open an indexed fasta file.
3883  */
3884
3885 static PyObject *__pyx_pf_9csamtools_9Fastafile__open(PyObject *__pyx_v_self, PyObject *__pyx_arg_filename); /*proto*/
3886 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        ";
3887 static PyObject *__pyx_pf_9csamtools_9Fastafile__open(PyObject *__pyx_v_self, PyObject *__pyx_arg_filename) {
3888   char *__pyx_v_filename;
3889   PyObject *__pyx_r = NULL;
3890   int __pyx_t_1;
3891   PyObject *__pyx_t_2 = NULL;
3892   PyObject *__pyx_t_3 = NULL;
3893   __Pyx_TraceDeclarations
3894   __Pyx_RefNannySetupContext("_open");
3895   __Pyx_TraceCall("_open", __pyx_f[0], 275);
3896   assert(__pyx_arg_filename); {
3897     __pyx_v_filename = PyBytes_AsString(__pyx_arg_filename); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 276; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3898   }
3899   goto __pyx_L4_argument_unpacking_done;
3900   __pyx_L3_error:;
3901   __Pyx_AddTraceback("csamtools.Fastafile._open");
3902   __Pyx_RefNannyFinishContext();
3903   return NULL;
3904   __pyx_L4_argument_unpacking_done:;
3905
3906   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":283
3907  * 
3908  *         # close a previously opened file
3909  *         if self.fastafile != NULL: self.close()             # <<<<<<<<<<<<<<
3910  *         if self._filename != NULL: free(self._filename)
3911  *         self._filename = strdup(filename)
3912  */
3913   __pyx_t_1 = (((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile != NULL);
3914   if (__pyx_t_1) {
3915     __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__close); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3916     __Pyx_GOTREF(__pyx_t_2);
3917     __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 = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3918     __Pyx_GOTREF(__pyx_t_3);
3919     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3920     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3921     goto __pyx_L5;
3922   }
3923   __pyx_L5:;
3924
3925   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":284
3926  *         # close a previously opened file
3927  *         if self.fastafile != NULL: self.close()
3928  *         if self._filename != NULL: free(self._filename)             # <<<<<<<<<<<<<<
3929  *         self._filename = strdup(filename)
3930  *         self.fastafile = fai_load( filename )
3931  */
3932   __pyx_t_1 = (((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->_filename != NULL);
3933   if (__pyx_t_1) {
3934     free(((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->_filename);
3935     goto __pyx_L6;
3936   }
3937   __pyx_L6:;
3938
3939   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":285
3940  *         if self.fastafile != NULL: self.close()
3941  *         if self._filename != NULL: free(self._filename)
3942  *         self._filename = strdup(filename)             # <<<<<<<<<<<<<<
3943  *         self.fastafile = fai_load( filename )
3944  * 
3945  */
3946   ((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->_filename = strdup(__pyx_v_filename);
3947
3948   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":286
3949  *         if self._filename != NULL: free(self._filename)
3950  *         self._filename = strdup(filename)
3951  *         self.fastafile = fai_load( filename )             # <<<<<<<<<<<<<<
3952  * 
3953  *         if self.fastafile == NULL:
3954  */
3955   ((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile = fai_load(__pyx_v_filename);
3956
3957   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":288
3958  *         self.fastafile = fai_load( filename )
3959  * 
3960  *         if self.fastafile == NULL:             # <<<<<<<<<<<<<<
3961  *             raise IOError("could not open file `%s`" % filename )
3962  * 
3963  */
3964   __pyx_t_1 = (((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile == NULL);
3965   if (__pyx_t_1) {
3966
3967     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":289
3968  * 
3969  *         if self.fastafile == NULL:
3970  *             raise IOError("could not open file `%s`" % filename )             # <<<<<<<<<<<<<<
3971  * 
3972  *     def close( self ):
3973  */
3974     __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;}
3975     __Pyx_GOTREF(((PyObject *)__pyx_t_3));
3976     __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;}
3977     __Pyx_GOTREF(((PyObject *)__pyx_t_2));
3978     __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
3979     __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;}
3980     __Pyx_GOTREF(__pyx_t_3);
3981     PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
3982     __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
3983     __pyx_t_2 = 0;
3984     __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;}
3985     __Pyx_GOTREF(__pyx_t_2);
3986     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3987     __Pyx_Raise(__pyx_t_2, 0, 0);
3988     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3989     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3990     goto __pyx_L7;
3991   }
3992   __pyx_L7:;
3993
3994   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3995   goto __pyx_L0;
3996   __pyx_L1_error:;
3997   __Pyx_XDECREF(__pyx_t_2);
3998   __Pyx_XDECREF(__pyx_t_3);
3999   __Pyx_AddTraceback("csamtools.Fastafile._open");
4000   __pyx_r = NULL;
4001   __pyx_L0:;
4002   __Pyx_XGIVEREF(__pyx_r);
4003   __Pyx_TraceReturn(__pyx_r);
4004   __Pyx_RefNannyFinishContext();
4005   return __pyx_r;
4006 }
4007
4008 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":291
4009  *             raise IOError("could not open file `%s`" % filename )
4010  * 
4011  *     def close( self ):             # <<<<<<<<<<<<<<
4012  *         if self.fastafile != NULL:
4013  *             fai_destroy( self.fastafile )
4014  */
4015
4016 static PyObject *__pyx_pf_9csamtools_9Fastafile_close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
4017 static char __pyx_doc_9csamtools_9Fastafile_close[] = "Fastafile.close(self)";
4018 static PyObject *__pyx_pf_9csamtools_9Fastafile_close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
4019   PyObject *__pyx_r = NULL;
4020   int __pyx_t_1;
4021   __Pyx_TraceDeclarations
4022   __Pyx_RefNannySetupContext("close");
4023   __Pyx_TraceCall("close", __pyx_f[0], 291);
4024
4025   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":292
4026  * 
4027  *     def close( self ):
4028  *         if self.fastafile != NULL:             # <<<<<<<<<<<<<<
4029  *             fai_destroy( self.fastafile )
4030  *             self.fastafile = NULL
4031  */
4032   __pyx_t_1 = (((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile != NULL);
4033   if (__pyx_t_1) {
4034
4035     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":293
4036  *     def close( self ):
4037  *         if self.fastafile != NULL:
4038  *             fai_destroy( self.fastafile )             # <<<<<<<<<<<<<<
4039  *             self.fastafile = NULL
4040  * 
4041  */
4042     fai_destroy(((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile);
4043
4044     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":294
4045  *         if self.fastafile != NULL:
4046  *             fai_destroy( self.fastafile )
4047  *             self.fastafile = NULL             # <<<<<<<<<<<<<<
4048  * 
4049  *     def __dealloc__(self):
4050  */
4051     ((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile = NULL;
4052     goto __pyx_L5;
4053   }
4054   __pyx_L5:;
4055
4056   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
4057   __Pyx_XGIVEREF(__pyx_r);
4058   __Pyx_TraceReturn(__pyx_r);
4059   __Pyx_RefNannyFinishContext();
4060   return __pyx_r;
4061 }
4062
4063 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":296
4064  *             self.fastafile = NULL
4065  * 
4066  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
4067  *         self.close()
4068  *         if self._filename != NULL: free(self._filename)
4069  */
4070
4071 static void __pyx_pf_9csamtools_9Fastafile___dealloc__(PyObject *__pyx_v_self); /*proto*/
4072 static void __pyx_pf_9csamtools_9Fastafile___dealloc__(PyObject *__pyx_v_self) {
4073   PyObject *__pyx_t_1 = NULL;
4074   PyObject *__pyx_t_2 = NULL;
4075   int __pyx_t_3;
4076   __Pyx_TraceDeclarations
4077   __Pyx_RefNannySetupContext("__dealloc__");
4078   __Pyx_TraceCall("__dealloc__", __pyx_f[0], 296);
4079
4080   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":297
4081  * 
4082  *     def __dealloc__(self):
4083  *         self.close()             # <<<<<<<<<<<<<<
4084  *         if self._filename != NULL: free(self._filename)
4085  * 
4086  */
4087   __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__close); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4088   __Pyx_GOTREF(__pyx_t_1);
4089   __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 = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4090   __Pyx_GOTREF(__pyx_t_2);
4091   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4092   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4093
4094   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":298
4095  *     def __dealloc__(self):
4096  *         self.close()
4097  *         if self._filename != NULL: free(self._filename)             # <<<<<<<<<<<<<<
4098  * 
4099  *     property filename:
4100  */
4101   __pyx_t_3 = (((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->_filename != NULL);
4102   if (__pyx_t_3) {
4103     free(((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->_filename);
4104     goto __pyx_L5;
4105   }
4106   __pyx_L5:;
4107
4108   goto __pyx_L0;
4109   __pyx_L1_error:;
4110   __Pyx_XDECREF(__pyx_t_1);
4111   __Pyx_XDECREF(__pyx_t_2);
4112   __Pyx_AddTraceback("csamtools.Fastafile.__dealloc__");
4113   __pyx_L0:;
4114   __Pyx_TraceReturn(Py_None);
4115   __Pyx_RefNannyFinishContext();
4116 }
4117
4118 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":302
4119  *     property filename:
4120  *         '''number of :term:`filename` associated with this object.'''
4121  *         def __get__(self):             # <<<<<<<<<<<<<<
4122  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
4123  *             return self._filename
4124  */
4125
4126 static PyObject *__pyx_pf_9csamtools_9Fastafile_8filename___get__(PyObject *__pyx_v_self); /*proto*/
4127 static PyObject *__pyx_pf_9csamtools_9Fastafile_8filename___get__(PyObject *__pyx_v_self) {
4128   PyObject *__pyx_r = NULL;
4129   PyObject *__pyx_t_1 = NULL;
4130   PyObject *__pyx_t_2 = NULL;
4131   int __pyx_t_3;
4132   int __pyx_t_4;
4133   __Pyx_TraceDeclarations
4134   __Pyx_RefNannySetupContext("__get__");
4135   __Pyx_TraceCall("__get__", __pyx_f[0], 302);
4136
4137   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":303
4138  *         '''number of :term:`filename` associated with this object.'''
4139  *         def __get__(self):
4140  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
4141  *             return self._filename
4142  * 
4143  */
4144   __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4145   __Pyx_GOTREF(__pyx_t_1);
4146   __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 = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4147   __Pyx_GOTREF(__pyx_t_2);
4148   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4149   __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4150   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4151   __pyx_t_4 = (!__pyx_t_3);
4152   if (__pyx_t_4) {
4153     __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;}
4154     __Pyx_GOTREF(__pyx_t_2);
4155     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
4156     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
4157     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
4158     __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;}
4159     __Pyx_GOTREF(__pyx_t_1);
4160     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4161     __Pyx_Raise(__pyx_t_1, 0, 0);
4162     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4163     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4164     goto __pyx_L5;
4165   }
4166   __pyx_L5:;
4167
4168   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":304
4169  *         def __get__(self):
4170  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
4171  *             return self._filename             # <<<<<<<<<<<<<<
4172  * 
4173  *     def fetch( self,
4174  */
4175   __Pyx_XDECREF(__pyx_r);
4176   __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;}
4177   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
4178   __pyx_r = ((PyObject *)__pyx_t_1);
4179   __pyx_t_1 = 0;
4180   goto __pyx_L0;
4181
4182   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
4183   goto __pyx_L0;
4184   __pyx_L1_error:;
4185   __Pyx_XDECREF(__pyx_t_1);
4186   __Pyx_XDECREF(__pyx_t_2);
4187   __Pyx_AddTraceback("csamtools.Fastafile.filename.__get__");
4188   __pyx_r = NULL;
4189   __pyx_L0:;
4190   __Pyx_XGIVEREF(__pyx_r);
4191   __Pyx_TraceReturn(__pyx_r);
4192   __Pyx_RefNannyFinishContext();
4193   return __pyx_r;
4194 }
4195
4196 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":306
4197  *             return self._filename
4198  * 
4199  *     def fetch( self,             # <<<<<<<<<<<<<<
4200  *                reference = None,
4201  *                start = None,
4202  */
4203
4204 static PyObject *__pyx_pf_9csamtools_9Fastafile_fetch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
4205 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        ";
4206 static PyObject *__pyx_pf_9csamtools_9Fastafile_fetch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
4207   PyObject *__pyx_v_reference = 0;
4208   PyObject *__pyx_v_start = 0;
4209   PyObject *__pyx_v_end = 0;
4210   PyObject *__pyx_v_region = 0;
4211   int __pyx_v_length;
4212   char *__pyx_v_seq;
4213   PyObject *__pyx_v_py_seq;
4214   PyObject *__pyx_r = NULL;
4215   PyObject *__pyx_t_1 = NULL;
4216   PyObject *__pyx_t_2 = NULL;
4217   int __pyx_t_3;
4218   int __pyx_t_4;
4219   char *__pyx_t_5;
4220   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__reference,&__pyx_n_s__start,&__pyx_n_s__end,&__pyx_n_s__region,0};
4221   __Pyx_TraceDeclarations
4222   __Pyx_RefNannySetupContext("fetch");
4223   __Pyx_TraceCall("fetch", __pyx_f[0], 306);
4224   if (unlikely(__pyx_kwds)) {
4225     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
4226     PyObject* values[4] = {0,0,0,0};
4227
4228     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":307
4229  * 
4230  *     def fetch( self,
4231  *                reference = None,             # <<<<<<<<<<<<<<
4232  *                start = None,
4233  *                end = None,
4234  */
4235     values[0] = ((PyObject *)Py_None);
4236
4237     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":308
4238  *     def fetch( self,
4239  *                reference = None,
4240  *                start = None,             # <<<<<<<<<<<<<<
4241  *                end = None,
4242  *                region = None):
4243  */
4244     values[1] = ((PyObject *)Py_None);
4245
4246     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":309
4247  *                reference = None,
4248  *                start = None,
4249  *                end = None,             # <<<<<<<<<<<<<<
4250  *                region = None):
4251  * 
4252  */
4253     values[2] = ((PyObject *)Py_None);
4254
4255     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":310
4256  *                start = None,
4257  *                end = None,
4258  *                region = None):             # <<<<<<<<<<<<<<
4259  * 
4260  *         '''*(reference = None, start = None, end = None, region = None)*
4261  */
4262     values[3] = ((PyObject *)Py_None);
4263     switch (PyTuple_GET_SIZE(__pyx_args)) {
4264       case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
4265       case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
4266       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
4267       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4268       case  0: break;
4269       default: goto __pyx_L5_argtuple_error;
4270     }
4271     switch (PyTuple_GET_SIZE(__pyx_args)) {
4272       case  0:
4273       if (kw_args > 0) {
4274         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reference);
4275         if (value) { values[0] = value; kw_args--; }
4276       }
4277       case  1:
4278       if (kw_args > 0) {
4279         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start);
4280         if (value) { values[1] = value; kw_args--; }
4281       }
4282       case  2:
4283       if (kw_args > 0) {
4284         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end);
4285         if (value) { values[2] = value; kw_args--; }
4286       }
4287       case  3:
4288       if (kw_args > 0) {
4289         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__region);
4290         if (value) { values[3] = value; kw_args--; }
4291       }
4292     }
4293     if (unlikely(kw_args > 0)) {
4294       if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "fetch") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
4295     }
4296     __pyx_v_reference = values[0];
4297     __pyx_v_start = values[1];
4298     __pyx_v_end = values[2];
4299     __pyx_v_region = values[3];
4300   } else {
4301
4302     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":307
4303  * 
4304  *     def fetch( self,
4305  *                reference = None,             # <<<<<<<<<<<<<<
4306  *                start = None,
4307  *                end = None,
4308  */
4309     __pyx_v_reference = ((PyObject *)Py_None);
4310
4311     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":308
4312  *     def fetch( self,
4313  *                reference = None,
4314  *                start = None,             # <<<<<<<<<<<<<<
4315  *                end = None,
4316  *                region = None):
4317  */
4318     __pyx_v_start = ((PyObject *)Py_None);
4319
4320     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":309
4321  *                reference = None,
4322  *                start = None,
4323  *                end = None,             # <<<<<<<<<<<<<<
4324  *                region = None):
4325  * 
4326  */
4327     __pyx_v_end = ((PyObject *)Py_None);
4328
4329     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":310
4330  *                start = None,
4331  *                end = None,
4332  *                region = None):             # <<<<<<<<<<<<<<
4333  * 
4334  *         '''*(reference = None, start = None, end = None, region = None)*
4335  */
4336     __pyx_v_region = ((PyObject *)Py_None);
4337     switch (PyTuple_GET_SIZE(__pyx_args)) {
4338       case  4: __pyx_v_region = PyTuple_GET_ITEM(__pyx_args, 3);
4339       case  3: __pyx_v_end = PyTuple_GET_ITEM(__pyx_args, 2);
4340       case  2: __pyx_v_start = PyTuple_GET_ITEM(__pyx_args, 1);
4341       case  1: __pyx_v_reference = PyTuple_GET_ITEM(__pyx_args, 0);
4342       case  0: break;
4343       default: goto __pyx_L5_argtuple_error;
4344     }
4345   }
4346   goto __pyx_L4_argument_unpacking_done;
4347   __pyx_L5_argtuple_error:;
4348   __Pyx_RaiseArgtupleInvalid("fetch", 0, 0, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
4349   __pyx_L3_error:;
4350   __Pyx_AddTraceback("csamtools.Fastafile.fetch");
4351   __Pyx_RefNannyFinishContext();
4352   return NULL;
4353   __pyx_L4_argument_unpacking_done:;
4354   __Pyx_INCREF(__pyx_v_start);
4355   __Pyx_INCREF(__pyx_v_end);
4356   __Pyx_INCREF(__pyx_v_region);
4357   __pyx_v_py_seq = Py_None; __Pyx_INCREF(Py_None);
4358
4359   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":327
4360  *         '''
4361  * 
4362  *         if not self._isOpen():             # <<<<<<<<<<<<<<
4363  *             raise ValueError( "I/O operation on closed file" )
4364  * 
4365  */
4366   __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4367   __Pyx_GOTREF(__pyx_t_1);
4368   __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 = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4369   __Pyx_GOTREF(__pyx_t_2);
4370   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4371   __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4372   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4373   __pyx_t_4 = (!__pyx_t_3);
4374   if (__pyx_t_4) {
4375
4376     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":328
4377  * 
4378  *         if not self._isOpen():
4379  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
4380  * 
4381  *         cdef int length
4382  */
4383     __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;}
4384     __Pyx_GOTREF(__pyx_t_2);
4385     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
4386     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
4387     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
4388     __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;}
4389     __Pyx_GOTREF(__pyx_t_1);
4390     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4391     __Pyx_Raise(__pyx_t_1, 0, 0);
4392     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4393     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 328; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4394     goto __pyx_L6;
4395   }
4396   __pyx_L6:;
4397
4398   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":333
4399  *         cdef char * seq
4400  * 
4401  *         if not region:             # <<<<<<<<<<<<<<
4402  *             if reference is None: raise ValueError( 'no sequence/region supplied.' )
4403  *             if start is None: start = 0
4404  */
4405   __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_region); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4406   __pyx_t_3 = (!__pyx_t_4);
4407   if (__pyx_t_3) {
4408
4409     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":334
4410  * 
4411  *         if not region:
4412  *             if reference is None: raise ValueError( 'no sequence/region supplied.' )             # <<<<<<<<<<<<<<
4413  *             if start is None: start = 0
4414  *             if end is None: end = max_pos -1
4415  */
4416     __pyx_t_3 = (__pyx_v_reference == Py_None);
4417     if (__pyx_t_3) {
4418       __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;}
4419       __Pyx_GOTREF(__pyx_t_1);
4420       __Pyx_INCREF(((PyObject *)__pyx_kp_s_6));
4421       PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_6));
4422       __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_6));
4423       __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;}
4424       __Pyx_GOTREF(__pyx_t_2);
4425       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4426       __Pyx_Raise(__pyx_t_2, 0, 0);
4427       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4428       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4429       goto __pyx_L8;
4430     }
4431     __pyx_L8:;
4432
4433     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":335
4434  *         if not region:
4435  *             if reference is None: raise ValueError( 'no sequence/region supplied.' )
4436  *             if start is None: start = 0             # <<<<<<<<<<<<<<
4437  *             if end is None: end = max_pos -1
4438  * 
4439  */
4440     __pyx_t_3 = (__pyx_v_start == Py_None);
4441     if (__pyx_t_3) {
4442       __Pyx_INCREF(__pyx_int_0);
4443       __Pyx_DECREF(__pyx_v_start);
4444       __pyx_v_start = __pyx_int_0;
4445       goto __pyx_L9;
4446     }
4447     __pyx_L9:;
4448
4449     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":336
4450  *             if reference is None: raise ValueError( 'no sequence/region supplied.' )
4451  *             if start is None: start = 0
4452  *             if end is None: end = max_pos -1             # <<<<<<<<<<<<<<
4453  * 
4454  *             if start > end: raise ValueError( 'invalid region: start (%i) > end (%i)' % (start, end) )
4455  */
4456     __pyx_t_3 = (__pyx_v_end == Py_None);
4457     if (__pyx_t_3) {
4458       __pyx_t_2 = PyInt_FromLong((__pyx_v_9csamtools_max_pos - 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4459       __Pyx_GOTREF(__pyx_t_2);
4460       __Pyx_DECREF(__pyx_v_end);
4461       __pyx_v_end = __pyx_t_2;
4462       __pyx_t_2 = 0;
4463       goto __pyx_L10;
4464     }
4465     __pyx_L10:;
4466
4467     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":338
4468  *             if end is None: end = max_pos -1
4469  * 
4470  *             if start > end: raise ValueError( 'invalid region: start (%i) > end (%i)' % (start, end) )             # <<<<<<<<<<<<<<
4471  *             if start == end: return ""
4472  *             # valid ranges are from 0 to 2^29-1
4473  */
4474     __pyx_t_2 = PyObject_RichCompare(__pyx_v_start, __pyx_v_end, Py_GT); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4475     __Pyx_GOTREF(__pyx_t_2);
4476     __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4477     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4478     if (__pyx_t_3) {
4479       __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;}
4480       __Pyx_GOTREF(__pyx_t_2);
4481       __Pyx_INCREF(__pyx_v_start);
4482       PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_start);
4483       __Pyx_GIVEREF(__pyx_v_start);
4484       __Pyx_INCREF(__pyx_v_end);
4485       PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_end);
4486       __Pyx_GIVEREF(__pyx_v_end);
4487       __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;}
4488       __Pyx_GOTREF(((PyObject *)__pyx_t_1));
4489       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4490       __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;}
4491       __Pyx_GOTREF(__pyx_t_2);
4492       PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
4493       __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
4494       __pyx_t_1 = 0;
4495       __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;}
4496       __Pyx_GOTREF(__pyx_t_1);
4497       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4498       __Pyx_Raise(__pyx_t_1, 0, 0);
4499       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4500       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4501       goto __pyx_L11;
4502     }
4503     __pyx_L11:;
4504
4505     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":339
4506  * 
4507  *             if start > end: raise ValueError( 'invalid region: start (%i) > end (%i)' % (start, end) )
4508  *             if start == end: return ""             # <<<<<<<<<<<<<<
4509  *             # valid ranges are from 0 to 2^29-1
4510  *             if not 0 <= start < max_pos: raise ValueError( 'start out of range (%i)' % start )
4511  */
4512     __pyx_t_1 = PyObject_RichCompare(__pyx_v_start, __pyx_v_end, Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4513     __Pyx_GOTREF(__pyx_t_1);
4514     __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4515     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4516     if (__pyx_t_3) {
4517       __Pyx_XDECREF(__pyx_r);
4518       __Pyx_INCREF(((PyObject *)__pyx_kp_s_8));
4519       __pyx_r = ((PyObject *)__pyx_kp_s_8);
4520       goto __pyx_L0;
4521       goto __pyx_L12;
4522     }
4523     __pyx_L12:;
4524
4525     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":341
4526  *             if start == end: return ""
4527  *             # valid ranges are from 0 to 2^29-1
4528  *             if not 0 <= start < max_pos: raise ValueError( 'start out of range (%i)' % start )             # <<<<<<<<<<<<<<
4529  *             if not 0 <= end < max_pos: raise ValueError( 'end out of range (%i)' % end )
4530  *             # note: faidx_fetch_seq has a bug such that out-of-range access
4531  */
4532     __pyx_t_1 = PyObject_RichCompare(__pyx_int_0, __pyx_v_start, Py_LE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4533     __Pyx_GOTREF(__pyx_t_1);
4534     if (__Pyx_PyObject_IsTrue(__pyx_t_1)) {
4535       __Pyx_DECREF(__pyx_t_1);
4536       __pyx_t_2 = PyInt_FromLong(__pyx_v_9csamtools_max_pos); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4537       __Pyx_GOTREF(__pyx_t_2);
4538       __pyx_t_1 = PyObject_RichCompare(__pyx_v_start, __pyx_t_2, Py_LT); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4539       __Pyx_GOTREF(__pyx_t_1);
4540       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4541     }
4542     __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4543     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4544     __pyx_t_4 = (!__pyx_t_3);
4545     if (__pyx_t_4) {
4546       __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;}
4547       __Pyx_GOTREF(((PyObject *)__pyx_t_1));
4548       __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;}
4549       __Pyx_GOTREF(__pyx_t_2);
4550       PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
4551       __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
4552       __pyx_t_1 = 0;
4553       __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;}
4554       __Pyx_GOTREF(__pyx_t_1);
4555       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4556       __Pyx_Raise(__pyx_t_1, 0, 0);
4557       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4558       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4559       goto __pyx_L13;
4560     }
4561     __pyx_L13:;
4562
4563     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":342
4564  *             # valid ranges are from 0 to 2^29-1
4565  *             if not 0 <= start < max_pos: raise ValueError( 'start out of range (%i)' % start )
4566  *             if not 0 <= end < max_pos: raise ValueError( 'end out of range (%i)' % end )             # <<<<<<<<<<<<<<
4567  *             # note: faidx_fetch_seq has a bug such that out-of-range access
4568  *             # always returns the last residue. Hence do not use faidx_fetch_seq,
4569  */
4570     __pyx_t_1 = PyObject_RichCompare(__pyx_int_0, __pyx_v_end, Py_LE); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4571     __Pyx_GOTREF(__pyx_t_1);
4572     if (__Pyx_PyObject_IsTrue(__pyx_t_1)) {
4573       __Pyx_DECREF(__pyx_t_1);
4574       __pyx_t_2 = PyInt_FromLong(__pyx_v_9csamtools_max_pos); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4575       __Pyx_GOTREF(__pyx_t_2);
4576       __pyx_t_1 = PyObject_RichCompare(__pyx_v_end, __pyx_t_2, Py_LT); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4577       __Pyx_GOTREF(__pyx_t_1);
4578       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4579     }
4580     __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4581     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4582     __pyx_t_3 = (!__pyx_t_4);
4583     if (__pyx_t_3) {
4584       __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;}
4585       __Pyx_GOTREF(((PyObject *)__pyx_t_1));
4586       __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;}
4587       __Pyx_GOTREF(__pyx_t_2);
4588       PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
4589       __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
4590       __pyx_t_1 = 0;
4591       __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;}
4592       __Pyx_GOTREF(__pyx_t_1);
4593       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4594       __Pyx_Raise(__pyx_t_1, 0, 0);
4595       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4596       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4597       goto __pyx_L14;
4598     }
4599     __pyx_L14:;
4600
4601     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":351
4602  *             #                       end-1,
4603  *             #                       &length)
4604  *             region = "%s:%i-%i" % (reference, start+1, end)             # <<<<<<<<<<<<<<
4605  *             seq = fai_fetch( self.fastafile,
4606  *                              region,
4607  */
4608     __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;}
4609     __Pyx_GOTREF(__pyx_t_1);
4610     __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;}
4611     __Pyx_GOTREF(__pyx_t_2);
4612     __Pyx_INCREF(__pyx_v_reference);
4613     PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_reference);
4614     __Pyx_GIVEREF(__pyx_v_reference);
4615     PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
4616     __Pyx_GIVEREF(__pyx_t_1);
4617     __Pyx_INCREF(__pyx_v_end);
4618     PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_end);
4619     __Pyx_GIVEREF(__pyx_v_end);
4620     __pyx_t_1 = 0;
4621     __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;}
4622     __Pyx_GOTREF(((PyObject *)__pyx_t_1));
4623     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4624     __Pyx_DECREF(__pyx_v_region);
4625     __pyx_v_region = ((PyObject *)__pyx_t_1);
4626     __pyx_t_1 = 0;
4627
4628     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":353
4629  *             region = "%s:%i-%i" % (reference, start+1, end)
4630  *             seq = fai_fetch( self.fastafile,
4631  *                              region,             # <<<<<<<<<<<<<<
4632  *                              &length )
4633  *         else:
4634  */
4635     __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;}
4636
4637     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":354
4638  *             seq = fai_fetch( self.fastafile,
4639  *                              region,
4640  *                              &length )             # <<<<<<<<<<<<<<
4641  *         else:
4642  *             # samtools adds a '\0' at the end
4643  */
4644     __pyx_v_seq = fai_fetch(((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile, __pyx_t_5, (&__pyx_v_length));
4645     goto __pyx_L7;
4646   }
4647   /*else*/ {
4648
4649     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":357
4650  *         else:
4651  *             # samtools adds a '\0' at the end
4652  *             seq = fai_fetch( self.fastafile, region, &length )             # <<<<<<<<<<<<<<
4653  * 
4654  *         # copy to python
4655  */
4656     __pyx_t_5 = PyBytes_AsString(__pyx_v_region); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4657     __pyx_v_seq = fai_fetch(((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_self)->fastafile, __pyx_t_5, (&__pyx_v_length));
4658   }
4659   __pyx_L7:;
4660
4661   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":360
4662  * 
4663  *         # copy to python
4664  *         if seq == NULL:             # <<<<<<<<<<<<<<
4665  *             return ""
4666  *         else:
4667  */
4668   __pyx_t_3 = (__pyx_v_seq == NULL);
4669   if (__pyx_t_3) {
4670
4671     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":361
4672  *         # copy to python
4673  *         if seq == NULL:
4674  *             return ""             # <<<<<<<<<<<<<<
4675  *         else:
4676  *             try:
4677  */
4678     __Pyx_XDECREF(__pyx_r);
4679     __Pyx_INCREF(((PyObject *)__pyx_kp_s_8));
4680     __pyx_r = ((PyObject *)__pyx_kp_s_8);
4681     goto __pyx_L0;
4682     goto __pyx_L15;
4683   }
4684   /*else*/ {
4685
4686     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":363
4687  *             return ""
4688  *         else:
4689  *             try:             # <<<<<<<<<<<<<<
4690  *                 py_seq = PyString_FromStringAndSize(seq, length)
4691  *             finally:
4692  */
4693     /*try:*/ {
4694
4695       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":364
4696  *         else:
4697  *             try:
4698  *                 py_seq = PyString_FromStringAndSize(seq, length)             # <<<<<<<<<<<<<<
4699  *             finally:
4700  *                 free(seq)
4701  */
4702       __pyx_t_1 = PyString_FromStringAndSize(__pyx_v_seq, __pyx_v_length); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L17;}
4703       __Pyx_GOTREF(__pyx_t_1);
4704       __Pyx_DECREF(__pyx_v_py_seq);
4705       __pyx_v_py_seq = __pyx_t_1;
4706       __pyx_t_1 = 0;
4707     }
4708
4709     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":366
4710  *                 py_seq = PyString_FromStringAndSize(seq, length)
4711  *             finally:
4712  *                 free(seq)             # <<<<<<<<<<<<<<
4713  * 
4714  *         return py_seq
4715  */
4716     /*finally:*/ {
4717       int __pyx_why;
4718       PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
4719       int __pyx_exc_lineno;
4720       __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
4721       __pyx_why = 0; goto __pyx_L18;
4722       __pyx_L17: {
4723         __pyx_why = 4;
4724         __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
4725         __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
4726         __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
4727         __pyx_exc_lineno = __pyx_lineno;
4728         goto __pyx_L18;
4729       }
4730       __pyx_L18:;
4731       free(__pyx_v_seq);
4732       switch (__pyx_why) {
4733         case 4: {
4734           __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
4735           __pyx_lineno = __pyx_exc_lineno;
4736           __pyx_exc_type = 0;
4737           __pyx_exc_value = 0;
4738           __pyx_exc_tb = 0;
4739           goto __pyx_L1_error;
4740         }
4741       }
4742     }
4743   }
4744   __pyx_L15:;
4745
4746   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":368
4747  *                 free(seq)
4748  * 
4749  *         return py_seq             # <<<<<<<<<<<<<<
4750  * 
4751  *     cdef char * _fetch( self, char * reference, int start, int end, int * length ):
4752  */
4753   __Pyx_XDECREF(__pyx_r);
4754   __Pyx_INCREF(__pyx_v_py_seq);
4755   __pyx_r = __pyx_v_py_seq;
4756   goto __pyx_L0;
4757
4758   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
4759   goto __pyx_L0;
4760   __pyx_L1_error:;
4761   __Pyx_XDECREF(__pyx_t_1);
4762   __Pyx_XDECREF(__pyx_t_2);
4763   __Pyx_AddTraceback("csamtools.Fastafile.fetch");
4764   __pyx_r = NULL;
4765   __pyx_L0:;
4766   __Pyx_DECREF(__pyx_v_py_seq);
4767   __Pyx_DECREF(__pyx_v_start);
4768   __Pyx_DECREF(__pyx_v_end);
4769   __Pyx_DECREF(__pyx_v_region);
4770   __Pyx_XGIVEREF(__pyx_r);
4771   __Pyx_TraceReturn(__pyx_r);
4772   __Pyx_RefNannyFinishContext();
4773   return __pyx_r;
4774 }
4775
4776 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":370
4777  *         return py_seq
4778  * 
4779  *     cdef char * _fetch( self, char * reference, int start, int end, int * length ):             # <<<<<<<<<<<<<<
4780  *         '''fetch sequence for reference, start and end'''
4781  * 
4782  */
4783
4784 static  char *__pyx_f_9csamtools_9Fastafile__fetch(struct __pyx_obj_9csamtools_Fastafile *__pyx_v_self, char *__pyx_v_reference, int __pyx_v_start, int __pyx_v_end, int *__pyx_v_length) {
4785   char *__pyx_r;
4786   __Pyx_TraceDeclarations
4787   __Pyx_RefNannySetupContext("_fetch");
4788   __Pyx_TraceCall("_fetch", __pyx_f[0], 370);
4789
4790   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":377
4791  *                                start,
4792  *                                end-1,
4793  *                                length )             # <<<<<<<<<<<<<<
4794  * 
4795  * #------------------------------------------------------------------------
4796  */
4797   __pyx_r = faidx_fetch_seq(__pyx_v_self->fastafile, __pyx_v_reference, __pyx_v_start, (__pyx_v_end - 1), __pyx_v_length);
4798   goto __pyx_L0;
4799
4800   __pyx_r = 0;
4801   __pyx_L0:;
4802   __Pyx_TraceReturn(Py_None);
4803   __Pyx_RefNannyFinishContext();
4804   return __pyx_r;
4805 }
4806
4807 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":382
4808  * #------------------------------------------------------------------------
4809  * #------------------------------------------------------------------------
4810  * cdef int count_callback( bam1_t *alignment, void *f):             # <<<<<<<<<<<<<<
4811  *      '''callback for bam_fetch - count number of reads.
4812  *      '''
4813  */
4814
4815 static  int __pyx_f_9csamtools_count_callback(bam1_t *__pyx_v_alignment, void *__pyx_v_f) {
4816   int *__pyx_v_counter;
4817   int __pyx_r;
4818   __Pyx_TraceDeclarations
4819   __Pyx_RefNannySetupContext("count_callback");
4820   __Pyx_TraceCall("count_callback", __pyx_f[0], 382);
4821
4822   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":385
4823  *      '''callback for bam_fetch - count number of reads.
4824  *      '''
4825  *      cdef int* counter = (<int*>f)             # <<<<<<<<<<<<<<
4826  *      counter[0] += 1;
4827  * 
4828  */
4829   __pyx_v_counter = ((int *)__pyx_v_f);
4830
4831   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":386
4832  *      '''
4833  *      cdef int* counter = (<int*>f)
4834  *      counter[0] += 1;             # <<<<<<<<<<<<<<
4835  * 
4836  * ctypedef struct MateData:
4837  */
4838   (__pyx_v_counter[0]) += 1;
4839
4840   __pyx_r = 0;
4841   __Pyx_TraceReturn(Py_None);
4842   __Pyx_RefNannyFinishContext();
4843   return __pyx_r;
4844 }
4845
4846 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":396
4847  * #------------------------------------------------------------------------
4848  * #------------------------------------------------------------------------
4849  * cdef int mate_callback( bam1_t *alignment, void *f):             # <<<<<<<<<<<<<<
4850  *      '''callback for bam_fetch = filter mate
4851  *      '''
4852  */
4853
4854 static  int __pyx_f_9csamtools_mate_callback(bam1_t *__pyx_v_alignment, void *__pyx_v_f) {
4855   __pyx_t_9csamtools_MateData *__pyx_v_d;
4856   int __pyx_r;
4857   int __pyx_t_1;
4858   int __pyx_t_2;
4859   int __pyx_t_3;
4860   __Pyx_TraceDeclarations
4861   __Pyx_RefNannySetupContext("mate_callback");
4862   __Pyx_TraceCall("mate_callback", __pyx_f[0], 396);
4863
4864   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":399
4865  *      '''callback for bam_fetch = filter mate
4866  *      '''
4867  *      cdef MateData * d = (<MateData*>f)             # <<<<<<<<<<<<<<
4868  *      # printf("mate = %p, name1 = %s, name2=%s\t%i\t%i\t%i\n",
4869  *      #        d.mate, d.name, bam1_qname(alignment),
4870  */
4871   __pyx_v_d = ((__pyx_t_9csamtools_MateData *)__pyx_v_f);
4872
4873   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":404
4874  *      #        d.flag, alignment.core.flag, alignment.core.flag & d.flag)
4875  * 
4876  *      if d.mate == NULL:             # <<<<<<<<<<<<<<
4877  *          # could be sped up by comparing the lengths of query strings first
4878  *          # using l_qname
4879  */
4880   __pyx_t_1 = (__pyx_v_d->mate == NULL);
4881   if (__pyx_t_1) {
4882
4883     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":410
4884  *          # also, make sure that we get the other read by comparing
4885  *          # the flags
4886  *          if alignment.core.flag & d.flag != 0 and \             # <<<<<<<<<<<<<<
4887  *                  strcmp( bam1_qname( alignment ), d.name ) == 0:
4888  *              d.mate = bam_dup1( alignment )
4889  */
4890     __pyx_t_1 = ((__pyx_v_alignment->core.flag & __pyx_v_d->flag) != 0);
4891     if (__pyx_t_1) {
4892
4893       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":411
4894  *          # the flags
4895  *          if alignment.core.flag & d.flag != 0 and \
4896  *                  strcmp( bam1_qname( alignment ), d.name ) == 0:             # <<<<<<<<<<<<<<
4897  *              d.mate = bam_dup1( alignment )
4898  * 
4899  */
4900       __pyx_t_2 = (strcmp(bam1_qname(__pyx_v_alignment), __pyx_v_d->name) == 0);
4901       __pyx_t_3 = __pyx_t_2;
4902     } else {
4903       __pyx_t_3 = __pyx_t_1;
4904     }
4905     if (__pyx_t_3) {
4906
4907       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":412
4908  *          if alignment.core.flag & d.flag != 0 and \
4909  *                  strcmp( bam1_qname( alignment ), d.name ) == 0:
4910  *              d.mate = bam_dup1( alignment )             # <<<<<<<<<<<<<<
4911  * 
4912  * 
4913  */
4914       __pyx_v_d->mate = bam_dup1(__pyx_v_alignment);
4915       goto __pyx_L4;
4916     }
4917     __pyx_L4:;
4918     goto __pyx_L3;
4919   }
4920   __pyx_L3:;
4921
4922   __pyx_r = 0;
4923   __Pyx_TraceReturn(Py_None);
4924   __Pyx_RefNannyFinishContext();
4925   return __pyx_r;
4926 }
4927
4928 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":455
4929  *     '''
4930  * 
4931  *     def __cinit__(self, *args, **kwargs ):             # <<<<<<<<<<<<<<
4932  *         self.samfile = NULL
4933  *         self._filename = NULL
4934  */
4935
4936 static int __pyx_pf_9csamtools_7Samfile___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
4937 static int __pyx_pf_9csamtools_7Samfile___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
4938   PyObject *__pyx_v_args = 0;
4939   PyObject *__pyx_v_kwargs = 0;
4940   int __pyx_r;
4941   PyObject *__pyx_t_1 = NULL;
4942   PyObject *__pyx_t_2 = NULL;
4943   PyObject *__pyx_t_3 = NULL;
4944   __Pyx_TraceDeclarations
4945   __Pyx_RefNannySetupContext("__cinit__");
4946   __Pyx_TraceCall("__cinit__", __pyx_f[0], 455);
4947   if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 1))) return -1;
4948   __pyx_v_kwargs = (__pyx_kwds) ? PyDict_Copy(__pyx_kwds) : PyDict_New();
4949   if (unlikely(!__pyx_v_kwargs)) return -1;
4950   __Pyx_GOTREF(__pyx_v_kwargs);
4951   __Pyx_INCREF(__pyx_args);
4952   __pyx_v_args = __pyx_args;
4953
4954   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":456
4955  * 
4956  *     def __cinit__(self, *args, **kwargs ):
4957  *         self.samfile = NULL             # <<<<<<<<<<<<<<
4958  *         self._filename = NULL
4959  *         self.isbam = False
4960  */
4961   ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile = NULL;
4962
4963   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":457
4964  *     def __cinit__(self, *args, **kwargs ):
4965  *         self.samfile = NULL
4966  *         self._filename = NULL             # <<<<<<<<<<<<<<
4967  *         self.isbam = False
4968  *         self._open( *args, **kwargs )
4969  */
4970   ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->_filename = NULL;
4971
4972   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":458
4973  *         self.samfile = NULL
4974  *         self._filename = NULL
4975  *         self.isbam = False             # <<<<<<<<<<<<<<
4976  *         self._open( *args, **kwargs )
4977  * 
4978  */
4979   ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam = 0;
4980
4981   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":459
4982  *         self._filename = NULL
4983  *         self.isbam = False
4984  *         self._open( *args, **kwargs )             # <<<<<<<<<<<<<<
4985  * 
4986  *         # allocate memory for iterator
4987  */
4988   __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;}
4989   __Pyx_GOTREF(__pyx_t_1);
4990   __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;}
4991   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
4992   __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;}
4993   __Pyx_GOTREF(__pyx_t_3);
4994   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4995   __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
4996   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4997
4998   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":462
4999  * 
5000  *         # allocate memory for iterator
5001  *         self.b = <bam1_t*>calloc(1, sizeof(bam1_t))             # <<<<<<<<<<<<<<
5002  * 
5003  *     def _isOpen( self ):
5004  */
5005   ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->b = ((bam1_t *)calloc(1, (sizeof(bam1_t))));
5006
5007   __pyx_r = 0;
5008   goto __pyx_L0;
5009   __pyx_L1_error:;
5010   __Pyx_XDECREF(__pyx_t_1);
5011   __Pyx_XDECREF(__pyx_t_2);
5012   __Pyx_XDECREF(__pyx_t_3);
5013   __Pyx_AddTraceback("csamtools.Samfile.__cinit__");
5014   __pyx_r = -1;
5015   __pyx_L0:;
5016   __Pyx_DECREF(__pyx_v_args);
5017   __Pyx_DECREF(__pyx_v_kwargs);
5018   __Pyx_TraceReturn(Py_None);
5019   __Pyx_RefNannyFinishContext();
5020   return __pyx_r;
5021 }
5022
5023 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":464
5024  *         self.b = <bam1_t*>calloc(1, sizeof(bam1_t))
5025  * 
5026  *     def _isOpen( self ):             # <<<<<<<<<<<<<<
5027  *         '''return true if samfile has been opened.'''
5028  *         return self.samfile != NULL
5029  */
5030
5031 static PyObject *__pyx_pf_9csamtools_7Samfile__isOpen(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
5032 static char __pyx_doc_9csamtools_7Samfile__isOpen[] = "Samfile._isOpen(self)\nreturn true if samfile has been opened.";
5033 static PyObject *__pyx_pf_9csamtools_7Samfile__isOpen(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
5034   PyObject *__pyx_r = NULL;
5035   PyObject *__pyx_t_1 = NULL;
5036   __Pyx_TraceDeclarations
5037   __Pyx_RefNannySetupContext("_isOpen");
5038   __Pyx_TraceCall("_isOpen", __pyx_f[0], 464);
5039
5040   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":466
5041  *     def _isOpen( self ):
5042  *         '''return true if samfile has been opened.'''
5043  *         return self.samfile != NULL             # <<<<<<<<<<<<<<
5044  * 
5045  *     def _hasIndex( self ):
5046  */
5047   __Pyx_XDECREF(__pyx_r);
5048   __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;}
5049   __Pyx_GOTREF(__pyx_t_1);
5050   __pyx_r = __pyx_t_1;
5051   __pyx_t_1 = 0;
5052   goto __pyx_L0;
5053
5054   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5055   goto __pyx_L0;
5056   __pyx_L1_error:;
5057   __Pyx_XDECREF(__pyx_t_1);
5058   __Pyx_AddTraceback("csamtools.Samfile._isOpen");
5059   __pyx_r = NULL;
5060   __pyx_L0:;
5061   __Pyx_XGIVEREF(__pyx_r);
5062   __Pyx_TraceReturn(__pyx_r);
5063   __Pyx_RefNannyFinishContext();
5064   return __pyx_r;
5065 }
5066
5067 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":468
5068  *         return self.samfile != NULL
5069  * 
5070  *     def _hasIndex( self ):             # <<<<<<<<<<<<<<
5071  *         '''return true if samfile has an existing (and opened) index.'''
5072  *         return self.index != NULL
5073  */
5074
5075 static PyObject *__pyx_pf_9csamtools_7Samfile__hasIndex(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
5076 static char __pyx_doc_9csamtools_7Samfile__hasIndex[] = "Samfile._hasIndex(self)\nreturn true if samfile has an existing (and opened) index.";
5077 static PyObject *__pyx_pf_9csamtools_7Samfile__hasIndex(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
5078   PyObject *__pyx_r = NULL;
5079   PyObject *__pyx_t_1 = NULL;
5080   __Pyx_TraceDeclarations
5081   __Pyx_RefNannySetupContext("_hasIndex");
5082   __Pyx_TraceCall("_hasIndex", __pyx_f[0], 468);
5083
5084   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":470
5085  *     def _hasIndex( self ):
5086  *         '''return true if samfile has an existing (and opened) index.'''
5087  *         return self.index != NULL             # <<<<<<<<<<<<<<
5088  * 
5089  *     def _open( self,
5090  */
5091   __Pyx_XDECREF(__pyx_r);
5092   __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;}
5093   __Pyx_GOTREF(__pyx_t_1);
5094   __pyx_r = __pyx_t_1;
5095   __pyx_t_1 = 0;
5096   goto __pyx_L0;
5097
5098   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5099   goto __pyx_L0;
5100   __pyx_L1_error:;
5101   __Pyx_XDECREF(__pyx_t_1);
5102   __Pyx_AddTraceback("csamtools.Samfile._hasIndex");
5103   __pyx_r = NULL;
5104   __pyx_L0:;
5105   __Pyx_XGIVEREF(__pyx_r);
5106   __Pyx_TraceReturn(__pyx_r);
5107   __Pyx_RefNannyFinishContext();
5108   return __pyx_r;
5109 }
5110
5111 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":472
5112  *         return self.index != NULL
5113  * 
5114  *     def _open( self,             # <<<<<<<<<<<<<<
5115  *                char * filename,
5116  *                mode = None,
5117  */
5118
5119 static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
5120 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        ";
5121 static PyObject *__pyx_pf_9csamtools_7Samfile__open(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
5122   char *__pyx_v_filename;
5123   PyObject *__pyx_v_mode = 0;
5124   struct __pyx_obj_9csamtools_Samfile *__pyx_v_template = 0;
5125   PyObject *__pyx_v_referencenames = 0;
5126   PyObject *__pyx_v_referencelengths = 0;
5127   PyObject *__pyx_v_text = 0;
5128   PyObject *__pyx_v_header = 0;
5129   PyObject *__pyx_v_port = 0;
5130   PyObject *__pyx_v_msg;
5131   bam_header_t *__pyx_v_header_to_write;
5132   char *__pyx_v_ctext;
5133   PyObject *__pyx_v_n;
5134   PyObject *__pyx_v_x;
5135   PyObject *__pyx_v_name;
5136   PyObject *__pyx_v_store;
5137   PyObject *__pyx_r = NULL;
5138   int __pyx_t_1;
5139   PyObject *__pyx_t_2 = NULL;
5140   PyObject *__pyx_t_3 = NULL;
5141   PyObject *__pyx_t_4 = NULL;
5142   PyObject *__pyx_t_5 = NULL;
5143   int __pyx_t_6;
5144   int __pyx_t_7;
5145   int __pyx_t_8;
5146   Py_ssize_t __pyx_t_9;
5147   Py_ssize_t __pyx_t_10;
5148   size_t __pyx_t_11;
5149   int32_t __pyx_t_12;
5150   long __pyx_t_13;
5151   uint32_t __pyx_t_14;
5152   char *__pyx_t_15;
5153   int __pyx_t_16;
5154   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};
5155   __Pyx_TraceDeclarations
5156   __Pyx_RefNannySetupContext("_open");
5157   __Pyx_TraceCall("_open", __pyx_f[0], 472);
5158   if (unlikely(__pyx_kwds)) {
5159     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
5160     PyObject* values[8] = {0,0,0,0,0,0,0,0};
5161
5162     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":474
5163  *     def _open( self,
5164  *                char * filename,
5165  *                mode = None,             # <<<<<<<<<<<<<<
5166  *                Samfile template = None,
5167  *                referencenames = None,
5168  */
5169     values[1] = ((PyObject *)Py_None);
5170
5171     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":475
5172  *                char * filename,
5173  *                mode = None,
5174  *                Samfile template = None,             # <<<<<<<<<<<<<<
5175  *                referencenames = None,
5176  *                referencelengths = None,
5177  */
5178     values[2] = (PyObject *)((struct __pyx_obj_9csamtools_Samfile *)Py_None);
5179
5180     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":476
5181  *                mode = None,
5182  *                Samfile template = None,
5183  *                referencenames = None,             # <<<<<<<<<<<<<<
5184  *                referencelengths = None,
5185  *                text = None,
5186  */
5187     values[3] = ((PyObject *)Py_None);
5188
5189     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":477
5190  *                Samfile template = None,
5191  *                referencenames = None,
5192  *                referencelengths = None,             # <<<<<<<<<<<<<<
5193  *                text = None,
5194  *                header = None,
5195  */
5196     values[4] = ((PyObject *)Py_None);
5197
5198     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":478
5199  *                referencenames = None,
5200  *                referencelengths = None,
5201  *                text = None,             # <<<<<<<<<<<<<<
5202  *                header = None,
5203  *                port = None,
5204  */
5205     values[5] = ((PyObject *)Py_None);
5206
5207     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":479
5208  *                referencelengths = None,
5209  *                text = None,
5210  *                header = None,             # <<<<<<<<<<<<<<
5211  *                port = None,
5212  *               ):
5213  */
5214     values[6] = ((PyObject *)Py_None);
5215
5216     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":480
5217  *                text = None,
5218  *                header = None,
5219  *                port = None,             # <<<<<<<<<<<<<<
5220  *               ):
5221  *         '''open a sam/bam file.
5222  */
5223     values[7] = ((PyObject *)Py_None);
5224     switch (PyTuple_GET_SIZE(__pyx_args)) {
5225       case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
5226       case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
5227       case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
5228       case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
5229       case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
5230       case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
5231       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5232       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5233       case  0: break;
5234       default: goto __pyx_L5_argtuple_error;
5235     }
5236     switch (PyTuple_GET_SIZE(__pyx_args)) {
5237       case  0:
5238       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filename);
5239       if (likely(values[0])) kw_args--;
5240       else goto __pyx_L5_argtuple_error;
5241       case  1:
5242       if (kw_args > 0) {
5243         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__mode);
5244         if (value) { values[1] = value; kw_args--; }
5245       }
5246       case  2:
5247       if (kw_args > 0) {
5248         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__template);
5249         if (value) { values[2] = value; kw_args--; }
5250       }
5251       case  3:
5252       if (kw_args > 0) {
5253         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__referencenames);
5254         if (value) { values[3] = value; kw_args--; }
5255       }
5256       case  4:
5257       if (kw_args > 0) {
5258         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__referencelengths);
5259         if (value) { values[4] = value; kw_args--; }
5260       }
5261       case  5:
5262       if (kw_args > 0) {
5263         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__text);
5264         if (value) { values[5] = value; kw_args--; }
5265       }
5266       case  6:
5267       if (kw_args > 0) {
5268         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__header);
5269         if (value) { values[6] = value; kw_args--; }
5270       }
5271       case  7:
5272       if (kw_args > 0) {
5273         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__port);
5274         if (value) { values[7] = value; kw_args--; }
5275       }
5276     }
5277     if (unlikely(kw_args > 0)) {
5278       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;}
5279     }
5280     __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;}
5281     __pyx_v_mode = values[1];
5282     __pyx_v_template = ((struct __pyx_obj_9csamtools_Samfile *)values[2]);
5283     __pyx_v_referencenames = values[3];
5284     __pyx_v_referencelengths = values[4];
5285     __pyx_v_text = values[5];
5286     __pyx_v_header = values[6];
5287     __pyx_v_port = values[7];
5288   } else {
5289
5290     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":474
5291  *     def _open( self,
5292  *                char * filename,
5293  *                mode = None,             # <<<<<<<<<<<<<<
5294  *                Samfile template = None,
5295  *                referencenames = None,
5296  */
5297     __pyx_v_mode = ((PyObject *)Py_None);
5298
5299     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":475
5300  *                char * filename,
5301  *                mode = None,
5302  *                Samfile template = None,             # <<<<<<<<<<<<<<
5303  *                referencenames = None,
5304  *                referencelengths = None,
5305  */
5306     __pyx_v_template = ((struct __pyx_obj_9csamtools_Samfile *)Py_None);
5307
5308     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":476
5309  *                mode = None,
5310  *                Samfile template = None,
5311  *                referencenames = None,             # <<<<<<<<<<<<<<
5312  *                referencelengths = None,
5313  *                text = None,
5314  */
5315     __pyx_v_referencenames = ((PyObject *)Py_None);
5316
5317     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":477
5318  *                Samfile template = None,
5319  *                referencenames = None,
5320  *                referencelengths = None,             # <<<<<<<<<<<<<<
5321  *                text = None,
5322  *                header = None,
5323  */
5324     __pyx_v_referencelengths = ((PyObject *)Py_None);
5325
5326     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":478
5327  *                referencenames = None,
5328  *                referencelengths = None,
5329  *                text = None,             # <<<<<<<<<<<<<<
5330  *                header = None,
5331  *                port = None,
5332  */
5333     __pyx_v_text = ((PyObject *)Py_None);
5334
5335     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":479
5336  *                referencelengths = None,
5337  *                text = None,
5338  *                header = None,             # <<<<<<<<<<<<<<
5339  *                port = None,
5340  *               ):
5341  */
5342     __pyx_v_header = ((PyObject *)Py_None);
5343
5344     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":480
5345  *                text = None,
5346  *                header = None,
5347  *                port = None,             # <<<<<<<<<<<<<<
5348  *               ):
5349  *         '''open a sam/bam file.
5350  */
5351     __pyx_v_port = ((PyObject *)Py_None);
5352     switch (PyTuple_GET_SIZE(__pyx_args)) {
5353       case  8: __pyx_v_port = PyTuple_GET_ITEM(__pyx_args, 7);
5354       case  7: __pyx_v_header = PyTuple_GET_ITEM(__pyx_args, 6);
5355       case  6: __pyx_v_text = PyTuple_GET_ITEM(__pyx_args, 5);
5356       case  5: __pyx_v_referencelengths = PyTuple_GET_ITEM(__pyx_args, 4);
5357       case  4: __pyx_v_referencenames = PyTuple_GET_ITEM(__pyx_args, 3);
5358       case  3: __pyx_v_template = ((struct __pyx_obj_9csamtools_Samfile *)PyTuple_GET_ITEM(__pyx_args, 2));
5359       case  2: __pyx_v_mode = PyTuple_GET_ITEM(__pyx_args, 1);
5360       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;}
5361       break;
5362       default: goto __pyx_L5_argtuple_error;
5363     }
5364   }
5365   goto __pyx_L4_argument_unpacking_done;
5366   __pyx_L5_argtuple_error:;
5367   __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;}
5368   __pyx_L3_error:;
5369   __Pyx_AddTraceback("csamtools.Samfile._open");
5370   __Pyx_RefNannyFinishContext();
5371   return NULL;
5372   __pyx_L4_argument_unpacking_done:;
5373   __pyx_v_msg = Py_None; __Pyx_INCREF(Py_None);
5374   __pyx_v_n = Py_None; __Pyx_INCREF(Py_None);
5375   __pyx_v_x = Py_None; __Pyx_INCREF(Py_None);
5376   __pyx_v_name = Py_None; __Pyx_INCREF(Py_None);
5377   __pyx_v_store = Py_None; __Pyx_INCREF(Py_None);
5378   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;}
5379
5380   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":489
5381  * 
5382  *         # read mode autodetection
5383  *         if mode is None:             # <<<<<<<<<<<<<<
5384  *             try:
5385  *                 self._open(filename, 'r', template=template,
5386  */
5387   __pyx_t_1 = (__pyx_v_mode == Py_None);
5388   if (__pyx_t_1) {
5389
5390     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":490
5391  *         # read mode autodetection
5392  *         if mode is None:
5393  *             try:             # <<<<<<<<<<<<<<
5394  *                 self._open(filename, 'r', template=template,
5395  *                            referencenames=referencenames,
5396  */
5397     {
5398       PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
5399       __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
5400       __Pyx_XGOTREF(__pyx_save_exc_type);
5401       __Pyx_XGOTREF(__pyx_save_exc_value);
5402       __Pyx_XGOTREF(__pyx_save_exc_tb);
5403       /*try:*/ {
5404
5405         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":491
5406  *         if mode is None:
5407  *             try:
5408  *                 self._open(filename, 'r', template=template,             # <<<<<<<<<<<<<<
5409  *                            referencenames=referencenames,
5410  *                            referencelengths=referencelengths,
5411  */
5412         __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;}
5413         __Pyx_GOTREF(__pyx_t_2);
5414         __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;}
5415         __Pyx_GOTREF(((PyObject *)__pyx_t_3));
5416         __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;}
5417         __Pyx_GOTREF(__pyx_t_4);
5418         PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3));
5419         __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
5420         __Pyx_INCREF(((PyObject *)__pyx_n_s__r));
5421         PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_n_s__r));
5422         __Pyx_GIVEREF(((PyObject *)__pyx_n_s__r));
5423         __pyx_t_3 = 0;
5424         __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;}
5425         __Pyx_GOTREF(((PyObject *)__pyx_t_3));
5426         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;}
5427
5428         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":492
5429  *             try:
5430  *                 self._open(filename, 'r', template=template,
5431  *                            referencenames=referencenames,             # <<<<<<<<<<<<<<
5432  *                            referencelengths=referencelengths,
5433  *                            text=text, header=header, port=port)
5434  */
5435         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;}
5436
5437         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":493
5438  *                 self._open(filename, 'r', template=template,
5439  *                            referencenames=referencenames,
5440  *                            referencelengths=referencelengths,             # <<<<<<<<<<<<<<
5441  *                            text=text, header=header, port=port)
5442  *                 return
5443  */
5444         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;}
5445
5446         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":494
5447  *                            referencenames=referencenames,
5448  *                            referencelengths=referencelengths,
5449  *                            text=text, header=header, port=port)             # <<<<<<<<<<<<<<
5450  *                 return
5451  *             except ValueError, msg:
5452  */
5453         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;}
5454         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;}
5455         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;}
5456         __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;}
5457         __Pyx_GOTREF(__pyx_t_5);
5458         __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5459         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5460         __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
5461         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5462
5463         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":495
5464  *                            referencelengths=referencelengths,
5465  *                            text=text, header=header, port=port)
5466  *                 return             # <<<<<<<<<<<<<<
5467  *             except ValueError, msg:
5468  *                 pass
5469  */
5470         __Pyx_XDECREF(__pyx_r);
5471         __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5472         goto __pyx_L11_try_return;
5473       }
5474       __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
5475       __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
5476       __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
5477       goto __pyx_L14_try_end;
5478       __pyx_L11_try_return:;
5479       __Pyx_XGIVEREF(__pyx_save_exc_type);
5480       __Pyx_XGIVEREF(__pyx_save_exc_value);
5481       __Pyx_XGIVEREF(__pyx_save_exc_tb);
5482       __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
5483       goto __pyx_L0;
5484       __pyx_L7_error:;
5485       __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
5486       __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
5487       __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
5488       __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
5489
5490       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":496
5491  *                            text=text, header=header, port=port)
5492  *                 return
5493  *             except ValueError, msg:             # <<<<<<<<<<<<<<
5494  *                 pass
5495  *             self._open(filename, 'rb', template=template,
5496  */
5497       __pyx_t_6 = PyErr_ExceptionMatches(__pyx_builtin_ValueError);
5498       if (__pyx_t_6) {
5499         __Pyx_AddTraceback("csamtools.Samfile._open");
5500         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;}
5501         __Pyx_GOTREF(__pyx_t_5);
5502         __Pyx_GOTREF(__pyx_t_3);
5503         __Pyx_GOTREF(__pyx_t_4);
5504         __Pyx_INCREF(__pyx_t_3);
5505         __Pyx_DECREF(__pyx_v_msg);
5506         __pyx_v_msg = __pyx_t_3;
5507         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5508         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5509         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5510         goto __pyx_L8_exception_handled;
5511       }
5512       __pyx_L9_except_error:;
5513       __Pyx_XGIVEREF(__pyx_save_exc_type);
5514       __Pyx_XGIVEREF(__pyx_save_exc_value);
5515       __Pyx_XGIVEREF(__pyx_save_exc_tb);
5516       __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
5517       goto __pyx_L1_error;
5518       __pyx_L8_exception_handled:;
5519       __Pyx_XGIVEREF(__pyx_save_exc_type);
5520       __Pyx_XGIVEREF(__pyx_save_exc_value);
5521       __Pyx_XGIVEREF(__pyx_save_exc_tb);
5522       __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
5523       __pyx_L14_try_end:;
5524     }
5525
5526     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":498
5527  *             except ValueError, msg:
5528  *                 pass
5529  *             self._open(filename, 'rb', template=template,             # <<<<<<<<<<<<<<
5530  *                        referencenames=referencenames,
5531  *                        referencelengths=referencelengths,
5532  */
5533     __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;}
5534     __Pyx_GOTREF(__pyx_t_4);
5535     __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;}
5536     __Pyx_GOTREF(((PyObject *)__pyx_t_3));
5537     __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;}
5538     __Pyx_GOTREF(__pyx_t_5);
5539     PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_3));
5540     __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
5541     __Pyx_INCREF(((PyObject *)__pyx_n_s__rb));
5542     PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)__pyx_n_s__rb));
5543     __Pyx_GIVEREF(((PyObject *)__pyx_n_s__rb));
5544     __pyx_t_3 = 0;
5545     __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;}
5546     __Pyx_GOTREF(((PyObject *)__pyx_t_3));
5547     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;}
5548
5549     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":499
5550  *                 pass
5551  *             self._open(filename, 'rb', template=template,
5552  *                        referencenames=referencenames,             # <<<<<<<<<<<<<<
5553  *                        referencelengths=referencelengths,
5554  *                        text=text, header=header, port=port)
5555  */
5556     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;}
5557
5558     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":500
5559  *             self._open(filename, 'rb', template=template,
5560  *                        referencenames=referencenames,
5561  *                        referencelengths=referencelengths,             # <<<<<<<<<<<<<<
5562  *                        text=text, header=header, port=port)
5563  *             return
5564  */
5565     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;}
5566
5567     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":501
5568  *                        referencenames=referencenames,
5569  *                        referencelengths=referencelengths,
5570  *                        text=text, header=header, port=port)             # <<<<<<<<<<<<<<
5571  *             return
5572  * 
5573  */
5574     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;}
5575     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;}
5576     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;}
5577     __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;}
5578     __Pyx_GOTREF(__pyx_t_2);
5579     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5580     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
5581     __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
5582     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5583
5584     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":502
5585  *                        referencelengths=referencelengths,
5586  *                        text=text, header=header, port=port)
5587  *             return             # <<<<<<<<<<<<<<
5588  * 
5589  *         assert mode in ( "r","w","rb","wb", "wh", "wbu" ), "invalid file opening mode `%s`" % mode
5590  */
5591     __Pyx_XDECREF(__pyx_r);
5592     __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5593     goto __pyx_L0;
5594     goto __pyx_L6;
5595   }
5596   __pyx_L6:;
5597
5598   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":504
5599  *             return
5600  * 
5601  *         assert mode in ( "r","w","rb","wb", "wh", "wbu" ), "invalid file opening mode `%s`" % mode             # <<<<<<<<<<<<<<
5602  *         assert filename != NULL
5603  * 
5604  */
5605   #ifndef PYREX_WITHOUT_ASSERTIONS
5606   __Pyx_INCREF(__pyx_v_mode);
5607   __pyx_t_2 = __pyx_v_mode;
5608   __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;}
5609   __Pyx_GOTREF(__pyx_t_3);
5610   __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;}
5611   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5612   __pyx_t_7 = __pyx_t_1;
5613   if (!__pyx_t_7) {
5614     __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;}
5615     __Pyx_GOTREF(__pyx_t_3);
5616     __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;}
5617     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5618     __pyx_t_8 = __pyx_t_1;
5619     __pyx_t_1 = __pyx_t_8;
5620   } else {
5621     __pyx_t_1 = __pyx_t_7;
5622   }
5623   if (!__pyx_t_1) {
5624     __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;}
5625     __Pyx_GOTREF(__pyx_t_3);
5626     __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;}
5627     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5628     __pyx_t_8 = __pyx_t_7;
5629     __pyx_t_7 = __pyx_t_8;
5630   } else {
5631     __pyx_t_7 = __pyx_t_1;
5632   }
5633   if (!__pyx_t_7) {
5634     __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;}
5635     __Pyx_GOTREF(__pyx_t_3);
5636     __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;}
5637     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5638     __pyx_t_8 = __pyx_t_1;
5639     __pyx_t_1 = __pyx_t_8;
5640   } else {
5641     __pyx_t_1 = __pyx_t_7;
5642   }
5643   if (!__pyx_t_1) {
5644     __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;}
5645     __Pyx_GOTREF(__pyx_t_3);
5646     __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;}
5647     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5648     __pyx_t_8 = __pyx_t_7;
5649     __pyx_t_7 = __pyx_t_8;
5650   } else {
5651     __pyx_t_7 = __pyx_t_1;
5652   }
5653   if (!__pyx_t_7) {
5654     __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;}
5655     __Pyx_GOTREF(__pyx_t_3);
5656     __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;}
5657     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5658     __pyx_t_8 = __pyx_t_1;
5659     __pyx_t_1 = __pyx_t_8;
5660   } else {
5661     __pyx_t_1 = __pyx_t_7;
5662   }
5663   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5664   if (unlikely(!__pyx_t_1)) {
5665     __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;}
5666     __Pyx_GOTREF(((PyObject *)__pyx_t_2));
5667     PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_t_2));
5668     __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
5669     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5670   }
5671   #endif
5672
5673   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":505
5674  * 
5675  *         assert mode in ( "r","w","rb","wb", "wh", "wbu" ), "invalid file opening mode `%s`" % mode
5676  *         assert filename != NULL             # <<<<<<<<<<<<<<
5677  * 
5678  *         # close a previously opened file
5679  */
5680   #ifndef PYREX_WITHOUT_ASSERTIONS
5681   if (unlikely(!(__pyx_v_filename != NULL))) {
5682     PyErr_SetNone(PyExc_AssertionError);
5683     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5684   }
5685   #endif
5686
5687   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":508
5688  * 
5689  *         # close a previously opened file
5690  *         if self.samfile != NULL: self.close()             # <<<<<<<<<<<<<<
5691  *         self.samfile = NULL
5692  * 
5693  */
5694   __pyx_t_1 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile != NULL);
5695   if (__pyx_t_1) {
5696     __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;}
5697     __Pyx_GOTREF(__pyx_t_2);
5698     __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;}
5699     __Pyx_GOTREF(__pyx_t_3);
5700     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5701     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5702     goto __pyx_L17;
5703   }
5704   __pyx_L17:;
5705
5706   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":509
5707  *         # close a previously opened file
5708  *         if self.samfile != NULL: self.close()
5709  *         self.samfile = NULL             # <<<<<<<<<<<<<<
5710  * 
5711  *         cdef bam_header_t * header_to_write
5712  */
5713   ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile = NULL;
5714
5715   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":512
5716  * 
5717  *         cdef bam_header_t * header_to_write
5718  *         header_to_write = NULL             # <<<<<<<<<<<<<<
5719  * 
5720  *         if self._filename != NULL: free(self._filename )
5721  */
5722   __pyx_v_header_to_write = NULL;
5723
5724   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":514
5725  *         header_to_write = NULL
5726  * 
5727  *         if self._filename != NULL: free(self._filename )             # <<<<<<<<<<<<<<
5728  *         self._filename = strdup( filename )
5729  * 
5730  */
5731   __pyx_t_1 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->_filename != NULL);
5732   if (__pyx_t_1) {
5733     free(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->_filename);
5734     goto __pyx_L18;
5735   }
5736   __pyx_L18:;
5737
5738   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":515
5739  * 
5740  *         if self._filename != NULL: free(self._filename )
5741  *         self._filename = strdup( filename )             # <<<<<<<<<<<<<<
5742  * 
5743  *         self.isbam = len(mode) > 1 and mode[1] == 'b'
5744  */
5745   ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->_filename = strdup(__pyx_v_filename);
5746
5747   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":517
5748  *         self._filename = strdup( filename )
5749  * 
5750  *         self.isbam = len(mode) > 1 and mode[1] == 'b'             # <<<<<<<<<<<<<<
5751  * 
5752  *         self.isremote = strncmp(filename,"http:",5) == 0 or \
5753  */
5754   __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;}
5755   __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;}
5756   __Pyx_GOTREF(__pyx_t_3);
5757   __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;}
5758   if (__pyx_t_1) {
5759     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5760     __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;}
5761     __Pyx_GOTREF(__pyx_t_2);
5762     __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;}
5763     __Pyx_GOTREF(__pyx_t_5);
5764     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5765     __pyx_t_2 = __pyx_t_5;
5766     __pyx_t_5 = 0;
5767   } else {
5768     __pyx_t_2 = __pyx_t_3;
5769     __pyx_t_3 = 0;
5770   }
5771   __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;}
5772   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5773   ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam = __pyx_t_6;
5774
5775   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":519
5776  *         self.isbam = len(mode) > 1 and mode[1] == 'b'
5777  * 
5778  *         self.isremote = strncmp(filename,"http:",5) == 0 or \             # <<<<<<<<<<<<<<
5779  *             strncmp(filename,"ftp:",4) == 0
5780  * 
5781  */
5782   __pyx_t_1 = (strncmp(__pyx_v_filename, __pyx_k_13, 5) == 0);
5783   if (!__pyx_t_1) {
5784
5785     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":520
5786  * 
5787  *         self.isremote = strncmp(filename,"http:",5) == 0 or \
5788  *             strncmp(filename,"ftp:",4) == 0             # <<<<<<<<<<<<<<
5789  * 
5790  *         cdef char * ctext
5791  */
5792     __pyx_t_7 = (strncmp(__pyx_v_filename, __pyx_k_14, 4) == 0);
5793     __pyx_t_8 = __pyx_t_7;
5794   } else {
5795     __pyx_t_8 = __pyx_t_1;
5796   }
5797
5798   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":519
5799  *         self.isbam = len(mode) > 1 and mode[1] == 'b'
5800  * 
5801  *         self.isremote = strncmp(filename,"http:",5) == 0 or \             # <<<<<<<<<<<<<<
5802  *             strncmp(filename,"ftp:",4) == 0
5803  * 
5804  */
5805   ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isremote = __pyx_t_8;
5806
5807   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":523
5808  * 
5809  *         cdef char * ctext
5810  *         ctext = NULL             # <<<<<<<<<<<<<<
5811  * 
5812  *         if mode[0] == 'w':
5813  */
5814   __pyx_v_ctext = NULL;
5815
5816   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":525
5817  *         ctext = NULL
5818  * 
5819  *         if mode[0] == 'w':             # <<<<<<<<<<<<<<
5820  *             # open file for writing
5821  * 
5822  */
5823   __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;}
5824   __Pyx_GOTREF(__pyx_t_2);
5825   __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;}
5826   __Pyx_GOTREF(__pyx_t_3);
5827   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5828   __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;}
5829   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5830   if (__pyx_t_8) {
5831
5832     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":529
5833  * 
5834  *             # header structure (used for writing)
5835  *             if template:             # <<<<<<<<<<<<<<
5836  *                 # copy header from another file
5837  *                 header_to_write = template.samfile.header
5838  */
5839     __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;}
5840     if (__pyx_t_8) {
5841
5842       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":531
5843  *             if template:
5844  *                 # copy header from another file
5845  *                 header_to_write = template.samfile.header             # <<<<<<<<<<<<<<
5846  * 
5847  *             elif header:
5848  */
5849       __pyx_v_header_to_write = __pyx_v_template->samfile->header;
5850       goto __pyx_L20;
5851     }
5852
5853     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":533
5854  *                 header_to_write = template.samfile.header
5855  * 
5856  *             elif header:             # <<<<<<<<<<<<<<
5857  *                 header_to_write = self._buildHeader( header )
5858  * 
5859  */
5860     __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;}
5861     if (__pyx_t_8) {
5862
5863       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":534
5864  * 
5865  *             elif header:
5866  *                 header_to_write = self._buildHeader( header )             # <<<<<<<<<<<<<<
5867  * 
5868  *             else:
5869  */
5870       __pyx_v_header_to_write = ((struct __pyx_vtabstruct_9csamtools_Samfile *)((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->__pyx_vtab)->_buildHeader(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self), __pyx_v_header);
5871       goto __pyx_L20;
5872     }
5873     /*else*/ {
5874
5875       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":538
5876  *             else:
5877  *                 # build header from a target names and lengths
5878  *                 assert referencenames and referencelengths, "either supply options `template`, `header` or  both `referencenames` and `referencelengths` for writing"             # <<<<<<<<<<<<<<
5879  *                 assert len(referencenames) == len(referencelengths), "unequal names and lengths of reference sequences"
5880  * 
5881  */
5882       #ifndef PYREX_WITHOUT_ASSERTIONS
5883       __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;}
5884       if (__pyx_t_8) {
5885         __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;}
5886         __pyx_t_7 = __pyx_t_1;
5887       } else {
5888         __pyx_t_7 = __pyx_t_8;
5889       }
5890       if (unlikely(!__pyx_t_7)) {
5891         PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_15));
5892         {__pyx_filename = __pyx_f[0]; __pyx_lineno = 538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5893       }
5894       #endif
5895
5896       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":539
5897  *                 # build header from a target names and lengths
5898  *                 assert referencenames and referencelengths, "either supply options `template`, `header` or  both `referencenames` and `referencelengths` for writing"
5899  *                 assert len(referencenames) == len(referencelengths), "unequal names and lengths of reference sequences"             # <<<<<<<<<<<<<<
5900  * 
5901  *                 # allocate and fill header
5902  */
5903       #ifndef PYREX_WITHOUT_ASSERTIONS
5904       __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;}
5905       __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;}
5906       if (unlikely(!(__pyx_t_9 == __pyx_t_10))) {
5907         PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_16));
5908         {__pyx_filename = __pyx_f[0]; __pyx_lineno = 539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5909       }
5910       #endif
5911
5912       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":542
5913  * 
5914  *                 # allocate and fill header
5915  *                 header_to_write = bam_header_init()             # <<<<<<<<<<<<<<
5916  *                 header_to_write.n_targets = len(referencenames)
5917  *                 n = 0
5918  */
5919       __pyx_v_header_to_write = bam_header_init();
5920
5921       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":543
5922  *                 # allocate and fill header
5923  *                 header_to_write = bam_header_init()
5924  *                 header_to_write.n_targets = len(referencenames)             # <<<<<<<<<<<<<<
5925  *                 n = 0
5926  *                 for x in referencenames: n += len(x) + 1
5927  */
5928       __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;}
5929       __pyx_v_header_to_write->n_targets = __pyx_t_10;
5930
5931       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":544
5932  *                 header_to_write = bam_header_init()
5933  *                 header_to_write.n_targets = len(referencenames)
5934  *                 n = 0             # <<<<<<<<<<<<<<
5935  *                 for x in referencenames: n += len(x) + 1
5936  *                 header_to_write.target_name = <char**>calloc(n, sizeof(char*))
5937  */
5938       __Pyx_INCREF(__pyx_int_0);
5939       __Pyx_DECREF(__pyx_v_n);
5940       __pyx_v_n = __pyx_int_0;
5941
5942       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":545
5943  *                 header_to_write.n_targets = len(referencenames)
5944  *                 n = 0
5945  *                 for x in referencenames: n += len(x) + 1             # <<<<<<<<<<<<<<
5946  *                 header_to_write.target_name = <char**>calloc(n, sizeof(char*))
5947  *                 header_to_write.target_len = <uint32_t*>calloc(n, sizeof(uint32_t))
5948  */
5949       if (PyList_CheckExact(__pyx_v_referencenames) || PyTuple_CheckExact(__pyx_v_referencenames)) {
5950         __pyx_t_10 = 0; __pyx_t_3 = __pyx_v_referencenames; __Pyx_INCREF(__pyx_t_3);
5951       } else {
5952         __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;}
5953         __Pyx_GOTREF(__pyx_t_3);
5954       }
5955       for (;;) {
5956         if (likely(PyList_CheckExact(__pyx_t_3))) {
5957           if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_3)) break;
5958           __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_10); __Pyx_INCREF(__pyx_t_2); __pyx_t_10++;
5959         } else if (likely(PyTuple_CheckExact(__pyx_t_3))) {
5960           if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
5961           __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_10); __Pyx_INCREF(__pyx_t_2); __pyx_t_10++;
5962         } else {
5963           __pyx_t_2 = PyIter_Next(__pyx_t_3);
5964           if (!__pyx_t_2) {
5965             if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5966             break;
5967           }
5968           __Pyx_GOTREF(__pyx_t_2);
5969         }
5970         __Pyx_DECREF(__pyx_v_x);
5971         __pyx_v_x = __pyx_t_2;
5972         __pyx_t_2 = 0;
5973         __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;}
5974         __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;}
5975         __Pyx_GOTREF(__pyx_t_2);
5976         __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;}
5977         __Pyx_GOTREF(__pyx_t_5);
5978         __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5979         __Pyx_DECREF(__pyx_v_n);
5980         __pyx_v_n = __pyx_t_5;
5981         __pyx_t_5 = 0;
5982       }
5983       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5984
5985       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":546
5986  *                 n = 0
5987  *                 for x in referencenames: n += len(x) + 1
5988  *                 header_to_write.target_name = <char**>calloc(n, sizeof(char*))             # <<<<<<<<<<<<<<
5989  *                 header_to_write.target_len = <uint32_t*>calloc(n, sizeof(uint32_t))
5990  *                 for x from 0 <= x < header_to_write.n_targets:
5991  */
5992       __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;}
5993       __pyx_v_header_to_write->target_name = ((char **)calloc(__pyx_t_11, (sizeof(char *))));
5994
5995       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":547
5996  *                 for x in referencenames: n += len(x) + 1
5997  *                 header_to_write.target_name = <char**>calloc(n, sizeof(char*))
5998  *                 header_to_write.target_len = <uint32_t*>calloc(n, sizeof(uint32_t))             # <<<<<<<<<<<<<<
5999  *                 for x from 0 <= x < header_to_write.n_targets:
6000  *                     header_to_write.target_len[x] = referencelengths[x]
6001  */
6002       __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;}
6003       __pyx_v_header_to_write->target_len = ((uint32_t *)calloc(__pyx_t_11, (sizeof(uint32_t))));
6004
6005       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":548
6006  *                 header_to_write.target_name = <char**>calloc(n, sizeof(char*))
6007  *                 header_to_write.target_len = <uint32_t*>calloc(n, sizeof(uint32_t))
6008  *                 for x from 0 <= x < header_to_write.n_targets:             # <<<<<<<<<<<<<<
6009  *                     header_to_write.target_len[x] = referencelengths[x]
6010  *                     name = referencenames[x]
6011  */
6012       __pyx_t_12 = __pyx_v_header_to_write->n_targets;
6013       for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_12; __pyx_t_13++) {
6014         __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;}
6015         __Pyx_GOTREF(__pyx_t_3);
6016         __Pyx_DECREF(__pyx_v_x);
6017         __pyx_v_x = __pyx_t_3;
6018         __pyx_t_3 = 0;
6019
6020         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":549
6021  *                 header_to_write.target_len = <uint32_t*>calloc(n, sizeof(uint32_t))
6022  *                 for x from 0 <= x < header_to_write.n_targets:
6023  *                     header_to_write.target_len[x] = referencelengths[x]             # <<<<<<<<<<<<<<
6024  *                     name = referencenames[x]
6025  *                     header_to_write.target_name[x] = <char*>calloc(len(name)+1, sizeof(char))
6026  */
6027         __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;}
6028         __Pyx_GOTREF(__pyx_t_3);
6029         __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;}
6030         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6031         __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;}
6032         (__pyx_v_header_to_write->target_len[__pyx_t_10]) = __pyx_t_14;
6033
6034         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":550
6035  *                 for x from 0 <= x < header_to_write.n_targets:
6036  *                     header_to_write.target_len[x] = referencelengths[x]
6037  *                     name = referencenames[x]             # <<<<<<<<<<<<<<
6038  *                     header_to_write.target_name[x] = <char*>calloc(len(name)+1, sizeof(char))
6039  *                     strncpy( header_to_write.target_name[x], name, len(name) )
6040  */
6041         __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;}
6042         __Pyx_GOTREF(__pyx_t_3);
6043         __Pyx_DECREF(__pyx_v_name);
6044         __pyx_v_name = __pyx_t_3;
6045         __pyx_t_3 = 0;
6046
6047         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":551
6048  *                     header_to_write.target_len[x] = referencelengths[x]
6049  *                     name = referencenames[x]
6050  *                     header_to_write.target_name[x] = <char*>calloc(len(name)+1, sizeof(char))             # <<<<<<<<<<<<<<
6051  *                     strncpy( header_to_write.target_name[x], name, len(name) )
6052  * 
6053  */
6054         __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;}
6055         __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;}
6056         (__pyx_v_header_to_write->target_name[__pyx_t_9]) = ((char *)calloc((__pyx_t_10 + 1), (sizeof(char))));
6057
6058         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":552
6059  *                     name = referencenames[x]
6060  *                     header_to_write.target_name[x] = <char*>calloc(len(name)+1, sizeof(char))
6061  *                     strncpy( header_to_write.target_name[x], name, len(name) )             # <<<<<<<<<<<<<<
6062  * 
6063  *                 if text != None:
6064  */
6065         __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;}
6066         __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;}
6067         __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;}
6068         strncpy((__pyx_v_header_to_write->target_name[__pyx_t_10]), __pyx_t_15, __pyx_t_9);
6069         __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;}
6070       }
6071
6072       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":548
6073  *                 header_to_write.target_name = <char**>calloc(n, sizeof(char*))
6074  *                 header_to_write.target_len = <uint32_t*>calloc(n, sizeof(uint32_t))
6075  *                 for x from 0 <= x < header_to_write.n_targets:             # <<<<<<<<<<<<<<
6076  *                     header_to_write.target_len[x] = referencelengths[x]
6077  *                     name = referencenames[x]
6078  */
6079       __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;}
6080       __Pyx_GOTREF(__pyx_t_3);
6081       __Pyx_DECREF(__pyx_v_x);
6082       __pyx_v_x = __pyx_t_3;
6083       __pyx_t_3 = 0;
6084
6085       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":554
6086  *                     strncpy( header_to_write.target_name[x], name, len(name) )
6087  * 
6088  *                 if text != None:             # <<<<<<<<<<<<<<
6089  *                     # copy without \0
6090  *                     ctext = text
6091  */
6092       __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;}
6093       __Pyx_GOTREF(__pyx_t_3);
6094       __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;}
6095       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6096       if (__pyx_t_7) {
6097
6098         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":556
6099  *                 if text != None:
6100  *                     # copy without \0
6101  *                     ctext = text             # <<<<<<<<<<<<<<
6102  *                     header_to_write.l_text = strlen(ctext)
6103  *                     header_to_write.text = <char*>calloc( strlen(ctext), sizeof(char) )
6104  */
6105         __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;}
6106         __pyx_v_ctext = __pyx_t_15;
6107
6108         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":557
6109  *                     # copy without \0
6110  *                     ctext = text
6111  *                     header_to_write.l_text = strlen(ctext)             # <<<<<<<<<<<<<<
6112  *                     header_to_write.text = <char*>calloc( strlen(ctext), sizeof(char) )
6113  *                     memcpy( header_to_write.text, ctext, strlen(ctext) )
6114  */
6115         __pyx_v_header_to_write->l_text = strlen(__pyx_v_ctext);
6116
6117         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":558
6118  *                     ctext = text
6119  *                     header_to_write.l_text = strlen(ctext)
6120  *                     header_to_write.text = <char*>calloc( strlen(ctext), sizeof(char) )             # <<<<<<<<<<<<<<
6121  *                     memcpy( header_to_write.text, ctext, strlen(ctext) )
6122  * 
6123  */
6124         __pyx_v_header_to_write->text = ((char *)calloc(strlen(__pyx_v_ctext), (sizeof(char))));
6125
6126         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":559
6127  *                     header_to_write.l_text = strlen(ctext)
6128  *                     header_to_write.text = <char*>calloc( strlen(ctext), sizeof(char) )
6129  *                     memcpy( header_to_write.text, ctext, strlen(ctext) )             # <<<<<<<<<<<<<<
6130  * 
6131  *                 header_to_write.hash = NULL
6132  */
6133         memcpy(__pyx_v_header_to_write->text, __pyx_v_ctext, strlen(__pyx_v_ctext));
6134         goto __pyx_L25;
6135       }
6136       __pyx_L25:;
6137
6138       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":561
6139  *                     memcpy( header_to_write.text, ctext, strlen(ctext) )
6140  * 
6141  *                 header_to_write.hash = NULL             # <<<<<<<<<<<<<<
6142  *                 header_to_write.rg2lib = NULL
6143  * 
6144  */
6145       __pyx_v_header_to_write->hash = NULL;
6146
6147       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":562
6148  * 
6149  *                 header_to_write.hash = NULL
6150  *                 header_to_write.rg2lib = NULL             # <<<<<<<<<<<<<<
6151  * 
6152  *             # open file. Header gets written to file at the same time for bam files
6153  */
6154       __pyx_v_header_to_write->rg2lib = NULL;
6155     }
6156     __pyx_L20:;
6157
6158     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":566
6159  *             # open file. Header gets written to file at the same time for bam files
6160  *             # and sam files (in the latter case, the mode needs to be wh)
6161  *             store = StderrStore()             # <<<<<<<<<<<<<<
6162  *             self.samfile = samopen( filename, mode, header_to_write )
6163  *             store.release()
6164  */
6165     __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;}
6166     __Pyx_GOTREF(__pyx_t_3);
6167     __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;}
6168     __Pyx_GOTREF(__pyx_t_5);
6169     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6170     __Pyx_DECREF(__pyx_v_store);
6171     __pyx_v_store = __pyx_t_5;
6172     __pyx_t_5 = 0;
6173
6174     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":567
6175  *             # and sam files (in the latter case, the mode needs to be wh)
6176  *             store = StderrStore()
6177  *             self.samfile = samopen( filename, mode, header_to_write )             # <<<<<<<<<<<<<<
6178  *             store.release()
6179  * 
6180  */
6181     __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;}
6182     ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile = samopen(__pyx_v_filename, __pyx_t_15, __pyx_v_header_to_write);
6183
6184     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":568
6185  *             store = StderrStore()
6186  *             self.samfile = samopen( filename, mode, header_to_write )
6187  *             store.release()             # <<<<<<<<<<<<<<
6188  * 
6189  *             # bam_header_destroy takes care of cleaning up of all the members
6190  */
6191     __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;}
6192     __Pyx_GOTREF(__pyx_t_5);
6193     __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;}
6194     __Pyx_GOTREF(__pyx_t_3);
6195     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6196     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6197
6198     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":571
6199  * 
6200  *             # bam_header_destroy takes care of cleaning up of all the members
6201  *             if not template and header_to_write != NULL:             # <<<<<<<<<<<<<<
6202  *                 bam_header_destroy( header_to_write )
6203  * 
6204  */
6205     __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;}
6206     __pyx_t_8 = (!__pyx_t_7);
6207     if (__pyx_t_8) {
6208       __pyx_t_7 = (__pyx_v_header_to_write != NULL);
6209       __pyx_t_1 = __pyx_t_7;
6210     } else {
6211       __pyx_t_1 = __pyx_t_8;
6212     }
6213     if (__pyx_t_1) {
6214
6215       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":572
6216  *             # bam_header_destroy takes care of cleaning up of all the members
6217  *             if not template and header_to_write != NULL:
6218  *                 bam_header_destroy( header_to_write )             # <<<<<<<<<<<<<<
6219  * 
6220  *         elif mode[0] == "r":
6221  */
6222       bam_header_destroy(__pyx_v_header_to_write);
6223       goto __pyx_L26;
6224     }
6225     __pyx_L26:;
6226     goto __pyx_L19;
6227   }
6228
6229   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":574
6230  *                 bam_header_destroy( header_to_write )
6231  * 
6232  *         elif mode[0] == "r":             # <<<<<<<<<<<<<<
6233  *             # open file for reading
6234  *             if strncmp( filename, "-", 1) != 0 and \
6235  */
6236   __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;}
6237   __Pyx_GOTREF(__pyx_t_3);
6238   __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;}
6239   __Pyx_GOTREF(__pyx_t_5);
6240   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6241   __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;}
6242   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6243   if (__pyx_t_1) {
6244
6245     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":576
6246  *         elif mode[0] == "r":
6247  *             # open file for reading
6248  *             if strncmp( filename, "-", 1) != 0 and \             # <<<<<<<<<<<<<<
6249  *                     not self.isremote and \
6250  *                     not os.path.exists( filename ):
6251  */
6252     __pyx_t_1 = (strncmp(__pyx_v_filename, __pyx_k_17, 1) != 0);
6253     if (__pyx_t_1) {
6254
6255       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":577
6256  *             # open file for reading
6257  *             if strncmp( filename, "-", 1) != 0 and \
6258  *                     not self.isremote and \             # <<<<<<<<<<<<<<
6259  *                     not os.path.exists( filename ):
6260  *                 raise IOError( "file `%s` not found" % filename)
6261  */
6262       __pyx_t_8 = (!((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isremote);
6263       if (__pyx_t_8) {
6264
6265         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":578
6266  *             if strncmp( filename, "-", 1) != 0 and \
6267  *                     not self.isremote and \
6268  *                     not os.path.exists( filename ):             # <<<<<<<<<<<<<<
6269  *                 raise IOError( "file `%s` not found" % filename)
6270  * 
6271  */
6272         __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;}
6273         __Pyx_GOTREF(__pyx_t_5);
6274         __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;}
6275         __Pyx_GOTREF(__pyx_t_3);
6276         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6277         __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;}
6278         __Pyx_GOTREF(__pyx_t_5);
6279         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6280         __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;}
6281         __Pyx_GOTREF(((PyObject *)__pyx_t_3));
6282         __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;}
6283         __Pyx_GOTREF(__pyx_t_2);
6284         PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_3));
6285         __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
6286         __pyx_t_3 = 0;
6287         __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;}
6288         __Pyx_GOTREF(__pyx_t_3);
6289         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6290         __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6291         __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;}
6292         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6293         __pyx_t_16 = (!__pyx_t_7);
6294         __pyx_t_7 = __pyx_t_16;
6295       } else {
6296         __pyx_t_7 = __pyx_t_8;
6297       }
6298       __pyx_t_8 = __pyx_t_7;
6299     } else {
6300       __pyx_t_8 = __pyx_t_1;
6301     }
6302     if (__pyx_t_8) {
6303
6304       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":579
6305  *                     not self.isremote and \
6306  *                     not os.path.exists( filename ):
6307  *                 raise IOError( "file `%s` not found" % filename)             # <<<<<<<<<<<<<<
6308  * 
6309  *             # try to detect errors
6310  */
6311       __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;}
6312       __Pyx_GOTREF(((PyObject *)__pyx_t_3));
6313       __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;}
6314       __Pyx_GOTREF(((PyObject *)__pyx_t_2));
6315       __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
6316       __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;}
6317       __Pyx_GOTREF(__pyx_t_3);
6318       PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
6319       __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
6320       __pyx_t_2 = 0;
6321       __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;}
6322       __Pyx_GOTREF(__pyx_t_2);
6323       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6324       __Pyx_Raise(__pyx_t_2, 0, 0);
6325       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6326       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 579; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6327       goto __pyx_L27;
6328     }
6329     __pyx_L27:;
6330
6331     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":582
6332  * 
6333  *             # try to detect errors
6334  *             self.samfile = samopen( filename, mode, NULL )             # <<<<<<<<<<<<<<
6335  *             if self.samfile == NULL:
6336  *                 raise ValueError( "could not open file (mode='%s') - is it SAM/BAM format?" % mode)
6337  */
6338     __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;}
6339     ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile = samopen(__pyx_v_filename, __pyx_t_15, NULL);
6340
6341     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":583
6342  *             # try to detect errors
6343  *             self.samfile = samopen( filename, mode, NULL )
6344  *             if self.samfile == NULL:             # <<<<<<<<<<<<<<
6345  *                 raise ValueError( "could not open file (mode='%s') - is it SAM/BAM format?" % mode)
6346  * 
6347  */
6348     __pyx_t_8 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile == NULL);
6349     if (__pyx_t_8) {
6350
6351       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":584
6352  *             self.samfile = samopen( filename, mode, NULL )
6353  *             if self.samfile == NULL:
6354  *                 raise ValueError( "could not open file (mode='%s') - is it SAM/BAM format?" % mode)             # <<<<<<<<<<<<<<
6355  * 
6356  *             if self.samfile.header == NULL:
6357  */
6358       __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;}
6359       __Pyx_GOTREF(((PyObject *)__pyx_t_2));
6360       __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;}
6361       __Pyx_GOTREF(__pyx_t_3);
6362       PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
6363       __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
6364       __pyx_t_2 = 0;
6365       __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;}
6366       __Pyx_GOTREF(__pyx_t_2);
6367       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6368       __Pyx_Raise(__pyx_t_2, 0, 0);
6369       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6370       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 584; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6371       goto __pyx_L28;
6372     }
6373     __pyx_L28:;
6374
6375     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":586
6376  *                 raise ValueError( "could not open file (mode='%s') - is it SAM/BAM format?" % mode)
6377  * 
6378  *             if self.samfile.header == NULL:             # <<<<<<<<<<<<<<
6379  *                 raise ValueError( "file does not have valid header (mode='%s') - is it SAM/BAM format?" % mode )
6380  * 
6381  */
6382     __pyx_t_8 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header == NULL);
6383     if (__pyx_t_8) {
6384
6385       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":587
6386  * 
6387  *             if self.samfile.header == NULL:
6388  *                 raise ValueError( "file does not have valid header (mode='%s') - is it SAM/BAM format?" % mode )             # <<<<<<<<<<<<<<
6389  * 
6390  *             #disabled for autodetection to work
6391  */
6392       __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;}
6393       __Pyx_GOTREF(((PyObject *)__pyx_t_2));
6394       __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;}
6395       __Pyx_GOTREF(__pyx_t_3);
6396       PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
6397       __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
6398       __pyx_t_2 = 0;
6399       __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;}
6400       __Pyx_GOTREF(__pyx_t_2);
6401       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6402       __Pyx_Raise(__pyx_t_2, 0, 0);
6403       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6404       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6405       goto __pyx_L29;
6406     }
6407     __pyx_L29:;
6408
6409     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":590
6410  * 
6411  *             #disabled for autodetection to work
6412  *             if self.samfile.header.n_targets == 0:             # <<<<<<<<<<<<<<
6413  *                 raise ValueError( "file header is empty (mode='%s') - is it SAM/BAM format?" % mode)
6414  * 
6415  */
6416     __pyx_t_8 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->n_targets == 0);
6417     if (__pyx_t_8) {
6418
6419       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":591
6420  *             #disabled for autodetection to work
6421  *             if self.samfile.header.n_targets == 0:
6422  *                 raise ValueError( "file header is empty (mode='%s') - is it SAM/BAM format?" % mode)             # <<<<<<<<<<<<<<
6423  * 
6424  *         if self.samfile == NULL:
6425  */
6426       __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;}
6427       __Pyx_GOTREF(((PyObject *)__pyx_t_2));
6428       __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;}
6429       __Pyx_GOTREF(__pyx_t_3);
6430       PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
6431       __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
6432       __pyx_t_2 = 0;
6433       __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;}
6434       __Pyx_GOTREF(__pyx_t_2);
6435       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6436       __Pyx_Raise(__pyx_t_2, 0, 0);
6437       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6438       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6439       goto __pyx_L30;
6440     }
6441     __pyx_L30:;
6442     goto __pyx_L19;
6443   }
6444   __pyx_L19:;
6445
6446   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":593
6447  *                 raise ValueError( "file header is empty (mode='%s') - is it SAM/BAM format?" % mode)
6448  * 
6449  *         if self.samfile == NULL:             # <<<<<<<<<<<<<<
6450  *             raise IOError("could not open file `%s`" % filename )
6451  * 
6452  */
6453   __pyx_t_8 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile == NULL);
6454   if (__pyx_t_8) {
6455
6456     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":594
6457  * 
6458  *         if self.samfile == NULL:
6459  *             raise IOError("could not open file `%s`" % filename )             # <<<<<<<<<<<<<<
6460  * 
6461  *         # check for index and open if present
6462  */
6463     __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;}
6464     __Pyx_GOTREF(((PyObject *)__pyx_t_2));
6465     __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;}
6466     __Pyx_GOTREF(((PyObject *)__pyx_t_3));
6467     __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
6468     __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;}
6469     __Pyx_GOTREF(__pyx_t_2);
6470     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_3));
6471     __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
6472     __pyx_t_3 = 0;
6473     __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;}
6474     __Pyx_GOTREF(__pyx_t_3);
6475     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6476     __Pyx_Raise(__pyx_t_3, 0, 0);
6477     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6478     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6479     goto __pyx_L31;
6480   }
6481   __pyx_L31:;
6482
6483   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":597
6484  * 
6485  *         # check for index and open if present
6486  *         if mode[0] == "r" and self.isbam:             # <<<<<<<<<<<<<<
6487  * 
6488  *             if not self.isremote:
6489  */
6490   __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;}
6491   __Pyx_GOTREF(__pyx_t_3);
6492   __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;}
6493   __Pyx_GOTREF(__pyx_t_2);
6494   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6495   __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;}
6496   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6497   if (__pyx_t_8) {
6498     __pyx_t_1 = ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam;
6499   } else {
6500     __pyx_t_1 = __pyx_t_8;
6501   }
6502   if (__pyx_t_1) {
6503
6504     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":599
6505  *         if mode[0] == "r" and self.isbam:
6506  * 
6507  *             if not self.isremote:             # <<<<<<<<<<<<<<
6508  *                 if not os.path.exists(filename +".bai"):
6509  *                     self.index = NULL
6510  */
6511     __pyx_t_1 = (!((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isremote);
6512     if (__pyx_t_1) {
6513
6514       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":600
6515  * 
6516  *             if not self.isremote:
6517  *                 if not os.path.exists(filename +".bai"):             # <<<<<<<<<<<<<<
6518  *                     self.index = NULL
6519  *                 else:
6520  */
6521       __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;}
6522       __Pyx_GOTREF(__pyx_t_2);
6523       __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;}
6524       __Pyx_GOTREF(__pyx_t_3);
6525       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6526       __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;}
6527       __Pyx_GOTREF(__pyx_t_2);
6528       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6529       __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;}
6530       __Pyx_GOTREF(((PyObject *)__pyx_t_3));
6531       __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;}
6532       __Pyx_GOTREF(__pyx_t_5);
6533       __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
6534       __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;}
6535       __Pyx_GOTREF(__pyx_t_3);
6536       PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5);
6537       __Pyx_GIVEREF(__pyx_t_5);
6538       __pyx_t_5 = 0;
6539       __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;}
6540       __Pyx_GOTREF(__pyx_t_5);
6541       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6542       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6543       __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;}
6544       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6545       __pyx_t_8 = (!__pyx_t_1);
6546       if (__pyx_t_8) {
6547
6548         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":601
6549  *             if not self.isremote:
6550  *                 if not os.path.exists(filename +".bai"):
6551  *                     self.index = NULL             # <<<<<<<<<<<<<<
6552  *                 else:
6553  *                     # returns NULL if there is no index or index could not be opened
6554  */
6555         ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index = NULL;
6556         goto __pyx_L34;
6557       }
6558       /*else*/ {
6559
6560         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":604
6561  *                 else:
6562  *                     # returns NULL if there is no index or index could not be opened
6563  *                     self.index = bam_index_load(filename)             # <<<<<<<<<<<<<<
6564  *                     if self.index == NULL:
6565  *                         raise IOError("error while opening index `%s` " % filename )
6566  */
6567         ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index = bam_index_load(__pyx_v_filename);
6568
6569         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":605
6570  *                     # returns NULL if there is no index or index could not be opened
6571  *                     self.index = bam_index_load(filename)
6572  *                     if self.index == NULL:             # <<<<<<<<<<<<<<
6573  *                         raise IOError("error while opening index `%s` " % filename )
6574  *             else:
6575  */
6576         __pyx_t_8 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index == NULL);
6577         if (__pyx_t_8) {
6578
6579           /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":606
6580  *                     self.index = bam_index_load(filename)
6581  *                     if self.index == NULL:
6582  *                         raise IOError("error while opening index `%s` " % filename )             # <<<<<<<<<<<<<<
6583  *             else:
6584  *                 self.index = bam_index_load(filename)
6585  */
6586           __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;}
6587           __Pyx_GOTREF(((PyObject *)__pyx_t_5));
6588           __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;}
6589           __Pyx_GOTREF(((PyObject *)__pyx_t_3));
6590           __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
6591           __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;}
6592           __Pyx_GOTREF(__pyx_t_5);
6593           PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_3));
6594           __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
6595           __pyx_t_3 = 0;
6596           __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;}
6597           __Pyx_GOTREF(__pyx_t_3);
6598           __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6599           __Pyx_Raise(__pyx_t_3, 0, 0);
6600           __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6601           {__pyx_filename = __pyx_f[0]; __pyx_lineno = 606; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6602           goto __pyx_L35;
6603         }
6604         __pyx_L35:;
6605       }
6606       __pyx_L34:;
6607       goto __pyx_L33;
6608     }
6609     /*else*/ {
6610
6611       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":608
6612  *                         raise IOError("error while opening index `%s` " % filename )
6613  *             else:
6614  *                 self.index = bam_index_load(filename)             # <<<<<<<<<<<<<<
6615  *                 if self.index == NULL:
6616  *                     raise IOError("error while opening index `%s` " % filename )
6617  */
6618       ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index = bam_index_load(__pyx_v_filename);
6619
6620       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":609
6621  *             else:
6622  *                 self.index = bam_index_load(filename)
6623  *                 if self.index == NULL:             # <<<<<<<<<<<<<<
6624  *                     raise IOError("error while opening index `%s` " % filename )
6625  * 
6626  */
6627       __pyx_t_8 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index == NULL);
6628       if (__pyx_t_8) {
6629
6630         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":610
6631  *                 self.index = bam_index_load(filename)
6632  *                 if self.index == NULL:
6633  *                     raise IOError("error while opening index `%s` " % filename )             # <<<<<<<<<<<<<<
6634  * 
6635  *     def gettid( self, reference ):
6636  */
6637         __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;}
6638         __Pyx_GOTREF(((PyObject *)__pyx_t_3));
6639         __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;}
6640         __Pyx_GOTREF(((PyObject *)__pyx_t_5));
6641         __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
6642         __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;}
6643         __Pyx_GOTREF(__pyx_t_3);
6644         PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_5));
6645         __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
6646         __pyx_t_5 = 0;
6647         __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;}
6648         __Pyx_GOTREF(__pyx_t_5);
6649         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6650         __Pyx_Raise(__pyx_t_5, 0, 0);
6651         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6652         {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6653         goto __pyx_L36;
6654       }
6655       __pyx_L36:;
6656     }
6657     __pyx_L33:;
6658     goto __pyx_L32;
6659   }
6660   __pyx_L32:;
6661
6662   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
6663   goto __pyx_L0;
6664   __pyx_L1_error:;
6665   __Pyx_XDECREF(__pyx_t_2);
6666   __Pyx_XDECREF(__pyx_t_3);
6667   __Pyx_XDECREF(__pyx_t_4);
6668   __Pyx_XDECREF(__pyx_t_5);
6669   __Pyx_AddTraceback("csamtools.Samfile._open");
6670   __pyx_r = NULL;
6671   __pyx_L0:;
6672   __Pyx_DECREF(__pyx_v_msg);
6673   __Pyx_DECREF(__pyx_v_n);
6674   __Pyx_DECREF(__pyx_v_x);
6675   __Pyx_DECREF(__pyx_v_name);
6676   __Pyx_DECREF(__pyx_v_store);
6677   __Pyx_XGIVEREF(__pyx_r);
6678   __Pyx_TraceReturn(__pyx_r);
6679   __Pyx_RefNannyFinishContext();
6680   return __pyx_r;
6681 }
6682
6683 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":612
6684  *                     raise IOError("error while opening index `%s` " % filename )
6685  * 
6686  *     def gettid( self, reference ):             # <<<<<<<<<<<<<<
6687  *         '''
6688  *         convert :term:`reference` name into numerical :term:`tid`
6689  */
6690
6691 static PyObject *__pyx_pf_9csamtools_7Samfile_gettid(PyObject *__pyx_v_self, PyObject *__pyx_v_reference); /*proto*/
6692 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        ";
6693 static PyObject *__pyx_pf_9csamtools_7Samfile_gettid(PyObject *__pyx_v_self, PyObject *__pyx_v_reference) {
6694   PyObject *__pyx_r = NULL;
6695   PyObject *__pyx_t_1 = NULL;
6696   PyObject *__pyx_t_2 = NULL;
6697   int __pyx_t_3;
6698   int __pyx_t_4;
6699   char *__pyx_t_5;
6700   __Pyx_TraceDeclarations
6701   __Pyx_RefNannySetupContext("gettid");
6702   __Pyx_TraceCall("gettid", __pyx_f[0], 612);
6703
6704   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":618
6705  *         returns -1 if reference is not known.
6706  *         '''
6707  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
6708  *         return pysam_reference2tid( self.samfile.header, reference )
6709  * 
6710  */
6711   __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;}
6712   __Pyx_GOTREF(__pyx_t_1);
6713   __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;}
6714   __Pyx_GOTREF(__pyx_t_2);
6715   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6716   __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;}
6717   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6718   __pyx_t_4 = (!__pyx_t_3);
6719   if (__pyx_t_4) {
6720     __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;}
6721     __Pyx_GOTREF(__pyx_t_2);
6722     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
6723     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
6724     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
6725     __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;}
6726     __Pyx_GOTREF(__pyx_t_1);
6727     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6728     __Pyx_Raise(__pyx_t_1, 0, 0);
6729     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6730     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6731     goto __pyx_L5;
6732   }
6733   __pyx_L5:;
6734
6735   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":619
6736  *         '''
6737  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
6738  *         return pysam_reference2tid( self.samfile.header, reference )             # <<<<<<<<<<<<<<
6739  * 
6740  *     def getrname( self, tid ):
6741  */
6742   __Pyx_XDECREF(__pyx_r);
6743   __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;}
6744   __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;}
6745   __Pyx_GOTREF(__pyx_t_1);
6746   __pyx_r = __pyx_t_1;
6747   __pyx_t_1 = 0;
6748   goto __pyx_L0;
6749
6750   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
6751   goto __pyx_L0;
6752   __pyx_L1_error:;
6753   __Pyx_XDECREF(__pyx_t_1);
6754   __Pyx_XDECREF(__pyx_t_2);
6755   __Pyx_AddTraceback("csamtools.Samfile.gettid");
6756   __pyx_r = NULL;
6757   __pyx_L0:;
6758   __Pyx_XGIVEREF(__pyx_r);
6759   __Pyx_TraceReturn(__pyx_r);
6760   __Pyx_RefNannyFinishContext();
6761   return __pyx_r;
6762 }
6763
6764 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":621
6765  *         return pysam_reference2tid( self.samfile.header, reference )
6766  * 
6767  *     def getrname( self, tid ):             # <<<<<<<<<<<<<<
6768  *         '''
6769  *         convert numerical :term:`tid` into :term:`reference` name.'''
6770  */
6771
6772 static PyObject *__pyx_pf_9csamtools_7Samfile_getrname(PyObject *__pyx_v_self, PyObject *__pyx_v_tid); /*proto*/
6773 static char __pyx_doc_9csamtools_7Samfile_getrname[] = "Samfile.getrname(self, tid)\n\n        convert numerical :term:`tid` into :term:`reference` name.";
6774 static PyObject *__pyx_pf_9csamtools_7Samfile_getrname(PyObject *__pyx_v_self, PyObject *__pyx_v_tid) {
6775   PyObject *__pyx_r = NULL;
6776   PyObject *__pyx_t_1 = NULL;
6777   PyObject *__pyx_t_2 = NULL;
6778   int __pyx_t_3;
6779   int __pyx_t_4;
6780   Py_ssize_t __pyx_t_5;
6781   __Pyx_TraceDeclarations
6782   __Pyx_RefNannySetupContext("getrname");
6783   __Pyx_TraceCall("getrname", __pyx_f[0], 621);
6784
6785   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":624
6786  *         '''
6787  *         convert numerical :term:`tid` into :term:`reference` name.'''
6788  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
6789  *         if not 0 <= tid < self.samfile.header.n_targets:
6790  *             raise ValueError( "tid %i out of range 0<=tid<%i" % (tid, self.samfile.header.n_targets ) )
6791  */
6792   __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;}
6793   __Pyx_GOTREF(__pyx_t_1);
6794   __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;}
6795   __Pyx_GOTREF(__pyx_t_2);
6796   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6797   __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;}
6798   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6799   __pyx_t_4 = (!__pyx_t_3);
6800   if (__pyx_t_4) {
6801     __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;}
6802     __Pyx_GOTREF(__pyx_t_2);
6803     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
6804     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
6805     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
6806     __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;}
6807     __Pyx_GOTREF(__pyx_t_1);
6808     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6809     __Pyx_Raise(__pyx_t_1, 0, 0);
6810     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6811     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6812     goto __pyx_L5;
6813   }
6814   __pyx_L5:;
6815
6816   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":625
6817  *         convert numerical :term:`tid` into :term:`reference` name.'''
6818  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
6819  *         if not 0 <= tid < self.samfile.header.n_targets:             # <<<<<<<<<<<<<<
6820  *             raise ValueError( "tid %i out of range 0<=tid<%i" % (tid, self.samfile.header.n_targets ) )
6821  *         return self.samfile.header.target_name[tid]
6822  */
6823   __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;}
6824   __Pyx_GOTREF(__pyx_t_1);
6825   if (__Pyx_PyObject_IsTrue(__pyx_t_1)) {
6826     __Pyx_DECREF(__pyx_t_1);
6827     __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;}
6828     __Pyx_GOTREF(__pyx_t_2);
6829     __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;}
6830     __Pyx_GOTREF(__pyx_t_1);
6831     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6832   }
6833   __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;}
6834   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6835   __pyx_t_3 = (!__pyx_t_4);
6836   if (__pyx_t_3) {
6837
6838     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":626
6839  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
6840  *         if not 0 <= tid < self.samfile.header.n_targets:
6841  *             raise ValueError( "tid %i out of range 0<=tid<%i" % (tid, self.samfile.header.n_targets ) )             # <<<<<<<<<<<<<<
6842  *         return self.samfile.header.target_name[tid]
6843  * 
6844  */
6845     __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;}
6846     __Pyx_GOTREF(__pyx_t_1);
6847     __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;}
6848     __Pyx_GOTREF(__pyx_t_2);
6849     __Pyx_INCREF(__pyx_v_tid);
6850     PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_tid);
6851     __Pyx_GIVEREF(__pyx_v_tid);
6852     PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
6853     __Pyx_GIVEREF(__pyx_t_1);
6854     __pyx_t_1 = 0;
6855     __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;}
6856     __Pyx_GOTREF(((PyObject *)__pyx_t_1));
6857     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6858     __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;}
6859     __Pyx_GOTREF(__pyx_t_2);
6860     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
6861     __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
6862     __pyx_t_1 = 0;
6863     __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;}
6864     __Pyx_GOTREF(__pyx_t_1);
6865     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6866     __Pyx_Raise(__pyx_t_1, 0, 0);
6867     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6868     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 626; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6869     goto __pyx_L6;
6870   }
6871   __pyx_L6:;
6872
6873   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":627
6874  *         if not 0 <= tid < self.samfile.header.n_targets:
6875  *             raise ValueError( "tid %i out of range 0<=tid<%i" % (tid, self.samfile.header.n_targets ) )
6876  *         return self.samfile.header.target_name[tid]             # <<<<<<<<<<<<<<
6877  * 
6878  *     cdef char * _getrname( self, int tid ):
6879  */
6880   __Pyx_XDECREF(__pyx_r);
6881   __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;}
6882   __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;}
6883   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
6884   __pyx_r = ((PyObject *)__pyx_t_1);
6885   __pyx_t_1 = 0;
6886   goto __pyx_L0;
6887
6888   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
6889   goto __pyx_L0;
6890   __pyx_L1_error:;
6891   __Pyx_XDECREF(__pyx_t_1);
6892   __Pyx_XDECREF(__pyx_t_2);
6893   __Pyx_AddTraceback("csamtools.Samfile.getrname");
6894   __pyx_r = NULL;
6895   __pyx_L0:;
6896   __Pyx_XGIVEREF(__pyx_r);
6897   __Pyx_TraceReturn(__pyx_r);
6898   __Pyx_RefNannyFinishContext();
6899   return __pyx_r;
6900 }
6901
6902 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":629
6903  *         return self.samfile.header.target_name[tid]
6904  * 
6905  *     cdef char * _getrname( self, int tid ):             # <<<<<<<<<<<<<<
6906  *         '''
6907  *         convert numerical :term:`tid` into :term:`reference` name.'''
6908  */
6909
6910 static  char *__pyx_f_9csamtools_7Samfile__getrname(struct __pyx_obj_9csamtools_Samfile *__pyx_v_self, int __pyx_v_tid) {
6911   char *__pyx_r;
6912   PyObject *__pyx_t_1 = NULL;
6913   PyObject *__pyx_t_2 = NULL;
6914   int __pyx_t_3;
6915   int __pyx_t_4;
6916   PyObject *__pyx_t_5 = NULL;
6917   __Pyx_TraceDeclarations
6918   __Pyx_RefNannySetupContext("_getrname");
6919   __Pyx_TraceCall("_getrname", __pyx_f[0], 629);
6920
6921   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":632
6922  *         '''
6923  *         convert numerical :term:`tid` into :term:`reference` name.'''
6924  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
6925  *         if not 0 <= tid < self.samfile.header.n_targets:
6926  *             raise ValueError( "tid %i out of range 0<=tid<%i" % (tid, self.samfile.header.n_targets ) )
6927  */
6928   __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;}
6929   __Pyx_GOTREF(__pyx_t_1);
6930   __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;}
6931   __Pyx_GOTREF(__pyx_t_2);
6932   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6933   __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;}
6934   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6935   __pyx_t_4 = (!__pyx_t_3);
6936   if (__pyx_t_4) {
6937     __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;}
6938     __Pyx_GOTREF(__pyx_t_2);
6939     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
6940     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
6941     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
6942     __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;}
6943     __Pyx_GOTREF(__pyx_t_1);
6944     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6945     __Pyx_Raise(__pyx_t_1, 0, 0);
6946     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6947     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6948     goto __pyx_L3;
6949   }
6950   __pyx_L3:;
6951
6952   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":633
6953  *         convert numerical :term:`tid` into :term:`reference` name.'''
6954  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
6955  *         if not 0 <= tid < self.samfile.header.n_targets:             # <<<<<<<<<<<<<<
6956  *             raise ValueError( "tid %i out of range 0<=tid<%i" % (tid, self.samfile.header.n_targets ) )
6957  *         return self.samfile.header.target_name[tid]
6958  */
6959   __pyx_t_4 = (0 <= __pyx_v_tid);
6960   if (__pyx_t_4) {
6961     __pyx_t_4 = (__pyx_v_tid < __pyx_v_self->samfile->header->n_targets);
6962   }
6963   __pyx_t_3 = (!__pyx_t_4);
6964   if (__pyx_t_3) {
6965
6966     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":634
6967  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
6968  *         if not 0 <= tid < self.samfile.header.n_targets:
6969  *             raise ValueError( "tid %i out of range 0<=tid<%i" % (tid, self.samfile.header.n_targets ) )             # <<<<<<<<<<<<<<
6970  *         return self.samfile.header.target_name[tid]
6971  * 
6972  */
6973     __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;}
6974     __Pyx_GOTREF(__pyx_t_1);
6975     __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;}
6976     __Pyx_GOTREF(__pyx_t_2);
6977     __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;}
6978     __Pyx_GOTREF(__pyx_t_5);
6979     PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
6980     __Pyx_GIVEREF(__pyx_t_1);
6981     PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
6982     __Pyx_GIVEREF(__pyx_t_2);
6983     __pyx_t_1 = 0;
6984     __pyx_t_2 = 0;
6985     __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;}
6986     __Pyx_GOTREF(((PyObject *)__pyx_t_2));
6987     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6988     __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;}
6989     __Pyx_GOTREF(__pyx_t_5);
6990     PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_2));
6991     __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
6992     __pyx_t_2 = 0;
6993     __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;}
6994     __Pyx_GOTREF(__pyx_t_2);
6995     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6996     __Pyx_Raise(__pyx_t_2, 0, 0);
6997     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6998     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
6999     goto __pyx_L4;
7000   }
7001   __pyx_L4:;
7002
7003   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":635
7004  *         if not 0 <= tid < self.samfile.header.n_targets:
7005  *             raise ValueError( "tid %i out of range 0<=tid<%i" % (tid, self.samfile.header.n_targets ) )
7006  *         return self.samfile.header.target_name[tid]             # <<<<<<<<<<<<<<
7007  * 
7008  *     def _parseRegion( self,
7009  */
7010   __pyx_r = (__pyx_v_self->samfile->header->target_name[__pyx_v_tid]);
7011   goto __pyx_L0;
7012
7013   __pyx_r = 0;
7014   goto __pyx_L0;
7015   __pyx_L1_error:;
7016   __Pyx_XDECREF(__pyx_t_1);
7017   __Pyx_XDECREF(__pyx_t_2);
7018   __Pyx_XDECREF(__pyx_t_5);
7019   __Pyx_WriteUnraisable("csamtools.Samfile._getrname");
7020   __pyx_r = 0;
7021   __pyx_L0:;
7022   __Pyx_TraceReturn(Py_None);
7023   __Pyx_RefNannyFinishContext();
7024   return __pyx_r;
7025 }
7026
7027 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":637
7028  *         return self.samfile.header.target_name[tid]
7029  * 
7030  *     def _parseRegion( self,             # <<<<<<<<<<<<<<
7031  *                       reference = None,
7032  *                       start = None,
7033  */
7034
7035 static PyObject *__pyx_pf_9csamtools_7Samfile__parseRegion(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
7036 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        ";
7037 static PyObject *__pyx_pf_9csamtools_7Samfile__parseRegion(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
7038   PyObject *__pyx_v_reference = 0;
7039   PyObject *__pyx_v_start = 0;
7040   PyObject *__pyx_v_end = 0;
7041   PyObject *__pyx_v_region = 0;
7042   int __pyx_v_rtid;
7043   PY_LONG_LONG __pyx_v_rstart;
7044   PY_LONG_LONG __pyx_v_rend;
7045   PyObject *__pyx_v_parts;
7046   PyObject *__pyx_r = NULL;
7047   PyObject *__pyx_t_1 = NULL;
7048   int __pyx_t_2;
7049   PY_LONG_LONG __pyx_t_3;
7050   int __pyx_t_4;
7051   PyObject *__pyx_t_5 = NULL;
7052   PyObject *__pyx_t_6 = NULL;
7053   PyObject *__pyx_t_7 = NULL;
7054   PyObject *__pyx_t_8 = NULL;
7055   Py_ssize_t __pyx_t_9;
7056   int __pyx_t_10;
7057   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__reference,&__pyx_n_s__start,&__pyx_n_s__end,&__pyx_n_s__region,0};
7058   __Pyx_TraceDeclarations
7059   __Pyx_RefNannySetupContext("_parseRegion");
7060   __Pyx_TraceCall("_parseRegion", __pyx_f[0], 637);
7061   if (unlikely(__pyx_kwds)) {
7062     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
7063     PyObject* values[4] = {0,0,0,0};
7064
7065     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":638
7066  * 
7067  *     def _parseRegion( self,
7068  *                       reference = None,             # <<<<<<<<<<<<<<
7069  *                       start = None,
7070  *                       end = None,
7071  */
7072     values[0] = ((PyObject *)Py_None);
7073
7074     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":639
7075  *     def _parseRegion( self,
7076  *                       reference = None,
7077  *                       start = None,             # <<<<<<<<<<<<<<
7078  *                       end = None,
7079  *                       region = None ):
7080  */
7081     values[1] = ((PyObject *)Py_None);
7082
7083     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":640
7084  *                       reference = None,
7085  *                       start = None,
7086  *                       end = None,             # <<<<<<<<<<<<<<
7087  *                       region = None ):
7088  *         '''
7089  */
7090     values[2] = ((PyObject *)Py_None);
7091
7092     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":641
7093  *                       start = None,
7094  *                       end = None,
7095  *                       region = None ):             # <<<<<<<<<<<<<<
7096  *         '''
7097  *         parse region information.
7098  */
7099     values[3] = ((PyObject *)Py_None);
7100     switch (PyTuple_GET_SIZE(__pyx_args)) {
7101       case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
7102       case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
7103       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
7104       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
7105       case  0: break;
7106       default: goto __pyx_L5_argtuple_error;
7107     }
7108     switch (PyTuple_GET_SIZE(__pyx_args)) {
7109       case  0:
7110       if (kw_args > 0) {
7111         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reference);
7112         if (value) { values[0] = value; kw_args--; }
7113       }
7114       case  1:
7115       if (kw_args > 0) {
7116         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start);
7117         if (value) { values[1] = value; kw_args--; }
7118       }
7119       case  2:
7120       if (kw_args > 0) {
7121         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end);
7122         if (value) { values[2] = value; kw_args--; }
7123       }
7124       case  3:
7125       if (kw_args > 0) {
7126         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__region);
7127         if (value) { values[3] = value; kw_args--; }
7128       }
7129     }
7130     if (unlikely(kw_args > 0)) {
7131       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;}
7132     }
7133     __pyx_v_reference = values[0];
7134     __pyx_v_start = values[1];
7135     __pyx_v_end = values[2];
7136     __pyx_v_region = values[3];
7137   } else {
7138
7139     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":638
7140  * 
7141  *     def _parseRegion( self,
7142  *                       reference = None,             # <<<<<<<<<<<<<<
7143  *                       start = None,
7144  *                       end = None,
7145  */
7146     __pyx_v_reference = ((PyObject *)Py_None);
7147
7148     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":639
7149  *     def _parseRegion( self,
7150  *                       reference = None,
7151  *                       start = None,             # <<<<<<<<<<<<<<
7152  *                       end = None,
7153  *                       region = None ):
7154  */
7155     __pyx_v_start = ((PyObject *)Py_None);
7156
7157     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":640
7158  *                       reference = None,
7159  *                       start = None,
7160  *                       end = None,             # <<<<<<<<<<<<<<
7161  *                       region = None ):
7162  *         '''
7163  */
7164     __pyx_v_end = ((PyObject *)Py_None);
7165
7166     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":641
7167  *                       start = None,
7168  *                       end = None,
7169  *                       region = None ):             # <<<<<<<<<<<<<<
7170  *         '''
7171  *         parse region information.
7172  */
7173     __pyx_v_region = ((PyObject *)Py_None);
7174     switch (PyTuple_GET_SIZE(__pyx_args)) {
7175       case  4: __pyx_v_region = PyTuple_GET_ITEM(__pyx_args, 3);
7176       case  3: __pyx_v_end = PyTuple_GET_ITEM(__pyx_args, 2);
7177       case  2: __pyx_v_start = PyTuple_GET_ITEM(__pyx_args, 1);
7178       case  1: __pyx_v_reference = PyTuple_GET_ITEM(__pyx_args, 0);
7179       case  0: break;
7180       default: goto __pyx_L5_argtuple_error;
7181     }
7182   }
7183   goto __pyx_L4_argument_unpacking_done;
7184   __pyx_L5_argtuple_error:;
7185   __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;}
7186   __pyx_L3_error:;
7187   __Pyx_AddTraceback("csamtools.Samfile._parseRegion");
7188   __Pyx_RefNannyFinishContext();
7189   return NULL;
7190   __pyx_L4_argument_unpacking_done:;
7191   __Pyx_INCREF(__pyx_v_reference);
7192   __pyx_v_parts = Py_None; __Pyx_INCREF(Py_None);
7193
7194   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":660
7195  *         cdef long long rend
7196  * 
7197  *         rtid = -1             # <<<<<<<<<<<<<<
7198  *         rstart = 0
7199  *         rend = max_pos
7200  */
7201   __pyx_v_rtid = -1;
7202
7203   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":661
7204  * 
7205  *         rtid = -1
7206  *         rstart = 0             # <<<<<<<<<<<<<<
7207  *         rend = max_pos
7208  *         if start != None:
7209  */
7210   __pyx_v_rstart = 0;
7211
7212   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":662
7213  *         rtid = -1
7214  *         rstart = 0
7215  *         rend = max_pos             # <<<<<<<<<<<<<<
7216  *         if start != None:
7217  *             try:
7218  */
7219   __pyx_v_rend = __pyx_v_9csamtools_max_pos;
7220
7221   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":663
7222  *         rstart = 0
7223  *         rend = max_pos
7224  *         if start != None:             # <<<<<<<<<<<<<<
7225  *             try:
7226  *                 rstart = start
7227  */
7228   __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;}
7229   __Pyx_GOTREF(__pyx_t_1);
7230   __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;}
7231   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7232   if (__pyx_t_2) {
7233
7234     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":664
7235  *         rend = max_pos
7236  *         if start != None:
7237  *             try:             # <<<<<<<<<<<<<<
7238  *                 rstart = start
7239  *             except OverflowError:
7240  */
7241     {
7242       PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
7243       __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
7244       __Pyx_XGOTREF(__pyx_save_exc_type);
7245       __Pyx_XGOTREF(__pyx_save_exc_value);
7246       __Pyx_XGOTREF(__pyx_save_exc_tb);
7247       /*try:*/ {
7248
7249         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":665
7250  *         if start != None:
7251  *             try:
7252  *                 rstart = start             # <<<<<<<<<<<<<<
7253  *             except OverflowError:
7254  *                 raise ValueError( 'start out of range (%i)' % start )
7255  */
7256         __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;}
7257         __pyx_v_rstart = __pyx_t_3;
7258       }
7259       __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
7260       __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
7261       __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
7262       goto __pyx_L14_try_end;
7263       __pyx_L7_error:;
7264       __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
7265
7266       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":666
7267  *             try:
7268  *                 rstart = start
7269  *             except OverflowError:             # <<<<<<<<<<<<<<
7270  *                 raise ValueError( 'start out of range (%i)' % start )
7271  * 
7272  */
7273       __pyx_t_4 = PyErr_ExceptionMatches(__pyx_builtin_OverflowError);
7274       if (__pyx_t_4) {
7275         __Pyx_AddTraceback("csamtools.Samfile._parseRegion");
7276         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;}
7277         __Pyx_GOTREF(__pyx_t_1);
7278         __Pyx_GOTREF(__pyx_t_5);
7279         __Pyx_GOTREF(__pyx_t_6);
7280
7281         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":667
7282  *                 rstart = start
7283  *             except OverflowError:
7284  *                 raise ValueError( 'start out of range (%i)' % start )             # <<<<<<<<<<<<<<
7285  * 
7286  *         if end != None:
7287  */
7288         __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;}
7289         __Pyx_GOTREF(((PyObject *)__pyx_t_7));
7290         __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;}
7291         __Pyx_GOTREF(__pyx_t_8);
7292         PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_t_7));
7293         __Pyx_GIVEREF(((PyObject *)__pyx_t_7));
7294         __pyx_t_7 = 0;
7295         __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;}
7296         __Pyx_GOTREF(__pyx_t_7);
7297         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
7298         __Pyx_Raise(__pyx_t_7, 0, 0);
7299         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
7300         {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L9_except_error;}
7301         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7302         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
7303         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
7304         goto __pyx_L8_exception_handled;
7305       }
7306       __pyx_L9_except_error:;
7307       __Pyx_XGIVEREF(__pyx_save_exc_type);
7308       __Pyx_XGIVEREF(__pyx_save_exc_value);
7309       __Pyx_XGIVEREF(__pyx_save_exc_tb);
7310       __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
7311       goto __pyx_L1_error;
7312       __pyx_L8_exception_handled:;
7313       __Pyx_XGIVEREF(__pyx_save_exc_type);
7314       __Pyx_XGIVEREF(__pyx_save_exc_value);
7315       __Pyx_XGIVEREF(__pyx_save_exc_tb);
7316       __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
7317       __pyx_L14_try_end:;
7318     }
7319     goto __pyx_L6;
7320   }
7321   __pyx_L6:;
7322
7323   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":669
7324  *                 raise ValueError( 'start out of range (%i)' % start )
7325  * 
7326  *         if end != None:             # <<<<<<<<<<<<<<
7327  *             try:
7328  *                 rend = end
7329  */
7330   __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;}
7331   __Pyx_GOTREF(__pyx_t_6);
7332   __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;}
7333   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
7334   if (__pyx_t_2) {
7335
7336     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":670
7337  * 
7338  *         if end != None:
7339  *             try:             # <<<<<<<<<<<<<<
7340  *                 rend = end
7341  *             except OverflowError:
7342  */
7343     {
7344       PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
7345       __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
7346       __Pyx_XGOTREF(__pyx_save_exc_type);
7347       __Pyx_XGOTREF(__pyx_save_exc_value);
7348       __Pyx_XGOTREF(__pyx_save_exc_tb);
7349       /*try:*/ {
7350
7351         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":671
7352  *         if end != None:
7353  *             try:
7354  *                 rend = end             # <<<<<<<<<<<<<<
7355  *             except OverflowError:
7356  *                 raise ValueError( 'end out of range (%i)' % end )
7357  */
7358         __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;}
7359         __pyx_v_rend = __pyx_t_3;
7360       }
7361       __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
7362       __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
7363       __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
7364       goto __pyx_L25_try_end;
7365       __pyx_L18_error:;
7366       __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
7367       __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
7368       __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
7369       __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
7370       __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
7371
7372       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":672
7373  *             try:
7374  *                 rend = end
7375  *             except OverflowError:             # <<<<<<<<<<<<<<
7376  *                 raise ValueError( 'end out of range (%i)' % end )
7377  * 
7378  */
7379       __pyx_t_4 = PyErr_ExceptionMatches(__pyx_builtin_OverflowError);
7380       if (__pyx_t_4) {
7381         __Pyx_AddTraceback("csamtools.Samfile._parseRegion");
7382         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;}
7383         __Pyx_GOTREF(__pyx_t_6);
7384         __Pyx_GOTREF(__pyx_t_5);
7385         __Pyx_GOTREF(__pyx_t_1);
7386
7387         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":673
7388  *                 rend = end
7389  *             except OverflowError:
7390  *                 raise ValueError( 'end out of range (%i)' % end )             # <<<<<<<<<<<<<<
7391  * 
7392  *         if region:
7393  */
7394         __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;}
7395         __Pyx_GOTREF(((PyObject *)__pyx_t_7));
7396         __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;}
7397         __Pyx_GOTREF(__pyx_t_8);
7398         PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_t_7));
7399         __Pyx_GIVEREF(((PyObject *)__pyx_t_7));
7400         __pyx_t_7 = 0;
7401         __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;}
7402         __Pyx_GOTREF(__pyx_t_7);
7403         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
7404         __Pyx_Raise(__pyx_t_7, 0, 0);
7405         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
7406         {__pyx_filename = __pyx_f[0]; __pyx_lineno = 673; __pyx_clineno = __LINE__; goto __pyx_L20_except_error;}
7407         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
7408         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
7409         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7410         goto __pyx_L19_exception_handled;
7411       }
7412       __pyx_L20_except_error:;
7413       __Pyx_XGIVEREF(__pyx_save_exc_type);
7414       __Pyx_XGIVEREF(__pyx_save_exc_value);
7415       __Pyx_XGIVEREF(__pyx_save_exc_tb);
7416       __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
7417       goto __pyx_L1_error;
7418       __pyx_L19_exception_handled:;
7419       __Pyx_XGIVEREF(__pyx_save_exc_type);
7420       __Pyx_XGIVEREF(__pyx_save_exc_value);
7421       __Pyx_XGIVEREF(__pyx_save_exc_tb);
7422       __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
7423       __pyx_L25_try_end:;
7424     }
7425     goto __pyx_L17;
7426   }
7427   __pyx_L17:;
7428
7429   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":675
7430  *                 raise ValueError( 'end out of range (%i)' % end )
7431  * 
7432  *         if region:             # <<<<<<<<<<<<<<
7433  *             parts = re.split( "[:-]", region )
7434  *             reference = parts[0]
7435  */
7436   __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;}
7437   if (__pyx_t_2) {
7438
7439     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":676
7440  * 
7441  *         if region:
7442  *             parts = re.split( "[:-]", region )             # <<<<<<<<<<<<<<
7443  *             reference = parts[0]
7444  *             if len(parts) >= 2: rstart = int(parts[1]) - 1
7445  */
7446     __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;}
7447     __Pyx_GOTREF(__pyx_t_1);
7448     __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;}
7449     __Pyx_GOTREF(__pyx_t_5);
7450     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7451     __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;}
7452     __Pyx_GOTREF(__pyx_t_1);
7453     __Pyx_INCREF(((PyObject *)__pyx_kp_s_25));
7454     PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_25));
7455     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_25));
7456     __Pyx_INCREF(__pyx_v_region);
7457     PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_region);
7458     __Pyx_GIVEREF(__pyx_v_region);
7459     __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;}
7460     __Pyx_GOTREF(__pyx_t_6);
7461     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
7462     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7463     __Pyx_DECREF(__pyx_v_parts);
7464     __pyx_v_parts = __pyx_t_6;
7465     __pyx_t_6 = 0;
7466
7467     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":677
7468  *         if region:
7469  *             parts = re.split( "[:-]", region )
7470  *             reference = parts[0]             # <<<<<<<<<<<<<<
7471  *             if len(parts) >= 2: rstart = int(parts[1]) - 1
7472  *             if len(parts) >= 3: rend = int(parts[2])
7473  */
7474     __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;}
7475     __Pyx_GOTREF(__pyx_t_6);
7476     __Pyx_DECREF(__pyx_v_reference);
7477     __pyx_v_reference = __pyx_t_6;
7478     __pyx_t_6 = 0;
7479
7480     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":678
7481  *             parts = re.split( "[:-]", region )
7482  *             reference = parts[0]
7483  *             if len(parts) >= 2: rstart = int(parts[1]) - 1             # <<<<<<<<<<<<<<
7484  *             if len(parts) >= 3: rend = int(parts[2])
7485  * 
7486  */
7487     __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;}
7488     __pyx_t_2 = (__pyx_t_9 >= 2);
7489     if (__pyx_t_2) {
7490       __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;}
7491       __Pyx_GOTREF(__pyx_t_6);
7492       __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;}
7493       __Pyx_GOTREF(__pyx_t_1);
7494       PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
7495       __Pyx_GIVEREF(__pyx_t_6);
7496       __pyx_t_6 = 0;
7497       __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;}
7498       __Pyx_GOTREF(__pyx_t_6);
7499       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7500       __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;}
7501       __Pyx_GOTREF(__pyx_t_1);
7502       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
7503       __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;}
7504       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7505       __pyx_v_rstart = __pyx_t_3;
7506       goto __pyx_L29;
7507     }
7508     __pyx_L29:;
7509
7510     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":679
7511  *             reference = parts[0]
7512  *             if len(parts) >= 2: rstart = int(parts[1]) - 1
7513  *             if len(parts) >= 3: rend = int(parts[2])             # <<<<<<<<<<<<<<
7514  * 
7515  *         if not reference: return 0, 0, 0, 0
7516  */
7517     __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;}
7518     __pyx_t_2 = (__pyx_t_9 >= 3);
7519     if (__pyx_t_2) {
7520       __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;}
7521       __Pyx_GOTREF(__pyx_t_1);
7522       __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;}
7523       __Pyx_GOTREF(__pyx_t_6);
7524       PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
7525       __Pyx_GIVEREF(__pyx_t_1);
7526       __pyx_t_1 = 0;
7527       __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;}
7528       __Pyx_GOTREF(__pyx_t_1);
7529       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
7530       __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;}
7531       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7532       __pyx_v_rend = __pyx_t_3;
7533       goto __pyx_L30;
7534     }
7535     __pyx_L30:;
7536     goto __pyx_L28;
7537   }
7538   __pyx_L28:;
7539
7540   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":681
7541  *             if len(parts) >= 3: rend = int(parts[2])
7542  * 
7543  *         if not reference: return 0, 0, 0, 0             # <<<<<<<<<<<<<<
7544  * 
7545  *         rtid = self.gettid( reference )
7546  */
7547   __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;}
7548   __pyx_t_10 = (!__pyx_t_2);
7549   if (__pyx_t_10) {
7550     __Pyx_XDECREF(__pyx_r);
7551     __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;}
7552     __Pyx_GOTREF(__pyx_t_1);
7553     __Pyx_INCREF(__pyx_int_0);
7554     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_int_0);
7555     __Pyx_GIVEREF(__pyx_int_0);
7556     __Pyx_INCREF(__pyx_int_0);
7557     PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_int_0);
7558     __Pyx_GIVEREF(__pyx_int_0);
7559     __Pyx_INCREF(__pyx_int_0);
7560     PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_int_0);
7561     __Pyx_GIVEREF(__pyx_int_0);
7562     __Pyx_INCREF(__pyx_int_0);
7563     PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_int_0);
7564     __Pyx_GIVEREF(__pyx_int_0);
7565     __pyx_r = __pyx_t_1;
7566     __pyx_t_1 = 0;
7567     goto __pyx_L0;
7568     goto __pyx_L31;
7569   }
7570   __pyx_L31:;
7571
7572   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":683
7573  *         if not reference: return 0, 0, 0, 0
7574  * 
7575  *         rtid = self.gettid( reference )             # <<<<<<<<<<<<<<
7576  *         if rtid < 0: raise ValueError( "invalid reference `%s`" % reference )
7577  *         if rstart > rend: raise ValueError( 'invalid coordinates: start (%i) > end (%i)' % (rstart, rend) )
7578  */
7579   __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;}
7580   __Pyx_GOTREF(__pyx_t_1);
7581   __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;}
7582   __Pyx_GOTREF(__pyx_t_6);
7583   __Pyx_INCREF(__pyx_v_reference);
7584   PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_reference);
7585   __Pyx_GIVEREF(__pyx_v_reference);
7586   __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;}
7587   __Pyx_GOTREF(__pyx_t_5);
7588   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7589   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
7590   __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;}
7591   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
7592   __pyx_v_rtid = __pyx_t_4;
7593
7594   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":684
7595  * 
7596  *         rtid = self.gettid( reference )
7597  *         if rtid < 0: raise ValueError( "invalid reference `%s`" % reference )             # <<<<<<<<<<<<<<
7598  *         if rstart > rend: raise ValueError( 'invalid coordinates: start (%i) > end (%i)' % (rstart, rend) )
7599  *         if not 0 <= rstart < max_pos: raise ValueError( 'start out of range (%i)' % rstart )
7600  */
7601   __pyx_t_10 = (__pyx_v_rtid < 0);
7602   if (__pyx_t_10) {
7603     __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;}
7604     __Pyx_GOTREF(((PyObject *)__pyx_t_5));
7605     __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;}
7606     __Pyx_GOTREF(__pyx_t_6);
7607     PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_5));
7608     __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
7609     __pyx_t_5 = 0;
7610     __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;}
7611     __Pyx_GOTREF(__pyx_t_5);
7612     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
7613     __Pyx_Raise(__pyx_t_5, 0, 0);
7614     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
7615     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7616     goto __pyx_L32;
7617   }
7618   __pyx_L32:;
7619
7620   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":685
7621  *         rtid = self.gettid( reference )
7622  *         if rtid < 0: raise ValueError( "invalid reference `%s`" % reference )
7623  *         if rstart > rend: raise ValueError( 'invalid coordinates: start (%i) > end (%i)' % (rstart, rend) )             # <<<<<<<<<<<<<<
7624  *         if not 0 <= rstart < max_pos: raise ValueError( 'start out of range (%i)' % rstart )
7625  *         if not 0 <= rend <= max_pos: raise ValueError( 'end out of range (%i)' % rend )
7626  */
7627   __pyx_t_10 = (__pyx_v_rstart > __pyx_v_rend);
7628   if (__pyx_t_10) {
7629     __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;}
7630     __Pyx_GOTREF(__pyx_t_5);
7631     __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;}
7632     __Pyx_GOTREF(__pyx_t_6);
7633     __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;}
7634     __Pyx_GOTREF(__pyx_t_1);
7635     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
7636     __Pyx_GIVEREF(__pyx_t_5);
7637     PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_6);
7638     __Pyx_GIVEREF(__pyx_t_6);
7639     __pyx_t_5 = 0;
7640     __pyx_t_6 = 0;
7641     __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;}
7642     __Pyx_GOTREF(((PyObject *)__pyx_t_6));
7643     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7644     __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;}
7645     __Pyx_GOTREF(__pyx_t_1);
7646     PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_6));
7647     __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
7648     __pyx_t_6 = 0;
7649     __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;}
7650     __Pyx_GOTREF(__pyx_t_6);
7651     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7652     __Pyx_Raise(__pyx_t_6, 0, 0);
7653     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
7654     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7655     goto __pyx_L33;
7656   }
7657   __pyx_L33:;
7658
7659   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":686
7660  *         if rtid < 0: raise ValueError( "invalid reference `%s`" % reference )
7661  *         if rstart > rend: raise ValueError( 'invalid coordinates: start (%i) > end (%i)' % (rstart, rend) )
7662  *         if not 0 <= rstart < max_pos: raise ValueError( 'start out of range (%i)' % rstart )             # <<<<<<<<<<<<<<
7663  *         if not 0 <= rend <= max_pos: raise ValueError( 'end out of range (%i)' % rend )
7664  * 
7665  */
7666   __pyx_t_10 = (0 <= __pyx_v_rstart);
7667   if (__pyx_t_10) {
7668     __pyx_t_10 = (__pyx_v_rstart < __pyx_v_9csamtools_max_pos);
7669   }
7670   __pyx_t_2 = (!__pyx_t_10);
7671   if (__pyx_t_2) {
7672     __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;}
7673     __Pyx_GOTREF(__pyx_t_6);
7674     __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;}
7675     __Pyx_GOTREF(((PyObject *)__pyx_t_1));
7676     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
7677     __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;}
7678     __Pyx_GOTREF(__pyx_t_6);
7679     PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_1));
7680     __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
7681     __pyx_t_1 = 0;
7682     __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;}
7683     __Pyx_GOTREF(__pyx_t_1);
7684     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
7685     __Pyx_Raise(__pyx_t_1, 0, 0);
7686     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7687     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 686; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7688     goto __pyx_L34;
7689   }
7690   __pyx_L34:;
7691
7692   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":687
7693  *         if rstart > rend: raise ValueError( 'invalid coordinates: start (%i) > end (%i)' % (rstart, rend) )
7694  *         if not 0 <= rstart < max_pos: raise ValueError( 'start out of range (%i)' % rstart )
7695  *         if not 0 <= rend <= max_pos: raise ValueError( 'end out of range (%i)' % rend )             # <<<<<<<<<<<<<<
7696  * 
7697  *         return 1, rtid, rstart, rend
7698  */
7699   __pyx_t_2 = (0 <= __pyx_v_rend);
7700   if (__pyx_t_2) {
7701     __pyx_t_2 = (__pyx_v_rend <= __pyx_v_9csamtools_max_pos);
7702   }
7703   __pyx_t_10 = (!__pyx_t_2);
7704   if (__pyx_t_10) {
7705     __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;}
7706     __Pyx_GOTREF(__pyx_t_1);
7707     __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;}
7708     __Pyx_GOTREF(((PyObject *)__pyx_t_6));
7709     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7710     __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;}
7711     __Pyx_GOTREF(__pyx_t_1);
7712     PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_6));
7713     __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
7714     __pyx_t_6 = 0;
7715     __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;}
7716     __Pyx_GOTREF(__pyx_t_6);
7717     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7718     __Pyx_Raise(__pyx_t_6, 0, 0);
7719     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
7720     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 687; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7721     goto __pyx_L35;
7722   }
7723   __pyx_L35:;
7724
7725   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":689
7726  *         if not 0 <= rend <= max_pos: raise ValueError( 'end out of range (%i)' % rend )
7727  * 
7728  *         return 1, rtid, rstart, rend             # <<<<<<<<<<<<<<
7729  * 
7730  *     def seek( self, uint64_t offset, int where = 0):
7731  */
7732   __Pyx_XDECREF(__pyx_r);
7733   __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;}
7734   __Pyx_GOTREF(__pyx_t_6);
7735   __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;}
7736   __Pyx_GOTREF(__pyx_t_1);
7737   __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;}
7738   __Pyx_GOTREF(__pyx_t_5);
7739   __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;}
7740   __Pyx_GOTREF(__pyx_t_7);
7741   __Pyx_INCREF(__pyx_int_1);
7742   PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_int_1);
7743   __Pyx_GIVEREF(__pyx_int_1);
7744   PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_6);
7745   __Pyx_GIVEREF(__pyx_t_6);
7746   PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_t_1);
7747   __Pyx_GIVEREF(__pyx_t_1);
7748   PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_t_5);
7749   __Pyx_GIVEREF(__pyx_t_5);
7750   __pyx_t_6 = 0;
7751   __pyx_t_1 = 0;
7752   __pyx_t_5 = 0;
7753   __pyx_r = __pyx_t_7;
7754   __pyx_t_7 = 0;
7755   goto __pyx_L0;
7756
7757   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
7758   goto __pyx_L0;
7759   __pyx_L1_error:;
7760   __Pyx_XDECREF(__pyx_t_1);
7761   __Pyx_XDECREF(__pyx_t_5);
7762   __Pyx_XDECREF(__pyx_t_6);
7763   __Pyx_XDECREF(__pyx_t_7);
7764   __Pyx_XDECREF(__pyx_t_8);
7765   __Pyx_AddTraceback("csamtools.Samfile._parseRegion");
7766   __pyx_r = NULL;
7767   __pyx_L0:;
7768   __Pyx_DECREF(__pyx_v_parts);
7769   __Pyx_DECREF(__pyx_v_reference);
7770   __Pyx_XGIVEREF(__pyx_r);
7771   __Pyx_TraceReturn(__pyx_r);
7772   __Pyx_RefNannyFinishContext();
7773   return __pyx_r;
7774 }
7775
7776 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":691
7777  *         return 1, rtid, rstart, rend
7778  * 
7779  *     def seek( self, uint64_t offset, int where = 0):             # <<<<<<<<<<<<<<
7780  *         '''
7781  *         move file pointer to position *offset*, see :meth:`pysam.Samfile.tell`.
7782  */
7783
7784 static PyObject *__pyx_pf_9csamtools_7Samfile_seek(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
7785 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        ";
7786 static PyObject *__pyx_pf_9csamtools_7Samfile_seek(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
7787   uint64_t __pyx_v_offset;
7788   int __pyx_v_where;
7789   PyObject *__pyx_r = NULL;
7790   PyObject *__pyx_t_1 = NULL;
7791   PyObject *__pyx_t_2 = NULL;
7792   int __pyx_t_3;
7793   int __pyx_t_4;
7794   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__offset,&__pyx_n_s__where,0};
7795   __Pyx_TraceDeclarations
7796   __Pyx_RefNannySetupContext("seek");
7797   __Pyx_TraceCall("seek", __pyx_f[0], 691);
7798   if (unlikely(__pyx_kwds)) {
7799     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
7800     PyObject* values[2] = {0,0};
7801     switch (PyTuple_GET_SIZE(__pyx_args)) {
7802       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
7803       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
7804       case  0: break;
7805       default: goto __pyx_L5_argtuple_error;
7806     }
7807     switch (PyTuple_GET_SIZE(__pyx_args)) {
7808       case  0:
7809       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__offset);
7810       if (likely(values[0])) kw_args--;
7811       else goto __pyx_L5_argtuple_error;
7812       case  1:
7813       if (kw_args > 0) {
7814         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__where);
7815         if (value) { values[1] = value; kw_args--; }
7816       }
7817     }
7818     if (unlikely(kw_args > 0)) {
7819       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;}
7820     }
7821     __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;}
7822     if (values[1]) {
7823       __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;}
7824     } else {
7825       __pyx_v_where = ((int)0);
7826     }
7827   } else {
7828     __pyx_v_where = ((int)0);
7829     switch (PyTuple_GET_SIZE(__pyx_args)) {
7830       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;}
7831       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;}
7832       break;
7833       default: goto __pyx_L5_argtuple_error;
7834     }
7835   }
7836   goto __pyx_L4_argument_unpacking_done;
7837   __pyx_L5_argtuple_error:;
7838   __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;}
7839   __pyx_L3_error:;
7840   __Pyx_AddTraceback("csamtools.Samfile.seek");
7841   __Pyx_RefNannyFinishContext();
7842   return NULL;
7843   __pyx_L4_argument_unpacking_done:;
7844
7845   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":696
7846  *         '''
7847  * 
7848  *         if not self._isOpen():             # <<<<<<<<<<<<<<
7849  *             raise ValueError( "I/O operation on closed file" )
7850  *         if not self.isbam:
7851  */
7852   __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;}
7853   __Pyx_GOTREF(__pyx_t_1);
7854   __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;}
7855   __Pyx_GOTREF(__pyx_t_2);
7856   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7857   __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;}
7858   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7859   __pyx_t_4 = (!__pyx_t_3);
7860   if (__pyx_t_4) {
7861
7862     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":697
7863  * 
7864  *         if not self._isOpen():
7865  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
7866  *         if not self.isbam:
7867  *             raise NotImplementedError("seek only available in bam files")
7868  */
7869     __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;}
7870     __Pyx_GOTREF(__pyx_t_2);
7871     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
7872     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
7873     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
7874     __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;}
7875     __Pyx_GOTREF(__pyx_t_1);
7876     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7877     __Pyx_Raise(__pyx_t_1, 0, 0);
7878     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7879     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7880     goto __pyx_L6;
7881   }
7882   __pyx_L6:;
7883
7884   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":698
7885  *         if not self._isOpen():
7886  *             raise ValueError( "I/O operation on closed file" )
7887  *         if not self.isbam:             # <<<<<<<<<<<<<<
7888  *             raise NotImplementedError("seek only available in bam files")
7889  *         return bam_seek( self.samfile.x.bam, offset, where )
7890  */
7891   __pyx_t_4 = (!((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam);
7892   if (__pyx_t_4) {
7893
7894     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":699
7895  *             raise ValueError( "I/O operation on closed file" )
7896  *         if not self.isbam:
7897  *             raise NotImplementedError("seek only available in bam files")             # <<<<<<<<<<<<<<
7898  *         return bam_seek( self.samfile.x.bam, offset, where )
7899  * 
7900  */
7901     __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;}
7902     __Pyx_GOTREF(__pyx_t_1);
7903     __Pyx_INCREF(((PyObject *)__pyx_kp_s_28));
7904     PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_28));
7905     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_28));
7906     __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;}
7907     __Pyx_GOTREF(__pyx_t_2);
7908     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7909     __Pyx_Raise(__pyx_t_2, 0, 0);
7910     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7911     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7912     goto __pyx_L7;
7913   }
7914   __pyx_L7:;
7915
7916   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":700
7917  *         if not self.isbam:
7918  *             raise NotImplementedError("seek only available in bam files")
7919  *         return bam_seek( self.samfile.x.bam, offset, where )             # <<<<<<<<<<<<<<
7920  * 
7921  *     def tell( self ):
7922  */
7923   __Pyx_XDECREF(__pyx_r);
7924   __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;}
7925   __Pyx_GOTREF(__pyx_t_2);
7926   __pyx_r = __pyx_t_2;
7927   __pyx_t_2 = 0;
7928   goto __pyx_L0;
7929
7930   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
7931   goto __pyx_L0;
7932   __pyx_L1_error:;
7933   __Pyx_XDECREF(__pyx_t_1);
7934   __Pyx_XDECREF(__pyx_t_2);
7935   __Pyx_AddTraceback("csamtools.Samfile.seek");
7936   __pyx_r = NULL;
7937   __pyx_L0:;
7938   __Pyx_XGIVEREF(__pyx_r);
7939   __Pyx_TraceReturn(__pyx_r);
7940   __Pyx_RefNannyFinishContext();
7941   return __pyx_r;
7942 }
7943
7944 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":702
7945  *         return bam_seek( self.samfile.x.bam, offset, where )
7946  * 
7947  *     def tell( self ):             # <<<<<<<<<<<<<<
7948  *         '''
7949  *         return current file position
7950  */
7951
7952 static PyObject *__pyx_pf_9csamtools_7Samfile_tell(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
7953 static char __pyx_doc_9csamtools_7Samfile_tell[] = "Samfile.tell(self)\n\n        return current file position\n        ";
7954 static PyObject *__pyx_pf_9csamtools_7Samfile_tell(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
7955   PyObject *__pyx_r = NULL;
7956   PyObject *__pyx_t_1 = NULL;
7957   PyObject *__pyx_t_2 = NULL;
7958   int __pyx_t_3;
7959   int __pyx_t_4;
7960   __Pyx_TraceDeclarations
7961   __Pyx_RefNannySetupContext("tell");
7962   __Pyx_TraceCall("tell", __pyx_f[0], 702);
7963
7964   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":706
7965  *         return current file position
7966  *         '''
7967  *         if not self._isOpen():             # <<<<<<<<<<<<<<
7968  *             raise ValueError( "I/O operation on closed file" )
7969  *         if not self.isbam:
7970  */
7971   __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;}
7972   __Pyx_GOTREF(__pyx_t_1);
7973   __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;}
7974   __Pyx_GOTREF(__pyx_t_2);
7975   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7976   __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;}
7977   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7978   __pyx_t_4 = (!__pyx_t_3);
7979   if (__pyx_t_4) {
7980
7981     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":707
7982  *         '''
7983  *         if not self._isOpen():
7984  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
7985  *         if not self.isbam:
7986  *             raise NotImplementedError("seek only available in bam files")
7987  */
7988     __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;}
7989     __Pyx_GOTREF(__pyx_t_2);
7990     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
7991     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
7992     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
7993     __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;}
7994     __Pyx_GOTREF(__pyx_t_1);
7995     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7996     __Pyx_Raise(__pyx_t_1, 0, 0);
7997     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7998     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7999     goto __pyx_L5;
8000   }
8001   __pyx_L5:;
8002
8003   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":708
8004  *         if not self._isOpen():
8005  *             raise ValueError( "I/O operation on closed file" )
8006  *         if not self.isbam:             # <<<<<<<<<<<<<<
8007  *             raise NotImplementedError("seek only available in bam files")
8008  * 
8009  */
8010   __pyx_t_4 = (!((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam);
8011   if (__pyx_t_4) {
8012
8013     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":709
8014  *             raise ValueError( "I/O operation on closed file" )
8015  *         if not self.isbam:
8016  *             raise NotImplementedError("seek only available in bam files")             # <<<<<<<<<<<<<<
8017  * 
8018  *         return bam_tell( self.samfile.x.bam )
8019  */
8020     __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;}
8021     __Pyx_GOTREF(__pyx_t_1);
8022     __Pyx_INCREF(((PyObject *)__pyx_kp_s_28));
8023     PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_28));
8024     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_28));
8025     __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;}
8026     __Pyx_GOTREF(__pyx_t_2);
8027     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8028     __Pyx_Raise(__pyx_t_2, 0, 0);
8029     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8030     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8031     goto __pyx_L6;
8032   }
8033   __pyx_L6:;
8034
8035   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":711
8036  *             raise NotImplementedError("seek only available in bam files")
8037  * 
8038  *         return bam_tell( self.samfile.x.bam )             # <<<<<<<<<<<<<<
8039  * 
8040  *     def fetch( self,
8041  */
8042   __Pyx_XDECREF(__pyx_r);
8043   __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;}
8044   __Pyx_GOTREF(__pyx_t_2);
8045   __pyx_r = __pyx_t_2;
8046   __pyx_t_2 = 0;
8047   goto __pyx_L0;
8048
8049   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
8050   goto __pyx_L0;
8051   __pyx_L1_error:;
8052   __Pyx_XDECREF(__pyx_t_1);
8053   __Pyx_XDECREF(__pyx_t_2);
8054   __Pyx_AddTraceback("csamtools.Samfile.tell");
8055   __pyx_r = NULL;
8056   __pyx_L0:;
8057   __Pyx_XGIVEREF(__pyx_r);
8058   __Pyx_TraceReturn(__pyx_r);
8059   __Pyx_RefNannyFinishContext();
8060   return __pyx_r;
8061 }
8062
8063 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":713
8064  *         return bam_tell( self.samfile.x.bam )
8065  * 
8066  *     def fetch( self,             # <<<<<<<<<<<<<<
8067  *                reference = None,
8068  *                start = None,
8069  */
8070
8071 static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
8072 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        ";
8073 static PyObject *__pyx_pf_9csamtools_7Samfile_fetch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
8074   PyObject *__pyx_v_reference = 0;
8075   PyObject *__pyx_v_start = 0;
8076   PyObject *__pyx_v_end = 0;
8077   PyObject *__pyx_v_region = 0;
8078   PyObject *__pyx_v_callback = 0;
8079   PyObject *__pyx_v_until_eof = 0;
8080   int __pyx_v_rtid;
8081   int __pyx_v_rstart;
8082   int __pyx_v_rend;
8083   int __pyx_v_has_coord;
8084   PyObject *__pyx_r = NULL;
8085   PyObject *__pyx_t_1 = NULL;
8086   PyObject *__pyx_t_2 = NULL;
8087   int __pyx_t_3;
8088   int __pyx_t_4;
8089   PyObject *__pyx_t_5 = NULL;
8090   PyObject *__pyx_t_6 = NULL;
8091   PyObject *__pyx_t_7 = NULL;
8092   int __pyx_t_8;
8093   int __pyx_t_9;
8094   int __pyx_t_10;
8095   int __pyx_t_11;
8096   PyObject *__pyx_t_12 = NULL;
8097   int __pyx_t_13;
8098   int __pyx_t_14;
8099   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};
8100   __Pyx_TraceDeclarations
8101   __Pyx_RefNannySetupContext("fetch");
8102   __Pyx_TraceCall("fetch", __pyx_f[0], 713);
8103   if (unlikely(__pyx_kwds)) {
8104     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
8105     PyObject* values[6] = {0,0,0,0,0,0};
8106
8107     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":714
8108  * 
8109  *     def fetch( self,
8110  *                reference = None,             # <<<<<<<<<<<<<<
8111  *                start = None,
8112  *                end = None,
8113  */
8114     values[0] = ((PyObject *)Py_None);
8115
8116     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":715
8117  *     def fetch( self,
8118  *                reference = None,
8119  *                start = None,             # <<<<<<<<<<<<<<
8120  *                end = None,
8121  *                region = None,
8122  */
8123     values[1] = ((PyObject *)Py_None);
8124
8125     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":716
8126  *                reference = None,
8127  *                start = None,
8128  *                end = None,             # <<<<<<<<<<<<<<
8129  *                region = None,
8130  *                callback = None,
8131  */
8132     values[2] = ((PyObject *)Py_None);
8133
8134     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":717
8135  *                start = None,
8136  *                end = None,
8137  *                region = None,             # <<<<<<<<<<<<<<
8138  *                callback = None,
8139  *                until_eof = False ):
8140  */
8141     values[3] = ((PyObject *)Py_None);
8142
8143     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":718
8144  *                end = None,
8145  *                region = None,
8146  *                callback = None,             # <<<<<<<<<<<<<<
8147  *                until_eof = False ):
8148  *         '''
8149  */
8150     values[4] = ((PyObject *)Py_None);
8151     values[5] = __pyx_k_29;
8152     switch (PyTuple_GET_SIZE(__pyx_args)) {
8153       case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
8154       case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
8155       case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
8156       case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
8157       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
8158       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
8159       case  0: break;
8160       default: goto __pyx_L5_argtuple_error;
8161     }
8162     switch (PyTuple_GET_SIZE(__pyx_args)) {
8163       case  0:
8164       if (kw_args > 0) {
8165         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reference);
8166         if (value) { values[0] = value; kw_args--; }
8167       }
8168       case  1:
8169       if (kw_args > 0) {
8170         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start);
8171         if (value) { values[1] = value; kw_args--; }
8172       }
8173       case  2:
8174       if (kw_args > 0) {
8175         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end);
8176         if (value) { values[2] = value; kw_args--; }
8177       }
8178       case  3:
8179       if (kw_args > 0) {
8180         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__region);
8181         if (value) { values[3] = value; kw_args--; }
8182       }
8183       case  4:
8184       if (kw_args > 0) {
8185         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__callback);
8186         if (value) { values[4] = value; kw_args--; }
8187       }
8188       case  5:
8189       if (kw_args > 0) {
8190         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__until_eof);
8191         if (value) { values[5] = value; kw_args--; }
8192       }
8193     }
8194     if (unlikely(kw_args > 0)) {
8195       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;}
8196     }
8197     __pyx_v_reference = values[0];
8198     __pyx_v_start = values[1];
8199     __pyx_v_end = values[2];
8200     __pyx_v_region = values[3];
8201     __pyx_v_callback = values[4];
8202     __pyx_v_until_eof = values[5];
8203   } else {
8204
8205     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":714
8206  * 
8207  *     def fetch( self,
8208  *                reference = None,             # <<<<<<<<<<<<<<
8209  *                start = None,
8210  *                end = None,
8211  */
8212     __pyx_v_reference = ((PyObject *)Py_None);
8213
8214     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":715
8215  *     def fetch( self,
8216  *                reference = None,
8217  *                start = None,             # <<<<<<<<<<<<<<
8218  *                end = None,
8219  *                region = None,
8220  */
8221     __pyx_v_start = ((PyObject *)Py_None);
8222
8223     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":716
8224  *                reference = None,
8225  *                start = None,
8226  *                end = None,             # <<<<<<<<<<<<<<
8227  *                region = None,
8228  *                callback = None,
8229  */
8230     __pyx_v_end = ((PyObject *)Py_None);
8231
8232     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":717
8233  *                start = None,
8234  *                end = None,
8235  *                region = None,             # <<<<<<<<<<<<<<
8236  *                callback = None,
8237  *                until_eof = False ):
8238  */
8239     __pyx_v_region = ((PyObject *)Py_None);
8240
8241     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":718
8242  *                end = None,
8243  *                region = None,
8244  *                callback = None,             # <<<<<<<<<<<<<<
8245  *                until_eof = False ):
8246  *         '''
8247  */
8248     __pyx_v_callback = ((PyObject *)Py_None);
8249     __pyx_v_until_eof = __pyx_k_29;
8250     switch (PyTuple_GET_SIZE(__pyx_args)) {
8251       case  6: __pyx_v_until_eof = PyTuple_GET_ITEM(__pyx_args, 5);
8252       case  5: __pyx_v_callback = PyTuple_GET_ITEM(__pyx_args, 4);
8253       case  4: __pyx_v_region = PyTuple_GET_ITEM(__pyx_args, 3);
8254       case  3: __pyx_v_end = PyTuple_GET_ITEM(__pyx_args, 2);
8255       case  2: __pyx_v_start = PyTuple_GET_ITEM(__pyx_args, 1);
8256       case  1: __pyx_v_reference = PyTuple_GET_ITEM(__pyx_args, 0);
8257       case  0: break;
8258       default: goto __pyx_L5_argtuple_error;
8259     }
8260   }
8261   goto __pyx_L4_argument_unpacking_done;
8262   __pyx_L5_argtuple_error:;
8263   __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;}
8264   __pyx_L3_error:;
8265   __Pyx_AddTraceback("csamtools.Samfile.fetch");
8266   __Pyx_RefNannyFinishContext();
8267   return NULL;
8268   __pyx_L4_argument_unpacking_done:;
8269
8270   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":742
8271  *         cdef int rtid, rstart, rend, has_coord
8272  * 
8273  *         if not self._isOpen():             # <<<<<<<<<<<<<<
8274  *             raise ValueError( "I/O operation on closed file" )
8275  * 
8276  */
8277   __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;}
8278   __Pyx_GOTREF(__pyx_t_1);
8279   __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;}
8280   __Pyx_GOTREF(__pyx_t_2);
8281   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8282   __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;}
8283   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8284   __pyx_t_4 = (!__pyx_t_3);
8285   if (__pyx_t_4) {
8286
8287     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":743
8288  * 
8289  *         if not self._isOpen():
8290  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
8291  * 
8292  *         has_coord, rtid, rstart, rend = self._parseRegion( reference, start, end, region )
8293  */
8294     __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;}
8295     __Pyx_GOTREF(__pyx_t_2);
8296     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
8297     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
8298     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
8299     __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;}
8300     __Pyx_GOTREF(__pyx_t_1);
8301     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8302     __Pyx_Raise(__pyx_t_1, 0, 0);
8303     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8304     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 743; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8305     goto __pyx_L6;
8306   }
8307   __pyx_L6:;
8308
8309   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":745
8310  *             raise ValueError( "I/O operation on closed file" )
8311  * 
8312  *         has_coord, rtid, rstart, rend = self._parseRegion( reference, start, end, region )             # <<<<<<<<<<<<<<
8313  * 
8314  *         if self.isbam:
8315  */
8316   __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;}
8317   __Pyx_GOTREF(__pyx_t_1);
8318   __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;}
8319   __Pyx_GOTREF(__pyx_t_2);
8320   __Pyx_INCREF(__pyx_v_reference);
8321   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_reference);
8322   __Pyx_GIVEREF(__pyx_v_reference);
8323   __Pyx_INCREF(__pyx_v_start);
8324   PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_start);
8325   __Pyx_GIVEREF(__pyx_v_start);
8326   __Pyx_INCREF(__pyx_v_end);
8327   PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_end);
8328   __Pyx_GIVEREF(__pyx_v_end);
8329   __Pyx_INCREF(__pyx_v_region);
8330   PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_region);
8331   __Pyx_GIVEREF(__pyx_v_region);
8332   __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;}
8333   __Pyx_GOTREF(__pyx_t_5);
8334   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8335   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8336   if (PyTuple_CheckExact(__pyx_t_5) && likely(PyTuple_GET_SIZE(__pyx_t_5) == 4)) {
8337     PyObject* tuple = __pyx_t_5;
8338     __pyx_t_2 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_2);
8339     __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;}
8340     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8341     __pyx_t_1 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_1);
8342     __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;}
8343     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8344     __pyx_t_6 = PyTuple_GET_ITEM(tuple, 2); __Pyx_INCREF(__pyx_t_6);
8345     __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;}
8346     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
8347     __pyx_t_7 = PyTuple_GET_ITEM(tuple, 3); __Pyx_INCREF(__pyx_t_7);
8348     __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;}
8349     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
8350     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
8351     __pyx_v_has_coord = __pyx_t_8;
8352     __pyx_v_rtid = __pyx_t_9;
8353     __pyx_v_rstart = __pyx_t_10;
8354     __pyx_v_rend = __pyx_t_11;
8355   } else {
8356     __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;}
8357     __Pyx_GOTREF(__pyx_t_12);
8358     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
8359     __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;}
8360     __Pyx_GOTREF(__pyx_t_2);
8361     __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;}
8362     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8363     __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;}
8364     __Pyx_GOTREF(__pyx_t_1);
8365     __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;}
8366     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8367     __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;}
8368     __Pyx_GOTREF(__pyx_t_6);
8369     __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;}
8370     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
8371     __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;}
8372     __Pyx_GOTREF(__pyx_t_7);
8373     __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;}
8374     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
8375     if (__Pyx_EndUnpack(__pyx_t_12, 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8376     __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
8377     __pyx_v_has_coord = __pyx_t_11;
8378     __pyx_v_rtid = __pyx_t_10;
8379     __pyx_v_rstart = __pyx_t_9;
8380     __pyx_v_rend = __pyx_t_8;
8381   }
8382
8383   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":747
8384  *         has_coord, rtid, rstart, rend = self._parseRegion( reference, start, end, region )
8385  * 
8386  *         if self.isbam:             # <<<<<<<<<<<<<<
8387  *             if not until_eof and not self._hasIndex() and not self.isremote:
8388  *                 raise ValueError( "fetch called on bamfile without index" )
8389  */
8390   if (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam) {
8391
8392     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":748
8393  * 
8394  *         if self.isbam:
8395  *             if not until_eof and not self._hasIndex() and not self.isremote:             # <<<<<<<<<<<<<<
8396  *                 raise ValueError( "fetch called on bamfile without index" )
8397  * 
8398  */
8399     __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;}
8400     __pyx_t_3 = (!__pyx_t_4);
8401     if (__pyx_t_3) {
8402       __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;}
8403       __Pyx_GOTREF(__pyx_t_5);
8404       __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;}
8405       __Pyx_GOTREF(__pyx_t_7);
8406       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
8407       __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;}
8408       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
8409       __pyx_t_13 = (!__pyx_t_4);
8410       if (__pyx_t_13) {
8411         __pyx_t_4 = (!((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isremote);
8412         __pyx_t_14 = __pyx_t_4;
8413       } else {
8414         __pyx_t_14 = __pyx_t_13;
8415       }
8416       __pyx_t_13 = __pyx_t_14;
8417     } else {
8418       __pyx_t_13 = __pyx_t_3;
8419     }
8420     if (__pyx_t_13) {
8421
8422       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":749
8423  *         if self.isbam:
8424  *             if not until_eof and not self._hasIndex() and not self.isremote:
8425  *                 raise ValueError( "fetch called on bamfile without index" )             # <<<<<<<<<<<<<<
8426  * 
8427  *             if callback:
8428  */
8429       __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;}
8430       __Pyx_GOTREF(__pyx_t_7);
8431       __Pyx_INCREF(((PyObject *)__pyx_kp_s_30));
8432       PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_kp_s_30));
8433       __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_30));
8434       __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;}
8435       __Pyx_GOTREF(__pyx_t_5);
8436       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
8437       __Pyx_Raise(__pyx_t_5, 0, 0);
8438       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
8439       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8440       goto __pyx_L8;
8441     }
8442     __pyx_L8:;
8443
8444     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":751
8445  *                 raise ValueError( "fetch called on bamfile without index" )
8446  * 
8447  *             if callback:             # <<<<<<<<<<<<<<
8448  *                 if not has_coord: raise ValueError( "callback functionality requires a region/reference" )
8449  *                 if not self._hasIndex(): raise ValueError( "no index available for fetch" )
8450  */
8451     __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;}
8452     if (__pyx_t_13) {
8453
8454       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":752
8455  * 
8456  *             if callback:
8457  *                 if not has_coord: raise ValueError( "callback functionality requires a region/reference" )             # <<<<<<<<<<<<<<
8458  *                 if not self._hasIndex(): raise ValueError( "no index available for fetch" )
8459  *                 return bam_fetch(self.samfile.x.bam,
8460  */
8461       __pyx_t_13 = (!__pyx_v_has_coord);
8462       if (__pyx_t_13) {
8463         __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;}
8464         __Pyx_GOTREF(__pyx_t_5);
8465         __Pyx_INCREF(((PyObject *)__pyx_kp_s_31));
8466         PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_31));
8467         __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_31));
8468         __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;}
8469         __Pyx_GOTREF(__pyx_t_7);
8470         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
8471         __Pyx_Raise(__pyx_t_7, 0, 0);
8472         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
8473         {__pyx_filename = __pyx_f[0]; __pyx_lineno = 752; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8474         goto __pyx_L10;
8475       }
8476       __pyx_L10:;
8477
8478       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":753
8479  *             if callback:
8480  *                 if not has_coord: raise ValueError( "callback functionality requires a region/reference" )
8481  *                 if not self._hasIndex(): raise ValueError( "no index available for fetch" )             # <<<<<<<<<<<<<<
8482  *                 return bam_fetch(self.samfile.x.bam,
8483  *                                  self.index,
8484  */
8485       __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;}
8486       __Pyx_GOTREF(__pyx_t_7);
8487       __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;}
8488       __Pyx_GOTREF(__pyx_t_5);
8489       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
8490       __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;}
8491       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
8492       __pyx_t_3 = (!__pyx_t_13);
8493       if (__pyx_t_3) {
8494         __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;}
8495         __Pyx_GOTREF(__pyx_t_5);
8496         __Pyx_INCREF(((PyObject *)__pyx_kp_s_32));
8497         PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_32));
8498         __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_32));
8499         __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;}
8500         __Pyx_GOTREF(__pyx_t_7);
8501         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
8502         __Pyx_Raise(__pyx_t_7, 0, 0);
8503         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
8504         {__pyx_filename = __pyx_f[0]; __pyx_lineno = 753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8505         goto __pyx_L11;
8506       }
8507       __pyx_L11:;
8508
8509       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":754
8510  *                 if not has_coord: raise ValueError( "callback functionality requires a region/reference" )
8511  *                 if not self._hasIndex(): raise ValueError( "no index available for fetch" )
8512  *                 return bam_fetch(self.samfile.x.bam,             # <<<<<<<<<<<<<<
8513  *                                  self.index,
8514  *                                  rtid,
8515  */
8516       __Pyx_XDECREF(__pyx_r);
8517
8518       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":760
8519  *                                  rend,
8520  *                                  <void*>callback,
8521  *                                  fetch_callback )             # <<<<<<<<<<<<<<
8522  *             else:
8523  *                 if has_coord:
8524  */
8525       __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;}
8526       __Pyx_GOTREF(__pyx_t_7);
8527       __pyx_r = __pyx_t_7;
8528       __pyx_t_7 = 0;
8529       goto __pyx_L0;
8530       goto __pyx_L9;
8531     }
8532     /*else*/ {
8533
8534       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":762
8535  *                                  fetch_callback )
8536  *             else:
8537  *                 if has_coord:             # <<<<<<<<<<<<<<
8538  *                     return IteratorRowRegion( self, rtid, rstart, rend )
8539  *                 else:
8540  */
8541       if (__pyx_v_has_coord) {
8542
8543         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":763
8544  *             else:
8545  *                 if has_coord:
8546  *                     return IteratorRowRegion( self, rtid, rstart, rend )             # <<<<<<<<<<<<<<
8547  *                 else:
8548  *                     if until_eof:
8549  */
8550         __Pyx_XDECREF(__pyx_r);
8551         __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;}
8552         __Pyx_GOTREF(__pyx_t_7);
8553         __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;}
8554         __Pyx_GOTREF(__pyx_t_5);
8555         __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;}
8556         __Pyx_GOTREF(__pyx_t_6);
8557         __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;}
8558         __Pyx_GOTREF(__pyx_t_1);
8559         __Pyx_INCREF(__pyx_v_self);
8560         PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self);
8561         __Pyx_GIVEREF(__pyx_v_self);
8562         PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_7);
8563         __Pyx_GIVEREF(__pyx_t_7);
8564         PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_t_5);
8565         __Pyx_GIVEREF(__pyx_t_5);
8566         PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_t_6);
8567         __Pyx_GIVEREF(__pyx_t_6);
8568         __pyx_t_7 = 0;
8569         __pyx_t_5 = 0;
8570         __pyx_t_6 = 0;
8571         __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;}
8572         __Pyx_GOTREF(__pyx_t_6);
8573         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8574         __pyx_r = __pyx_t_6;
8575         __pyx_t_6 = 0;
8576         goto __pyx_L0;
8577         goto __pyx_L12;
8578       }
8579       /*else*/ {
8580
8581         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":765
8582  *                     return IteratorRowRegion( self, rtid, rstart, rend )
8583  *                 else:
8584  *                     if until_eof:             # <<<<<<<<<<<<<<
8585  *                         return IteratorRowAll( self )
8586  *                     else:
8587  */
8588         __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;}
8589         if (__pyx_t_3) {
8590
8591           /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":766
8592  *                 else:
8593  *                     if until_eof:
8594  *                         return IteratorRowAll( self )             # <<<<<<<<<<<<<<
8595  *                     else:
8596  *                         return IteratorRowAllRefs(self)
8597  */
8598           __Pyx_XDECREF(__pyx_r);
8599           __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;}
8600           __Pyx_GOTREF(__pyx_t_6);
8601           __Pyx_INCREF(__pyx_v_self);
8602           PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_self);
8603           __Pyx_GIVEREF(__pyx_v_self);
8604           __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;}
8605           __Pyx_GOTREF(__pyx_t_1);
8606           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
8607           __pyx_r = __pyx_t_1;
8608           __pyx_t_1 = 0;
8609           goto __pyx_L0;
8610           goto __pyx_L13;
8611         }
8612         /*else*/ {
8613
8614           /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":768
8615  *                         return IteratorRowAll( self )
8616  *                     else:
8617  *                         return IteratorRowAllRefs(self)             # <<<<<<<<<<<<<<
8618  *         else:
8619  *             # check if header is present - otherwise sam_read1 aborts
8620  */
8621           __Pyx_XDECREF(__pyx_r);
8622           __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;}
8623           __Pyx_GOTREF(__pyx_t_1);
8624           __Pyx_INCREF(__pyx_v_self);
8625           PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self);
8626           __Pyx_GIVEREF(__pyx_v_self);
8627           __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;}
8628           __Pyx_GOTREF(__pyx_t_6);
8629           __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8630           __pyx_r = __pyx_t_6;
8631           __pyx_t_6 = 0;
8632           goto __pyx_L0;
8633         }
8634         __pyx_L13:;
8635       }
8636       __pyx_L12:;
8637     }
8638     __pyx_L9:;
8639     goto __pyx_L7;
8640   }
8641   /*else*/ {
8642
8643     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":772
8644  *             # check if header is present - otherwise sam_read1 aborts
8645  *             # this happens if a bamfile is opened with mode 'r'
8646  *             if self.samfile.header.n_targets == 0:             # <<<<<<<<<<<<<<
8647  *                 raise ValueError( "fetch called for samfile without header")
8648  * 
8649  */
8650     __pyx_t_3 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->n_targets == 0);
8651     if (__pyx_t_3) {
8652
8653       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":773
8654  *             # this happens if a bamfile is opened with mode 'r'
8655  *             if self.samfile.header.n_targets == 0:
8656  *                 raise ValueError( "fetch called for samfile without header")             # <<<<<<<<<<<<<<
8657  * 
8658  *             if region != None:
8659  */
8660       __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;}
8661       __Pyx_GOTREF(__pyx_t_6);
8662       __Pyx_INCREF(((PyObject *)__pyx_kp_s_33));
8663       PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_33));
8664       __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_33));
8665       __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;}
8666       __Pyx_GOTREF(__pyx_t_1);
8667       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
8668       __Pyx_Raise(__pyx_t_1, 0, 0);
8669       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8670       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8671       goto __pyx_L14;
8672     }
8673     __pyx_L14:;
8674
8675     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":775
8676  *                 raise ValueError( "fetch called for samfile without header")
8677  * 
8678  *             if region != None:             # <<<<<<<<<<<<<<
8679  *                 raise ValueError ("fetch for a region is not available for sam files" )
8680  *             if callback:
8681  */
8682     __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;}
8683     __Pyx_GOTREF(__pyx_t_1);
8684     __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;}
8685     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8686     if (__pyx_t_3) {
8687
8688       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":776
8689  * 
8690  *             if region != None:
8691  *                 raise ValueError ("fetch for a region is not available for sam files" )             # <<<<<<<<<<<<<<
8692  *             if callback:
8693  *                 raise NotImplementedError( "callback not implemented yet" )
8694  */
8695       __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;}
8696       __Pyx_GOTREF(__pyx_t_1);
8697       __Pyx_INCREF(((PyObject *)__pyx_kp_s_34));
8698       PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_34));
8699       __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_34));
8700       __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;}
8701       __Pyx_GOTREF(__pyx_t_6);
8702       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8703       __Pyx_Raise(__pyx_t_6, 0, 0);
8704       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
8705       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8706       goto __pyx_L15;
8707     }
8708     __pyx_L15:;
8709
8710     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":777
8711  *             if region != None:
8712  *                 raise ValueError ("fetch for a region is not available for sam files" )
8713  *             if callback:             # <<<<<<<<<<<<<<
8714  *                 raise NotImplementedError( "callback not implemented yet" )
8715  *             else:
8716  */
8717     __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;}
8718     if (__pyx_t_3) {
8719
8720       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":778
8721  *                 raise ValueError ("fetch for a region is not available for sam files" )
8722  *             if callback:
8723  *                 raise NotImplementedError( "callback not implemented yet" )             # <<<<<<<<<<<<<<
8724  *             else:
8725  *                 return IteratorRowAll( self )
8726  */
8727       __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;}
8728       __Pyx_GOTREF(__pyx_t_6);
8729       __Pyx_INCREF(((PyObject *)__pyx_kp_s_35));
8730       PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_35));
8731       __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_35));
8732       __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;}
8733       __Pyx_GOTREF(__pyx_t_1);
8734       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
8735       __Pyx_Raise(__pyx_t_1, 0, 0);
8736       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8737       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8738       goto __pyx_L16;
8739     }
8740     /*else*/ {
8741
8742       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":780
8743  *                 raise NotImplementedError( "callback not implemented yet" )
8744  *             else:
8745  *                 return IteratorRowAll( self )             # <<<<<<<<<<<<<<
8746  * 
8747  *     def mate( self,
8748  */
8749       __Pyx_XDECREF(__pyx_r);
8750       __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;}
8751       __Pyx_GOTREF(__pyx_t_1);
8752       __Pyx_INCREF(__pyx_v_self);
8753       PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self);
8754       __Pyx_GIVEREF(__pyx_v_self);
8755       __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;}
8756       __Pyx_GOTREF(__pyx_t_6);
8757       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8758       __pyx_r = __pyx_t_6;
8759       __pyx_t_6 = 0;
8760       goto __pyx_L0;
8761     }
8762     __pyx_L16:;
8763   }
8764   __pyx_L7:;
8765
8766   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
8767   goto __pyx_L0;
8768   __pyx_L1_error:;
8769   __Pyx_XDECREF(__pyx_t_1);
8770   __Pyx_XDECREF(__pyx_t_2);
8771   __Pyx_XDECREF(__pyx_t_5);
8772   __Pyx_XDECREF(__pyx_t_6);
8773   __Pyx_XDECREF(__pyx_t_7);
8774   __Pyx_XDECREF(__pyx_t_12);
8775   __Pyx_AddTraceback("csamtools.Samfile.fetch");
8776   __pyx_r = NULL;
8777   __pyx_L0:;
8778   __Pyx_XGIVEREF(__pyx_r);
8779   __Pyx_TraceReturn(__pyx_r);
8780   __Pyx_RefNannyFinishContext();
8781   return __pyx_r;
8782 }
8783
8784 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":782
8785  *                 return IteratorRowAll( self )
8786  * 
8787  *     def mate( self,             # <<<<<<<<<<<<<<
8788  *               AlignedRead read ):
8789  *         '''return the mate of :class:`AlignedRead` *read*.
8790  */
8791
8792 static PyObject *__pyx_pf_9csamtools_7Samfile_mate(PyObject *__pyx_v_self, PyObject *__pyx_v_read); /*proto*/
8793 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        ";
8794 static PyObject *__pyx_pf_9csamtools_7Samfile_mate(PyObject *__pyx_v_self, PyObject *__pyx_v_read) {
8795   uint32_t __pyx_v_flag;
8796   __pyx_t_9csamtools_MateData __pyx_v_mate_data;
8797   int __pyx_v_x;
8798   struct __pyx_obj_9csamtools_AlignedRead *__pyx_v_dest = 0;
8799   PyObject *__pyx_r = NULL;
8800   int __pyx_t_1;
8801   PyObject *__pyx_t_2 = NULL;
8802   PyObject *__pyx_t_3 = NULL;
8803   __Pyx_TraceDeclarations
8804   __Pyx_RefNannySetupContext("mate");
8805   __Pyx_TraceCall("mate", __pyx_f[0], 782);
8806   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;}
8807
8808   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":795
8809  * 
8810  *         '''
8811  *         cdef uint32_t flag = read._delegate.core.flag             # <<<<<<<<<<<<<<
8812  * 
8813  *         if flag & BAM_FPAIRED == 0:
8814  */
8815   __pyx_v_flag = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_read)->_delegate->core.flag;
8816
8817   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":797
8818  *         cdef uint32_t flag = read._delegate.core.flag
8819  * 
8820  *         if flag & BAM_FPAIRED == 0:             # <<<<<<<<<<<<<<
8821  *             raise ValueError( "read %s: is unpaired" % (read.qname))
8822  *         if flag & BAM_FMUNMAP != 0:
8823  */
8824   __pyx_t_1 = ((__pyx_v_flag & 1) == 0);
8825   if (__pyx_t_1) {
8826
8827     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":798
8828  * 
8829  *         if flag & BAM_FPAIRED == 0:
8830  *             raise ValueError( "read %s: is unpaired" % (read.qname))             # <<<<<<<<<<<<<<
8831  *         if flag & BAM_FMUNMAP != 0:
8832  *             raise ValueError( "mate %s: is unmapped" % (read.qname))
8833  */
8834     __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;}
8835     __Pyx_GOTREF(__pyx_t_2);
8836     __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;}
8837     __Pyx_GOTREF(((PyObject *)__pyx_t_3));
8838     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8839     __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;}
8840     __Pyx_GOTREF(__pyx_t_2);
8841     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_3));
8842     __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
8843     __pyx_t_3 = 0;
8844     __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;}
8845     __Pyx_GOTREF(__pyx_t_3);
8846     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8847     __Pyx_Raise(__pyx_t_3, 0, 0);
8848     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
8849     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8850     goto __pyx_L5;
8851   }
8852   __pyx_L5:;
8853
8854   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":799
8855  *         if flag & BAM_FPAIRED == 0:
8856  *             raise ValueError( "read %s: is unpaired" % (read.qname))
8857  *         if flag & BAM_FMUNMAP != 0:             # <<<<<<<<<<<<<<
8858  *             raise ValueError( "mate %s: is unmapped" % (read.qname))
8859  * 
8860  */
8861   __pyx_t_1 = ((__pyx_v_flag & 8) != 0);
8862   if (__pyx_t_1) {
8863
8864     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":800
8865  *             raise ValueError( "read %s: is unpaired" % (read.qname))
8866  *         if flag & BAM_FMUNMAP != 0:
8867  *             raise ValueError( "mate %s: is unmapped" % (read.qname))             # <<<<<<<<<<<<<<
8868  * 
8869  *         cdef MateData mate_data
8870  */
8871     __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;}
8872     __Pyx_GOTREF(__pyx_t_3);
8873     __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;}
8874     __Pyx_GOTREF(((PyObject *)__pyx_t_2));
8875     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
8876     __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;}
8877     __Pyx_GOTREF(__pyx_t_3);
8878     PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_2));
8879     __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
8880     __pyx_t_2 = 0;
8881     __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;}
8882     __Pyx_GOTREF(__pyx_t_2);
8883     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
8884     __Pyx_Raise(__pyx_t_2, 0, 0);
8885     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8886     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8887     goto __pyx_L6;
8888   }
8889   __pyx_L6:;
8890
8891   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":804
8892  *         cdef MateData mate_data
8893  * 
8894  *         mate_data.name = <char *>bam1_qname(read._delegate)             # <<<<<<<<<<<<<<
8895  *         mate_data.mate = NULL
8896  *         # xor flags to get the other mate
8897  */
8898   __pyx_v_mate_data.name = bam1_qname(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_read)->_delegate);
8899
8900   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":805
8901  * 
8902  *         mate_data.name = <char *>bam1_qname(read._delegate)
8903  *         mate_data.mate = NULL             # <<<<<<<<<<<<<<
8904  *         # xor flags to get the other mate
8905  *         cdef int x = BAM_FREAD1 + BAM_FREAD2
8906  */
8907   __pyx_v_mate_data.mate = NULL;
8908
8909   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":807
8910  *         mate_data.mate = NULL
8911  *         # xor flags to get the other mate
8912  *         cdef int x = BAM_FREAD1 + BAM_FREAD2             # <<<<<<<<<<<<<<
8913  *         mate_data.flag = ( flag ^ x) & x
8914  * 
8915  */
8916   __pyx_v_x = 192;
8917
8918   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":808
8919  *         # xor flags to get the other mate
8920  *         cdef int x = BAM_FREAD1 + BAM_FREAD2
8921  *         mate_data.flag = ( flag ^ x) & x             # <<<<<<<<<<<<<<
8922  * 
8923  *         bam_fetch(self.samfile.x.bam,
8924  */
8925   __pyx_v_mate_data.flag = ((__pyx_v_flag ^ __pyx_v_x) & __pyx_v_x);
8926
8927   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":816
8928  *                   read._delegate.core.mpos + 1,
8929  *                   <void*>&mate_data,
8930  *                   mate_callback )             # <<<<<<<<<<<<<<
8931  * 
8932  *         if mate_data.mate == NULL:
8933  */
8934   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);
8935
8936   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":818
8937  *                   mate_callback )
8938  * 
8939  *         if mate_data.mate == NULL:             # <<<<<<<<<<<<<<
8940  *             raise ValueError( "mate not found" )
8941  * 
8942  */
8943   __pyx_t_1 = (__pyx_v_mate_data.mate == NULL);
8944   if (__pyx_t_1) {
8945
8946     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":819
8947  * 
8948  *         if mate_data.mate == NULL:
8949  *             raise ValueError( "mate not found" )             # <<<<<<<<<<<<<<
8950  * 
8951  *         cdef AlignedRead dest = AlignedRead.__new__(AlignedRead)
8952  */
8953     __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;}
8954     __Pyx_GOTREF(__pyx_t_2);
8955     __Pyx_INCREF(((PyObject *)__pyx_kp_s_38));
8956     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_38));
8957     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_38));
8958     __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;}
8959     __Pyx_GOTREF(__pyx_t_3);
8960     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8961     __Pyx_Raise(__pyx_t_3, 0, 0);
8962     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
8963     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
8964     goto __pyx_L7;
8965   }
8966   __pyx_L7:;
8967
8968   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":821
8969  *             raise ValueError( "mate not found" )
8970  * 
8971  *         cdef AlignedRead dest = AlignedRead.__new__(AlignedRead)             # <<<<<<<<<<<<<<
8972  *         dest._delegate = mate_data.mate
8973  *         return dest
8974  */
8975   __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;}
8976   __Pyx_GOTREF(__pyx_t_3);
8977   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;}
8978   __pyx_v_dest = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_t_3);
8979   __pyx_t_3 = 0;
8980
8981   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":822
8982  * 
8983  *         cdef AlignedRead dest = AlignedRead.__new__(AlignedRead)
8984  *         dest._delegate = mate_data.mate             # <<<<<<<<<<<<<<
8985  *         return dest
8986  * 
8987  */
8988   __pyx_v_dest->_delegate = __pyx_v_mate_data.mate;
8989
8990   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":823
8991  *         cdef AlignedRead dest = AlignedRead.__new__(AlignedRead)
8992  *         dest._delegate = mate_data.mate
8993  *         return dest             # <<<<<<<<<<<<<<
8994  * 
8995  *     def count( self,
8996  */
8997   __Pyx_XDECREF(__pyx_r);
8998   __Pyx_INCREF(((PyObject *)__pyx_v_dest));
8999   __pyx_r = ((PyObject *)__pyx_v_dest);
9000   goto __pyx_L0;
9001
9002   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
9003   goto __pyx_L0;
9004   __pyx_L1_error:;
9005   __Pyx_XDECREF(__pyx_t_2);
9006   __Pyx_XDECREF(__pyx_t_3);
9007   __Pyx_AddTraceback("csamtools.Samfile.mate");
9008   __pyx_r = NULL;
9009   __pyx_L0:;
9010   __Pyx_XDECREF((PyObject *)__pyx_v_dest);
9011   __Pyx_XGIVEREF(__pyx_r);
9012   __Pyx_TraceReturn(__pyx_r);
9013   __Pyx_RefNannyFinishContext();
9014   return __pyx_r;
9015 }
9016
9017 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":825
9018  *         return dest
9019  * 
9020  *     def count( self,             # <<<<<<<<<<<<<<
9021  *                reference = None,
9022  *                start = None,
9023  */
9024
9025 static PyObject *__pyx_pf_9csamtools_7Samfile_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
9026 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        ";
9027 static PyObject *__pyx_pf_9csamtools_7Samfile_count(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
9028   PyObject *__pyx_v_reference = 0;
9029   PyObject *__pyx_v_start = 0;
9030   PyObject *__pyx_v_end = 0;
9031   PyObject *__pyx_v_region = 0;
9032   PyObject *__pyx_v_until_eof = 0;
9033   int __pyx_v_rtid;
9034   int __pyx_v_rstart;
9035   int __pyx_v_rend;
9036   int __pyx_v_counter;
9037   PyObject *__pyx_r = NULL;
9038   PyObject *__pyx_t_1 = NULL;
9039   PyObject *__pyx_t_2 = NULL;
9040   int __pyx_t_3;
9041   int __pyx_t_4;
9042   PyObject *__pyx_t_5 = NULL;
9043   PyObject *__pyx_t_6 = NULL;
9044   PyObject *__pyx_t_7 = NULL;
9045   int __pyx_t_8;
9046   int __pyx_t_9;
9047   int __pyx_t_10;
9048   PyObject *__pyx_t_11 = NULL;
9049   int __pyx_t_12;
9050   int __pyx_t_13;
9051   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};
9052   __Pyx_TraceDeclarations
9053   __Pyx_RefNannySetupContext("count");
9054   __Pyx_TraceCall("count", __pyx_f[0], 825);
9055   if (unlikely(__pyx_kwds)) {
9056     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
9057     PyObject* values[5] = {0,0,0,0,0};
9058
9059     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":826
9060  * 
9061  *     def count( self,
9062  *                reference = None,             # <<<<<<<<<<<<<<
9063  *                start = None,
9064  *                end = None,
9065  */
9066     values[0] = ((PyObject *)Py_None);
9067
9068     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":827
9069  *     def count( self,
9070  *                reference = None,
9071  *                start = None,             # <<<<<<<<<<<<<<
9072  *                end = None,
9073  *                region = None,
9074  */
9075     values[1] = ((PyObject *)Py_None);
9076
9077     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":828
9078  *                reference = None,
9079  *                start = None,
9080  *                end = None,             # <<<<<<<<<<<<<<
9081  *                region = None,
9082  *                until_eof = False ):
9083  */
9084     values[2] = ((PyObject *)Py_None);
9085
9086     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":829
9087  *                start = None,
9088  *                end = None,
9089  *                region = None,             # <<<<<<<<<<<<<<
9090  *                until_eof = False ):
9091  *         '''*(reference = None, start = None, end = None, region = None, callback = None, until_eof = False)*
9092  */
9093     values[3] = ((PyObject *)Py_None);
9094     values[4] = __pyx_k_39;
9095     switch (PyTuple_GET_SIZE(__pyx_args)) {
9096       case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
9097       case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
9098       case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
9099       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
9100       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
9101       case  0: break;
9102       default: goto __pyx_L5_argtuple_error;
9103     }
9104     switch (PyTuple_GET_SIZE(__pyx_args)) {
9105       case  0:
9106       if (kw_args > 0) {
9107         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reference);
9108         if (value) { values[0] = value; kw_args--; }
9109       }
9110       case  1:
9111       if (kw_args > 0) {
9112         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start);
9113         if (value) { values[1] = value; kw_args--; }
9114       }
9115       case  2:
9116       if (kw_args > 0) {
9117         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end);
9118         if (value) { values[2] = value; kw_args--; }
9119       }
9120       case  3:
9121       if (kw_args > 0) {
9122         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__region);
9123         if (value) { values[3] = value; kw_args--; }
9124       }
9125       case  4:
9126       if (kw_args > 0) {
9127         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__until_eof);
9128         if (value) { values[4] = value; kw_args--; }
9129       }
9130     }
9131     if (unlikely(kw_args > 0)) {
9132       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;}
9133     }
9134     __pyx_v_reference = values[0];
9135     __pyx_v_start = values[1];
9136     __pyx_v_end = values[2];
9137     __pyx_v_region = values[3];
9138     __pyx_v_until_eof = values[4];
9139   } else {
9140
9141     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":826
9142  * 
9143  *     def count( self,
9144  *                reference = None,             # <<<<<<<<<<<<<<
9145  *                start = None,
9146  *                end = None,
9147  */
9148     __pyx_v_reference = ((PyObject *)Py_None);
9149
9150     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":827
9151  *     def count( self,
9152  *                reference = None,
9153  *                start = None,             # <<<<<<<<<<<<<<
9154  *                end = None,
9155  *                region = None,
9156  */
9157     __pyx_v_start = ((PyObject *)Py_None);
9158
9159     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":828
9160  *                reference = None,
9161  *                start = None,
9162  *                end = None,             # <<<<<<<<<<<<<<
9163  *                region = None,
9164  *                until_eof = False ):
9165  */
9166     __pyx_v_end = ((PyObject *)Py_None);
9167
9168     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":829
9169  *                start = None,
9170  *                end = None,
9171  *                region = None,             # <<<<<<<<<<<<<<
9172  *                until_eof = False ):
9173  *         '''*(reference = None, start = None, end = None, region = None, callback = None, until_eof = False)*
9174  */
9175     __pyx_v_region = ((PyObject *)Py_None);
9176     __pyx_v_until_eof = __pyx_k_39;
9177     switch (PyTuple_GET_SIZE(__pyx_args)) {
9178       case  5: __pyx_v_until_eof = PyTuple_GET_ITEM(__pyx_args, 4);
9179       case  4: __pyx_v_region = PyTuple_GET_ITEM(__pyx_args, 3);
9180       case  3: __pyx_v_end = PyTuple_GET_ITEM(__pyx_args, 2);
9181       case  2: __pyx_v_start = PyTuple_GET_ITEM(__pyx_args, 1);
9182       case  1: __pyx_v_reference = PyTuple_GET_ITEM(__pyx_args, 0);
9183       case  0: break;
9184       default: goto __pyx_L5_argtuple_error;
9185     }
9186   }
9187   goto __pyx_L4_argument_unpacking_done;
9188   __pyx_L5_argtuple_error:;
9189   __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;}
9190   __pyx_L3_error:;
9191   __Pyx_AddTraceback("csamtools.Samfile.count");
9192   __Pyx_RefNannyFinishContext();
9193   return NULL;
9194   __pyx_L4_argument_unpacking_done:;
9195   __Pyx_INCREF(__pyx_v_region);
9196
9197   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":843
9198  *         cdef int rend
9199  * 
9200  *         if not self._isOpen():             # <<<<<<<<<<<<<<
9201  *             raise ValueError( "I/O operation on closed file" )
9202  * 
9203  */
9204   __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;}
9205   __Pyx_GOTREF(__pyx_t_1);
9206   __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;}
9207   __Pyx_GOTREF(__pyx_t_2);
9208   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9209   __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;}
9210   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
9211   __pyx_t_4 = (!__pyx_t_3);
9212   if (__pyx_t_4) {
9213
9214     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":844
9215  * 
9216  *         if not self._isOpen():
9217  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
9218  * 
9219  *         region, rtid, rstart, rend = self._parseRegion( reference, start, end, region )
9220  */
9221     __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;}
9222     __Pyx_GOTREF(__pyx_t_2);
9223     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
9224     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
9225     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
9226     __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;}
9227     __Pyx_GOTREF(__pyx_t_1);
9228     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
9229     __Pyx_Raise(__pyx_t_1, 0, 0);
9230     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9231     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
9232     goto __pyx_L6;
9233   }
9234   __pyx_L6:;
9235
9236   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":846
9237  *             raise ValueError( "I/O operation on closed file" )
9238  * 
9239  *         region, rtid, rstart, rend = self._parseRegion( reference, start, end, region )             # <<<<<<<<<<<<<<
9240  * 
9241  *         cdef int counter
9242  */
9243   __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;}
9244   __Pyx_GOTREF(__pyx_t_1);
9245   __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;}
9246   __Pyx_GOTREF(__pyx_t_2);
9247   __Pyx_INCREF(__pyx_v_reference);
9248   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_reference);
9249   __Pyx_GIVEREF(__pyx_v_reference);
9250   __Pyx_INCREF(__pyx_v_start);
9251   PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_start);
9252   __Pyx_GIVEREF(__pyx_v_start);
9253   __Pyx_INCREF(__pyx_v_end);
9254   PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_end);
9255   __Pyx_GIVEREF(__pyx_v_end);
9256   __Pyx_INCREF(__pyx_v_region);
9257   PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_region);
9258   __Pyx_GIVEREF(__pyx_v_region);
9259   __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;}
9260   __Pyx_GOTREF(__pyx_t_5);
9261   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9262   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
9263   if (PyTuple_CheckExact(__pyx_t_5) && likely(PyTuple_GET_SIZE(__pyx_t_5) == 4)) {
9264     PyObject* tuple = __pyx_t_5;
9265     __pyx_t_2 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_2);
9266     __pyx_t_1 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_1);
9267     __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;}
9268     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9269     __pyx_t_6 = PyTuple_GET_ITEM(tuple, 2); __Pyx_INCREF(__pyx_t_6);
9270     __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;}
9271     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
9272     __pyx_t_7 = PyTuple_GET_ITEM(tuple, 3); __Pyx_INCREF(__pyx_t_7);
9273     __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;}
9274     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
9275     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
9276     __Pyx_DECREF(__pyx_v_region);
9277     __pyx_v_region = __pyx_t_2;
9278     __pyx_t_2 = 0;
9279     __pyx_v_rtid = __pyx_t_8;
9280     __pyx_v_rstart = __pyx_t_9;
9281     __pyx_v_rend = __pyx_t_10;
9282   } else {
9283     __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;}
9284     __Pyx_GOTREF(__pyx_t_11);
9285     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
9286     __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;}
9287     __Pyx_GOTREF(__pyx_t_2);
9288     __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;}
9289     __Pyx_GOTREF(__pyx_t_1);
9290     __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;}
9291     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9292     __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;}
9293     __Pyx_GOTREF(__pyx_t_6);
9294     __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;}
9295     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
9296     __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;}
9297     __Pyx_GOTREF(__pyx_t_7);
9298     __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;}
9299     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
9300     if (__Pyx_EndUnpack(__pyx_t_11, 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
9301     __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
9302     __Pyx_DECREF(__pyx_v_region);
9303     __pyx_v_region = __pyx_t_2;
9304     __pyx_t_2 = 0;
9305     __pyx_v_rtid = __pyx_t_10;
9306     __pyx_v_rstart = __pyx_t_9;
9307     __pyx_v_rend = __pyx_t_8;
9308   }
9309
9310   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":849
9311  * 
9312  *         cdef int counter
9313  *         counter = 0;             # <<<<<<<<<<<<<<
9314  * 
9315  *         if self.isbam:
9316  */
9317   __pyx_v_counter = 0;
9318
9319   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":851
9320  *         counter = 0;
9321  * 
9322  *         if self.isbam:             # <<<<<<<<<<<<<<
9323  *             if not until_eof and not self._hasIndex() and not self.isremote:
9324  *                 raise ValueError( "fetch called on bamfile without index" )
9325  */
9326   if (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam) {
9327
9328     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":852
9329  * 
9330  *         if self.isbam:
9331  *             if not until_eof and not self._hasIndex() and not self.isremote:             # <<<<<<<<<<<<<<
9332  *                 raise ValueError( "fetch called on bamfile without index" )
9333  * 
9334  */
9335     __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;}
9336     __pyx_t_3 = (!__pyx_t_4);
9337     if (__pyx_t_3) {
9338       __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;}
9339       __Pyx_GOTREF(__pyx_t_5);
9340       __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;}
9341       __Pyx_GOTREF(__pyx_t_7);
9342       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
9343       __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;}
9344       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
9345       __pyx_t_12 = (!__pyx_t_4);
9346       if (__pyx_t_12) {
9347         __pyx_t_4 = (!((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isremote);
9348         __pyx_t_13 = __pyx_t_4;
9349       } else {
9350         __pyx_t_13 = __pyx_t_12;
9351       }
9352       __pyx_t_12 = __pyx_t_13;
9353     } else {
9354       __pyx_t_12 = __pyx_t_3;
9355     }
9356     if (__pyx_t_12) {
9357
9358       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":853
9359  *         if self.isbam:
9360  *             if not until_eof and not self._hasIndex() and not self.isremote:
9361  *                 raise ValueError( "fetch called on bamfile without index" )             # <<<<<<<<<<<<<<
9362  * 
9363  *             if not region:
9364  */
9365       __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;}
9366       __Pyx_GOTREF(__pyx_t_7);
9367       __Pyx_INCREF(((PyObject *)__pyx_kp_s_30));
9368       PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_kp_s_30));
9369       __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_30));
9370       __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;}
9371       __Pyx_GOTREF(__pyx_t_5);
9372       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
9373       __Pyx_Raise(__pyx_t_5, 0, 0);
9374       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
9375       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
9376       goto __pyx_L8;
9377     }
9378     __pyx_L8:;
9379
9380     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":855
9381  *                 raise ValueError( "fetch called on bamfile without index" )
9382  * 
9383  *             if not region:             # <<<<<<<<<<<<<<
9384  *                 raise ValueError( "counting functionality requires a region/reference" )
9385  *             if not self._hasIndex(): raise ValueError( "no index available for fetch" )
9386  */
9387     __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;}
9388     __pyx_t_3 = (!__pyx_t_12);
9389     if (__pyx_t_3) {
9390
9391       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":856
9392  * 
9393  *             if not region:
9394  *                 raise ValueError( "counting functionality requires a region/reference" )             # <<<<<<<<<<<<<<
9395  *             if not self._hasIndex(): raise ValueError( "no index available for fetch" )
9396  *             bam_fetch(self.samfile.x.bam,
9397  */
9398       __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;}
9399       __Pyx_GOTREF(__pyx_t_5);
9400       __Pyx_INCREF(((PyObject *)__pyx_kp_s_40));
9401       PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_40));
9402       __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_40));
9403       __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;}
9404       __Pyx_GOTREF(__pyx_t_7);
9405       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
9406       __Pyx_Raise(__pyx_t_7, 0, 0);
9407       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
9408       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
9409       goto __pyx_L9;
9410     }
9411     __pyx_L9:;
9412
9413     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":857
9414  *             if not region:
9415  *                 raise ValueError( "counting functionality requires a region/reference" )
9416  *             if not self._hasIndex(): raise ValueError( "no index available for fetch" )             # <<<<<<<<<<<<<<
9417  *             bam_fetch(self.samfile.x.bam,
9418  *                              self.index,
9419  */
9420     __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;}
9421     __Pyx_GOTREF(__pyx_t_7);
9422     __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;}
9423     __Pyx_GOTREF(__pyx_t_5);
9424     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
9425     __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;}
9426     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
9427     __pyx_t_12 = (!__pyx_t_3);
9428     if (__pyx_t_12) {
9429       __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;}
9430       __Pyx_GOTREF(__pyx_t_5);
9431       __Pyx_INCREF(((PyObject *)__pyx_kp_s_32));
9432       PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_32));
9433       __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_32));
9434       __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;}
9435       __Pyx_GOTREF(__pyx_t_7);
9436       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
9437       __Pyx_Raise(__pyx_t_7, 0, 0);
9438       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
9439       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
9440       goto __pyx_L10;
9441     }
9442     __pyx_L10:;
9443
9444     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":864
9445  *                              rend,
9446  *                              <void*>&counter,
9447  *                              count_callback )             # <<<<<<<<<<<<<<
9448  *             return counter
9449  *         else:
9450  */
9451     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);
9452
9453     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":865
9454  *                              <void*>&counter,
9455  *                              count_callback )
9456  *             return counter             # <<<<<<<<<<<<<<
9457  *         else:
9458  *             raise ValueError ("count for a region is not available for sam files" )
9459  */
9460     __Pyx_XDECREF(__pyx_r);
9461     __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;}
9462     __Pyx_GOTREF(__pyx_t_7);
9463     __pyx_r = __pyx_t_7;
9464     __pyx_t_7 = 0;
9465     goto __pyx_L0;
9466     goto __pyx_L7;
9467   }
9468   /*else*/ {
9469
9470     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":867
9471  *             return counter
9472  *         else:
9473  *             raise ValueError ("count for a region is not available for sam files" )             # <<<<<<<<<<<<<<
9474  * 
9475  *     def pileup( self,
9476  */
9477     __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;}
9478     __Pyx_GOTREF(__pyx_t_7);
9479     __Pyx_INCREF(((PyObject *)__pyx_kp_s_41));
9480     PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_kp_s_41));
9481     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_41));
9482     __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;}
9483     __Pyx_GOTREF(__pyx_t_5);
9484     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
9485     __Pyx_Raise(__pyx_t_5, 0, 0);
9486     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
9487     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
9488   }
9489   __pyx_L7:;
9490
9491   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
9492   goto __pyx_L0;
9493   __pyx_L1_error:;
9494   __Pyx_XDECREF(__pyx_t_1);
9495   __Pyx_XDECREF(__pyx_t_2);
9496   __Pyx_XDECREF(__pyx_t_5);
9497   __Pyx_XDECREF(__pyx_t_6);
9498   __Pyx_XDECREF(__pyx_t_7);
9499   __Pyx_XDECREF(__pyx_t_11);
9500   __Pyx_AddTraceback("csamtools.Samfile.count");
9501   __pyx_r = NULL;
9502   __pyx_L0:;
9503   __Pyx_DECREF(__pyx_v_region);
9504   __Pyx_XGIVEREF(__pyx_r);
9505   __Pyx_TraceReturn(__pyx_r);
9506   __Pyx_RefNannyFinishContext();
9507   return __pyx_r;
9508 }
9509
9510 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":869
9511  *             raise ValueError ("count for a region is not available for sam files" )
9512  * 
9513  *     def pileup( self,             # <<<<<<<<<<<<<<
9514  *                 reference = None,
9515  *                 start = None,
9516  */
9517
9518 static PyObject *__pyx_pf_9csamtools_7Samfile_pileup(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
9519 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        ";
9520 static PyObject *__pyx_pf_9csamtools_7Samfile_pileup(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
9521   PyObject *__pyx_v_reference = 0;
9522   PyObject *__pyx_v_start = 0;
9523   PyObject *__pyx_v_end = 0;
9524   PyObject *__pyx_v_region = 0;
9525   PyObject *__pyx_v_callback = 0;
9526   PyObject *__pyx_v_kwargs = 0;
9527   int __pyx_v_rtid;
9528   int __pyx_v_rstart;
9529   int __pyx_v_rend;
9530   int __pyx_v_has_coord;
9531   bam_plbuf_t *__pyx_v_buf;
9532   PyObject *__pyx_r = NULL;
9533   PyObject *__pyx_t_1 = NULL;
9534   PyObject *__pyx_t_2 = NULL;
9535   int __pyx_t_3;
9536   int __pyx_t_4;
9537   PyObject *__pyx_t_5 = NULL;
9538   PyObject *__pyx_t_6 = NULL;
9539   PyObject *__pyx_t_7 = NULL;
9540   int __pyx_t_8;
9541   int __pyx_t_9;
9542   int __pyx_t_10;
9543   int __pyx_t_11;
9544   PyObject *__pyx_t_12 = NULL;
9545   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};
9546   __Pyx_TraceDeclarations
9547   __Pyx_RefNannySetupContext("pileup");
9548   __Pyx_TraceCall("pileup", __pyx_f[0], 869);
9549   __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return NULL;
9550   __Pyx_GOTREF(__pyx_v_kwargs);
9551   if (unlikely(__pyx_kwds)) {
9552     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
9553     PyObject* values[5] = {0,0,0,0,0};
9554
9555     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":870
9556  * 
9557  *     def pileup( self,
9558  *                 reference = None,             # <<<<<<<<<<<<<<
9559  *                 start = None,
9560  *                 end = None,
9561  */
9562     values[0] = ((PyObject *)Py_None);
9563
9564     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":871
9565  *     def pileup( self,
9566  *                 reference = None,
9567  *                 start = None,             # <<<<<<<<<<<<<<
9568  *                 end = None,
9569  *                 region = None,
9570  */
9571     values[1] = ((PyObject *)Py_None);
9572
9573     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":872
9574  *                 reference = None,
9575  *                 start = None,
9576  *                 end = None,             # <<<<<<<<<<<<<<
9577  *                 region = None,
9578  *                 callback = None,
9579  */
9580     values[2] = ((PyObject *)Py_None);
9581
9582     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":873
9583  *                 start = None,
9584  *                 end = None,
9585  *                 region = None,             # <<<<<<<<<<<<<<
9586  *                 callback = None,
9587  *                 **kwargs ):
9588  */
9589     values[3] = ((PyObject *)Py_None);
9590
9591     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":874
9592  *                 end = None,
9593  *                 region = None,
9594  *                 callback = None,             # <<<<<<<<<<<<<<
9595  *                 **kwargs ):
9596  *         '''
9597  */
9598     values[4] = ((PyObject *)Py_None);
9599     switch (PyTuple_GET_SIZE(__pyx_args)) {
9600       case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
9601       case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
9602       case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
9603       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
9604       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
9605       case  0: break;
9606       default: goto __pyx_L5_argtuple_error;
9607     }
9608     switch (PyTuple_GET_SIZE(__pyx_args)) {
9609       case  0:
9610       if (kw_args > 0) {
9611         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reference);
9612         if (value) { values[0] = value; kw_args--; }
9613       }
9614       case  1:
9615       if (kw_args > 0) {
9616         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start);
9617         if (value) { values[1] = value; kw_args--; }
9618       }
9619       case  2:
9620       if (kw_args > 0) {
9621         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end);
9622         if (value) { values[2] = value; kw_args--; }
9623       }
9624       case  3:
9625       if (kw_args > 0) {
9626         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__region);
9627         if (value) { values[3] = value; kw_args--; }
9628       }
9629       case  4:
9630       if (kw_args > 0) {
9631         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__callback);
9632         if (value) { values[4] = value; kw_args--; }
9633       }
9634     }
9635     if (unlikely(kw_args > 0)) {
9636       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;}
9637     }
9638     __pyx_v_reference = values[0];
9639     __pyx_v_start = values[1];
9640     __pyx_v_end = values[2];
9641     __pyx_v_region = values[3];
9642     __pyx_v_callback = values[4];
9643   } else {
9644
9645     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":870
9646  * 
9647  *     def pileup( self,
9648  *                 reference = None,             # <<<<<<<<<<<<<<
9649  *                 start = None,
9650  *                 end = None,
9651  */
9652     __pyx_v_reference = ((PyObject *)Py_None);
9653
9654     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":871
9655  *     def pileup( self,
9656  *                 reference = None,
9657  *                 start = None,             # <<<<<<<<<<<<<<
9658  *                 end = None,
9659  *                 region = None,
9660  */
9661     __pyx_v_start = ((PyObject *)Py_None);
9662
9663     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":872
9664  *                 reference = None,
9665  *                 start = None,
9666  *                 end = None,             # <<<<<<<<<<<<<<
9667  *                 region = None,
9668  *                 callback = None,
9669  */
9670     __pyx_v_end = ((PyObject *)Py_None);
9671
9672     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":873
9673  *                 start = None,
9674  *                 end = None,
9675  *                 region = None,             # <<<<<<<<<<<<<<
9676  *                 callback = None,
9677  *                 **kwargs ):
9678  */
9679     __pyx_v_region = ((PyObject *)Py_None);
9680
9681     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":874
9682  *                 end = None,
9683  *                 region = None,
9684  *                 callback = None,             # <<<<<<<<<<<<<<
9685  *                 **kwargs ):
9686  *         '''
9687  */
9688     __pyx_v_callback = ((PyObject *)Py_None);
9689     switch (PyTuple_GET_SIZE(__pyx_args)) {
9690       case  5: __pyx_v_callback = PyTuple_GET_ITEM(__pyx_args, 4);
9691       case  4: __pyx_v_region = PyTuple_GET_ITEM(__pyx_args, 3);
9692       case  3: __pyx_v_end = PyTuple_GET_ITEM(__pyx_args, 2);
9693       case  2: __pyx_v_start = PyTuple_GET_ITEM(__pyx_args, 1);
9694       case  1: __pyx_v_reference = PyTuple_GET_ITEM(__pyx_args, 0);
9695       case  0: break;
9696       default: goto __pyx_L5_argtuple_error;
9697     }
9698   }
9699   goto __pyx_L4_argument_unpacking_done;
9700   __pyx_L5_argtuple_error:;
9701   __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;}
9702   __pyx_L3_error:;
9703   __Pyx_DECREF(__pyx_v_kwargs);
9704   __Pyx_AddTraceback("csamtools.Samfile.pileup");
9705   __Pyx_RefNannyFinishContext();
9706   return NULL;
9707   __pyx_L4_argument_unpacking_done:;
9708
9709   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":921
9710  *         cdef bam_plbuf_t *buf
9711  * 
9712  *         if not self._isOpen():             # <<<<<<<<<<<<<<
9713  *             raise ValueError( "I/O operation on closed file" )
9714  * 
9715  */
9716   __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;}
9717   __Pyx_GOTREF(__pyx_t_1);
9718   __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;}
9719   __Pyx_GOTREF(__pyx_t_2);
9720   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9721   __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;}
9722   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
9723   __pyx_t_4 = (!__pyx_t_3);
9724   if (__pyx_t_4) {
9725
9726     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":922
9727  * 
9728  *         if not self._isOpen():
9729  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
9730  * 
9731  *         has_coord, rtid, rstart, rend = self._parseRegion( reference, start, end, region )
9732  */
9733     __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;}
9734     __Pyx_GOTREF(__pyx_t_2);
9735     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
9736     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
9737     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
9738     __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;}
9739     __Pyx_GOTREF(__pyx_t_1);
9740     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
9741     __Pyx_Raise(__pyx_t_1, 0, 0);
9742     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9743     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 922; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
9744     goto __pyx_L6;
9745   }
9746   __pyx_L6:;
9747
9748   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":924
9749  *             raise ValueError( "I/O operation on closed file" )
9750  * 
9751  *         has_coord, rtid, rstart, rend = self._parseRegion( reference, start, end, region )             # <<<<<<<<<<<<<<
9752  * 
9753  *         if self.isbam:
9754  */
9755   __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;}
9756   __Pyx_GOTREF(__pyx_t_1);
9757   __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;}
9758   __Pyx_GOTREF(__pyx_t_2);
9759   __Pyx_INCREF(__pyx_v_reference);
9760   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_reference);
9761   __Pyx_GIVEREF(__pyx_v_reference);
9762   __Pyx_INCREF(__pyx_v_start);
9763   PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_start);
9764   __Pyx_GIVEREF(__pyx_v_start);
9765   __Pyx_INCREF(__pyx_v_end);
9766   PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_end);
9767   __Pyx_GIVEREF(__pyx_v_end);
9768   __Pyx_INCREF(__pyx_v_region);
9769   PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_region);
9770   __Pyx_GIVEREF(__pyx_v_region);
9771   __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;}
9772   __Pyx_GOTREF(__pyx_t_5);
9773   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9774   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
9775   if (PyTuple_CheckExact(__pyx_t_5) && likely(PyTuple_GET_SIZE(__pyx_t_5) == 4)) {
9776     PyObject* tuple = __pyx_t_5;
9777     __pyx_t_2 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_2);
9778     __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;}
9779     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
9780     __pyx_t_1 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_1);
9781     __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;}
9782     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9783     __pyx_t_6 = PyTuple_GET_ITEM(tuple, 2); __Pyx_INCREF(__pyx_t_6);
9784     __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;}
9785     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
9786     __pyx_t_7 = PyTuple_GET_ITEM(tuple, 3); __Pyx_INCREF(__pyx_t_7);
9787     __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;}
9788     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
9789     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
9790     __pyx_v_has_coord = __pyx_t_8;
9791     __pyx_v_rtid = __pyx_t_9;
9792     __pyx_v_rstart = __pyx_t_10;
9793     __pyx_v_rend = __pyx_t_11;
9794   } else {
9795     __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;}
9796     __Pyx_GOTREF(__pyx_t_12);
9797     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
9798     __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;}
9799     __Pyx_GOTREF(__pyx_t_2);
9800     __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;}
9801     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
9802     __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;}
9803     __Pyx_GOTREF(__pyx_t_1);
9804     __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;}
9805     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
9806     __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;}
9807     __Pyx_GOTREF(__pyx_t_6);
9808     __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;}
9809     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
9810     __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;}
9811     __Pyx_GOTREF(__pyx_t_7);
9812     __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;}
9813     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
9814     if (__Pyx_EndUnpack(__pyx_t_12, 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
9815     __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
9816     __pyx_v_has_coord = __pyx_t_11;
9817     __pyx_v_rtid = __pyx_t_10;
9818     __pyx_v_rstart = __pyx_t_9;
9819     __pyx_v_rend = __pyx_t_8;
9820   }
9821
9822   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":926
9823  *         has_coord, rtid, rstart, rend = self._parseRegion( reference, start, end, region )
9824  * 
9825  *         if self.isbam:             # <<<<<<<<<<<<<<
9826  *             if not self._hasIndex(): raise ValueError( "no index available for pileup" )
9827  * 
9828  */
9829   if (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->isbam) {
9830
9831     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":927
9832  * 
9833  *         if self.isbam:
9834  *             if not self._hasIndex(): raise ValueError( "no index available for pileup" )             # <<<<<<<<<<<<<<
9835  * 
9836  *             if callback:
9837  */
9838     __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;}
9839     __Pyx_GOTREF(__pyx_t_5);
9840     __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;}
9841     __Pyx_GOTREF(__pyx_t_7);
9842     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
9843     __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;}
9844     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
9845     __pyx_t_3 = (!__pyx_t_4);
9846     if (__pyx_t_3) {
9847       __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;}
9848       __Pyx_GOTREF(__pyx_t_7);
9849       __Pyx_INCREF(((PyObject *)__pyx_kp_s_42));
9850       PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_kp_s_42));
9851       __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_42));
9852       __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;}
9853       __Pyx_GOTREF(__pyx_t_5);
9854       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
9855       __Pyx_Raise(__pyx_t_5, 0, 0);
9856       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
9857       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
9858       goto __pyx_L8;
9859     }
9860     __pyx_L8:;
9861
9862     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":929
9863  *             if not self._hasIndex(): raise ValueError( "no index available for pileup" )
9864  * 
9865  *             if callback:             # <<<<<<<<<<<<<<
9866  *                 if not has_coord: raise ValueError( "callback functionality requires a region/reference" )
9867  * 
9868  */
9869     __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;}
9870     if (__pyx_t_3) {
9871
9872       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":930
9873  * 
9874  *             if callback:
9875  *                 if not has_coord: raise ValueError( "callback functionality requires a region/reference" )             # <<<<<<<<<<<<<<
9876  * 
9877  *                 buf = bam_plbuf_init( <bam_pileup_f>pileup_callback, <void*>callback )
9878  */
9879       __pyx_t_3 = (!__pyx_v_has_coord);
9880       if (__pyx_t_3) {
9881         __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;}
9882         __Pyx_GOTREF(__pyx_t_5);
9883         __Pyx_INCREF(((PyObject *)__pyx_kp_s_31));
9884         PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_31));
9885         __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_31));
9886         __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;}
9887         __Pyx_GOTREF(__pyx_t_7);
9888         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
9889         __Pyx_Raise(__pyx_t_7, 0, 0);
9890         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
9891         {__pyx_filename = __pyx_f[0]; __pyx_lineno = 930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
9892         goto __pyx_L10;
9893       }
9894       __pyx_L10:;
9895
9896       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":932
9897  *                 if not has_coord: raise ValueError( "callback functionality requires a region/reference" )
9898  * 
9899  *                 buf = bam_plbuf_init( <bam_pileup_f>pileup_callback, <void*>callback )             # <<<<<<<<<<<<<<
9900  *                 bam_fetch(self.samfile.x.bam,
9901  *                           self.index, rtid, rstart, rend,
9902  */
9903       __pyx_v_buf = bam_plbuf_init(((bam_pileup_f)__pyx_f_9csamtools_pileup_callback), ((void *)__pyx_v_callback));
9904
9905       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":935
9906  *                 bam_fetch(self.samfile.x.bam,
9907  *                           self.index, rtid, rstart, rend,
9908  *                           buf, pileup_fetch_callback )             # <<<<<<<<<<<<<<
9909  * 
9910  *                 # finalize pileup
9911  */
9912       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);
9913
9914       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":938
9915  * 
9916  *                 # finalize pileup
9917  *                 bam_plbuf_push( NULL, buf)             # <<<<<<<<<<<<<<
9918  *                 bam_plbuf_destroy(buf)
9919  *             else:
9920  */
9921       bam_plbuf_push(NULL, __pyx_v_buf);
9922
9923       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":939
9924  *                 # finalize pileup
9925  *                 bam_plbuf_push( NULL, buf)
9926  *                 bam_plbuf_destroy(buf)             # <<<<<<<<<<<<<<
9927  *             else:
9928  *                 if has_coord:
9929  */
9930       bam_plbuf_destroy(__pyx_v_buf);
9931       goto __pyx_L9;
9932     }
9933     /*else*/ {
9934
9935       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":941
9936  *                 bam_plbuf_destroy(buf)
9937  *             else:
9938  *                 if has_coord:             # <<<<<<<<<<<<<<
9939  *                     return IteratorColumnRegion( self,
9940  *                                                  tid = rtid,
9941  */
9942       if (__pyx_v_has_coord) {
9943
9944         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":942
9945  *             else:
9946  *                 if has_coord:
9947  *                     return IteratorColumnRegion( self,             # <<<<<<<<<<<<<<
9948  *                                                  tid = rtid,
9949  *                                                  start = rstart,
9950  */
9951         __Pyx_XDECREF(__pyx_r);
9952         __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;}
9953         __Pyx_GOTREF(__pyx_t_7);
9954         __Pyx_INCREF(__pyx_v_self);
9955         PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_self);
9956         __Pyx_GIVEREF(__pyx_v_self);
9957         __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;}
9958         __Pyx_GOTREF(((PyObject *)__pyx_t_5));
9959
9960         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":943
9961  *                 if has_coord:
9962  *                     return IteratorColumnRegion( self,
9963  *                                                  tid = rtid,             # <<<<<<<<<<<<<<
9964  *                                                  start = rstart,
9965  *                                                  end = rend,
9966  */
9967         __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;}
9968         __Pyx_GOTREF(__pyx_t_6);
9969         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;}
9970         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
9971
9972         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":944
9973  *                     return IteratorColumnRegion( self,
9974  *                                                  tid = rtid,
9975  *                                                  start = rstart,             # <<<<<<<<<<<<<<
9976  *                                                  end = rend,
9977  *                                                  **kwargs )
9978  */
9979         __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;}
9980         __Pyx_GOTREF(__pyx_t_6);
9981         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;}
9982         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
9983
9984         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":945
9985  *                                                  tid = rtid,
9986  *                                                  start = rstart,
9987  *                                                  end = rend,             # <<<<<<<<<<<<<<
9988  *                                                  **kwargs )
9989  *                 else:
9990  */
9991         __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;}
9992         __Pyx_GOTREF(__pyx_t_6);
9993         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;}
9994         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
9995
9996         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":946
9997  *                                                  start = rstart,
9998  *                                                  end = rend,
9999  *                                                  **kwargs )             # <<<<<<<<<<<<<<
10000  *                 else:
10001  *                     return IteratorColumnAllRefs(self, **kwargs )
10002  */
10003         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;}
10004         __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;}
10005         __Pyx_GOTREF(__pyx_t_6);
10006         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
10007         __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
10008         __pyx_r = __pyx_t_6;
10009         __pyx_t_6 = 0;
10010         goto __pyx_L0;
10011         goto __pyx_L11;
10012       }
10013       /*else*/ {
10014
10015         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":948
10016  *                                                  **kwargs )
10017  *                 else:
10018  *                     return IteratorColumnAllRefs(self, **kwargs )             # <<<<<<<<<<<<<<
10019  * 
10020  *         else:
10021  */
10022         __Pyx_XDECREF(__pyx_r);
10023         __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;}
10024         __Pyx_GOTREF(__pyx_t_6);
10025         __Pyx_INCREF(__pyx_v_self);
10026         PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_self);
10027         __Pyx_GIVEREF(__pyx_v_self);
10028         __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;}
10029         __Pyx_GOTREF(__pyx_t_5);
10030         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
10031         __pyx_r = __pyx_t_5;
10032         __pyx_t_5 = 0;
10033         goto __pyx_L0;
10034       }
10035       __pyx_L11:;
10036     }
10037     __pyx_L9:;
10038     goto __pyx_L7;
10039   }
10040   /*else*/ {
10041
10042     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":951
10043  * 
10044  *         else:
10045  *             raise NotImplementedError( "pileup of samfiles not implemented yet" )             # <<<<<<<<<<<<<<
10046  * 
10047  *     def close( self ):
10048  */
10049     __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;}
10050     __Pyx_GOTREF(__pyx_t_5);
10051     __Pyx_INCREF(((PyObject *)__pyx_kp_s_43));
10052     PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_43));
10053     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_43));
10054     __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;}
10055     __Pyx_GOTREF(__pyx_t_6);
10056     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
10057     __Pyx_Raise(__pyx_t_6, 0, 0);
10058     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
10059     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 951; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
10060   }
10061   __pyx_L7:;
10062
10063   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
10064   goto __pyx_L0;
10065   __pyx_L1_error:;
10066   __Pyx_XDECREF(__pyx_t_1);
10067   __Pyx_XDECREF(__pyx_t_2);
10068   __Pyx_XDECREF(__pyx_t_5);
10069   __Pyx_XDECREF(__pyx_t_6);
10070   __Pyx_XDECREF(__pyx_t_7);
10071   __Pyx_XDECREF(__pyx_t_12);
10072   __Pyx_AddTraceback("csamtools.Samfile.pileup");
10073   __pyx_r = NULL;
10074   __pyx_L0:;
10075   __Pyx_DECREF(__pyx_v_kwargs);
10076   __Pyx_XGIVEREF(__pyx_r);
10077   __Pyx_TraceReturn(__pyx_r);
10078   __Pyx_RefNannyFinishContext();
10079   return __pyx_r;
10080 }
10081
10082 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":953
10083  *             raise NotImplementedError( "pileup of samfiles not implemented yet" )
10084  * 
10085  *     def close( self ):             # <<<<<<<<<<<<<<
10086  *         '''
10087  *         closes the :class:`pysam.Samfile`.'''
10088  */
10089
10090 static PyObject *__pyx_pf_9csamtools_7Samfile_close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
10091 static char __pyx_doc_9csamtools_7Samfile_close[] = "Samfile.close(self)\n\n        closes the :class:`pysam.Samfile`.";
10092 static PyObject *__pyx_pf_9csamtools_7Samfile_close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
10093   PyObject *__pyx_r = NULL;
10094   int __pyx_t_1;
10095   __Pyx_TraceDeclarations
10096   __Pyx_RefNannySetupContext("close");
10097   __Pyx_TraceCall("close", __pyx_f[0], 953);
10098
10099   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":956
10100  *         '''
10101  *         closes the :class:`pysam.Samfile`.'''
10102  *         if self.samfile != NULL:             # <<<<<<<<<<<<<<
10103  *             samclose( self.samfile )
10104  *             bam_index_destroy(self.index);
10105  */
10106   __pyx_t_1 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile != NULL);
10107   if (__pyx_t_1) {
10108
10109     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":957
10110  *         closes the :class:`pysam.Samfile`.'''
10111  *         if self.samfile != NULL:
10112  *             samclose( self.samfile )             # <<<<<<<<<<<<<<
10113  *             bam_index_destroy(self.index);
10114  *             self.samfile = NULL
10115  */
10116     samclose(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile);
10117
10118     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":958
10119  *         if self.samfile != NULL:
10120  *             samclose( self.samfile )
10121  *             bam_index_destroy(self.index);             # <<<<<<<<<<<<<<
10122  *             self.samfile = NULL
10123  * 
10124  */
10125     bam_index_destroy(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->index);
10126
10127     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":959
10128  *             samclose( self.samfile )
10129  *             bam_index_destroy(self.index);
10130  *             self.samfile = NULL             # <<<<<<<<<<<<<<
10131  * 
10132  *     def __dealloc__( self ):
10133  */
10134     ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile = NULL;
10135     goto __pyx_L5;
10136   }
10137   __pyx_L5:;
10138
10139   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
10140   __Pyx_XGIVEREF(__pyx_r);
10141   __Pyx_TraceReturn(__pyx_r);
10142   __Pyx_RefNannyFinishContext();
10143   return __pyx_r;
10144 }
10145
10146 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":961
10147  *             self.samfile = NULL
10148  * 
10149  *     def __dealloc__( self ):             # <<<<<<<<<<<<<<
10150  *         # remember: dealloc cannot call other methods
10151  *         # note: no doc string
10152  */
10153
10154 static void __pyx_pf_9csamtools_7Samfile___dealloc__(PyObject *__pyx_v_self); /*proto*/
10155 static void __pyx_pf_9csamtools_7Samfile___dealloc__(PyObject *__pyx_v_self) {
10156   PyObject *__pyx_t_1 = NULL;
10157   PyObject *__pyx_t_2 = NULL;
10158   int __pyx_t_3;
10159   __Pyx_TraceDeclarations
10160   __Pyx_RefNannySetupContext("__dealloc__");
10161   __Pyx_TraceCall("__dealloc__", __pyx_f[0], 961);
10162
10163   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":965
10164  *         # note: no doc string
10165  *         # note: __del__ is not called.
10166  *         self.close()             # <<<<<<<<<<<<<<
10167  *         bam_destroy1(self.b)
10168  *         if self._filename != NULL: free( self._filename )
10169  */
10170   __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;}
10171   __Pyx_GOTREF(__pyx_t_1);
10172   __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;}
10173   __Pyx_GOTREF(__pyx_t_2);
10174   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10175   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10176
10177   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":966
10178  *         # note: __del__ is not called.
10179  *         self.close()
10180  *         bam_destroy1(self.b)             # <<<<<<<<<<<<<<
10181  *         if self._filename != NULL: free( self._filename )
10182  * 
10183  */
10184   bam_destroy1(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->b);
10185
10186   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":967
10187  *         self.close()
10188  *         bam_destroy1(self.b)
10189  *         if self._filename != NULL: free( self._filename )             # <<<<<<<<<<<<<<
10190  * 
10191  *     cpdef int write( self, AlignedRead read ) except -1:
10192  */
10193   __pyx_t_3 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->_filename != NULL);
10194   if (__pyx_t_3) {
10195     free(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->_filename);
10196     goto __pyx_L5;
10197   }
10198   __pyx_L5:;
10199
10200   goto __pyx_L0;
10201   __pyx_L1_error:;
10202   __Pyx_XDECREF(__pyx_t_1);
10203   __Pyx_XDECREF(__pyx_t_2);
10204   __Pyx_AddTraceback("csamtools.Samfile.__dealloc__");
10205   __pyx_L0:;
10206   __Pyx_TraceReturn(Py_None);
10207   __Pyx_RefNannyFinishContext();
10208 }
10209
10210 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":969
10211  *         if self._filename != NULL: free( self._filename )
10212  * 
10213  *     cpdef int write( self, AlignedRead read ) except -1:             # <<<<<<<<<<<<<<
10214  *         '''
10215  *         write a single :class:`pysam.AlignedRead` to disk.
10216  */
10217
10218 static PyObject *__pyx_pf_9csamtools_7Samfile_write(PyObject *__pyx_v_self, PyObject *__pyx_v_read); /*proto*/
10219 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) {
10220   int __pyx_r;
10221   PyObject *__pyx_t_1 = NULL;
10222   PyObject *__pyx_t_2 = NULL;
10223   PyObject *__pyx_t_3 = NULL;
10224   int __pyx_t_4;
10225   int __pyx_t_5;
10226   int __pyx_t_6;
10227   __Pyx_TraceDeclarations
10228   __Pyx_RefNannySetupContext("write");
10229   __Pyx_TraceCall("write", __pyx_f[0], 969);
10230   /* Check if called by wrapper */
10231   if (unlikely(__pyx_skip_dispatch)) ;
10232   /* Check if overriden in Python */
10233   else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
10234     __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;}
10235     __Pyx_GOTREF(__pyx_t_1);
10236     if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (void *)&__pyx_pf_9csamtools_7Samfile_write)) {
10237       __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;}
10238       __Pyx_GOTREF(__pyx_t_2);
10239       __Pyx_INCREF(((PyObject *)__pyx_v_read));
10240       PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_read));
10241       __Pyx_GIVEREF(((PyObject *)__pyx_v_read));
10242       __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;}
10243       __Pyx_GOTREF(__pyx_t_3);
10244       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10245       __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;}
10246       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10247       __pyx_r = __pyx_t_4;
10248       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10249       goto __pyx_L0;
10250     }
10251     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10252   }
10253
10254   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":975
10255  *         returns the number of bytes written.
10256  *         '''
10257  *         if not self._isOpen():             # <<<<<<<<<<<<<<
10258  *             return 0
10259  * 
10260  */
10261   __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;}
10262   __Pyx_GOTREF(__pyx_t_1);
10263   __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;}
10264   __Pyx_GOTREF(__pyx_t_3);
10265   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10266   __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;}
10267   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
10268   __pyx_t_6 = (!__pyx_t_5);
10269   if (__pyx_t_6) {
10270
10271     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":976
10272  *         '''
10273  *         if not self._isOpen():
10274  *             return 0             # <<<<<<<<<<<<<<
10275  * 
10276  *         return samwrite( self.samfile, read._delegate )
10277  */
10278     __pyx_r = 0;
10279     goto __pyx_L0;
10280     goto __pyx_L3;
10281   }
10282   __pyx_L3:;
10283
10284   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":978
10285  *             return 0
10286  * 
10287  *         return samwrite( self.samfile, read._delegate )             # <<<<<<<<<<<<<<
10288  * 
10289  *     def __enter__(self):
10290  */
10291   __pyx_r = samwrite(__pyx_v_self->samfile, __pyx_v_read->_delegate);
10292   goto __pyx_L0;
10293
10294   __pyx_r = 0;
10295   goto __pyx_L0;
10296   __pyx_L1_error:;
10297   __Pyx_XDECREF(__pyx_t_1);
10298   __Pyx_XDECREF(__pyx_t_2);
10299   __Pyx_XDECREF(__pyx_t_3);
10300   __Pyx_WriteUnraisable("csamtools.Samfile.write");
10301   __pyx_r = 0;
10302   __pyx_L0:;
10303   __Pyx_TraceReturn(Py_None);
10304   __Pyx_RefNannyFinishContext();
10305   return __pyx_r;
10306 }
10307
10308 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":969
10309  *         if self._filename != NULL: free( self._filename )
10310  * 
10311  *     cpdef int write( self, AlignedRead read ) except -1:             # <<<<<<<<<<<<<<
10312  *         '''
10313  *         write a single :class:`pysam.AlignedRead` to disk.
10314  */
10315
10316 static PyObject *__pyx_pf_9csamtools_7Samfile_write(PyObject *__pyx_v_self, PyObject *__pyx_v_read); /*proto*/
10317 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        ";
10318 static PyObject *__pyx_pf_9csamtools_7Samfile_write(PyObject *__pyx_v_self, PyObject *__pyx_v_read) {
10319   PyObject *__pyx_r = NULL;
10320   PyObject *__pyx_t_1 = NULL;
10321   __Pyx_TraceDeclarations
10322   __Pyx_RefNannySetupContext("write");
10323   __Pyx_TraceCall("write", __pyx_f[0], 969);
10324   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;}
10325   __Pyx_XDECREF(__pyx_r);
10326   __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;}
10327   __Pyx_GOTREF(__pyx_t_1);
10328   __pyx_r = __pyx_t_1;
10329   __pyx_t_1 = 0;
10330   goto __pyx_L0;
10331
10332   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
10333   goto __pyx_L0;
10334   __pyx_L1_error:;
10335   __Pyx_XDECREF(__pyx_t_1);
10336   __Pyx_AddTraceback("csamtools.Samfile.write");
10337   __pyx_r = NULL;
10338   __pyx_L0:;
10339   __Pyx_XGIVEREF(__pyx_r);
10340   __Pyx_TraceReturn(__pyx_r);
10341   __Pyx_RefNannyFinishContext();
10342   return __pyx_r;
10343 }
10344
10345 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":980
10346  *         return samwrite( self.samfile, read._delegate )
10347  * 
10348  *     def __enter__(self):             # <<<<<<<<<<<<<<
10349  *         return self
10350  * 
10351  */
10352
10353 static PyObject *__pyx_pf_9csamtools_7Samfile___enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
10354 static char __pyx_doc_9csamtools_7Samfile___enter__[] = "Samfile.__enter__(self)";
10355 static PyObject *__pyx_pf_9csamtools_7Samfile___enter__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
10356   PyObject *__pyx_r = NULL;
10357   __Pyx_TraceDeclarations
10358   __Pyx_RefNannySetupContext("__enter__");
10359   __Pyx_TraceCall("__enter__", __pyx_f[0], 980);
10360
10361   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":981
10362  * 
10363  *     def __enter__(self):
10364  *         return self             # <<<<<<<<<<<<<<
10365  * 
10366  *     def __exit__(self, exc_type, exc_value, traceback):
10367  */
10368   __Pyx_XDECREF(__pyx_r);
10369   __Pyx_INCREF(__pyx_v_self);
10370   __pyx_r = __pyx_v_self;
10371   goto __pyx_L0;
10372
10373   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
10374   __pyx_L0:;
10375   __Pyx_XGIVEREF(__pyx_r);
10376   __Pyx_TraceReturn(__pyx_r);
10377   __Pyx_RefNannyFinishContext();
10378   return __pyx_r;
10379 }
10380
10381 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":983
10382  *         return self
10383  * 
10384  *     def __exit__(self, exc_type, exc_value, traceback):             # <<<<<<<<<<<<<<
10385  *         self.close()
10386  *         return False
10387  */
10388
10389 static PyObject *__pyx_pf_9csamtools_7Samfile___exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
10390 static char __pyx_doc_9csamtools_7Samfile___exit__[] = "Samfile.__exit__(self, exc_type, exc_value, traceback)";
10391 static PyObject *__pyx_pf_9csamtools_7Samfile___exit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
10392   PyObject *__pyx_v_exc_type = 0;
10393   PyObject *__pyx_v_exc_value = 0;
10394   PyObject *__pyx_v_traceback = 0;
10395   PyObject *__pyx_r = NULL;
10396   PyObject *__pyx_t_1 = NULL;
10397   PyObject *__pyx_t_2 = NULL;
10398   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__exc_type,&__pyx_n_s__exc_value,&__pyx_n_s__traceback,0};
10399   __Pyx_TraceDeclarations
10400   __Pyx_RefNannySetupContext("__exit__");
10401   __Pyx_TraceCall("__exit__", __pyx_f[0], 983);
10402   if (unlikely(__pyx_kwds)) {
10403     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
10404     PyObject* values[3] = {0,0,0};
10405     switch (PyTuple_GET_SIZE(__pyx_args)) {
10406       case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
10407       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
10408       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
10409       case  0: break;
10410       default: goto __pyx_L5_argtuple_error;
10411     }
10412     switch (PyTuple_GET_SIZE(__pyx_args)) {
10413       case  0:
10414       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__exc_type);
10415       if (likely(values[0])) kw_args--;
10416       else goto __pyx_L5_argtuple_error;
10417       case  1:
10418       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__exc_value);
10419       if (likely(values[1])) kw_args--;
10420       else {
10421         __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 983; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
10422       }
10423       case  2:
10424       values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__traceback);
10425       if (likely(values[2])) kw_args--;
10426       else {
10427         __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 983; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
10428       }
10429     }
10430     if (unlikely(kw_args > 0)) {
10431       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;}
10432     }
10433     __pyx_v_exc_type = values[0];
10434     __pyx_v_exc_value = values[1];
10435     __pyx_v_traceback = values[2];
10436   } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
10437     goto __pyx_L5_argtuple_error;
10438   } else {
10439     __pyx_v_exc_type = PyTuple_GET_ITEM(__pyx_args, 0);
10440     __pyx_v_exc_value = PyTuple_GET_ITEM(__pyx_args, 1);
10441     __pyx_v_traceback = PyTuple_GET_ITEM(__pyx_args, 2);
10442   }
10443   goto __pyx_L4_argument_unpacking_done;
10444   __pyx_L5_argtuple_error:;
10445   __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;}
10446   __pyx_L3_error:;
10447   __Pyx_AddTraceback("csamtools.Samfile.__exit__");
10448   __Pyx_RefNannyFinishContext();
10449   return NULL;
10450   __pyx_L4_argument_unpacking_done:;
10451
10452   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":984
10453  * 
10454  *     def __exit__(self, exc_type, exc_value, traceback):
10455  *         self.close()             # <<<<<<<<<<<<<<
10456  *         return False
10457  * 
10458  */
10459   __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;}
10460   __Pyx_GOTREF(__pyx_t_1);
10461   __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;}
10462   __Pyx_GOTREF(__pyx_t_2);
10463   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10464   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10465
10466   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":985
10467  *     def __exit__(self, exc_type, exc_value, traceback):
10468  *         self.close()
10469  *         return False             # <<<<<<<<<<<<<<
10470  * 
10471  *     ###############################################################
10472  */
10473   __Pyx_XDECREF(__pyx_r);
10474   __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;}
10475   __Pyx_GOTREF(__pyx_t_2);
10476   __pyx_r = __pyx_t_2;
10477   __pyx_t_2 = 0;
10478   goto __pyx_L0;
10479
10480   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
10481   goto __pyx_L0;
10482   __pyx_L1_error:;
10483   __Pyx_XDECREF(__pyx_t_1);
10484   __Pyx_XDECREF(__pyx_t_2);
10485   __Pyx_AddTraceback("csamtools.Samfile.__exit__");
10486   __pyx_r = NULL;
10487   __pyx_L0:;
10488   __Pyx_XGIVEREF(__pyx_r);
10489   __Pyx_TraceReturn(__pyx_r);
10490   __Pyx_RefNannyFinishContext();
10491   return __pyx_r;
10492 }
10493
10494 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":994
10495  *     property filename:
10496  *         '''number of :term:`filename` associated with this object.'''
10497  *         def __get__(self):             # <<<<<<<<<<<<<<
10498  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
10499  *             return self._filename
10500  */
10501
10502 static PyObject *__pyx_pf_9csamtools_7Samfile_8filename___get__(PyObject *__pyx_v_self); /*proto*/
10503 static PyObject *__pyx_pf_9csamtools_7Samfile_8filename___get__(PyObject *__pyx_v_self) {
10504   PyObject *__pyx_r = NULL;
10505   PyObject *__pyx_t_1 = NULL;
10506   PyObject *__pyx_t_2 = NULL;
10507   int __pyx_t_3;
10508   int __pyx_t_4;
10509   __Pyx_TraceDeclarations
10510   __Pyx_RefNannySetupContext("__get__");
10511   __Pyx_TraceCall("__get__", __pyx_f[0], 994);
10512
10513   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":995
10514  *         '''number of :term:`filename` associated with this object.'''
10515  *         def __get__(self):
10516  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
10517  *             return self._filename
10518  * 
10519  */
10520   __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;}
10521   __Pyx_GOTREF(__pyx_t_1);
10522   __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;}
10523   __Pyx_GOTREF(__pyx_t_2);
10524   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10525   __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;}
10526   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10527   __pyx_t_4 = (!__pyx_t_3);
10528   if (__pyx_t_4) {
10529     __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;}
10530     __Pyx_GOTREF(__pyx_t_2);
10531     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
10532     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
10533     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
10534     __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;}
10535     __Pyx_GOTREF(__pyx_t_1);
10536     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10537     __Pyx_Raise(__pyx_t_1, 0, 0);
10538     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10539     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
10540     goto __pyx_L5;
10541   }
10542   __pyx_L5:;
10543
10544   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":996
10545  *         def __get__(self):
10546  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
10547  *             return self._filename             # <<<<<<<<<<<<<<
10548  * 
10549  *     property nreferences:
10550  */
10551   __Pyx_XDECREF(__pyx_r);
10552   __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;}
10553   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
10554   __pyx_r = ((PyObject *)__pyx_t_1);
10555   __pyx_t_1 = 0;
10556   goto __pyx_L0;
10557
10558   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
10559   goto __pyx_L0;
10560   __pyx_L1_error:;
10561   __Pyx_XDECREF(__pyx_t_1);
10562   __Pyx_XDECREF(__pyx_t_2);
10563   __Pyx_AddTraceback("csamtools.Samfile.filename.__get__");
10564   __pyx_r = NULL;
10565   __pyx_L0:;
10566   __Pyx_XGIVEREF(__pyx_r);
10567   __Pyx_TraceReturn(__pyx_r);
10568   __Pyx_RefNannyFinishContext();
10569   return __pyx_r;
10570 }
10571
10572 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1000
10573  *     property nreferences:
10574  *         '''number of :term:`reference` sequences in the file.'''
10575  *         def __get__(self):             # <<<<<<<<<<<<<<
10576  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
10577  *             return self.samfile.header.n_targets
10578  */
10579
10580 static PyObject *__pyx_pf_9csamtools_7Samfile_11nreferences___get__(PyObject *__pyx_v_self); /*proto*/
10581 static PyObject *__pyx_pf_9csamtools_7Samfile_11nreferences___get__(PyObject *__pyx_v_self) {
10582   PyObject *__pyx_r = NULL;
10583   PyObject *__pyx_t_1 = NULL;
10584   PyObject *__pyx_t_2 = NULL;
10585   int __pyx_t_3;
10586   int __pyx_t_4;
10587   __Pyx_TraceDeclarations
10588   __Pyx_RefNannySetupContext("__get__");
10589   __Pyx_TraceCall("__get__", __pyx_f[0], 1000);
10590
10591   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1001
10592  *         '''number of :term:`reference` sequences in the file.'''
10593  *         def __get__(self):
10594  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
10595  *             return self.samfile.header.n_targets
10596  * 
10597  */
10598   __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;}
10599   __Pyx_GOTREF(__pyx_t_1);
10600   __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;}
10601   __Pyx_GOTREF(__pyx_t_2);
10602   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10603   __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;}
10604   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10605   __pyx_t_4 = (!__pyx_t_3);
10606   if (__pyx_t_4) {
10607     __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;}
10608     __Pyx_GOTREF(__pyx_t_2);
10609     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
10610     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
10611     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
10612     __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;}
10613     __Pyx_GOTREF(__pyx_t_1);
10614     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10615     __Pyx_Raise(__pyx_t_1, 0, 0);
10616     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10617     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
10618     goto __pyx_L5;
10619   }
10620   __pyx_L5:;
10621
10622   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1002
10623  *         def __get__(self):
10624  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
10625  *             return self.samfile.header.n_targets             # <<<<<<<<<<<<<<
10626  * 
10627  *     property references:
10628  */
10629   __Pyx_XDECREF(__pyx_r);
10630   __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;}
10631   __Pyx_GOTREF(__pyx_t_1);
10632   __pyx_r = __pyx_t_1;
10633   __pyx_t_1 = 0;
10634   goto __pyx_L0;
10635
10636   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
10637   goto __pyx_L0;
10638   __pyx_L1_error:;
10639   __Pyx_XDECREF(__pyx_t_1);
10640   __Pyx_XDECREF(__pyx_t_2);
10641   __Pyx_AddTraceback("csamtools.Samfile.nreferences.__get__");
10642   __pyx_r = NULL;
10643   __pyx_L0:;
10644   __Pyx_XGIVEREF(__pyx_r);
10645   __Pyx_TraceReturn(__pyx_r);
10646   __Pyx_RefNannyFinishContext();
10647   return __pyx_r;
10648 }
10649
10650 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1006
10651  *     property references:
10652  *         """tuple with the names of :term:`reference` sequences."""
10653  *         def __get__(self):             # <<<<<<<<<<<<<<
10654  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
10655  *             t = []
10656  */
10657
10658 static PyObject *__pyx_pf_9csamtools_7Samfile_10references___get__(PyObject *__pyx_v_self); /*proto*/
10659 static PyObject *__pyx_pf_9csamtools_7Samfile_10references___get__(PyObject *__pyx_v_self) {
10660   PyObject *__pyx_v_t;
10661   long __pyx_v_x;
10662   PyObject *__pyx_r = NULL;
10663   PyObject *__pyx_t_1 = NULL;
10664   PyObject *__pyx_t_2 = NULL;
10665   int __pyx_t_3;
10666   int __pyx_t_4;
10667   int32_t __pyx_t_5;
10668   int __pyx_t_6;
10669   __Pyx_TraceDeclarations
10670   __Pyx_RefNannySetupContext("__get__");
10671   __Pyx_TraceCall("__get__", __pyx_f[0], 1006);
10672   __pyx_v_t = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
10673
10674   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1007
10675  *         """tuple with the names of :term:`reference` sequences."""
10676  *         def __get__(self):
10677  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
10678  *             t = []
10679  *             for x from 0 <= x < self.samfile.header.n_targets:
10680  */
10681   __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;}
10682   __Pyx_GOTREF(__pyx_t_1);
10683   __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;}
10684   __Pyx_GOTREF(__pyx_t_2);
10685   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10686   __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;}
10687   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10688   __pyx_t_4 = (!__pyx_t_3);
10689   if (__pyx_t_4) {
10690     __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;}
10691     __Pyx_GOTREF(__pyx_t_2);
10692     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
10693     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
10694     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
10695     __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;}
10696     __Pyx_GOTREF(__pyx_t_1);
10697     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10698     __Pyx_Raise(__pyx_t_1, 0, 0);
10699     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10700     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
10701     goto __pyx_L5;
10702   }
10703   __pyx_L5:;
10704
10705   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1008
10706  *         def __get__(self):
10707  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
10708  *             t = []             # <<<<<<<<<<<<<<
10709  *             for x from 0 <= x < self.samfile.header.n_targets:
10710  *                 t.append( self.samfile.header.target_name[x] )
10711  */
10712   __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;}
10713   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
10714   __Pyx_DECREF(((PyObject *)__pyx_v_t));
10715   __pyx_v_t = __pyx_t_1;
10716   __pyx_t_1 = 0;
10717
10718   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1009
10719  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
10720  *             t = []
10721  *             for x from 0 <= x < self.samfile.header.n_targets:             # <<<<<<<<<<<<<<
10722  *                 t.append( self.samfile.header.target_name[x] )
10723  *             return tuple(t)
10724  */
10725   __pyx_t_5 = ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->n_targets;
10726   for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_5; __pyx_v_x++) {
10727
10728     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1010
10729  *             t = []
10730  *             for x from 0 <= x < self.samfile.header.n_targets:
10731  *                 t.append( self.samfile.header.target_name[x] )             # <<<<<<<<<<<<<<
10732  *             return tuple(t)
10733  * 
10734  */
10735     if (unlikely(__pyx_v_t == Py_None)) {
10736       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;} 
10737     }
10738     __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;}
10739     __Pyx_GOTREF(((PyObject *)__pyx_t_1));
10740     __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;}
10741     __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
10742   }
10743
10744   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1011
10745  *             for x from 0 <= x < self.samfile.header.n_targets:
10746  *                 t.append( self.samfile.header.target_name[x] )
10747  *             return tuple(t)             # <<<<<<<<<<<<<<
10748  * 
10749  *     property lengths:
10750  */
10751   __Pyx_XDECREF(__pyx_r);
10752   if (unlikely(__pyx_v_t == Py_None)) {
10753     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
10754   }
10755   __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;}
10756   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
10757   __pyx_r = ((PyObject *)__pyx_t_1);
10758   __pyx_t_1 = 0;
10759   goto __pyx_L0;
10760
10761   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
10762   goto __pyx_L0;
10763   __pyx_L1_error:;
10764   __Pyx_XDECREF(__pyx_t_1);
10765   __Pyx_XDECREF(__pyx_t_2);
10766   __Pyx_AddTraceback("csamtools.Samfile.references.__get__");
10767   __pyx_r = NULL;
10768   __pyx_L0:;
10769   __Pyx_DECREF(__pyx_v_t);
10770   __Pyx_XGIVEREF(__pyx_r);
10771   __Pyx_TraceReturn(__pyx_r);
10772   __Pyx_RefNannyFinishContext();
10773   return __pyx_r;
10774 }
10775
10776 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1017
10777  *         :attr:`pysam.Samfile.references`
10778  *         """
10779  *         def __get__(self):             # <<<<<<<<<<<<<<
10780  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
10781  *             t = []
10782  */
10783
10784 static PyObject *__pyx_pf_9csamtools_7Samfile_7lengths___get__(PyObject *__pyx_v_self); /*proto*/
10785 static PyObject *__pyx_pf_9csamtools_7Samfile_7lengths___get__(PyObject *__pyx_v_self) {
10786   PyObject *__pyx_v_t;
10787   long __pyx_v_x;
10788   PyObject *__pyx_r = NULL;
10789   PyObject *__pyx_t_1 = NULL;
10790   PyObject *__pyx_t_2 = NULL;
10791   int __pyx_t_3;
10792   int __pyx_t_4;
10793   int32_t __pyx_t_5;
10794   int __pyx_t_6;
10795   __Pyx_TraceDeclarations
10796   __Pyx_RefNannySetupContext("__get__");
10797   __Pyx_TraceCall("__get__", __pyx_f[0], 1017);
10798   __pyx_v_t = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
10799
10800   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1018
10801  *         """
10802  *         def __get__(self):
10803  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
10804  *             t = []
10805  *             for x from 0 <= x < self.samfile.header.n_targets:
10806  */
10807   __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;}
10808   __Pyx_GOTREF(__pyx_t_1);
10809   __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;}
10810   __Pyx_GOTREF(__pyx_t_2);
10811   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10812   __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;}
10813   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10814   __pyx_t_4 = (!__pyx_t_3);
10815   if (__pyx_t_4) {
10816     __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;}
10817     __Pyx_GOTREF(__pyx_t_2);
10818     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
10819     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
10820     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
10821     __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;}
10822     __Pyx_GOTREF(__pyx_t_1);
10823     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10824     __Pyx_Raise(__pyx_t_1, 0, 0);
10825     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10826     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1018; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
10827     goto __pyx_L5;
10828   }
10829   __pyx_L5:;
10830
10831   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1019
10832  *         def __get__(self):
10833  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
10834  *             t = []             # <<<<<<<<<<<<<<
10835  *             for x from 0 <= x < self.samfile.header.n_targets:
10836  *                 t.append( self.samfile.header.target_len[x] )
10837  */
10838   __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;}
10839   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
10840   __Pyx_DECREF(((PyObject *)__pyx_v_t));
10841   __pyx_v_t = __pyx_t_1;
10842   __pyx_t_1 = 0;
10843
10844   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1020
10845  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
10846  *             t = []
10847  *             for x from 0 <= x < self.samfile.header.n_targets:             # <<<<<<<<<<<<<<
10848  *                 t.append( self.samfile.header.target_len[x] )
10849  *             return tuple(t)
10850  */
10851   __pyx_t_5 = ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->n_targets;
10852   for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_5; __pyx_v_x++) {
10853
10854     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1021
10855  *             t = []
10856  *             for x from 0 <= x < self.samfile.header.n_targets:
10857  *                 t.append( self.samfile.header.target_len[x] )             # <<<<<<<<<<<<<<
10858  *             return tuple(t)
10859  * 
10860  */
10861     if (unlikely(__pyx_v_t == Py_None)) {
10862       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;} 
10863     }
10864     __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;}
10865     __Pyx_GOTREF(__pyx_t_1);
10866     __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;}
10867     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10868   }
10869
10870   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1022
10871  *             for x from 0 <= x < self.samfile.header.n_targets:
10872  *                 t.append( self.samfile.header.target_len[x] )
10873  *             return tuple(t)             # <<<<<<<<<<<<<<
10874  * 
10875  *     property text:
10876  */
10877   __Pyx_XDECREF(__pyx_r);
10878   if (unlikely(__pyx_v_t == Py_None)) {
10879     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
10880   }
10881   __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;}
10882   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
10883   __pyx_r = ((PyObject *)__pyx_t_1);
10884   __pyx_t_1 = 0;
10885   goto __pyx_L0;
10886
10887   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
10888   goto __pyx_L0;
10889   __pyx_L1_error:;
10890   __Pyx_XDECREF(__pyx_t_1);
10891   __Pyx_XDECREF(__pyx_t_2);
10892   __Pyx_AddTraceback("csamtools.Samfile.lengths.__get__");
10893   __pyx_r = NULL;
10894   __pyx_L0:;
10895   __Pyx_DECREF(__pyx_v_t);
10896   __Pyx_XGIVEREF(__pyx_r);
10897   __Pyx_TraceReturn(__pyx_r);
10898   __Pyx_RefNannyFinishContext();
10899   return __pyx_r;
10900 }
10901
10902 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1026
10903  *     property text:
10904  *         '''full contents of the :term:`sam file` header as a string.'''
10905  *         def __get__(self):             # <<<<<<<<<<<<<<
10906  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
10907  *             return PyString_FromStringAndSize(self.samfile.header.text, self.samfile.header.l_text)
10908  */
10909
10910 static PyObject *__pyx_pf_9csamtools_7Samfile_4text___get__(PyObject *__pyx_v_self); /*proto*/
10911 static PyObject *__pyx_pf_9csamtools_7Samfile_4text___get__(PyObject *__pyx_v_self) {
10912   PyObject *__pyx_r = NULL;
10913   PyObject *__pyx_t_1 = NULL;
10914   PyObject *__pyx_t_2 = NULL;
10915   int __pyx_t_3;
10916   int __pyx_t_4;
10917   __Pyx_TraceDeclarations
10918   __Pyx_RefNannySetupContext("__get__");
10919   __Pyx_TraceCall("__get__", __pyx_f[0], 1026);
10920
10921   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1027
10922  *         '''full contents of the :term:`sam file` header as a string.'''
10923  *         def __get__(self):
10924  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
10925  *             return PyString_FromStringAndSize(self.samfile.header.text, self.samfile.header.l_text)
10926  * 
10927  */
10928   __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;}
10929   __Pyx_GOTREF(__pyx_t_1);
10930   __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;}
10931   __Pyx_GOTREF(__pyx_t_2);
10932   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10933   __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;}
10934   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10935   __pyx_t_4 = (!__pyx_t_3);
10936   if (__pyx_t_4) {
10937     __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;}
10938     __Pyx_GOTREF(__pyx_t_2);
10939     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
10940     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
10941     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
10942     __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;}
10943     __Pyx_GOTREF(__pyx_t_1);
10944     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
10945     __Pyx_Raise(__pyx_t_1, 0, 0);
10946     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
10947     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
10948     goto __pyx_L5;
10949   }
10950   __pyx_L5:;
10951
10952   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1028
10953  *         def __get__(self):
10954  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
10955  *             return PyString_FromStringAndSize(self.samfile.header.text, self.samfile.header.l_text)             # <<<<<<<<<<<<<<
10956  * 
10957  *     property header:
10958  */
10959   __Pyx_XDECREF(__pyx_r);
10960   __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;}
10961   __Pyx_GOTREF(__pyx_t_1);
10962   __pyx_r = __pyx_t_1;
10963   __pyx_t_1 = 0;
10964   goto __pyx_L0;
10965
10966   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
10967   goto __pyx_L0;
10968   __pyx_L1_error:;
10969   __Pyx_XDECREF(__pyx_t_1);
10970   __Pyx_XDECREF(__pyx_t_2);
10971   __Pyx_AddTraceback("csamtools.Samfile.text.__get__");
10972   __pyx_r = NULL;
10973   __pyx_L0:;
10974   __Pyx_XGIVEREF(__pyx_r);
10975   __Pyx_TraceReturn(__pyx_r);
10976   __Pyx_RefNannyFinishContext();
10977   return __pyx_r;
10978 }
10979
10980 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1034
10981  *         a two-level dictionary.
10982  *         '''
10983  *         def __get__(self):             # <<<<<<<<<<<<<<
10984  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
10985  * 
10986  */
10987
10988 static PyObject *__pyx_pf_9csamtools_7Samfile_6header___get__(PyObject *__pyx_v_self); /*proto*/
10989 static PyObject *__pyx_pf_9csamtools_7Samfile_6header___get__(PyObject *__pyx_v_self) {
10990   PyObject *__pyx_v_result;
10991   PyObject *__pyx_v_t;
10992   PyObject *__pyx_v_line;
10993   PyObject *__pyx_v_fields;
10994   PyObject *__pyx_v_record;
10995   PyObject *__pyx_v_x;
10996   PyObject *__pyx_v_field;
10997   PyObject *__pyx_v_key;
10998   PyObject *__pyx_v_value;
10999   PyObject *__pyx_r = NULL;
11000   PyObject *__pyx_t_1 = NULL;
11001   PyObject *__pyx_t_2 = NULL;
11002   int __pyx_t_3;
11003   int __pyx_t_4;
11004   Py_ssize_t __pyx_t_5;
11005   PyObject *__pyx_t_6 = NULL;
11006   PyObject *__pyx_t_7 = NULL;
11007   PyObject *__pyx_t_8 = NULL;
11008   Py_ssize_t __pyx_t_9;
11009   PyObject *__pyx_t_10 = NULL;
11010   __Pyx_TraceDeclarations
11011   __Pyx_RefNannySetupContext("__get__");
11012   __Pyx_TraceCall("__get__", __pyx_f[0], 1034);
11013   __pyx_v_result = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
11014   __pyx_v_t = Py_None; __Pyx_INCREF(Py_None);
11015   __pyx_v_line = Py_None; __Pyx_INCREF(Py_None);
11016   __pyx_v_fields = Py_None; __Pyx_INCREF(Py_None);
11017   __pyx_v_record = Py_None; __Pyx_INCREF(Py_None);
11018   __pyx_v_x = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
11019   __pyx_v_field = Py_None; __Pyx_INCREF(Py_None);
11020   __pyx_v_key = Py_None; __Pyx_INCREF(Py_None);
11021   __pyx_v_value = Py_None; __Pyx_INCREF(Py_None);
11022
11023   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1035
11024  *         '''
11025  *         def __get__(self):
11026  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
11027  * 
11028  *             result = {}
11029  */
11030   __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;}
11031   __Pyx_GOTREF(__pyx_t_1);
11032   __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;}
11033   __Pyx_GOTREF(__pyx_t_2);
11034   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11035   __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;}
11036   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11037   __pyx_t_4 = (!__pyx_t_3);
11038   if (__pyx_t_4) {
11039     __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;}
11040     __Pyx_GOTREF(__pyx_t_2);
11041     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
11042     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
11043     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
11044     __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;}
11045     __Pyx_GOTREF(__pyx_t_1);
11046     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11047     __Pyx_Raise(__pyx_t_1, 0, 0);
11048     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11049     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11050     goto __pyx_L5;
11051   }
11052   __pyx_L5:;
11053
11054   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1037
11055  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
11056  * 
11057  *             result = {}             # <<<<<<<<<<<<<<
11058  * 
11059  *             if self.samfile.header.text != NULL:
11060  */
11061   __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;}
11062   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
11063   __Pyx_DECREF(((PyObject *)__pyx_v_result));
11064   __pyx_v_result = __pyx_t_1;
11065   __pyx_t_1 = 0;
11066
11067   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1039
11068  *             result = {}
11069  * 
11070  *             if self.samfile.header.text != NULL:             # <<<<<<<<<<<<<<
11071  *                 # convert to python string (note: call self.text to create 0-terminated string)
11072  *                 t = self.text
11073  */
11074   __pyx_t_4 = (((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile->header->text != NULL);
11075   if (__pyx_t_4) {
11076
11077     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1041
11078  *             if self.samfile.header.text != NULL:
11079  *                 # convert to python string (note: call self.text to create 0-terminated string)
11080  *                 t = self.text             # <<<<<<<<<<<<<<
11081  *                 for line in t.split("\n"):
11082  *                     if not line.strip(): continue
11083  */
11084     __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;}
11085     __Pyx_GOTREF(__pyx_t_1);
11086     __Pyx_DECREF(__pyx_v_t);
11087     __pyx_v_t = __pyx_t_1;
11088     __pyx_t_1 = 0;
11089
11090     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1042
11091  *                 # convert to python string (note: call self.text to create 0-terminated string)
11092  *                 t = self.text
11093  *                 for line in t.split("\n"):             # <<<<<<<<<<<<<<
11094  *                     if not line.strip(): continue
11095  *                     assert line.startswith("@"), "header line without '@': '%s'" % line
11096  */
11097     __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;}
11098     __Pyx_GOTREF(__pyx_t_1);
11099     __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;}
11100     __Pyx_GOTREF(__pyx_t_2);
11101     __Pyx_INCREF(((PyObject *)__pyx_kp_s_2));
11102     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_2));
11103     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_2));
11104     __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;}
11105     __Pyx_GOTREF(__pyx_t_6);
11106     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11107     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11108     if (PyList_CheckExact(__pyx_t_6) || PyTuple_CheckExact(__pyx_t_6)) {
11109       __pyx_t_5 = 0; __pyx_t_2 = __pyx_t_6; __Pyx_INCREF(__pyx_t_2);
11110     } else {
11111       __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;}
11112       __Pyx_GOTREF(__pyx_t_2);
11113     }
11114     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
11115     for (;;) {
11116       if (likely(PyList_CheckExact(__pyx_t_2))) {
11117         if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
11118         __pyx_t_6 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_6); __pyx_t_5++;
11119       } else if (likely(PyTuple_CheckExact(__pyx_t_2))) {
11120         if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
11121         __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_6); __pyx_t_5++;
11122       } else {
11123         __pyx_t_6 = PyIter_Next(__pyx_t_2);
11124         if (!__pyx_t_6) {
11125           if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11126           break;
11127         }
11128         __Pyx_GOTREF(__pyx_t_6);
11129       }
11130       __Pyx_DECREF(__pyx_v_line);
11131       __pyx_v_line = __pyx_t_6;
11132       __pyx_t_6 = 0;
11133
11134       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1043
11135  *                 t = self.text
11136  *                 for line in t.split("\n"):
11137  *                     if not line.strip(): continue             # <<<<<<<<<<<<<<
11138  *                     assert line.startswith("@"), "header line without '@': '%s'" % line
11139  *                     fields = line[1:].split("\t")
11140  */
11141       __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;}
11142       __Pyx_GOTREF(__pyx_t_6);
11143       __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;}
11144       __Pyx_GOTREF(__pyx_t_1);
11145       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
11146       __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;}
11147       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11148       __pyx_t_3 = (!__pyx_t_4);
11149       if (__pyx_t_3) {
11150         goto __pyx_L7_continue;
11151         goto __pyx_L9;
11152       }
11153       __pyx_L9:;
11154
11155       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1044
11156  *                 for line in t.split("\n"):
11157  *                     if not line.strip(): continue
11158  *                     assert line.startswith("@"), "header line without '@': '%s'" % line             # <<<<<<<<<<<<<<
11159  *                     fields = line[1:].split("\t")
11160  *                     record = fields[0]
11161  */
11162       #ifndef PYREX_WITHOUT_ASSERTIONS
11163       __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;}
11164       __Pyx_GOTREF(__pyx_t_1);
11165       __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;}
11166       __Pyx_GOTREF(__pyx_t_6);
11167       __Pyx_INCREF(((PyObject *)__pyx_kp_s_44));
11168       PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_44));
11169       __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_44));
11170       __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;}
11171       __Pyx_GOTREF(__pyx_t_7);
11172       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11173       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
11174       __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;}
11175       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
11176       if (unlikely(!__pyx_t_3)) {
11177         __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;}
11178         __Pyx_GOTREF(((PyObject *)__pyx_t_7));
11179         PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_t_7));
11180         __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
11181         {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11182       }
11183       #endif
11184
11185       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1045
11186  *                     if not line.strip(): continue
11187  *                     assert line.startswith("@"), "header line without '@': '%s'" % line
11188  *                     fields = line[1:].split("\t")             # <<<<<<<<<<<<<<
11189  *                     record = fields[0]
11190  *                     assert record in VALID_HEADER_TYPES, "header line with invalid type '%s': '%s'" % (record, line)
11191  */
11192       __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;}
11193       __Pyx_GOTREF(__pyx_t_7);
11194       __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;}
11195       __Pyx_GOTREF(__pyx_t_6);
11196       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
11197       __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;}
11198       __Pyx_GOTREF(__pyx_t_7);
11199       __Pyx_INCREF(((PyObject *)__pyx_kp_s_1));
11200       PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_kp_s_1));
11201       __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_1));
11202       __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;}
11203       __Pyx_GOTREF(__pyx_t_1);
11204       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
11205       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
11206       __Pyx_DECREF(__pyx_v_fields);
11207       __pyx_v_fields = __pyx_t_1;
11208       __pyx_t_1 = 0;
11209
11210       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1046
11211  *                     assert line.startswith("@"), "header line without '@': '%s'" % line
11212  *                     fields = line[1:].split("\t")
11213  *                     record = fields[0]             # <<<<<<<<<<<<<<
11214  *                     assert record in VALID_HEADER_TYPES, "header line with invalid type '%s': '%s'" % (record, line)
11215  * 
11216  */
11217       __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;}
11218       __Pyx_GOTREF(__pyx_t_1);
11219       __Pyx_DECREF(__pyx_v_record);
11220       __pyx_v_record = __pyx_t_1;
11221       __pyx_t_1 = 0;
11222
11223       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1047
11224  *                     fields = line[1:].split("\t")
11225  *                     record = fields[0]
11226  *                     assert record in VALID_HEADER_TYPES, "header line with invalid type '%s': '%s'" % (record, line)             # <<<<<<<<<<<<<<
11227  * 
11228  *                     # treat comments
11229  */
11230       #ifndef PYREX_WITHOUT_ASSERTIONS
11231       __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;}
11232       __Pyx_GOTREF(__pyx_t_1);
11233       __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;}
11234       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11235       if (unlikely(!__pyx_t_3)) {
11236         __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;}
11237         __Pyx_GOTREF(__pyx_t_1);
11238         __Pyx_INCREF(__pyx_v_record);
11239         PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_record);
11240         __Pyx_GIVEREF(__pyx_v_record);
11241         __Pyx_INCREF(__pyx_v_line);
11242         PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_line);
11243         __Pyx_GIVEREF(__pyx_v_line);
11244         __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;}
11245         __Pyx_GOTREF(((PyObject *)__pyx_t_7));
11246         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11247         PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_t_7));
11248         __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
11249         {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11250       }
11251       #endif
11252
11253       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1050
11254  * 
11255  *                     # treat comments
11256  *                     if record == "CO":             # <<<<<<<<<<<<<<
11257  *                         if record not in result: result[record] = []
11258  *                         result[record].append( "\t".join( fields[1:] ) )
11259  */
11260       __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;}
11261       __Pyx_GOTREF(__pyx_t_7);
11262       __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;}
11263       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
11264       if (__pyx_t_3) {
11265
11266         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1051
11267  *                     # treat comments
11268  *                     if record == "CO":
11269  *                         if record not in result: result[record] = []             # <<<<<<<<<<<<<<
11270  *                         result[record].append( "\t".join( fields[1:] ) )
11271  *                         continue
11272  */
11273         if (unlikely(((PyObject *)__pyx_v_result) == Py_None)) {
11274           __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11275         } else {
11276           __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;}
11277         }
11278         if (__pyx_t_3) {
11279           __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;}
11280           __Pyx_GOTREF(((PyObject *)__pyx_t_7));
11281           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;}
11282           __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
11283           goto __pyx_L11;
11284         }
11285         __pyx_L11:;
11286
11287         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1052
11288  *                     if record == "CO":
11289  *                         if record not in result: result[record] = []
11290  *                         result[record].append( "\t".join( fields[1:] ) )             # <<<<<<<<<<<<<<
11291  *                         continue
11292  * 
11293  */
11294         __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;}
11295         __Pyx_GOTREF(__pyx_t_7);
11296         __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;}
11297         __Pyx_GOTREF(__pyx_t_1);
11298         __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;}
11299         __Pyx_GOTREF(__pyx_t_6);
11300         __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;}
11301         __Pyx_GOTREF(__pyx_t_8);
11302         PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6);
11303         __Pyx_GIVEREF(__pyx_t_6);
11304         __pyx_t_6 = 0;
11305         __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;}
11306         __Pyx_GOTREF(__pyx_t_6);
11307         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11308         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
11309         __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;}
11310         __Pyx_GOTREF(__pyx_t_8);
11311         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
11312         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
11313         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
11314
11315         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1053
11316  *                         if record not in result: result[record] = []
11317  *                         result[record].append( "\t".join( fields[1:] ) )
11318  *                         continue             # <<<<<<<<<<<<<<
11319  * 
11320  *                     # the following is clumsy as generators do not work?
11321  */
11322         goto __pyx_L7_continue;
11323         goto __pyx_L10;
11324       }
11325       __pyx_L10:;
11326
11327       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1056
11328  * 
11329  *                     # the following is clumsy as generators do not work?
11330  *                     x = {}             # <<<<<<<<<<<<<<
11331  *                     for field in fields[1:]:
11332  *                         key, value = field.split(":",1)
11333  */
11334       __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;}
11335       __Pyx_GOTREF(((PyObject *)__pyx_t_8));
11336       __Pyx_DECREF(((PyObject *)__pyx_v_x));
11337       __pyx_v_x = __pyx_t_8;
11338       __pyx_t_8 = 0;
11339
11340       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1057
11341  *                     # the following is clumsy as generators do not work?
11342  *                     x = {}
11343  *                     for field in fields[1:]:             # <<<<<<<<<<<<<<
11344  *                         key, value = field.split(":",1)
11345  *                         # uppercase keys must be valid
11346  */
11347       __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;}
11348       __Pyx_GOTREF(__pyx_t_8);
11349       if (PyList_CheckExact(__pyx_t_8) || PyTuple_CheckExact(__pyx_t_8)) {
11350         __pyx_t_9 = 0; __pyx_t_6 = __pyx_t_8; __Pyx_INCREF(__pyx_t_6);
11351       } else {
11352         __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;}
11353         __Pyx_GOTREF(__pyx_t_6);
11354       }
11355       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
11356       for (;;) {
11357         if (likely(PyList_CheckExact(__pyx_t_6))) {
11358           if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_6)) break;
11359           __pyx_t_8 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_9); __Pyx_INCREF(__pyx_t_8); __pyx_t_9++;
11360         } else if (likely(PyTuple_CheckExact(__pyx_t_6))) {
11361           if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
11362           __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_9); __Pyx_INCREF(__pyx_t_8); __pyx_t_9++;
11363         } else {
11364           __pyx_t_8 = PyIter_Next(__pyx_t_6);
11365           if (!__pyx_t_8) {
11366             if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11367             break;
11368           }
11369           __Pyx_GOTREF(__pyx_t_8);
11370         }
11371         __Pyx_DECREF(__pyx_v_field);
11372         __pyx_v_field = __pyx_t_8;
11373         __pyx_t_8 = 0;
11374
11375         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1058
11376  *                     x = {}
11377  *                     for field in fields[1:]:
11378  *                         key, value = field.split(":",1)             # <<<<<<<<<<<<<<
11379  *                         # uppercase keys must be valid
11380  *                         # lowercase are permitted for user fields
11381  */
11382         __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;}
11383         __Pyx_GOTREF(__pyx_t_8);
11384         __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;}
11385         __Pyx_GOTREF(__pyx_t_7);
11386         __Pyx_INCREF(((PyObject *)__pyx_kp_s_47));
11387         PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_kp_s_47));
11388         __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_47));
11389         __Pyx_INCREF(__pyx_int_1);
11390         PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_int_1);
11391         __Pyx_GIVEREF(__pyx_int_1);
11392         __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;}
11393         __Pyx_GOTREF(__pyx_t_1);
11394         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
11395         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
11396         if (PyTuple_CheckExact(__pyx_t_1) && likely(PyTuple_GET_SIZE(__pyx_t_1) == 2)) {
11397           PyObject* tuple = __pyx_t_1;
11398           __pyx_t_7 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_7);
11399           __pyx_t_8 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_8);
11400           __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11401           __Pyx_DECREF(__pyx_v_key);
11402           __pyx_v_key = __pyx_t_7;
11403           __pyx_t_7 = 0;
11404           __Pyx_DECREF(__pyx_v_value);
11405           __pyx_v_value = __pyx_t_8;
11406           __pyx_t_8 = 0;
11407         } else {
11408           __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;}
11409           __Pyx_GOTREF(__pyx_t_10);
11410           __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11411           __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;}
11412           __Pyx_GOTREF(__pyx_t_7);
11413           __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;}
11414           __Pyx_GOTREF(__pyx_t_8);
11415           if (__Pyx_EndUnpack(__pyx_t_10, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11416           __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
11417           __Pyx_DECREF(__pyx_v_key);
11418           __pyx_v_key = __pyx_t_7;
11419           __pyx_t_7 = 0;
11420           __Pyx_DECREF(__pyx_v_value);
11421           __pyx_v_value = __pyx_t_8;
11422           __pyx_t_8 = 0;
11423         }
11424
11425         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1061
11426  *                         # uppercase keys must be valid
11427  *                         # lowercase are permitted for user fields
11428  *                         if key in VALID_HEADER_FIELDS[record]:             # <<<<<<<<<<<<<<
11429  *                             x[key] = VALID_HEADER_FIELDS[record][key](value)
11430  *                         elif not key.isupper():
11431  */
11432         __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;}
11433         __Pyx_GOTREF(__pyx_t_1);
11434         __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;}
11435         __Pyx_GOTREF(__pyx_t_8);
11436         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11437         __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;}
11438         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
11439         if (__pyx_t_3) {
11440
11441           /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1062
11442  *                         # lowercase are permitted for user fields
11443  *                         if key in VALID_HEADER_FIELDS[record]:
11444  *                             x[key] = VALID_HEADER_FIELDS[record][key](value)             # <<<<<<<<<<<<<<
11445  *                         elif not key.isupper():
11446  *                             x[key] = value
11447  */
11448           __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;}
11449           __Pyx_GOTREF(__pyx_t_8);
11450           __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;}
11451           __Pyx_GOTREF(__pyx_t_1);
11452           __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
11453           __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;}
11454           __Pyx_GOTREF(__pyx_t_8);
11455           __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11456           __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;}
11457           __Pyx_GOTREF(__pyx_t_1);
11458           __Pyx_INCREF(__pyx_v_value);
11459           PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_value);
11460           __Pyx_GIVEREF(__pyx_v_value);
11461           __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;}
11462           __Pyx_GOTREF(__pyx_t_7);
11463           __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
11464           __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11465           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;}
11466           __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
11467           goto __pyx_L14;
11468         }
11469
11470         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1063
11471  *                         if key in VALID_HEADER_FIELDS[record]:
11472  *                             x[key] = VALID_HEADER_FIELDS[record][key](value)
11473  *                         elif not key.isupper():             # <<<<<<<<<<<<<<
11474  *                             x[key] = value
11475  *                         else:
11476  */
11477         __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;}
11478         __Pyx_GOTREF(__pyx_t_7);
11479         __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;}
11480         __Pyx_GOTREF(__pyx_t_1);
11481         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
11482         __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;}
11483         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11484         __pyx_t_4 = (!__pyx_t_3);
11485         if (__pyx_t_4) {
11486
11487           /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1064
11488  *                             x[key] = VALID_HEADER_FIELDS[record][key](value)
11489  *                         elif not key.isupper():
11490  *                             x[key] = value             # <<<<<<<<<<<<<<
11491  *                         else:
11492  *                             raise ValueError( "unknown field code '%s' in record '%s'" % (key, record) )
11493  */
11494           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;}
11495           goto __pyx_L14;
11496         }
11497         /*else*/ {
11498
11499           /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1066
11500  *                             x[key] = value
11501  *                         else:
11502  *                             raise ValueError( "unknown field code '%s' in record '%s'" % (key, record) )             # <<<<<<<<<<<<<<
11503  * 
11504  *                     if VALID_HEADER_TYPES[record] == dict:
11505  */
11506           __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;}
11507           __Pyx_GOTREF(__pyx_t_1);
11508           __Pyx_INCREF(__pyx_v_key);
11509           PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_key);
11510           __Pyx_GIVEREF(__pyx_v_key);
11511           __Pyx_INCREF(__pyx_v_record);
11512           PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_record);
11513           __Pyx_GIVEREF(__pyx_v_record);
11514           __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;}
11515           __Pyx_GOTREF(((PyObject *)__pyx_t_7));
11516           __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11517           __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;}
11518           __Pyx_GOTREF(__pyx_t_1);
11519           PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_7));
11520           __Pyx_GIVEREF(((PyObject *)__pyx_t_7));
11521           __pyx_t_7 = 0;
11522           __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;}
11523           __Pyx_GOTREF(__pyx_t_7);
11524           __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11525           __Pyx_Raise(__pyx_t_7, 0, 0);
11526           __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
11527           {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11528         }
11529         __pyx_L14:;
11530       }
11531       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
11532
11533       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1068
11534  *                             raise ValueError( "unknown field code '%s' in record '%s'" % (key, record) )
11535  * 
11536  *                     if VALID_HEADER_TYPES[record] == dict:             # <<<<<<<<<<<<<<
11537  *                         if record in result:
11538  *                             raise ValueError( "multiple '%s' lines are not permitted" % record )
11539  */
11540       __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;}
11541       __Pyx_GOTREF(__pyx_t_6);
11542       __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;}
11543       __Pyx_GOTREF(__pyx_t_7);
11544       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
11545       __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;}
11546       __Pyx_GOTREF(__pyx_t_6);
11547       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
11548       __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;}
11549       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
11550       if (__pyx_t_4) {
11551
11552         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1069
11553  * 
11554  *                     if VALID_HEADER_TYPES[record] == dict:
11555  *                         if record in result:             # <<<<<<<<<<<<<<
11556  *                             raise ValueError( "multiple '%s' lines are not permitted" % record )
11557  *                         result[record] = x
11558  */
11559         if (unlikely(((PyObject *)__pyx_v_result) == Py_None)) {
11560           __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11561         } else {
11562           __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;}
11563         }
11564         if (__pyx_t_4) {
11565
11566           /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1070
11567  *                     if VALID_HEADER_TYPES[record] == dict:
11568  *                         if record in result:
11569  *                             raise ValueError( "multiple '%s' lines are not permitted" % record )             # <<<<<<<<<<<<<<
11570  *                         result[record] = x
11571  *                     elif VALID_HEADER_TYPES[record] == list:
11572  */
11573           __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;}
11574           __Pyx_GOTREF(((PyObject *)__pyx_t_6));
11575           __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;}
11576           __Pyx_GOTREF(__pyx_t_7);
11577           PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_t_6));
11578           __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
11579           __pyx_t_6 = 0;
11580           __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;}
11581           __Pyx_GOTREF(__pyx_t_6);
11582           __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
11583           __Pyx_Raise(__pyx_t_6, 0, 0);
11584           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
11585           {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11586           goto __pyx_L16;
11587         }
11588         __pyx_L16:;
11589
11590         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1071
11591  *                         if record in result:
11592  *                             raise ValueError( "multiple '%s' lines are not permitted" % record )
11593  *                         result[record] = x             # <<<<<<<<<<<<<<
11594  *                     elif VALID_HEADER_TYPES[record] == list:
11595  *                         if record not in result: result[record] = []
11596  */
11597         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;}
11598         goto __pyx_L15;
11599       }
11600
11601       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1072
11602  *                             raise ValueError( "multiple '%s' lines are not permitted" % record )
11603  *                         result[record] = x
11604  *                     elif VALID_HEADER_TYPES[record] == list:             # <<<<<<<<<<<<<<
11605  *                         if record not in result: result[record] = []
11606  *                         result[record].append( x )
11607  */
11608       __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;}
11609       __Pyx_GOTREF(__pyx_t_6);
11610       __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;}
11611       __Pyx_GOTREF(__pyx_t_7);
11612       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
11613       __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;}
11614       __Pyx_GOTREF(__pyx_t_6);
11615       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
11616       __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;}
11617       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
11618       if (__pyx_t_4) {
11619
11620         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1073
11621  *                         result[record] = x
11622  *                     elif VALID_HEADER_TYPES[record] == list:
11623  *                         if record not in result: result[record] = []             # <<<<<<<<<<<<<<
11624  *                         result[record].append( x )
11625  * 
11626  */
11627         if (unlikely(((PyObject *)__pyx_v_result) == Py_None)) {
11628           __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11629         } else {
11630           __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;}
11631         }
11632         if (__pyx_t_4) {
11633           __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;}
11634           __Pyx_GOTREF(((PyObject *)__pyx_t_6));
11635           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;}
11636           __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
11637           goto __pyx_L17;
11638         }
11639         __pyx_L17:;
11640
11641         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1074
11642  *                     elif VALID_HEADER_TYPES[record] == list:
11643  *                         if record not in result: result[record] = []
11644  *                         result[record].append( x )             # <<<<<<<<<<<<<<
11645  * 
11646  *             return result
11647  */
11648         __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;}
11649         __Pyx_GOTREF(__pyx_t_6);
11650         __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;}
11651         __Pyx_GOTREF(__pyx_t_7);
11652         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
11653         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
11654         goto __pyx_L15;
11655       }
11656       __pyx_L15:;
11657       __pyx_L7_continue:;
11658     }
11659     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11660     goto __pyx_L6;
11661   }
11662   __pyx_L6:;
11663
11664   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1076
11665  *                         result[record].append( x )
11666  * 
11667  *             return result             # <<<<<<<<<<<<<<
11668  * 
11669  *     def _buildLine( self, fields, record ):
11670  */
11671   __Pyx_XDECREF(__pyx_r);
11672   __Pyx_INCREF(((PyObject *)__pyx_v_result));
11673   __pyx_r = ((PyObject *)__pyx_v_result);
11674   goto __pyx_L0;
11675
11676   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
11677   goto __pyx_L0;
11678   __pyx_L1_error:;
11679   __Pyx_XDECREF(__pyx_t_1);
11680   __Pyx_XDECREF(__pyx_t_2);
11681   __Pyx_XDECREF(__pyx_t_6);
11682   __Pyx_XDECREF(__pyx_t_7);
11683   __Pyx_XDECREF(__pyx_t_8);
11684   __Pyx_XDECREF(__pyx_t_10);
11685   __Pyx_AddTraceback("csamtools.Samfile.header.__get__");
11686   __pyx_r = NULL;
11687   __pyx_L0:;
11688   __Pyx_DECREF(__pyx_v_result);
11689   __Pyx_DECREF(__pyx_v_t);
11690   __Pyx_DECREF(__pyx_v_line);
11691   __Pyx_DECREF(__pyx_v_fields);
11692   __Pyx_DECREF(__pyx_v_record);
11693   __Pyx_DECREF(__pyx_v_x);
11694   __Pyx_DECREF(__pyx_v_field);
11695   __Pyx_DECREF(__pyx_v_key);
11696   __Pyx_DECREF(__pyx_v_value);
11697   __Pyx_XGIVEREF(__pyx_r);
11698   __Pyx_TraceReturn(__pyx_r);
11699   __Pyx_RefNannyFinishContext();
11700   return __pyx_r;
11701 }
11702
11703 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1078
11704  *             return result
11705  * 
11706  *     def _buildLine( self, fields, record ):             # <<<<<<<<<<<<<<
11707  *         '''build a header line from *fields* dictionary for *record*'''
11708  * 
11709  */
11710
11711 static PyObject *__pyx_pf_9csamtools_7Samfile__buildLine(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
11712 static char __pyx_doc_9csamtools_7Samfile__buildLine[] = "Samfile._buildLine(self, fields, record)\nbuild a header line from *fields* dictionary for *record*";
11713 static PyObject *__pyx_pf_9csamtools_7Samfile__buildLine(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
11714   PyObject *__pyx_v_fields = 0;
11715   PyObject *__pyx_v_record = 0;
11716   PyObject *__pyx_v_line;
11717   PyObject *__pyx_v_key;
11718   PyObject *__pyx_r = NULL;
11719   PyObject *__pyx_t_1 = NULL;
11720   PyObject *__pyx_t_2 = NULL;
11721   int __pyx_t_3;
11722   int __pyx_t_4;
11723   Py_ssize_t __pyx_t_5;
11724   PyObject *__pyx_t_6 = NULL;
11725   int __pyx_t_7;
11726   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__fields,&__pyx_n_s__record,0};
11727   __Pyx_TraceDeclarations
11728   __Pyx_RefNannySetupContext("_buildLine");
11729   __Pyx_TraceCall("_buildLine", __pyx_f[0], 1078);
11730   if (unlikely(__pyx_kwds)) {
11731     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
11732     PyObject* values[2] = {0,0};
11733     switch (PyTuple_GET_SIZE(__pyx_args)) {
11734       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
11735       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
11736       case  0: break;
11737       default: goto __pyx_L5_argtuple_error;
11738     }
11739     switch (PyTuple_GET_SIZE(__pyx_args)) {
11740       case  0:
11741       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fields);
11742       if (likely(values[0])) kw_args--;
11743       else goto __pyx_L5_argtuple_error;
11744       case  1:
11745       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__record);
11746       if (likely(values[1])) kw_args--;
11747       else {
11748         __Pyx_RaiseArgtupleInvalid("_buildLine", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1078; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
11749       }
11750     }
11751     if (unlikely(kw_args > 0)) {
11752       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;}
11753     }
11754     __pyx_v_fields = values[0];
11755     __pyx_v_record = values[1];
11756   } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
11757     goto __pyx_L5_argtuple_error;
11758   } else {
11759     __pyx_v_fields = PyTuple_GET_ITEM(__pyx_args, 0);
11760     __pyx_v_record = PyTuple_GET_ITEM(__pyx_args, 1);
11761   }
11762   goto __pyx_L4_argument_unpacking_done;
11763   __pyx_L5_argtuple_error:;
11764   __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;}
11765   __pyx_L3_error:;
11766   __Pyx_AddTraceback("csamtools.Samfile._buildLine");
11767   __Pyx_RefNannyFinishContext();
11768   return NULL;
11769   __pyx_L4_argument_unpacking_done:;
11770   __pyx_v_line = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
11771   __pyx_v_key = Py_None; __Pyx_INCREF(Py_None);
11772
11773   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1082
11774  * 
11775  *         # TODO: add checking for field and sort order
11776  *         line = ["@%s" % record ]             # <<<<<<<<<<<<<<
11777  *         if record == "CO":
11778  *             line.append( fields )
11779  */
11780   __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;}
11781   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
11782   __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;}
11783   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
11784   PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
11785   __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
11786   __pyx_t_1 = 0;
11787   __Pyx_DECREF(((PyObject *)__pyx_v_line));
11788   __pyx_v_line = __pyx_t_2;
11789   __pyx_t_2 = 0;
11790
11791   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1083
11792  *         # TODO: add checking for field and sort order
11793  *         line = ["@%s" % record ]
11794  *         if record == "CO":             # <<<<<<<<<<<<<<
11795  *             line.append( fields )
11796  *         else:
11797  */
11798   __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;}
11799   __Pyx_GOTREF(__pyx_t_2);
11800   __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;}
11801   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11802   if (__pyx_t_3) {
11803
11804     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1084
11805  *         line = ["@%s" % record ]
11806  *         if record == "CO":
11807  *             line.append( fields )             # <<<<<<<<<<<<<<
11808  *         else:
11809  *             # write fields of the specification
11810  */
11811     if (unlikely(__pyx_v_line == Py_None)) {
11812       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;} 
11813     }
11814     __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;}
11815     goto __pyx_L6;
11816   }
11817   /*else*/ {
11818
11819     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1087
11820  *         else:
11821  *             # write fields of the specification
11822  *             for key in VALID_HEADER_ORDER[record]:             # <<<<<<<<<<<<<<
11823  *                 if key in fields:
11824  *                     line.append( "%s:%s" % (key, str(fields[key])))
11825  */
11826     __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;}
11827     __Pyx_GOTREF(__pyx_t_2);
11828     __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;}
11829     __Pyx_GOTREF(__pyx_t_1);
11830     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11831     if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
11832       __pyx_t_5 = 0; __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2);
11833     } else {
11834       __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;}
11835       __Pyx_GOTREF(__pyx_t_2);
11836     }
11837     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11838     for (;;) {
11839       if (likely(PyList_CheckExact(__pyx_t_2))) {
11840         if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
11841         __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++;
11842       } else if (likely(PyTuple_CheckExact(__pyx_t_2))) {
11843         if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
11844         __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++;
11845       } else {
11846         __pyx_t_1 = PyIter_Next(__pyx_t_2);
11847         if (!__pyx_t_1) {
11848           if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11849           break;
11850         }
11851         __Pyx_GOTREF(__pyx_t_1);
11852       }
11853       __Pyx_DECREF(__pyx_v_key);
11854       __pyx_v_key = __pyx_t_1;
11855       __pyx_t_1 = 0;
11856
11857       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1088
11858  *             # write fields of the specification
11859  *             for key in VALID_HEADER_ORDER[record]:
11860  *                 if key in fields:             # <<<<<<<<<<<<<<
11861  *                     line.append( "%s:%s" % (key, str(fields[key])))
11862  *             # write user fields
11863  */
11864       __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;}
11865       if (__pyx_t_3) {
11866
11867         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1089
11868  *             for key in VALID_HEADER_ORDER[record]:
11869  *                 if key in fields:
11870  *                     line.append( "%s:%s" % (key, str(fields[key])))             # <<<<<<<<<<<<<<
11871  *             # write user fields
11872  *             for key in fields:
11873  */
11874         if (unlikely(__pyx_v_line == Py_None)) {
11875           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;} 
11876         }
11877         __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;}
11878         __Pyx_GOTREF(__pyx_t_1);
11879         __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;}
11880         __Pyx_GOTREF(__pyx_t_6);
11881         PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
11882         __Pyx_GIVEREF(__pyx_t_1);
11883         __pyx_t_1 = 0;
11884         __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;}
11885         __Pyx_GOTREF(__pyx_t_1);
11886         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
11887         __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;}
11888         __Pyx_GOTREF(__pyx_t_6);
11889         __Pyx_INCREF(__pyx_v_key);
11890         PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_key);
11891         __Pyx_GIVEREF(__pyx_v_key);
11892         PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_1);
11893         __Pyx_GIVEREF(__pyx_t_1);
11894         __pyx_t_1 = 0;
11895         __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;}
11896         __Pyx_GOTREF(((PyObject *)__pyx_t_1));
11897         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
11898         __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;}
11899         __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
11900         goto __pyx_L9;
11901       }
11902       __pyx_L9:;
11903     }
11904     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11905
11906     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1091
11907  *                     line.append( "%s:%s" % (key, str(fields[key])))
11908  *             # write user fields
11909  *             for key in fields:             # <<<<<<<<<<<<<<
11910  *                 if not key.isupper():
11911  *                     line.append( "%s:%s" % (key, str(fields[key])))
11912  */
11913     if (PyList_CheckExact(__pyx_v_fields) || PyTuple_CheckExact(__pyx_v_fields)) {
11914       __pyx_t_5 = 0; __pyx_t_2 = __pyx_v_fields; __Pyx_INCREF(__pyx_t_2);
11915     } else {
11916       __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;}
11917       __Pyx_GOTREF(__pyx_t_2);
11918     }
11919     for (;;) {
11920       if (likely(PyList_CheckExact(__pyx_t_2))) {
11921         if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
11922         __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++;
11923       } else if (likely(PyTuple_CheckExact(__pyx_t_2))) {
11924         if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
11925         __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++;
11926       } else {
11927         __pyx_t_1 = PyIter_Next(__pyx_t_2);
11928         if (!__pyx_t_1) {
11929           if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
11930           break;
11931         }
11932         __Pyx_GOTREF(__pyx_t_1);
11933       }
11934       __Pyx_DECREF(__pyx_v_key);
11935       __pyx_v_key = __pyx_t_1;
11936       __pyx_t_1 = 0;
11937
11938       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1092
11939  *             # write user fields
11940  *             for key in fields:
11941  *                 if not key.isupper():             # <<<<<<<<<<<<<<
11942  *                     line.append( "%s:%s" % (key, str(fields[key])))
11943  * 
11944  */
11945       __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;}
11946       __Pyx_GOTREF(__pyx_t_1);
11947       __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;}
11948       __Pyx_GOTREF(__pyx_t_6);
11949       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11950       __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;}
11951       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
11952       __pyx_t_7 = (!__pyx_t_3);
11953       if (__pyx_t_7) {
11954
11955         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1093
11956  *             for key in fields:
11957  *                 if not key.isupper():
11958  *                     line.append( "%s:%s" % (key, str(fields[key])))             # <<<<<<<<<<<<<<
11959  * 
11960  *         return "\t".join( line )
11961  */
11962         if (unlikely(__pyx_v_line == Py_None)) {
11963           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;} 
11964         }
11965         __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;}
11966         __Pyx_GOTREF(__pyx_t_6);
11967         __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;}
11968         __Pyx_GOTREF(__pyx_t_1);
11969         PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_6);
11970         __Pyx_GIVEREF(__pyx_t_6);
11971         __pyx_t_6 = 0;
11972         __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;}
11973         __Pyx_GOTREF(__pyx_t_6);
11974         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11975         __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;}
11976         __Pyx_GOTREF(__pyx_t_1);
11977         __Pyx_INCREF(__pyx_v_key);
11978         PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_key);
11979         __Pyx_GIVEREF(__pyx_v_key);
11980         PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_6);
11981         __Pyx_GIVEREF(__pyx_t_6);
11982         __pyx_t_6 = 0;
11983         __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;}
11984         __Pyx_GOTREF(((PyObject *)__pyx_t_6));
11985         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
11986         __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;}
11987         __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
11988         goto __pyx_L12;
11989       }
11990       __pyx_L12:;
11991     }
11992     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
11993   }
11994   __pyx_L6:;
11995
11996   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1095
11997  *                     line.append( "%s:%s" % (key, str(fields[key])))
11998  * 
11999  *         return "\t".join( line )             # <<<<<<<<<<<<<<
12000  * 
12001  *     cdef bam_header_t * _buildHeader( self, new_header ):
12002  */
12003   __Pyx_XDECREF(__pyx_r);
12004   __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;}
12005   __Pyx_GOTREF(__pyx_t_2);
12006   __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;}
12007   __Pyx_GOTREF(__pyx_t_6);
12008   __Pyx_INCREF(((PyObject *)__pyx_v_line));
12009   PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_line));
12010   __Pyx_GIVEREF(((PyObject *)__pyx_v_line));
12011   __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;}
12012   __Pyx_GOTREF(__pyx_t_1);
12013   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12014   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
12015   __pyx_r = __pyx_t_1;
12016   __pyx_t_1 = 0;
12017   goto __pyx_L0;
12018
12019   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
12020   goto __pyx_L0;
12021   __pyx_L1_error:;
12022   __Pyx_XDECREF(__pyx_t_1);
12023   __Pyx_XDECREF(__pyx_t_2);
12024   __Pyx_XDECREF(__pyx_t_6);
12025   __Pyx_AddTraceback("csamtools.Samfile._buildLine");
12026   __pyx_r = NULL;
12027   __pyx_L0:;
12028   __Pyx_DECREF(__pyx_v_line);
12029   __Pyx_DECREF(__pyx_v_key);
12030   __Pyx_XGIVEREF(__pyx_r);
12031   __Pyx_TraceReturn(__pyx_r);
12032   __Pyx_RefNannyFinishContext();
12033   return __pyx_r;
12034 }
12035
12036 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1097
12037  *         return "\t".join( line )
12038  * 
12039  *     cdef bam_header_t * _buildHeader( self, new_header ):             # <<<<<<<<<<<<<<
12040  *         '''return a new header built from a dictionary in *new_header*.
12041  * 
12042  */
12043
12044 static  bam_header_t *__pyx_f_9csamtools_7Samfile__buildHeader(struct __pyx_obj_9csamtools_Samfile *__pyx_v_self, PyObject *__pyx_v_new_header) {
12045   PyObject *__pyx_v_lines;
12046   bam_header_t *__pyx_v_dest;
12047   PyObject *__pyx_v_record;
12048   PyObject *__pyx_v_ttype;
12049   PyObject *__pyx_v_data;
12050   PyObject *__pyx_v_fields;
12051   PyObject *__pyx_v_text;
12052   PyObject *__pyx_v_seqs;
12053   long __pyx_v_x;
12054   PyObject *__pyx_v_seqname;
12055   PyObject *__pyx_v_seqlen;
12056   bam_header_t *__pyx_r;
12057   PyObject *__pyx_t_1 = NULL;
12058   Py_ssize_t __pyx_t_2;
12059   PyObject *__pyx_t_3 = NULL;
12060   int __pyx_t_4;
12061   PyObject *__pyx_t_5 = NULL;
12062   PyObject *__pyx_t_6 = NULL;
12063   int __pyx_t_7;
12064   Py_ssize_t __pyx_t_8;
12065   PyObject *__pyx_t_9 = NULL;
12066   char *__pyx_t_10;
12067   PyObject *__pyx_t_11 = NULL;
12068   int32_t __pyx_t_12;
12069   uint32_t __pyx_t_13;
12070   __Pyx_TraceDeclarations
12071   __Pyx_RefNannySetupContext("_buildHeader");
12072   __Pyx_TraceCall("_buildHeader", __pyx_f[0], 1097);
12073   __pyx_v_lines = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
12074   __pyx_v_record = Py_None; __Pyx_INCREF(Py_None);
12075   __pyx_v_ttype = Py_None; __Pyx_INCREF(Py_None);
12076   __pyx_v_data = Py_None; __Pyx_INCREF(Py_None);
12077   __pyx_v_fields = Py_None; __Pyx_INCREF(Py_None);
12078   __pyx_v_text = Py_None; __Pyx_INCREF(Py_None);
12079   __pyx_v_seqs = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
12080   __pyx_v_seqname = Py_None; __Pyx_INCREF(Py_None);
12081   __pyx_v_seqlen = Py_None; __Pyx_INCREF(Py_None);
12082
12083   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1103
12084  *         '''
12085  * 
12086  *         lines = []             # <<<<<<<<<<<<<<
12087  * 
12088  *         # check if hash exists
12089  */
12090   __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;}
12091   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
12092   __Pyx_DECREF(((PyObject *)__pyx_v_lines));
12093   __pyx_v_lines = __pyx_t_1;
12094   __pyx_t_1 = 0;
12095
12096   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1110
12097  *         cdef bam_header_t * dest
12098  * 
12099  *         dest = bam_header_init()             # <<<<<<<<<<<<<<
12100  * 
12101  *         for record in VALID_HEADERS:
12102  */
12103   __pyx_v_dest = bam_header_init();
12104
12105   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1112
12106  *         dest = bam_header_init()
12107  * 
12108  *         for record in VALID_HEADERS:             # <<<<<<<<<<<<<<
12109  *             if record in new_header:
12110  *                 ttype = VALID_HEADER_TYPES[record]
12111  */
12112   __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;}
12113   __Pyx_GOTREF(__pyx_t_1);
12114   if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
12115     __pyx_t_2 = 0; __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3);
12116   } else {
12117     __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;}
12118     __Pyx_GOTREF(__pyx_t_3);
12119   }
12120   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12121   for (;;) {
12122     if (likely(PyList_CheckExact(__pyx_t_3))) {
12123       if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_3)) break;
12124       __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++;
12125     } else if (likely(PyTuple_CheckExact(__pyx_t_3))) {
12126       if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
12127       __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++;
12128     } else {
12129       __pyx_t_1 = PyIter_Next(__pyx_t_3);
12130       if (!__pyx_t_1) {
12131         if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
12132         break;
12133       }
12134       __Pyx_GOTREF(__pyx_t_1);
12135     }
12136     __Pyx_DECREF(__pyx_v_record);
12137     __pyx_v_record = __pyx_t_1;
12138     __pyx_t_1 = 0;
12139
12140     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1113
12141  * 
12142  *         for record in VALID_HEADERS:
12143  *             if record in new_header:             # <<<<<<<<<<<<<<
12144  *                 ttype = VALID_HEADER_TYPES[record]
12145  *                 data = new_header[record]
12146  */
12147     __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;}
12148     if (__pyx_t_4) {
12149
12150       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1114
12151  *         for record in VALID_HEADERS:
12152  *             if record in new_header:
12153  *                 ttype = VALID_HEADER_TYPES[record]             # <<<<<<<<<<<<<<
12154  *                 data = new_header[record]
12155  *                 if type( data ) != type( ttype() ):
12156  */
12157       __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;}
12158       __Pyx_GOTREF(__pyx_t_1);
12159       __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;}
12160       __Pyx_GOTREF(__pyx_t_5);
12161       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12162       __Pyx_DECREF(__pyx_v_ttype);
12163       __pyx_v_ttype = __pyx_t_5;
12164       __pyx_t_5 = 0;
12165
12166       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1115
12167  *             if record in new_header:
12168  *                 ttype = VALID_HEADER_TYPES[record]
12169  *                 data = new_header[record]             # <<<<<<<<<<<<<<
12170  *                 if type( data ) != type( ttype() ):
12171  *                     raise ValueError( "invalid type for record %s: %s, expected %s" % (record, type(data), type(ttype()) ) )
12172  */
12173       __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;}
12174       __Pyx_GOTREF(__pyx_t_5);
12175       __Pyx_DECREF(__pyx_v_data);
12176       __pyx_v_data = __pyx_t_5;
12177       __pyx_t_5 = 0;
12178
12179       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1116
12180  *                 ttype = VALID_HEADER_TYPES[record]
12181  *                 data = new_header[record]
12182  *                 if type( data ) != type( ttype() ):             # <<<<<<<<<<<<<<
12183  *                     raise ValueError( "invalid type for record %s: %s, expected %s" % (record, type(data), type(ttype()) ) )
12184  *                 if type( data ) == types.DictType:
12185  */
12186       __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;}
12187       __Pyx_GOTREF(__pyx_t_5);
12188       __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;}
12189       __Pyx_GOTREF(__pyx_t_1);
12190       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
12191       __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;}
12192       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12193       if (__pyx_t_4) {
12194
12195         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1117
12196  *                 data = new_header[record]
12197  *                 if type( data ) != type( ttype() ):
12198  *                     raise ValueError( "invalid type for record %s: %s, expected %s" % (record, type(data), type(ttype()) ) )             # <<<<<<<<<<<<<<
12199  *                 if type( data ) == types.DictType:
12200  *                     lines.append( self._buildLine( data, record ) )
12201  */
12202         __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;}
12203         __Pyx_GOTREF(__pyx_t_1);
12204         __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;}
12205         __Pyx_GOTREF(__pyx_t_5);
12206         __Pyx_INCREF(__pyx_v_record);
12207         PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_record);
12208         __Pyx_GIVEREF(__pyx_v_record);
12209         __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_data)));
12210         PyTuple_SET_ITEM(__pyx_t_5, 1, ((PyObject *)Py_TYPE(__pyx_v_data)));
12211         __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_v_data)));
12212         __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_t_1)));
12213         PyTuple_SET_ITEM(__pyx_t_5, 2, ((PyObject *)Py_TYPE(__pyx_t_1)));
12214         __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_t_1)));
12215         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12216         __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;}
12217         __Pyx_GOTREF(((PyObject *)__pyx_t_1));
12218         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
12219         __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;}
12220         __Pyx_GOTREF(__pyx_t_5);
12221         PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_1));
12222         __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
12223         __pyx_t_1 = 0;
12224         __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;}
12225         __Pyx_GOTREF(__pyx_t_1);
12226         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
12227         __Pyx_Raise(__pyx_t_1, 0, 0);
12228         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12229         {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
12230         goto __pyx_L6;
12231       }
12232       __pyx_L6:;
12233
12234       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1118
12235  *                 if type( data ) != type( ttype() ):
12236  *                     raise ValueError( "invalid type for record %s: %s, expected %s" % (record, type(data), type(ttype()) ) )
12237  *                 if type( data ) == types.DictType:             # <<<<<<<<<<<<<<
12238  *                     lines.append( self._buildLine( data, record ) )
12239  *                 else:
12240  */
12241       __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;}
12242       __Pyx_GOTREF(__pyx_t_1);
12243       __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;}
12244       __Pyx_GOTREF(__pyx_t_5);
12245       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12246       __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;}
12247       __Pyx_GOTREF(__pyx_t_1);
12248       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
12249       __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;}
12250       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12251       if (__pyx_t_4) {
12252
12253         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1119
12254  *                     raise ValueError( "invalid type for record %s: %s, expected %s" % (record, type(data), type(ttype()) ) )
12255  *                 if type( data ) == types.DictType:
12256  *                     lines.append( self._buildLine( data, record ) )             # <<<<<<<<<<<<<<
12257  *                 else:
12258  *                     for fields in new_header[record]:
12259  */
12260         if (unlikely(__pyx_v_lines == Py_None)) {
12261           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;} 
12262         }
12263         __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;}
12264         __Pyx_GOTREF(__pyx_t_1);
12265         __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;}
12266         __Pyx_GOTREF(__pyx_t_5);
12267         __Pyx_INCREF(__pyx_v_data);
12268         PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_data);
12269         __Pyx_GIVEREF(__pyx_v_data);
12270         __Pyx_INCREF(__pyx_v_record);
12271         PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_record);
12272         __Pyx_GIVEREF(__pyx_v_record);
12273         __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;}
12274         __Pyx_GOTREF(__pyx_t_6);
12275         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12276         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
12277         __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;}
12278         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
12279         goto __pyx_L7;
12280       }
12281       /*else*/ {
12282
12283         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1121
12284  *                     lines.append( self._buildLine( data, record ) )
12285  *                 else:
12286  *                     for fields in new_header[record]:             # <<<<<<<<<<<<<<
12287  *                         lines.append( self._buildLine( fields, record ) )
12288  * 
12289  */
12290         __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;}
12291         __Pyx_GOTREF(__pyx_t_6);
12292         if (PyList_CheckExact(__pyx_t_6) || PyTuple_CheckExact(__pyx_t_6)) {
12293           __pyx_t_8 = 0; __pyx_t_5 = __pyx_t_6; __Pyx_INCREF(__pyx_t_5);
12294         } else {
12295           __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;}
12296           __Pyx_GOTREF(__pyx_t_5);
12297         }
12298         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
12299         for (;;) {
12300           if (likely(PyList_CheckExact(__pyx_t_5))) {
12301             if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_5)) break;
12302             __pyx_t_6 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_8); __Pyx_INCREF(__pyx_t_6); __pyx_t_8++;
12303           } else if (likely(PyTuple_CheckExact(__pyx_t_5))) {
12304             if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_5)) break;
12305             __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_8); __Pyx_INCREF(__pyx_t_6); __pyx_t_8++;
12306           } else {
12307             __pyx_t_6 = PyIter_Next(__pyx_t_5);
12308             if (!__pyx_t_6) {
12309               if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
12310               break;
12311             }
12312             __Pyx_GOTREF(__pyx_t_6);
12313           }
12314           __Pyx_DECREF(__pyx_v_fields);
12315           __pyx_v_fields = __pyx_t_6;
12316           __pyx_t_6 = 0;
12317
12318           /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1122
12319  *                 else:
12320  *                     for fields in new_header[record]:
12321  *                         lines.append( self._buildLine( fields, record ) )             # <<<<<<<<<<<<<<
12322  * 
12323  *         text = "\n".join(lines) + "\n"
12324  */
12325           if (unlikely(__pyx_v_lines == Py_None)) {
12326             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;} 
12327           }
12328           __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;}
12329           __Pyx_GOTREF(__pyx_t_6);
12330           __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;}
12331           __Pyx_GOTREF(__pyx_t_1);
12332           __Pyx_INCREF(__pyx_v_fields);
12333           PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_fields);
12334           __Pyx_GIVEREF(__pyx_v_fields);
12335           __Pyx_INCREF(__pyx_v_record);
12336           PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_record);
12337           __Pyx_GIVEREF(__pyx_v_record);
12338           __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;}
12339           __Pyx_GOTREF(__pyx_t_9);
12340           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
12341           __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12342           __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;}
12343           __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
12344         }
12345         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
12346       }
12347       __pyx_L7:;
12348       goto __pyx_L5;
12349     }
12350     __pyx_L5:;
12351   }
12352   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
12353
12354   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1124
12355  *                         lines.append( self._buildLine( fields, record ) )
12356  * 
12357  *         text = "\n".join(lines) + "\n"             # <<<<<<<<<<<<<<
12358  *         if dest.text != NULL: free( dest.text )
12359  *         dest.text = <char*>calloc( len(text), sizeof(char))
12360  */
12361   __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;}
12362   __Pyx_GOTREF(__pyx_t_3);
12363   __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;}
12364   __Pyx_GOTREF(__pyx_t_5);
12365   __Pyx_INCREF(((PyObject *)__pyx_v_lines));
12366   PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_lines));
12367   __Pyx_GIVEREF(((PyObject *)__pyx_v_lines));
12368   __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;}
12369   __Pyx_GOTREF(__pyx_t_9);
12370   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
12371   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
12372   __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;}
12373   __Pyx_GOTREF(__pyx_t_5);
12374   __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
12375   __Pyx_DECREF(__pyx_v_text);
12376   __pyx_v_text = __pyx_t_5;
12377   __pyx_t_5 = 0;
12378
12379   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1125
12380  * 
12381  *         text = "\n".join(lines) + "\n"
12382  *         if dest.text != NULL: free( dest.text )             # <<<<<<<<<<<<<<
12383  *         dest.text = <char*>calloc( len(text), sizeof(char))
12384  *         dest.l_text = len(text)
12385  */
12386   __pyx_t_4 = (__pyx_v_dest->text != NULL);
12387   if (__pyx_t_4) {
12388     free(__pyx_v_dest->text);
12389     goto __pyx_L10;
12390   }
12391   __pyx_L10:;
12392
12393   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1126
12394  *         text = "\n".join(lines) + "\n"
12395  *         if dest.text != NULL: free( dest.text )
12396  *         dest.text = <char*>calloc( len(text), sizeof(char))             # <<<<<<<<<<<<<<
12397  *         dest.l_text = len(text)
12398  *         strncpy( dest.text, text, dest.l_text )
12399  */
12400   __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;}
12401   __pyx_v_dest->text = ((char *)calloc(__pyx_t_2, (sizeof(char))));
12402
12403   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1127
12404  *         if dest.text != NULL: free( dest.text )
12405  *         dest.text = <char*>calloc( len(text), sizeof(char))
12406  *         dest.l_text = len(text)             # <<<<<<<<<<<<<<
12407  *         strncpy( dest.text, text, dest.l_text )
12408  * 
12409  */
12410   __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;}
12411   __pyx_v_dest->l_text = __pyx_t_2;
12412
12413   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1128
12414  *         dest.text = <char*>calloc( len(text), sizeof(char))
12415  *         dest.l_text = len(text)
12416  *         strncpy( dest.text, text, dest.l_text )             # <<<<<<<<<<<<<<
12417  * 
12418  *         # collect targets
12419  */
12420   __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;}
12421   strncpy(__pyx_v_dest->text, __pyx_t_10, __pyx_v_dest->l_text);
12422
12423   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1131
12424  * 
12425  *         # collect targets
12426  *         if "SQ" in new_header:             # <<<<<<<<<<<<<<
12427  *             seqs = []
12428  *             for fields in new_header["SQ"]:
12429  */
12430   __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;}
12431   if (__pyx_t_4) {
12432
12433     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1132
12434  *         # collect targets
12435  *         if "SQ" in new_header:
12436  *             seqs = []             # <<<<<<<<<<<<<<
12437  *             for fields in new_header["SQ"]:
12438  *                 try:
12439  */
12440     __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;}
12441     __Pyx_GOTREF(((PyObject *)__pyx_t_5));
12442     __Pyx_DECREF(((PyObject *)__pyx_v_seqs));
12443     __pyx_v_seqs = __pyx_t_5;
12444     __pyx_t_5 = 0;
12445
12446     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1133
12447  *         if "SQ" in new_header:
12448  *             seqs = []
12449  *             for fields in new_header["SQ"]:             # <<<<<<<<<<<<<<
12450  *                 try:
12451  *                     seqs.append( (fields["SN"], fields["LN"] ) )
12452  */
12453     __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;}
12454     __Pyx_GOTREF(__pyx_t_5);
12455     if (PyList_CheckExact(__pyx_t_5) || PyTuple_CheckExact(__pyx_t_5)) {
12456       __pyx_t_2 = 0; __pyx_t_9 = __pyx_t_5; __Pyx_INCREF(__pyx_t_9);
12457     } else {
12458       __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;}
12459       __Pyx_GOTREF(__pyx_t_9);
12460     }
12461     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
12462     for (;;) {
12463       if (likely(PyList_CheckExact(__pyx_t_9))) {
12464         if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_9)) break;
12465         __pyx_t_5 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++;
12466       } else if (likely(PyTuple_CheckExact(__pyx_t_9))) {
12467         if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_9)) break;
12468         __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_2); __Pyx_INCREF(__pyx_t_5); __pyx_t_2++;
12469       } else {
12470         __pyx_t_5 = PyIter_Next(__pyx_t_9);
12471         if (!__pyx_t_5) {
12472           if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
12473           break;
12474         }
12475         __Pyx_GOTREF(__pyx_t_5);
12476       }
12477       __Pyx_DECREF(__pyx_v_fields);
12478       __pyx_v_fields = __pyx_t_5;
12479       __pyx_t_5 = 0;
12480
12481       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1134
12482  *             seqs = []
12483  *             for fields in new_header["SQ"]:
12484  *                 try:             # <<<<<<<<<<<<<<
12485  *                     seqs.append( (fields["SN"], fields["LN"] ) )
12486  *                 except KeyError:
12487  */
12488       {
12489         PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
12490         __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
12491         __Pyx_XGOTREF(__pyx_save_exc_type);
12492         __Pyx_XGOTREF(__pyx_save_exc_value);
12493         __Pyx_XGOTREF(__pyx_save_exc_tb);
12494         /*try:*/ {
12495
12496           /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1135
12497  *             for fields in new_header["SQ"]:
12498  *                 try:
12499  *                     seqs.append( (fields["SN"], fields["LN"] ) )             # <<<<<<<<<<<<<<
12500  *                 except KeyError:
12501  *                     raise KeyError( "incomplete sequence information in '%s'" % str(fields))
12502  */
12503           if (unlikely(__pyx_v_seqs == Py_None)) {
12504             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;} 
12505           }
12506           __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;}
12507           __Pyx_GOTREF(__pyx_t_5);
12508           __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;}
12509           __Pyx_GOTREF(__pyx_t_3);
12510           __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;}
12511           __Pyx_GOTREF(__pyx_t_1);
12512           PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_5);
12513           __Pyx_GIVEREF(__pyx_t_5);
12514           PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
12515           __Pyx_GIVEREF(__pyx_t_3);
12516           __pyx_t_5 = 0;
12517           __pyx_t_3 = 0;
12518           __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;}
12519           __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12520         }
12521         __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
12522         __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
12523         __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
12524         goto __pyx_L21_try_end;
12525         __pyx_L14_error:;
12526         __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
12527         __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
12528         __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
12529         __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
12530
12531         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1136
12532  *                 try:
12533  *                     seqs.append( (fields["SN"], fields["LN"] ) )
12534  *                 except KeyError:             # <<<<<<<<<<<<<<
12535  *                     raise KeyError( "incomplete sequence information in '%s'" % str(fields))
12536  * 
12537  */
12538         __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_KeyError);
12539         if (__pyx_t_7) {
12540           __Pyx_AddTraceback("csamtools.Samfile._buildHeader");
12541           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;}
12542           __Pyx_GOTREF(__pyx_t_1);
12543           __Pyx_GOTREF(__pyx_t_3);
12544           __Pyx_GOTREF(__pyx_t_5);
12545
12546           /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1137
12547  *                     seqs.append( (fields["SN"], fields["LN"] ) )
12548  *                 except KeyError:
12549  *                     raise KeyError( "incomplete sequence information in '%s'" % str(fields))             # <<<<<<<<<<<<<<
12550  * 
12551  *             dest.n_targets = len(seqs)
12552  */
12553           __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;}
12554           __Pyx_GOTREF(__pyx_t_6);
12555           __Pyx_INCREF(__pyx_v_fields);
12556           PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_fields);
12557           __Pyx_GIVEREF(__pyx_v_fields);
12558           __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;}
12559           __Pyx_GOTREF(__pyx_t_11);
12560           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
12561           __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;}
12562           __Pyx_GOTREF(((PyObject *)__pyx_t_6));
12563           __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
12564           __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;}
12565           __Pyx_GOTREF(__pyx_t_11);
12566           PyTuple_SET_ITEM(__pyx_t_11, 0, ((PyObject *)__pyx_t_6));
12567           __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
12568           __pyx_t_6 = 0;
12569           __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;}
12570           __Pyx_GOTREF(__pyx_t_6);
12571           __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
12572           __Pyx_Raise(__pyx_t_6, 0, 0);
12573           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
12574           {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1137; __pyx_clineno = __LINE__; goto __pyx_L16_except_error;}
12575           __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12576           __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
12577           __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
12578           goto __pyx_L15_exception_handled;
12579         }
12580         __pyx_L16_except_error:;
12581         __Pyx_XGIVEREF(__pyx_save_exc_type);
12582         __Pyx_XGIVEREF(__pyx_save_exc_value);
12583         __Pyx_XGIVEREF(__pyx_save_exc_tb);
12584         __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
12585         goto __pyx_L1_error;
12586         __pyx_L15_exception_handled:;
12587         __Pyx_XGIVEREF(__pyx_save_exc_type);
12588         __Pyx_XGIVEREF(__pyx_save_exc_value);
12589         __Pyx_XGIVEREF(__pyx_save_exc_tb);
12590         __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
12591         __pyx_L21_try_end:;
12592       }
12593     }
12594     __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
12595
12596     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1139
12597  *                     raise KeyError( "incomplete sequence information in '%s'" % str(fields))
12598  * 
12599  *             dest.n_targets = len(seqs)             # <<<<<<<<<<<<<<
12600  *             dest.target_name = <char**>calloc( dest.n_targets, sizeof(char*) )
12601  *             dest.target_len = <uint32_t*>calloc( dest.n_targets, sizeof(uint32_t) )
12602  */
12603     if (unlikely(__pyx_v_seqs == Py_None)) {
12604       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;} 
12605     }
12606     __pyx_t_2 = PyList_GET_SIZE(((PyObject *)__pyx_v_seqs)); 
12607     __pyx_v_dest->n_targets = __pyx_t_2;
12608
12609     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1140
12610  * 
12611  *             dest.n_targets = len(seqs)
12612  *             dest.target_name = <char**>calloc( dest.n_targets, sizeof(char*) )             # <<<<<<<<<<<<<<
12613  *             dest.target_len = <uint32_t*>calloc( dest.n_targets, sizeof(uint32_t) )
12614  * 
12615  */
12616     __pyx_v_dest->target_name = ((char **)calloc(__pyx_v_dest->n_targets, (sizeof(char *))));
12617
12618     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1141
12619  *             dest.n_targets = len(seqs)
12620  *             dest.target_name = <char**>calloc( dest.n_targets, sizeof(char*) )
12621  *             dest.target_len = <uint32_t*>calloc( dest.n_targets, sizeof(uint32_t) )             # <<<<<<<<<<<<<<
12622  * 
12623  *             for x from 0 <= x < dest.n_targets:
12624  */
12625     __pyx_v_dest->target_len = ((uint32_t *)calloc(__pyx_v_dest->n_targets, (sizeof(uint32_t))));
12626
12627     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1143
12628  *             dest.target_len = <uint32_t*>calloc( dest.n_targets, sizeof(uint32_t) )
12629  * 
12630  *             for x from 0 <= x < dest.n_targets:             # <<<<<<<<<<<<<<
12631  *                 seqname, seqlen = seqs[x]
12632  *                 dest.target_name[x] = <char*>calloc( len( seqname ) + 1, sizeof(char) )
12633  */
12634     __pyx_t_12 = __pyx_v_dest->n_targets;
12635     for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_12; __pyx_v_x++) {
12636
12637       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1144
12638  * 
12639  *             for x from 0 <= x < dest.n_targets:
12640  *                 seqname, seqlen = seqs[x]             # <<<<<<<<<<<<<<
12641  *                 dest.target_name[x] = <char*>calloc( len( seqname ) + 1, sizeof(char) )
12642  *                 strncpy( dest.target_name[x], seqname, len(seqname) + 1 )
12643  */
12644       __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;}
12645       __Pyx_GOTREF(__pyx_t_9);
12646       if (PyTuple_CheckExact(__pyx_t_9) && likely(PyTuple_GET_SIZE(__pyx_t_9) == 2)) {
12647         PyObject* tuple = __pyx_t_9;
12648         __pyx_t_5 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_5);
12649         __pyx_t_3 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_3);
12650         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
12651         __Pyx_DECREF(__pyx_v_seqname);
12652         __pyx_v_seqname = __pyx_t_5;
12653         __pyx_t_5 = 0;
12654         __Pyx_DECREF(__pyx_v_seqlen);
12655         __pyx_v_seqlen = __pyx_t_3;
12656         __pyx_t_3 = 0;
12657       } else {
12658         __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;}
12659         __Pyx_GOTREF(__pyx_t_1);
12660         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
12661         __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;}
12662         __Pyx_GOTREF(__pyx_t_5);
12663         __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;}
12664         __Pyx_GOTREF(__pyx_t_3);
12665         if (__Pyx_EndUnpack(__pyx_t_1, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
12666         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12667         __Pyx_DECREF(__pyx_v_seqname);
12668         __pyx_v_seqname = __pyx_t_5;
12669         __pyx_t_5 = 0;
12670         __Pyx_DECREF(__pyx_v_seqlen);
12671         __pyx_v_seqlen = __pyx_t_3;
12672         __pyx_t_3 = 0;
12673       }
12674
12675       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1145
12676  *             for x from 0 <= x < dest.n_targets:
12677  *                 seqname, seqlen = seqs[x]
12678  *                 dest.target_name[x] = <char*>calloc( len( seqname ) + 1, sizeof(char) )             # <<<<<<<<<<<<<<
12679  *                 strncpy( dest.target_name[x], seqname, len(seqname) + 1 )
12680  *                 dest.target_len[x] = seqlen
12681  */
12682       __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;}
12683       (__pyx_v_dest->target_name[__pyx_v_x]) = ((char *)calloc((__pyx_t_2 + 1), (sizeof(char))));
12684
12685       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1146
12686  *                 seqname, seqlen = seqs[x]
12687  *                 dest.target_name[x] = <char*>calloc( len( seqname ) + 1, sizeof(char) )
12688  *                 strncpy( dest.target_name[x], seqname, len(seqname) + 1 )             # <<<<<<<<<<<<<<
12689  *                 dest.target_len[x] = seqlen
12690  * 
12691  */
12692       __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;}
12693       __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;}
12694       strncpy((__pyx_v_dest->target_name[__pyx_v_x]), __pyx_t_10, (__pyx_t_2 + 1));
12695
12696       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1147
12697  *                 dest.target_name[x] = <char*>calloc( len( seqname ) + 1, sizeof(char) )
12698  *                 strncpy( dest.target_name[x], seqname, len(seqname) + 1 )
12699  *                 dest.target_len[x] = seqlen             # <<<<<<<<<<<<<<
12700  * 
12701  *         return dest
12702  */
12703       __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;}
12704       (__pyx_v_dest->target_len[__pyx_v_x]) = __pyx_t_13;
12705     }
12706     goto __pyx_L11;
12707   }
12708   __pyx_L11:;
12709
12710   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1149
12711  *                 dest.target_len[x] = seqlen
12712  * 
12713  *         return dest             # <<<<<<<<<<<<<<
12714  * 
12715  *     ###############################################################
12716  */
12717   __pyx_r = __pyx_v_dest;
12718   goto __pyx_L0;
12719
12720   __pyx_r = 0;
12721   goto __pyx_L0;
12722   __pyx_L1_error:;
12723   __Pyx_XDECREF(__pyx_t_1);
12724   __Pyx_XDECREF(__pyx_t_3);
12725   __Pyx_XDECREF(__pyx_t_5);
12726   __Pyx_XDECREF(__pyx_t_6);
12727   __Pyx_XDECREF(__pyx_t_9);
12728   __Pyx_XDECREF(__pyx_t_11);
12729   __Pyx_WriteUnraisable("csamtools.Samfile._buildHeader");
12730   __pyx_r = 0;
12731   __pyx_L0:;
12732   __Pyx_DECREF(__pyx_v_lines);
12733   __Pyx_DECREF(__pyx_v_record);
12734   __Pyx_DECREF(__pyx_v_ttype);
12735   __Pyx_DECREF(__pyx_v_data);
12736   __Pyx_DECREF(__pyx_v_fields);
12737   __Pyx_DECREF(__pyx_v_text);
12738   __Pyx_DECREF(__pyx_v_seqs);
12739   __Pyx_DECREF(__pyx_v_seqname);
12740   __Pyx_DECREF(__pyx_v_seqlen);
12741   __Pyx_TraceReturn(Py_None);
12742   __Pyx_RefNannyFinishContext();
12743   return __pyx_r;
12744 }
12745
12746 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1159
12747  *     ## Possible solutions: deprecate or open new file handle
12748  *     ###############################################################
12749  *     def __iter__(self):             # <<<<<<<<<<<<<<
12750  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
12751  *         return self
12752  */
12753
12754 static PyObject *__pyx_pf_9csamtools_7Samfile___iter__(PyObject *__pyx_v_self); /*proto*/
12755 static PyObject *__pyx_pf_9csamtools_7Samfile___iter__(PyObject *__pyx_v_self) {
12756   PyObject *__pyx_r = NULL;
12757   PyObject *__pyx_t_1 = NULL;
12758   PyObject *__pyx_t_2 = NULL;
12759   int __pyx_t_3;
12760   int __pyx_t_4;
12761   __Pyx_TraceDeclarations
12762   __Pyx_RefNannySetupContext("__iter__");
12763   __Pyx_TraceCall("__iter__", __pyx_f[0], 1159);
12764
12765   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1160
12766  *     ###############################################################
12767  *     def __iter__(self):
12768  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
12769  *         return self
12770  * 
12771  */
12772   __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;}
12773   __Pyx_GOTREF(__pyx_t_1);
12774   __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;}
12775   __Pyx_GOTREF(__pyx_t_2);
12776   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12777   __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;}
12778   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12779   __pyx_t_4 = (!__pyx_t_3);
12780   if (__pyx_t_4) {
12781     __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;}
12782     __Pyx_GOTREF(__pyx_t_2);
12783     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
12784     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
12785     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
12786     __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;}
12787     __Pyx_GOTREF(__pyx_t_1);
12788     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
12789     __Pyx_Raise(__pyx_t_1, 0, 0);
12790     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
12791     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
12792     goto __pyx_L5;
12793   }
12794   __pyx_L5:;
12795
12796   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1161
12797  *     def __iter__(self):
12798  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
12799  *         return self             # <<<<<<<<<<<<<<
12800  * 
12801  *     cdef bam1_t * getCurrent( self ):
12802  */
12803   __Pyx_XDECREF(__pyx_r);
12804   __Pyx_INCREF(__pyx_v_self);
12805   __pyx_r = __pyx_v_self;
12806   goto __pyx_L0;
12807
12808   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
12809   goto __pyx_L0;
12810   __pyx_L1_error:;
12811   __Pyx_XDECREF(__pyx_t_1);
12812   __Pyx_XDECREF(__pyx_t_2);
12813   __Pyx_AddTraceback("csamtools.Samfile.__iter__");
12814   __pyx_r = NULL;
12815   __pyx_L0:;
12816   __Pyx_XGIVEREF(__pyx_r);
12817   __Pyx_TraceReturn(__pyx_r);
12818   __Pyx_RefNannyFinishContext();
12819   return __pyx_r;
12820 }
12821
12822 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1163
12823  *         return self
12824  * 
12825  *     cdef bam1_t * getCurrent( self ):             # <<<<<<<<<<<<<<
12826  *         return self.b
12827  * 
12828  */
12829
12830 static  bam1_t *__pyx_f_9csamtools_7Samfile_getCurrent(struct __pyx_obj_9csamtools_Samfile *__pyx_v_self) {
12831   bam1_t *__pyx_r;
12832   __Pyx_TraceDeclarations
12833   __Pyx_RefNannySetupContext("getCurrent");
12834   __Pyx_TraceCall("getCurrent", __pyx_f[0], 1163);
12835
12836   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1164
12837  * 
12838  *     cdef bam1_t * getCurrent( self ):
12839  *         return self.b             # <<<<<<<<<<<<<<
12840  * 
12841  *     cdef int cnext(self):
12842  */
12843   __pyx_r = __pyx_v_self->b;
12844   goto __pyx_L0;
12845
12846   __pyx_r = 0;
12847   __pyx_L0:;
12848   __Pyx_TraceReturn(Py_None);
12849   __Pyx_RefNannyFinishContext();
12850   return __pyx_r;
12851 }
12852
12853 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1166
12854  *         return self.b
12855  * 
12856  *     cdef int cnext(self):             # <<<<<<<<<<<<<<
12857  *         '''
12858  *         cversion of iterator. Used by :class:`pysam.Samfile.IteratorColumn`.
12859  */
12860
12861 static  int __pyx_f_9csamtools_7Samfile_cnext(struct __pyx_obj_9csamtools_Samfile *__pyx_v_self) {
12862   int __pyx_r;
12863   __Pyx_TraceDeclarations
12864   __Pyx_RefNannySetupContext("cnext");
12865   __Pyx_TraceCall("cnext", __pyx_f[0], 1166);
12866
12867   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1171
12868  *         '''
12869  *         cdef int ret
12870  *         return samread(self.samfile, self.b)             # <<<<<<<<<<<<<<
12871  * 
12872  *     def __next__(self):
12873  */
12874   __pyx_r = samread(__pyx_v_self->samfile, __pyx_v_self->b);
12875   goto __pyx_L0;
12876
12877   __pyx_r = 0;
12878   __pyx_L0:;
12879   __Pyx_TraceReturn(Py_None);
12880   __Pyx_RefNannyFinishContext();
12881   return __pyx_r;
12882 }
12883
12884 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1173
12885  *         return samread(self.samfile, self.b)
12886  * 
12887  *     def __next__(self):             # <<<<<<<<<<<<<<
12888  *         """
12889  *         python version of next().
12890  */
12891
12892 static PyObject *__pyx_pf_9csamtools_7Samfile___next__(PyObject *__pyx_v_self); /*proto*/
12893 static char __pyx_doc_9csamtools_7Samfile___next__[] = "\n        python version of next().\n        ";
12894 struct wrapperbase __pyx_wrapperbase_9csamtools_7Samfile___next__;
12895 static PyObject *__pyx_pf_9csamtools_7Samfile___next__(PyObject *__pyx_v_self) {
12896   int __pyx_v_ret;
12897   PyObject *__pyx_r = NULL;
12898   int __pyx_t_1;
12899   PyObject *__pyx_t_2 = NULL;
12900   __Pyx_TraceDeclarations
12901   __Pyx_RefNannySetupContext("__next__");
12902   __Pyx_TraceCall("__next__", __pyx_f[0], 1173);
12903
12904   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1178
12905  *         """
12906  *         cdef int ret
12907  *         ret = samread(self.samfile, self.b)             # <<<<<<<<<<<<<<
12908  *         if (ret > 0):
12909  *             return makeAlignedRead( self.b )
12910  */
12911   __pyx_v_ret = samread(((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->samfile, ((struct __pyx_obj_9csamtools_Samfile *)__pyx_v_self)->b);
12912
12913   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1179
12914  *         cdef int ret
12915  *         ret = samread(self.samfile, self.b)
12916  *         if (ret > 0):             # <<<<<<<<<<<<<<
12917  *             return makeAlignedRead( self.b )
12918  *         else:
12919  */
12920   __pyx_t_1 = (__pyx_v_ret > 0);
12921   if (__pyx_t_1) {
12922
12923     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1180
12924  *         ret = samread(self.samfile, self.b)
12925  *         if (ret > 0):
12926  *             return makeAlignedRead( self.b )             # <<<<<<<<<<<<<<
12927  *         else:
12928  *             raise StopIteration
12929  */
12930     __Pyx_XDECREF(__pyx_r);
12931     __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;}
12932     __Pyx_GOTREF(__pyx_t_2);
12933     __pyx_r = __pyx_t_2;
12934     __pyx_t_2 = 0;
12935     goto __pyx_L0;
12936     goto __pyx_L5;
12937   }
12938   /*else*/ {
12939
12940     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1182
12941  *             return makeAlignedRead( self.b )
12942  *         else:
12943  *             raise StopIteration             # <<<<<<<<<<<<<<
12944  * 
12945  * ##-------------------------------------------------------------------
12946  */
12947     __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
12948     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
12949   }
12950   __pyx_L5:;
12951
12952   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
12953   goto __pyx_L0;
12954   __pyx_L1_error:;
12955   __Pyx_XDECREF(__pyx_t_2);
12956   __Pyx_AddTraceback("csamtools.Samfile.__next__");
12957   __pyx_r = NULL;
12958   __pyx_L0:;
12959   __Pyx_XGIVEREF(__pyx_r);
12960   __Pyx_TraceReturn(__pyx_r);
12961   __Pyx_RefNannyFinishContext();
12962   return __pyx_r;
12963 }
12964
12965 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1234
12966  *     cdef int owns_samfile
12967  * 
12968  *     def __cinit__(self, Samfile samfile, int tid, int beg, int end, int reopen = True ):             # <<<<<<<<<<<<<<
12969  * 
12970  *         if not samfile._isOpen():
12971  */
12972
12973 static int __pyx_pf_9csamtools_17IteratorRowRegion___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
12974 static int __pyx_pf_9csamtools_17IteratorRowRegion___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
12975   struct __pyx_obj_9csamtools_Samfile *__pyx_v_samfile = 0;
12976   int __pyx_v_tid;
12977   int __pyx_v_beg;
12978   int __pyx_v_end;
12979   int __pyx_v_reopen;
12980   PyObject *__pyx_v_mode;
12981   PyObject *__pyx_v_store;
12982   int __pyx_r;
12983   PyObject *__pyx_t_1 = NULL;
12984   PyObject *__pyx_t_2 = NULL;
12985   int __pyx_t_3;
12986   int __pyx_t_4;
12987   char *__pyx_t_5;
12988   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};
12989   __Pyx_TraceDeclarations
12990   __Pyx_RefNannySetupContext("__cinit__");
12991   __Pyx_TraceCall("__cinit__", __pyx_f[0], 1234);
12992   if (unlikely(__pyx_kwds)) {
12993     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
12994     PyObject* values[5] = {0,0,0,0,0};
12995     switch (PyTuple_GET_SIZE(__pyx_args)) {
12996       case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
12997       case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
12998       case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
12999       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
13000       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
13001       case  0: break;
13002       default: goto __pyx_L5_argtuple_error;
13003     }
13004     switch (PyTuple_GET_SIZE(__pyx_args)) {
13005       case  0:
13006       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__samfile);
13007       if (likely(values[0])) kw_args--;
13008       else goto __pyx_L5_argtuple_error;
13009       case  1:
13010       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__tid);
13011       if (likely(values[1])) kw_args--;
13012       else {
13013         __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 4, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
13014       }
13015       case  2:
13016       values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__beg);
13017       if (likely(values[2])) kw_args--;
13018       else {
13019         __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 4, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
13020       }
13021       case  3:
13022       values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end);
13023       if (likely(values[3])) kw_args--;
13024       else {
13025         __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 4, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1234; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
13026       }
13027       case  4:
13028       if (kw_args > 0) {
13029         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reopen);
13030         if (value) { values[4] = value; kw_args--; }
13031       }
13032     }
13033     if (unlikely(kw_args > 0)) {
13034       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;}
13035     }
13036     __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)values[0]);
13037     __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;}
13038     __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;}
13039     __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;}
13040     if (values[4]) {
13041       __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;}
13042     } else {
13043       __pyx_v_reopen = ((int)1);
13044     }
13045   } else {
13046     __pyx_v_reopen = ((int)1);
13047     switch (PyTuple_GET_SIZE(__pyx_args)) {
13048       case  5:
13049       __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;}
13050       case  4:
13051       __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;}
13052       __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;}
13053       __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;}
13054       __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)PyTuple_GET_ITEM(__pyx_args, 0));
13055       break;
13056       default: goto __pyx_L5_argtuple_error;
13057     }
13058   }
13059   goto __pyx_L4_argument_unpacking_done;
13060   __pyx_L5_argtuple_error:;
13061   __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;}
13062   __pyx_L3_error:;
13063   __Pyx_AddTraceback("csamtools.IteratorRowRegion.__cinit__");
13064   __Pyx_RefNannyFinishContext();
13065   return -1;
13066   __pyx_L4_argument_unpacking_done:;
13067   __pyx_v_mode = Py_None; __Pyx_INCREF(Py_None);
13068   __pyx_v_store = Py_None; __Pyx_INCREF(Py_None);
13069   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;}
13070
13071   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1236
13072  *     def __cinit__(self, Samfile samfile, int tid, int beg, int end, int reopen = True ):
13073  * 
13074  *         if not samfile._isOpen():             # <<<<<<<<<<<<<<
13075  *             raise ValueError( "I/O operation on closed file" )
13076  * 
13077  */
13078   __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;}
13079   __Pyx_GOTREF(__pyx_t_1);
13080   __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;}
13081   __Pyx_GOTREF(__pyx_t_2);
13082   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
13083   __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;}
13084   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13085   __pyx_t_4 = (!__pyx_t_3);
13086   if (__pyx_t_4) {
13087
13088     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1237
13089  * 
13090  *         if not samfile._isOpen():
13091  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
13092  * 
13093  *         if not samfile._hasIndex():
13094  */
13095     __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;}
13096     __Pyx_GOTREF(__pyx_t_2);
13097     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
13098     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
13099     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
13100     __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;}
13101     __Pyx_GOTREF(__pyx_t_1);
13102     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13103     __Pyx_Raise(__pyx_t_1, 0, 0);
13104     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
13105     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
13106     goto __pyx_L6;
13107   }
13108   __pyx_L6:;
13109
13110   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1239
13111  *             raise ValueError( "I/O operation on closed file" )
13112  * 
13113  *         if not samfile._hasIndex():             # <<<<<<<<<<<<<<
13114  *             raise ValueError( "no index available for iteration" )
13115  * 
13116  */
13117   __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;}
13118   __Pyx_GOTREF(__pyx_t_1);
13119   __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;}
13120   __Pyx_GOTREF(__pyx_t_2);
13121   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
13122   __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;}
13123   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13124   __pyx_t_3 = (!__pyx_t_4);
13125   if (__pyx_t_3) {
13126
13127     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1240
13128  * 
13129  *         if not samfile._hasIndex():
13130  *             raise ValueError( "no index available for iteration" )             # <<<<<<<<<<<<<<
13131  * 
13132  *         # makes sure that samfile stays alive as long as the
13133  */
13134     __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;}
13135     __Pyx_GOTREF(__pyx_t_2);
13136     __Pyx_INCREF(((PyObject *)__pyx_kp_s_54));
13137     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_54));
13138     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_54));
13139     __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;}
13140     __Pyx_GOTREF(__pyx_t_1);
13141     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13142     __Pyx_Raise(__pyx_t_1, 0, 0);
13143     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
13144     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
13145     goto __pyx_L7;
13146   }
13147   __pyx_L7:;
13148
13149   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1244
13150  *         # makes sure that samfile stays alive as long as the
13151  *         # iterator is alive
13152  *         self.samfile = samfile             # <<<<<<<<<<<<<<
13153  * 
13154  *         if samfile.isbam: mode = "rb"
13155  */
13156   __Pyx_INCREF(((PyObject *)__pyx_v_samfile));
13157   __Pyx_GIVEREF(((PyObject *)__pyx_v_samfile));
13158   __Pyx_GOTREF(((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->samfile);
13159   __Pyx_DECREF(((PyObject *)((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->samfile));
13160   ((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->samfile = __pyx_v_samfile;
13161
13162   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1246
13163  *         self.samfile = samfile
13164  * 
13165  *         if samfile.isbam: mode = "rb"             # <<<<<<<<<<<<<<
13166  *         else: mode = "r"
13167  * 
13168  */
13169   if (__pyx_v_samfile->isbam) {
13170     __Pyx_INCREF(((PyObject *)__pyx_n_s__rb));
13171     __Pyx_DECREF(__pyx_v_mode);
13172     __pyx_v_mode = ((PyObject *)__pyx_n_s__rb);
13173     goto __pyx_L8;
13174   }
13175   /*else*/ {
13176
13177     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1247
13178  * 
13179  *         if samfile.isbam: mode = "rb"
13180  *         else: mode = "r"             # <<<<<<<<<<<<<<
13181  * 
13182  *         # reopen the file - note that this makes the iterator
13183  */
13184     __Pyx_INCREF(((PyObject *)__pyx_n_s__r));
13185     __Pyx_DECREF(__pyx_v_mode);
13186     __pyx_v_mode = ((PyObject *)__pyx_n_s__r);
13187   }
13188   __pyx_L8:;
13189
13190   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1251
13191  *         # reopen the file - note that this makes the iterator
13192  *         # slow and causes pileup to slow down significantly.
13193  *         if reopen:             # <<<<<<<<<<<<<<
13194  *             store = StderrStore()
13195  *             self.fp = samopen( samfile._filename, mode, NULL )
13196  */
13197   if (__pyx_v_reopen) {
13198
13199     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1252
13200  *         # slow and causes pileup to slow down significantly.
13201  *         if reopen:
13202  *             store = StderrStore()             # <<<<<<<<<<<<<<
13203  *             self.fp = samopen( samfile._filename, mode, NULL )
13204  *             store.release()
13205  */
13206     __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;}
13207     __Pyx_GOTREF(__pyx_t_1);
13208     __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;}
13209     __Pyx_GOTREF(__pyx_t_2);
13210     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
13211     __Pyx_DECREF(__pyx_v_store);
13212     __pyx_v_store = __pyx_t_2;
13213     __pyx_t_2 = 0;
13214
13215     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1253
13216  *         if reopen:
13217  *             store = StderrStore()
13218  *             self.fp = samopen( samfile._filename, mode, NULL )             # <<<<<<<<<<<<<<
13219  *             store.release()
13220  *             assert self.fp != NULL
13221  */
13222     __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;}
13223     ((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->fp = samopen(__pyx_v_samfile->_filename, __pyx_t_5, NULL);
13224
13225     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1254
13226  *             store = StderrStore()
13227  *             self.fp = samopen( samfile._filename, mode, NULL )
13228  *             store.release()             # <<<<<<<<<<<<<<
13229  *             assert self.fp != NULL
13230  *             self.owns_samfile = True
13231  */
13232     __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;}
13233     __Pyx_GOTREF(__pyx_t_2);
13234     __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;}
13235     __Pyx_GOTREF(__pyx_t_1);
13236     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13237     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
13238
13239     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1255
13240  *             self.fp = samopen( samfile._filename, mode, NULL )
13241  *             store.release()
13242  *             assert self.fp != NULL             # <<<<<<<<<<<<<<
13243  *             self.owns_samfile = True
13244  *         else:
13245  */
13246     #ifndef PYREX_WITHOUT_ASSERTIONS
13247     if (unlikely(!(((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->fp != NULL))) {
13248       PyErr_SetNone(PyExc_AssertionError);
13249       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
13250     }
13251     #endif
13252
13253     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1256
13254  *             store.release()
13255  *             assert self.fp != NULL
13256  *             self.owns_samfile = True             # <<<<<<<<<<<<<<
13257  *         else:
13258  *             self.fp = self.samfile.samfile
13259  */
13260     ((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->owns_samfile = 1;
13261     goto __pyx_L9;
13262   }
13263   /*else*/ {
13264
13265     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1258
13266  *             self.owns_samfile = True
13267  *         else:
13268  *             self.fp = self.samfile.samfile             # <<<<<<<<<<<<<<
13269  *             self.owns_samfile = False
13270  * 
13271  */
13272     ((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->fp = ((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->samfile->samfile;
13273
13274     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1259
13275  *         else:
13276  *             self.fp = self.samfile.samfile
13277  *             self.owns_samfile = False             # <<<<<<<<<<<<<<
13278  * 
13279  *         self.retval = 0
13280  */
13281     ((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->owns_samfile = 0;
13282   }
13283   __pyx_L9:;
13284
13285   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1261
13286  *             self.owns_samfile = False
13287  * 
13288  *         self.retval = 0             # <<<<<<<<<<<<<<
13289  * 
13290  *         self.iter = bam_iter_query(self.samfile.index,
13291  */
13292   ((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->retval = 0;
13293
13294   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1263
13295  *         self.retval = 0
13296  * 
13297  *         self.iter = bam_iter_query(self.samfile.index,             # <<<<<<<<<<<<<<
13298  *                                    tid,
13299  *                                    beg,
13300  */
13301   ((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);
13302
13303   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1267
13304  *                                    beg,
13305  *                                    end)
13306  *         self.b = bam_init1()             # <<<<<<<<<<<<<<
13307  * 
13308  *     def __iter__(self):
13309  */
13310   ((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->b = bam_init1();
13311
13312   __pyx_r = 0;
13313   goto __pyx_L0;
13314   __pyx_L1_error:;
13315   __Pyx_XDECREF(__pyx_t_1);
13316   __Pyx_XDECREF(__pyx_t_2);
13317   __Pyx_AddTraceback("csamtools.IteratorRowRegion.__cinit__");
13318   __pyx_r = -1;
13319   __pyx_L0:;
13320   __Pyx_DECREF(__pyx_v_mode);
13321   __Pyx_DECREF(__pyx_v_store);
13322   __Pyx_TraceReturn(Py_None);
13323   __Pyx_RefNannyFinishContext();
13324   return __pyx_r;
13325 }
13326
13327 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1269
13328  *         self.b = bam_init1()
13329  * 
13330  *     def __iter__(self):             # <<<<<<<<<<<<<<
13331  *         return self
13332  * 
13333  */
13334
13335 static PyObject *__pyx_pf_9csamtools_17IteratorRowRegion___iter__(PyObject *__pyx_v_self); /*proto*/
13336 static PyObject *__pyx_pf_9csamtools_17IteratorRowRegion___iter__(PyObject *__pyx_v_self) {
13337   PyObject *__pyx_r = NULL;
13338   __Pyx_TraceDeclarations
13339   __Pyx_RefNannySetupContext("__iter__");
13340   __Pyx_TraceCall("__iter__", __pyx_f[0], 1269);
13341
13342   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1270
13343  * 
13344  *     def __iter__(self):
13345  *         return self             # <<<<<<<<<<<<<<
13346  * 
13347  *     cdef bam1_t * getCurrent( self ):
13348  */
13349   __Pyx_XDECREF(__pyx_r);
13350   __Pyx_INCREF(__pyx_v_self);
13351   __pyx_r = __pyx_v_self;
13352   goto __pyx_L0;
13353
13354   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
13355   __pyx_L0:;
13356   __Pyx_XGIVEREF(__pyx_r);
13357   __Pyx_TraceReturn(__pyx_r);
13358   __Pyx_RefNannyFinishContext();
13359   return __pyx_r;
13360 }
13361
13362 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1272
13363  *         return self
13364  * 
13365  *     cdef bam1_t * getCurrent( self ):             # <<<<<<<<<<<<<<
13366  *         return self.b
13367  * 
13368  */
13369
13370 static  bam1_t *__pyx_f_9csamtools_17IteratorRowRegion_getCurrent(struct __pyx_obj_9csamtools_IteratorRowRegion *__pyx_v_self) {
13371   bam1_t *__pyx_r;
13372   __Pyx_TraceDeclarations
13373   __Pyx_RefNannySetupContext("getCurrent");
13374   __Pyx_TraceCall("getCurrent", __pyx_f[0], 1272);
13375
13376   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1273
13377  * 
13378  *     cdef bam1_t * getCurrent( self ):
13379  *         return self.b             # <<<<<<<<<<<<<<
13380  * 
13381  *     cdef int cnext(self):
13382  */
13383   __pyx_r = __pyx_v_self->b;
13384   goto __pyx_L0;
13385
13386   __pyx_r = 0;
13387   __pyx_L0:;
13388   __Pyx_TraceReturn(Py_None);
13389   __Pyx_RefNannyFinishContext();
13390   return __pyx_r;
13391 }
13392
13393 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1275
13394  *         return self.b
13395  * 
13396  *     cdef int cnext(self):             # <<<<<<<<<<<<<<
13397  *         '''cversion of iterator. Used by IteratorColumn'''
13398  *         self.retval = bam_iter_read( self.fp.x.bam,
13399  */
13400
13401 static  int __pyx_f_9csamtools_17IteratorRowRegion_cnext(struct __pyx_obj_9csamtools_IteratorRowRegion *__pyx_v_self) {
13402   int __pyx_r;
13403   __Pyx_TraceDeclarations
13404   __Pyx_RefNannySetupContext("cnext");
13405   __Pyx_TraceCall("cnext", __pyx_f[0], 1275);
13406
13407   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1277
13408  *     cdef int cnext(self):
13409  *         '''cversion of iterator. Used by IteratorColumn'''
13410  *         self.retval = bam_iter_read( self.fp.x.bam,             # <<<<<<<<<<<<<<
13411  *                                      self.iter,
13412  *                                      self.b)
13413  */
13414   __pyx_v_self->retval = bam_iter_read(__pyx_v_self->fp->x.bam, __pyx_v_self->iter, __pyx_v_self->b);
13415
13416   __pyx_r = 0;
13417   __Pyx_TraceReturn(Py_None);
13418   __Pyx_RefNannyFinishContext();
13419   return __pyx_r;
13420 }
13421
13422 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1281
13423  *                                      self.b)
13424  * 
13425  *     def __next__(self):             # <<<<<<<<<<<<<<
13426  *         """python version of next().
13427  *         """
13428  */
13429
13430 static PyObject *__pyx_pf_9csamtools_17IteratorRowRegion___next__(PyObject *__pyx_v_self); /*proto*/
13431 static char __pyx_doc_9csamtools_17IteratorRowRegion___next__[] = "python version of next().\n        ";
13432 struct wrapperbase __pyx_wrapperbase_9csamtools_17IteratorRowRegion___next__;
13433 static PyObject *__pyx_pf_9csamtools_17IteratorRowRegion___next__(PyObject *__pyx_v_self) {
13434   PyObject *__pyx_r = NULL;
13435   int __pyx_t_1;
13436   PyObject *__pyx_t_2 = NULL;
13437   __Pyx_TraceDeclarations
13438   __Pyx_RefNannySetupContext("__next__");
13439   __Pyx_TraceCall("__next__", __pyx_f[0], 1281);
13440
13441   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1284
13442  *         """python version of next().
13443  *         """
13444  *         self.cnext()             # <<<<<<<<<<<<<<
13445  *         if self.retval < 0: raise StopIteration
13446  *         return makeAlignedRead( self.b )
13447  */
13448   ((struct __pyx_vtabstruct_9csamtools_IteratorRowRegion *)((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->__pyx_vtab)->cnext(((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self));
13449
13450   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1285
13451  *         """
13452  *         self.cnext()
13453  *         if self.retval < 0: raise StopIteration             # <<<<<<<<<<<<<<
13454  *         return makeAlignedRead( self.b )
13455  * 
13456  */
13457   __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->retval < 0);
13458   if (__pyx_t_1) {
13459     __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
13460     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
13461     goto __pyx_L5;
13462   }
13463   __pyx_L5:;
13464
13465   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1286
13466  *         self.cnext()
13467  *         if self.retval < 0: raise StopIteration
13468  *         return makeAlignedRead( self.b )             # <<<<<<<<<<<<<<
13469  * 
13470  *     def __dealloc__(self):
13471  */
13472   __Pyx_XDECREF(__pyx_r);
13473   __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;}
13474   __Pyx_GOTREF(__pyx_t_2);
13475   __pyx_r = __pyx_t_2;
13476   __pyx_t_2 = 0;
13477   goto __pyx_L0;
13478
13479   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
13480   goto __pyx_L0;
13481   __pyx_L1_error:;
13482   __Pyx_XDECREF(__pyx_t_2);
13483   __Pyx_AddTraceback("csamtools.IteratorRowRegion.__next__");
13484   __pyx_r = NULL;
13485   __pyx_L0:;
13486   __Pyx_XGIVEREF(__pyx_r);
13487   __Pyx_TraceReturn(__pyx_r);
13488   __Pyx_RefNannyFinishContext();
13489   return __pyx_r;
13490 }
13491
13492 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1288
13493  *         return makeAlignedRead( self.b )
13494  * 
13495  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
13496  *         bam_destroy1(self.b)
13497  *         if self.owns_samfile: samclose( self.fp )
13498  */
13499
13500 static void __pyx_pf_9csamtools_17IteratorRowRegion___dealloc__(PyObject *__pyx_v_self); /*proto*/
13501 static void __pyx_pf_9csamtools_17IteratorRowRegion___dealloc__(PyObject *__pyx_v_self) {
13502   __Pyx_TraceDeclarations
13503   __Pyx_RefNannySetupContext("__dealloc__");
13504   __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1288);
13505
13506   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1289
13507  * 
13508  *     def __dealloc__(self):
13509  *         bam_destroy1(self.b)             # <<<<<<<<<<<<<<
13510  *         if self.owns_samfile: samclose( self.fp )
13511  * 
13512  */
13513   bam_destroy1(((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->b);
13514
13515   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1290
13516  *     def __dealloc__(self):
13517  *         bam_destroy1(self.b)
13518  *         if self.owns_samfile: samclose( self.fp )             # <<<<<<<<<<<<<<
13519  * 
13520  * cdef class IteratorRowAll(IteratorRow):
13521  */
13522   if (((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->owns_samfile) {
13523     samclose(((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_v_self)->fp);
13524     goto __pyx_L5;
13525   }
13526   __pyx_L5:;
13527
13528   __Pyx_TraceReturn(Py_None);
13529   __Pyx_RefNannyFinishContext();
13530 }
13531
13532 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1307
13533  *     cdef int owns_samfile
13534  * 
13535  *     def __cinit__(self, Samfile samfile, int reopen = True ):             # <<<<<<<<<<<<<<
13536  * 
13537  *         if not samfile._isOpen():
13538  */
13539
13540 static int __pyx_pf_9csamtools_14IteratorRowAll___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
13541 static int __pyx_pf_9csamtools_14IteratorRowAll___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
13542   struct __pyx_obj_9csamtools_Samfile *__pyx_v_samfile = 0;
13543   int __pyx_v_reopen;
13544   PyObject *__pyx_v_mode;
13545   PyObject *__pyx_v_store;
13546   int __pyx_r;
13547   PyObject *__pyx_t_1 = NULL;
13548   PyObject *__pyx_t_2 = NULL;
13549   int __pyx_t_3;
13550   int __pyx_t_4;
13551   char *__pyx_t_5;
13552   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__samfile,&__pyx_n_s__reopen,0};
13553   __Pyx_TraceDeclarations
13554   __Pyx_RefNannySetupContext("__cinit__");
13555   __Pyx_TraceCall("__cinit__", __pyx_f[0], 1307);
13556   if (unlikely(__pyx_kwds)) {
13557     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
13558     PyObject* values[2] = {0,0};
13559     switch (PyTuple_GET_SIZE(__pyx_args)) {
13560       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
13561       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
13562       case  0: break;
13563       default: goto __pyx_L5_argtuple_error;
13564     }
13565     switch (PyTuple_GET_SIZE(__pyx_args)) {
13566       case  0:
13567       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__samfile);
13568       if (likely(values[0])) kw_args--;
13569       else goto __pyx_L5_argtuple_error;
13570       case  1:
13571       if (kw_args > 0) {
13572         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reopen);
13573         if (value) { values[1] = value; kw_args--; }
13574       }
13575     }
13576     if (unlikely(kw_args > 0)) {
13577       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;}
13578     }
13579     __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)values[0]);
13580     if (values[1]) {
13581       __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;}
13582     } else {
13583       __pyx_v_reopen = ((int)1);
13584     }
13585   } else {
13586     __pyx_v_reopen = ((int)1);
13587     switch (PyTuple_GET_SIZE(__pyx_args)) {
13588       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;}
13589       case  1: __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)PyTuple_GET_ITEM(__pyx_args, 0));
13590       break;
13591       default: goto __pyx_L5_argtuple_error;
13592     }
13593   }
13594   goto __pyx_L4_argument_unpacking_done;
13595   __pyx_L5_argtuple_error:;
13596   __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;}
13597   __pyx_L3_error:;
13598   __Pyx_AddTraceback("csamtools.IteratorRowAll.__cinit__");
13599   __Pyx_RefNannyFinishContext();
13600   return -1;
13601   __pyx_L4_argument_unpacking_done:;
13602   __pyx_v_mode = Py_None; __Pyx_INCREF(Py_None);
13603   __pyx_v_store = Py_None; __Pyx_INCREF(Py_None);
13604   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;}
13605
13606   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1309
13607  *     def __cinit__(self, Samfile samfile, int reopen = True ):
13608  * 
13609  *         if not samfile._isOpen():             # <<<<<<<<<<<<<<
13610  *             raise ValueError( "I/O operation on closed file" )
13611  * 
13612  */
13613   __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;}
13614   __Pyx_GOTREF(__pyx_t_1);
13615   __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;}
13616   __Pyx_GOTREF(__pyx_t_2);
13617   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
13618   __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;}
13619   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13620   __pyx_t_4 = (!__pyx_t_3);
13621   if (__pyx_t_4) {
13622
13623     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1310
13624  * 
13625  *         if not samfile._isOpen():
13626  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
13627  * 
13628  *         if samfile.isbam: mode = "rb"
13629  */
13630     __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;}
13631     __Pyx_GOTREF(__pyx_t_2);
13632     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
13633     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
13634     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
13635     __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;}
13636     __Pyx_GOTREF(__pyx_t_1);
13637     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13638     __Pyx_Raise(__pyx_t_1, 0, 0);
13639     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
13640     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
13641     goto __pyx_L6;
13642   }
13643   __pyx_L6:;
13644
13645   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1312
13646  *             raise ValueError( "I/O operation on closed file" )
13647  * 
13648  *         if samfile.isbam: mode = "rb"             # <<<<<<<<<<<<<<
13649  *         else: mode = "r"
13650  * 
13651  */
13652   if (__pyx_v_samfile->isbam) {
13653     __Pyx_INCREF(((PyObject *)__pyx_n_s__rb));
13654     __Pyx_DECREF(__pyx_v_mode);
13655     __pyx_v_mode = ((PyObject *)__pyx_n_s__rb);
13656     goto __pyx_L7;
13657   }
13658   /*else*/ {
13659
13660     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1313
13661  * 
13662  *         if samfile.isbam: mode = "rb"
13663  *         else: mode = "r"             # <<<<<<<<<<<<<<
13664  * 
13665  *         # reopen the file to avoid iterator conflict
13666  */
13667     __Pyx_INCREF(((PyObject *)__pyx_n_s__r));
13668     __Pyx_DECREF(__pyx_v_mode);
13669     __pyx_v_mode = ((PyObject *)__pyx_n_s__r);
13670   }
13671   __pyx_L7:;
13672
13673   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1316
13674  * 
13675  *         # reopen the file to avoid iterator conflict
13676  *         if reopen:             # <<<<<<<<<<<<<<
13677  *             store = StderrStore()
13678  *             self.fp = samopen( samfile._filename, mode, NULL )
13679  */
13680   if (__pyx_v_reopen) {
13681
13682     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1317
13683  *         # reopen the file to avoid iterator conflict
13684  *         if reopen:
13685  *             store = StderrStore()             # <<<<<<<<<<<<<<
13686  *             self.fp = samopen( samfile._filename, mode, NULL )
13687  *             store.release()
13688  */
13689     __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;}
13690     __Pyx_GOTREF(__pyx_t_1);
13691     __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;}
13692     __Pyx_GOTREF(__pyx_t_2);
13693     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
13694     __Pyx_DECREF(__pyx_v_store);
13695     __pyx_v_store = __pyx_t_2;
13696     __pyx_t_2 = 0;
13697
13698     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1318
13699  *         if reopen:
13700  *             store = StderrStore()
13701  *             self.fp = samopen( samfile._filename, mode, NULL )             # <<<<<<<<<<<<<<
13702  *             store.release()
13703  *             assert self.fp != NULL
13704  */
13705     __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;}
13706     ((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->fp = samopen(__pyx_v_samfile->_filename, __pyx_t_5, NULL);
13707
13708     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1319
13709  *             store = StderrStore()
13710  *             self.fp = samopen( samfile._filename, mode, NULL )
13711  *             store.release()             # <<<<<<<<<<<<<<
13712  *             assert self.fp != NULL
13713  *             self.owns_samfile = True
13714  */
13715     __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;}
13716     __Pyx_GOTREF(__pyx_t_2);
13717     __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;}
13718     __Pyx_GOTREF(__pyx_t_1);
13719     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
13720     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
13721
13722     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1320
13723  *             self.fp = samopen( samfile._filename, mode, NULL )
13724  *             store.release()
13725  *             assert self.fp != NULL             # <<<<<<<<<<<<<<
13726  *             self.owns_samfile = True
13727  *         else:
13728  */
13729     #ifndef PYREX_WITHOUT_ASSERTIONS
13730     if (unlikely(!(((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->fp != NULL))) {
13731       PyErr_SetNone(PyExc_AssertionError);
13732       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
13733     }
13734     #endif
13735
13736     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1321
13737  *             store.release()
13738  *             assert self.fp != NULL
13739  *             self.owns_samfile = True             # <<<<<<<<<<<<<<
13740  *         else:
13741  *             self.fp = samfile.samfile
13742  */
13743     ((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->owns_samfile = 1;
13744     goto __pyx_L8;
13745   }
13746   /*else*/ {
13747
13748     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1323
13749  *             self.owns_samfile = True
13750  *         else:
13751  *             self.fp = samfile.samfile             # <<<<<<<<<<<<<<
13752  *             self.owns_samfile = False
13753  * 
13754  */
13755     ((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->fp = __pyx_v_samfile->samfile;
13756
13757     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1324
13758  *         else:
13759  *             self.fp = samfile.samfile
13760  *             self.owns_samfile = False             # <<<<<<<<<<<<<<
13761  * 
13762  *         # allocate memory for alignment
13763  */
13764     ((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->owns_samfile = 0;
13765   }
13766   __pyx_L8:;
13767
13768   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1327
13769  * 
13770  *         # allocate memory for alignment
13771  *         self.b = <bam1_t*>calloc(1, sizeof(bam1_t))             # <<<<<<<<<<<<<<
13772  * 
13773  *     def __iter__(self):
13774  */
13775   ((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->b = ((bam1_t *)calloc(1, (sizeof(bam1_t))));
13776
13777   __pyx_r = 0;
13778   goto __pyx_L0;
13779   __pyx_L1_error:;
13780   __Pyx_XDECREF(__pyx_t_1);
13781   __Pyx_XDECREF(__pyx_t_2);
13782   __Pyx_AddTraceback("csamtools.IteratorRowAll.__cinit__");
13783   __pyx_r = -1;
13784   __pyx_L0:;
13785   __Pyx_DECREF(__pyx_v_mode);
13786   __Pyx_DECREF(__pyx_v_store);
13787   __Pyx_TraceReturn(Py_None);
13788   __Pyx_RefNannyFinishContext();
13789   return __pyx_r;
13790 }
13791
13792 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1329
13793  *         self.b = <bam1_t*>calloc(1, sizeof(bam1_t))
13794  * 
13795  *     def __iter__(self):             # <<<<<<<<<<<<<<
13796  *         return self
13797  * 
13798  */
13799
13800 static PyObject *__pyx_pf_9csamtools_14IteratorRowAll___iter__(PyObject *__pyx_v_self); /*proto*/
13801 static PyObject *__pyx_pf_9csamtools_14IteratorRowAll___iter__(PyObject *__pyx_v_self) {
13802   PyObject *__pyx_r = NULL;
13803   __Pyx_TraceDeclarations
13804   __Pyx_RefNannySetupContext("__iter__");
13805   __Pyx_TraceCall("__iter__", __pyx_f[0], 1329);
13806
13807   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1330
13808  * 
13809  *     def __iter__(self):
13810  *         return self             # <<<<<<<<<<<<<<
13811  * 
13812  *     cdef bam1_t * getCurrent( self ):
13813  */
13814   __Pyx_XDECREF(__pyx_r);
13815   __Pyx_INCREF(__pyx_v_self);
13816   __pyx_r = __pyx_v_self;
13817   goto __pyx_L0;
13818
13819   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
13820   __pyx_L0:;
13821   __Pyx_XGIVEREF(__pyx_r);
13822   __Pyx_TraceReturn(__pyx_r);
13823   __Pyx_RefNannyFinishContext();
13824   return __pyx_r;
13825 }
13826
13827 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1332
13828  *         return self
13829  * 
13830  *     cdef bam1_t * getCurrent( self ):             # <<<<<<<<<<<<<<
13831  *         return self.b
13832  * 
13833  */
13834
13835 static  bam1_t *__pyx_f_9csamtools_14IteratorRowAll_getCurrent(struct __pyx_obj_9csamtools_IteratorRowAll *__pyx_v_self) {
13836   bam1_t *__pyx_r;
13837   __Pyx_TraceDeclarations
13838   __Pyx_RefNannySetupContext("getCurrent");
13839   __Pyx_TraceCall("getCurrent", __pyx_f[0], 1332);
13840
13841   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1333
13842  * 
13843  *     cdef bam1_t * getCurrent( self ):
13844  *         return self.b             # <<<<<<<<<<<<<<
13845  * 
13846  *     cdef int cnext(self):
13847  */
13848   __pyx_r = __pyx_v_self->b;
13849   goto __pyx_L0;
13850
13851   __pyx_r = 0;
13852   __pyx_L0:;
13853   __Pyx_TraceReturn(Py_None);
13854   __Pyx_RefNannyFinishContext();
13855   return __pyx_r;
13856 }
13857
13858 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1335
13859  *         return self.b
13860  * 
13861  *     cdef int cnext(self):             # <<<<<<<<<<<<<<
13862  *         '''cversion of iterator. Used by IteratorColumn'''
13863  *         cdef int ret
13864  */
13865
13866 static  int __pyx_f_9csamtools_14IteratorRowAll_cnext(struct __pyx_obj_9csamtools_IteratorRowAll *__pyx_v_self) {
13867   int __pyx_r;
13868   __Pyx_TraceDeclarations
13869   __Pyx_RefNannySetupContext("cnext");
13870   __Pyx_TraceCall("cnext", __pyx_f[0], 1335);
13871
13872   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1338
13873  *         '''cversion of iterator. Used by IteratorColumn'''
13874  *         cdef int ret
13875  *         return samread(self.fp, self.b)             # <<<<<<<<<<<<<<
13876  * 
13877  *     def __next__(self):
13878  */
13879   __pyx_r = samread(__pyx_v_self->fp, __pyx_v_self->b);
13880   goto __pyx_L0;
13881
13882   __pyx_r = 0;
13883   __pyx_L0:;
13884   __Pyx_TraceReturn(Py_None);
13885   __Pyx_RefNannyFinishContext();
13886   return __pyx_r;
13887 }
13888
13889 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1340
13890  *         return samread(self.fp, self.b)
13891  * 
13892  *     def __next__(self):             # <<<<<<<<<<<<<<
13893  *         """python version of next().
13894  * 
13895  */
13896
13897 static PyObject *__pyx_pf_9csamtools_14IteratorRowAll___next__(PyObject *__pyx_v_self); /*proto*/
13898 static char __pyx_doc_9csamtools_14IteratorRowAll___next__[] = "python version of next().\n\n        pyrex uses this non-standard name instead of next()\n        ";
13899 struct wrapperbase __pyx_wrapperbase_9csamtools_14IteratorRowAll___next__;
13900 static PyObject *__pyx_pf_9csamtools_14IteratorRowAll___next__(PyObject *__pyx_v_self) {
13901   int __pyx_v_ret;
13902   PyObject *__pyx_r = NULL;
13903   int __pyx_t_1;
13904   PyObject *__pyx_t_2 = NULL;
13905   __Pyx_TraceDeclarations
13906   __Pyx_RefNannySetupContext("__next__");
13907   __Pyx_TraceCall("__next__", __pyx_f[0], 1340);
13908
13909   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1346
13910  *         """
13911  *         cdef int ret
13912  *         ret = samread(self.fp, self.b)             # <<<<<<<<<<<<<<
13913  *         if (ret > 0):
13914  *             return makeAlignedRead( self.b )
13915  */
13916   __pyx_v_ret = samread(((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->fp, ((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->b);
13917
13918   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1347
13919  *         cdef int ret
13920  *         ret = samread(self.fp, self.b)
13921  *         if (ret > 0):             # <<<<<<<<<<<<<<
13922  *             return makeAlignedRead( self.b )
13923  *         else:
13924  */
13925   __pyx_t_1 = (__pyx_v_ret > 0);
13926   if (__pyx_t_1) {
13927
13928     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1348
13929  *         ret = samread(self.fp, self.b)
13930  *         if (ret > 0):
13931  *             return makeAlignedRead( self.b )             # <<<<<<<<<<<<<<
13932  *         else:
13933  *             raise StopIteration
13934  */
13935     __Pyx_XDECREF(__pyx_r);
13936     __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;}
13937     __Pyx_GOTREF(__pyx_t_2);
13938     __pyx_r = __pyx_t_2;
13939     __pyx_t_2 = 0;
13940     goto __pyx_L0;
13941     goto __pyx_L5;
13942   }
13943   /*else*/ {
13944
13945     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1350
13946  *             return makeAlignedRead( self.b )
13947  *         else:
13948  *             raise StopIteration             # <<<<<<<<<<<<<<
13949  * 
13950  *     def __dealloc__(self):
13951  */
13952     __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
13953     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
13954   }
13955   __pyx_L5:;
13956
13957   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
13958   goto __pyx_L0;
13959   __pyx_L1_error:;
13960   __Pyx_XDECREF(__pyx_t_2);
13961   __Pyx_AddTraceback("csamtools.IteratorRowAll.__next__");
13962   __pyx_r = NULL;
13963   __pyx_L0:;
13964   __Pyx_XGIVEREF(__pyx_r);
13965   __Pyx_TraceReturn(__pyx_r);
13966   __Pyx_RefNannyFinishContext();
13967   return __pyx_r;
13968 }
13969
13970 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1352
13971  *             raise StopIteration
13972  * 
13973  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
13974  *         bam_destroy1(self.b)
13975  *         if self.owns_samfile: samclose( self.fp )
13976  */
13977
13978 static void __pyx_pf_9csamtools_14IteratorRowAll___dealloc__(PyObject *__pyx_v_self); /*proto*/
13979 static void __pyx_pf_9csamtools_14IteratorRowAll___dealloc__(PyObject *__pyx_v_self) {
13980   __Pyx_TraceDeclarations
13981   __Pyx_RefNannySetupContext("__dealloc__");
13982   __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1352);
13983
13984   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1353
13985  * 
13986  *     def __dealloc__(self):
13987  *         bam_destroy1(self.b)             # <<<<<<<<<<<<<<
13988  *         if self.owns_samfile: samclose( self.fp )
13989  * 
13990  */
13991   bam_destroy1(((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->b);
13992
13993   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1354
13994  *     def __dealloc__(self):
13995  *         bam_destroy1(self.b)
13996  *         if self.owns_samfile: samclose( self.fp )             # <<<<<<<<<<<<<<
13997  * 
13998  * cdef class IteratorRowAllRefs(IteratorRow):
13999  */
14000   if (((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->owns_samfile) {
14001     samclose(((struct __pyx_obj_9csamtools_IteratorRowAll *)__pyx_v_self)->fp);
14002     goto __pyx_L5;
14003   }
14004   __pyx_L5:;
14005
14006   __Pyx_TraceReturn(Py_None);
14007   __Pyx_RefNannyFinishContext();
14008 }
14009
14010 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1363
14011  *     cdef IteratorRowRegion rowiter
14012  * 
14013  *     def __cinit__(self, Samfile samfile):             # <<<<<<<<<<<<<<
14014  *         assert samfile._isOpen()
14015  *         if not samfile._hasIndex(): raise ValueError("no index available for fetch")
14016  */
14017
14018 static int __pyx_pf_9csamtools_18IteratorRowAllRefs___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
14019 static int __pyx_pf_9csamtools_18IteratorRowAllRefs___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
14020   struct __pyx_obj_9csamtools_Samfile *__pyx_v_samfile = 0;
14021   int __pyx_r;
14022   PyObject *__pyx_t_1 = NULL;
14023   PyObject *__pyx_t_2 = NULL;
14024   int __pyx_t_3;
14025   int __pyx_t_4;
14026   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__samfile,0};
14027   __Pyx_TraceDeclarations
14028   __Pyx_RefNannySetupContext("__cinit__");
14029   __Pyx_TraceCall("__cinit__", __pyx_f[0], 1363);
14030   if (unlikely(__pyx_kwds)) {
14031     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
14032     PyObject* values[1] = {0};
14033     switch (PyTuple_GET_SIZE(__pyx_args)) {
14034       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
14035       case  0: break;
14036       default: goto __pyx_L5_argtuple_error;
14037     }
14038     switch (PyTuple_GET_SIZE(__pyx_args)) {
14039       case  0:
14040       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__samfile);
14041       if (likely(values[0])) kw_args--;
14042       else goto __pyx_L5_argtuple_error;
14043     }
14044     if (unlikely(kw_args > 0)) {
14045       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;}
14046     }
14047     __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)values[0]);
14048   } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
14049     goto __pyx_L5_argtuple_error;
14050   } else {
14051     __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)PyTuple_GET_ITEM(__pyx_args, 0));
14052   }
14053   goto __pyx_L4_argument_unpacking_done;
14054   __pyx_L5_argtuple_error:;
14055   __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;}
14056   __pyx_L3_error:;
14057   __Pyx_AddTraceback("csamtools.IteratorRowAllRefs.__cinit__");
14058   __Pyx_RefNannyFinishContext();
14059   return -1;
14060   __pyx_L4_argument_unpacking_done:;
14061   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;}
14062
14063   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1364
14064  * 
14065  *     def __cinit__(self, Samfile samfile):
14066  *         assert samfile._isOpen()             # <<<<<<<<<<<<<<
14067  *         if not samfile._hasIndex(): raise ValueError("no index available for fetch")
14068  *         self.samfile = samfile
14069  */
14070   #ifndef PYREX_WITHOUT_ASSERTIONS
14071   __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;}
14072   __Pyx_GOTREF(__pyx_t_1);
14073   __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;}
14074   __Pyx_GOTREF(__pyx_t_2);
14075   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
14076   __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;}
14077   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
14078   if (unlikely(!__pyx_t_3)) {
14079     PyErr_SetNone(PyExc_AssertionError);
14080     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
14081   }
14082   #endif
14083
14084   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1365
14085  *     def __cinit__(self, Samfile samfile):
14086  *         assert samfile._isOpen()
14087  *         if not samfile._hasIndex(): raise ValueError("no index available for fetch")             # <<<<<<<<<<<<<<
14088  *         self.samfile = samfile
14089  *         self.tid = -1
14090  */
14091   __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;}
14092   __Pyx_GOTREF(__pyx_t_2);
14093   __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;}
14094   __Pyx_GOTREF(__pyx_t_1);
14095   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
14096   __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;}
14097   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
14098   __pyx_t_4 = (!__pyx_t_3);
14099   if (__pyx_t_4) {
14100     __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;}
14101     __Pyx_GOTREF(__pyx_t_1);
14102     __Pyx_INCREF(((PyObject *)__pyx_kp_s_32));
14103     PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_32));
14104     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_32));
14105     __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;}
14106     __Pyx_GOTREF(__pyx_t_2);
14107     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
14108     __Pyx_Raise(__pyx_t_2, 0, 0);
14109     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
14110     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
14111     goto __pyx_L6;
14112   }
14113   __pyx_L6:;
14114
14115   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1366
14116  *         assert samfile._isOpen()
14117  *         if not samfile._hasIndex(): raise ValueError("no index available for fetch")
14118  *         self.samfile = samfile             # <<<<<<<<<<<<<<
14119  *         self.tid = -1
14120  * 
14121  */
14122   __Pyx_INCREF(((PyObject *)__pyx_v_samfile));
14123   __Pyx_GIVEREF(((PyObject *)__pyx_v_samfile));
14124   __Pyx_GOTREF(((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->samfile);
14125   __Pyx_DECREF(((PyObject *)((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->samfile));
14126   ((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->samfile = __pyx_v_samfile;
14127
14128   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1367
14129  *         if not samfile._hasIndex(): raise ValueError("no index available for fetch")
14130  *         self.samfile = samfile
14131  *         self.tid = -1             # <<<<<<<<<<<<<<
14132  * 
14133  *     def nextiter(self):
14134  */
14135   ((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->tid = -1;
14136
14137   __pyx_r = 0;
14138   goto __pyx_L0;
14139   __pyx_L1_error:;
14140   __Pyx_XDECREF(__pyx_t_1);
14141   __Pyx_XDECREF(__pyx_t_2);
14142   __Pyx_AddTraceback("csamtools.IteratorRowAllRefs.__cinit__");
14143   __pyx_r = -1;
14144   __pyx_L0:;
14145   __Pyx_TraceReturn(Py_None);
14146   __Pyx_RefNannyFinishContext();
14147   return __pyx_r;
14148 }
14149
14150 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1369
14151  *         self.tid = -1
14152  * 
14153  *     def nextiter(self):             # <<<<<<<<<<<<<<
14154  *         self.rowiter = IteratorRowRegion(self.samfile, self.tid, 0, 1<<29)
14155  * 
14156  */
14157
14158 static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs_nextiter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
14159 static char __pyx_doc_9csamtools_18IteratorRowAllRefs_nextiter[] = "IteratorRowAllRefs.nextiter(self)";
14160 static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs_nextiter(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
14161   PyObject *__pyx_r = NULL;
14162   PyObject *__pyx_t_1 = NULL;
14163   PyObject *__pyx_t_2 = NULL;
14164   __Pyx_TraceDeclarations
14165   __Pyx_RefNannySetupContext("nextiter");
14166   __Pyx_TraceCall("nextiter", __pyx_f[0], 1369);
14167
14168   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1370
14169  * 
14170  *     def nextiter(self):
14171  *         self.rowiter = IteratorRowRegion(self.samfile, self.tid, 0, 1<<29)             # <<<<<<<<<<<<<<
14172  * 
14173  *     def __iter__(self):
14174  */
14175   __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;}
14176   __Pyx_GOTREF(__pyx_t_1);
14177   __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;}
14178   __Pyx_GOTREF(__pyx_t_2);
14179   __Pyx_INCREF(((PyObject *)((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->samfile));
14180   PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->samfile));
14181   __Pyx_GIVEREF(((PyObject *)((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->samfile));
14182   PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
14183   __Pyx_GIVEREF(__pyx_t_1);
14184   __Pyx_INCREF(__pyx_int_0);
14185   PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_int_0);
14186   __Pyx_GIVEREF(__pyx_int_0);
14187   __Pyx_INCREF(__pyx_int_536870912);
14188   PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_int_536870912);
14189   __Pyx_GIVEREF(__pyx_int_536870912);
14190   __pyx_t_1 = 0;
14191   __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;}
14192   __Pyx_GOTREF(__pyx_t_1);
14193   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
14194   __Pyx_GIVEREF(__pyx_t_1);
14195   __Pyx_GOTREF(((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->rowiter);
14196   __Pyx_DECREF(((PyObject *)((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->rowiter));
14197   ((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->rowiter = ((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_t_1);
14198   __pyx_t_1 = 0;
14199
14200   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
14201   goto __pyx_L0;
14202   __pyx_L1_error:;
14203   __Pyx_XDECREF(__pyx_t_1);
14204   __Pyx_XDECREF(__pyx_t_2);
14205   __Pyx_AddTraceback("csamtools.IteratorRowAllRefs.nextiter");
14206   __pyx_r = NULL;
14207   __pyx_L0:;
14208   __Pyx_XGIVEREF(__pyx_r);
14209   __Pyx_TraceReturn(__pyx_r);
14210   __Pyx_RefNannyFinishContext();
14211   return __pyx_r;
14212 }
14213
14214 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1372
14215  *         self.rowiter = IteratorRowRegion(self.samfile, self.tid, 0, 1<<29)
14216  * 
14217  *     def __iter__(self):             # <<<<<<<<<<<<<<
14218  *         return self
14219  * 
14220  */
14221
14222 static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs___iter__(PyObject *__pyx_v_self); /*proto*/
14223 static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs___iter__(PyObject *__pyx_v_self) {
14224   PyObject *__pyx_r = NULL;
14225   __Pyx_TraceDeclarations
14226   __Pyx_RefNannySetupContext("__iter__");
14227   __Pyx_TraceCall("__iter__", __pyx_f[0], 1372);
14228
14229   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1373
14230  * 
14231  *     def __iter__(self):
14232  *         return self             # <<<<<<<<<<<<<<
14233  * 
14234  *     def __next__(self):
14235  */
14236   __Pyx_XDECREF(__pyx_r);
14237   __Pyx_INCREF(__pyx_v_self);
14238   __pyx_r = __pyx_v_self;
14239   goto __pyx_L0;
14240
14241   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
14242   __pyx_L0:;
14243   __Pyx_XGIVEREF(__pyx_r);
14244   __Pyx_TraceReturn(__pyx_r);
14245   __Pyx_RefNannyFinishContext();
14246   return __pyx_r;
14247 }
14248
14249 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1375
14250  *         return self
14251  * 
14252  *     def __next__(self):             # <<<<<<<<<<<<<<
14253  *         """python version of next().
14254  * 
14255  */
14256
14257 static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs___next__(PyObject *__pyx_v_self); /*proto*/
14258 static char __pyx_doc_9csamtools_18IteratorRowAllRefs___next__[] = "python version of next().\n\n        pyrex uses this non-standard name instead of next()\n        ";
14259 struct wrapperbase __pyx_wrapperbase_9csamtools_18IteratorRowAllRefs___next__;
14260 static PyObject *__pyx_pf_9csamtools_18IteratorRowAllRefs___next__(PyObject *__pyx_v_self) {
14261   PyObject *__pyx_r = NULL;
14262   int __pyx_t_1;
14263   PyObject *__pyx_t_2 = NULL;
14264   int __pyx_t_3;
14265   PyObject *__pyx_t_4 = NULL;
14266   PyObject *__pyx_t_5 = NULL;
14267   __Pyx_TraceDeclarations
14268   __Pyx_RefNannySetupContext("__next__");
14269   __Pyx_TraceCall("__next__", __pyx_f[0], 1375);
14270
14271   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1381
14272  *         """
14273  *         # Create an initial iterator
14274  *         if self.tid==-1:             # <<<<<<<<<<<<<<
14275  *             if not self.samfile.nreferences:
14276  *                 raise StopIteration
14277  */
14278   __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->tid == -1);
14279   if (__pyx_t_1) {
14280
14281     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1382
14282  *         # Create an initial iterator
14283  *         if self.tid==-1:
14284  *             if not self.samfile.nreferences:             # <<<<<<<<<<<<<<
14285  *                 raise StopIteration
14286  *             self.tid = 0
14287  */
14288     __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;}
14289     __Pyx_GOTREF(__pyx_t_2);
14290     __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;}
14291     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
14292     __pyx_t_3 = (!__pyx_t_1);
14293     if (__pyx_t_3) {
14294
14295       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1383
14296  *         if self.tid==-1:
14297  *             if not self.samfile.nreferences:
14298  *                 raise StopIteration             # <<<<<<<<<<<<<<
14299  *             self.tid = 0
14300  *             self.nextiter()
14301  */
14302       __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
14303       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
14304       goto __pyx_L6;
14305     }
14306     __pyx_L6:;
14307
14308     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1384
14309  *             if not self.samfile.nreferences:
14310  *                 raise StopIteration
14311  *             self.tid = 0             # <<<<<<<<<<<<<<
14312  *             self.nextiter()
14313  * 
14314  */
14315     ((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->tid = 0;
14316
14317     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1385
14318  *                 raise StopIteration
14319  *             self.tid = 0
14320  *             self.nextiter()             # <<<<<<<<<<<<<<
14321  * 
14322  *         while 1:
14323  */
14324     __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;}
14325     __Pyx_GOTREF(__pyx_t_2);
14326     __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;}
14327     __Pyx_GOTREF(__pyx_t_4);
14328     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
14329     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
14330     goto __pyx_L5;
14331   }
14332   __pyx_L5:;
14333
14334   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1387
14335  *             self.nextiter()
14336  * 
14337  *         while 1:             # <<<<<<<<<<<<<<
14338  *             self.rowiter.cnext()
14339  * 
14340  */
14341   while (1) {
14342     if (!1) break;
14343
14344     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1388
14345  * 
14346  *         while 1:
14347  *             self.rowiter.cnext()             # <<<<<<<<<<<<<<
14348  * 
14349  *             # If current iterator is not exhausted, return aligned read
14350  */
14351     ((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);
14352
14353     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1391
14354  * 
14355  *             # If current iterator is not exhausted, return aligned read
14356  *             if self.rowiter.retval>0:             # <<<<<<<<<<<<<<
14357  *                 return makeAlignedRead(self.rowiter.b)
14358  * 
14359  */
14360     __pyx_t_3 = (((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->rowiter->retval > 0);
14361     if (__pyx_t_3) {
14362
14363       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1392
14364  *             # If current iterator is not exhausted, return aligned read
14365  *             if self.rowiter.retval>0:
14366  *                 return makeAlignedRead(self.rowiter.b)             # <<<<<<<<<<<<<<
14367  * 
14368  *             self.tid += 1
14369  */
14370       __Pyx_XDECREF(__pyx_r);
14371       __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;}
14372       __Pyx_GOTREF(__pyx_t_4);
14373       __pyx_r = __pyx_t_4;
14374       __pyx_t_4 = 0;
14375       goto __pyx_L0;
14376       goto __pyx_L9;
14377     }
14378     __pyx_L9:;
14379
14380     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1394
14381  *                 return makeAlignedRead(self.rowiter.b)
14382  * 
14383  *             self.tid += 1             # <<<<<<<<<<<<<<
14384  * 
14385  *             # Otherwise, proceed to next reference or stop
14386  */
14387     ((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)__pyx_v_self)->tid += 1;
14388
14389     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1397
14390  * 
14391  *             # Otherwise, proceed to next reference or stop
14392  *             if self.tid<self.samfile.nreferences:             # <<<<<<<<<<<<<<
14393  *                 self.nextiter()
14394  *             else:
14395  */
14396     __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;}
14397     __Pyx_GOTREF(__pyx_t_4);
14398     __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;}
14399     __Pyx_GOTREF(__pyx_t_2);
14400     __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;}
14401     __Pyx_GOTREF(__pyx_t_5);
14402     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
14403     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
14404     __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;}
14405     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
14406     if (__pyx_t_3) {
14407
14408       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1398
14409  *             # Otherwise, proceed to next reference or stop
14410  *             if self.tid<self.samfile.nreferences:
14411  *                 self.nextiter()             # <<<<<<<<<<<<<<
14412  *             else:
14413  *                 raise StopIteration
14414  */
14415       __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;}
14416       __Pyx_GOTREF(__pyx_t_5);
14417       __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;}
14418       __Pyx_GOTREF(__pyx_t_2);
14419       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
14420       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
14421       goto __pyx_L10;
14422     }
14423     /*else*/ {
14424
14425       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1400
14426  *                 self.nextiter()
14427  *             else:
14428  *                 raise StopIteration             # <<<<<<<<<<<<<<
14429  * 
14430  * cdef class IteratorRowSelection(IteratorRow):
14431  */
14432       __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
14433       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
14434     }
14435     __pyx_L10:;
14436   }
14437
14438   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
14439   goto __pyx_L0;
14440   __pyx_L1_error:;
14441   __Pyx_XDECREF(__pyx_t_2);
14442   __Pyx_XDECREF(__pyx_t_4);
14443   __Pyx_XDECREF(__pyx_t_5);
14444   __Pyx_AddTraceback("csamtools.IteratorRowAllRefs.__next__");
14445   __pyx_r = NULL;
14446   __pyx_L0:;
14447   __Pyx_XGIVEREF(__pyx_r);
14448   __Pyx_TraceReturn(__pyx_r);
14449   __Pyx_RefNannyFinishContext();
14450   return __pyx_r;
14451 }
14452
14453 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1415
14454  *     cdef int owns_samfile
14455  * 
14456  *     def __cinit__(self, Samfile samfile, positions, int reopen = True ):             # <<<<<<<<<<<<<<
14457  * 
14458  *         if not samfile._isOpen():
14459  */
14460
14461 static int __pyx_pf_9csamtools_20IteratorRowSelection___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
14462 static int __pyx_pf_9csamtools_20IteratorRowSelection___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
14463   struct __pyx_obj_9csamtools_Samfile *__pyx_v_samfile = 0;
14464   PyObject *__pyx_v_positions = 0;
14465   int __pyx_v_reopen;
14466   PyObject *__pyx_v_mode;
14467   PyObject *__pyx_v_store;
14468   int __pyx_r;
14469   PyObject *__pyx_t_1 = NULL;
14470   PyObject *__pyx_t_2 = NULL;
14471   int __pyx_t_3;
14472   int __pyx_t_4;
14473   char *__pyx_t_5;
14474   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__samfile,&__pyx_n_s__positions,&__pyx_n_s__reopen,0};
14475   __Pyx_TraceDeclarations
14476   __Pyx_RefNannySetupContext("__cinit__");
14477   __Pyx_TraceCall("__cinit__", __pyx_f[0], 1415);
14478   if (unlikely(__pyx_kwds)) {
14479     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
14480     PyObject* values[3] = {0,0,0};
14481     switch (PyTuple_GET_SIZE(__pyx_args)) {
14482       case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
14483       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
14484       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
14485       case  0: break;
14486       default: goto __pyx_L5_argtuple_error;
14487     }
14488     switch (PyTuple_GET_SIZE(__pyx_args)) {
14489       case  0:
14490       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__samfile);
14491       if (likely(values[0])) kw_args--;
14492       else goto __pyx_L5_argtuple_error;
14493       case  1:
14494       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__positions);
14495       if (likely(values[1])) kw_args--;
14496       else {
14497         __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
14498       }
14499       case  2:
14500       if (kw_args > 0) {
14501         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reopen);
14502         if (value) { values[2] = value; kw_args--; }
14503       }
14504     }
14505     if (unlikely(kw_args > 0)) {
14506       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;}
14507     }
14508     __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)values[0]);
14509     __pyx_v_positions = values[1];
14510     if (values[2]) {
14511       __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;}
14512     } else {
14513       __pyx_v_reopen = ((int)1);
14514     }
14515   } else {
14516     __pyx_v_reopen = ((int)1);
14517     switch (PyTuple_GET_SIZE(__pyx_args)) {
14518       case  3:
14519       __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;}
14520       case  2:
14521       __pyx_v_positions = PyTuple_GET_ITEM(__pyx_args, 1);
14522       __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)PyTuple_GET_ITEM(__pyx_args, 0));
14523       break;
14524       default: goto __pyx_L5_argtuple_error;
14525     }
14526   }
14527   goto __pyx_L4_argument_unpacking_done;
14528   __pyx_L5_argtuple_error:;
14529   __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;}
14530   __pyx_L3_error:;
14531   __Pyx_AddTraceback("csamtools.IteratorRowSelection.__cinit__");
14532   __Pyx_RefNannyFinishContext();
14533   return -1;
14534   __pyx_L4_argument_unpacking_done:;
14535   __pyx_v_mode = Py_None; __Pyx_INCREF(Py_None);
14536   __pyx_v_store = Py_None; __Pyx_INCREF(Py_None);
14537   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;}
14538
14539   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1417
14540  *     def __cinit__(self, Samfile samfile, positions, int reopen = True ):
14541  * 
14542  *         if not samfile._isOpen():             # <<<<<<<<<<<<<<
14543  *             raise ValueError( "I/O operation on closed file" )
14544  * 
14545  */
14546   __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;}
14547   __Pyx_GOTREF(__pyx_t_1);
14548   __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;}
14549   __Pyx_GOTREF(__pyx_t_2);
14550   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
14551   __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;}
14552   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
14553   __pyx_t_4 = (!__pyx_t_3);
14554   if (__pyx_t_4) {
14555
14556     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1418
14557  * 
14558  *         if not samfile._isOpen():
14559  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
14560  * 
14561  *         if not samfile._isOpen():
14562  */
14563     __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;}
14564     __Pyx_GOTREF(__pyx_t_2);
14565     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
14566     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
14567     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
14568     __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;}
14569     __Pyx_GOTREF(__pyx_t_1);
14570     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
14571     __Pyx_Raise(__pyx_t_1, 0, 0);
14572     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
14573     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
14574     goto __pyx_L6;
14575   }
14576   __pyx_L6:;
14577
14578   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1420
14579  *             raise ValueError( "I/O operation on closed file" )
14580  * 
14581  *         if not samfile._isOpen():             # <<<<<<<<<<<<<<
14582  *             raise ValueError( "I/O operation on closed file" )
14583  * 
14584  */
14585   __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;}
14586   __Pyx_GOTREF(__pyx_t_1);
14587   __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;}
14588   __Pyx_GOTREF(__pyx_t_2);
14589   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
14590   __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;}
14591   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
14592   __pyx_t_3 = (!__pyx_t_4);
14593   if (__pyx_t_3) {
14594
14595     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1421
14596  * 
14597  *         if not samfile._isOpen():
14598  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
14599  * 
14600  *         assert samfile.isbam, "can only use this iterator on bam files"
14601  */
14602     __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;}
14603     __Pyx_GOTREF(__pyx_t_2);
14604     __Pyx_INCREF(((PyObject *)__pyx_kp_s_5));
14605     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_5));
14606     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_5));
14607     __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;}
14608     __Pyx_GOTREF(__pyx_t_1);
14609     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
14610     __Pyx_Raise(__pyx_t_1, 0, 0);
14611     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
14612     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
14613     goto __pyx_L7;
14614   }
14615   __pyx_L7:;
14616
14617   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1423
14618  *             raise ValueError( "I/O operation on closed file" )
14619  * 
14620  *         assert samfile.isbam, "can only use this iterator on bam files"             # <<<<<<<<<<<<<<
14621  *         mode = "rb"
14622  * 
14623  */
14624   #ifndef PYREX_WITHOUT_ASSERTIONS
14625   if (unlikely(!__pyx_v_samfile->isbam)) {
14626     PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_55));
14627     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
14628   }
14629   #endif
14630
14631   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1424
14632  * 
14633  *         assert samfile.isbam, "can only use this iterator on bam files"
14634  *         mode = "rb"             # <<<<<<<<<<<<<<
14635  * 
14636  *         # reopen the file to avoid iterator conflict
14637  */
14638   __Pyx_INCREF(((PyObject *)__pyx_n_s__rb));
14639   __Pyx_DECREF(__pyx_v_mode);
14640   __pyx_v_mode = ((PyObject *)__pyx_n_s__rb);
14641
14642   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1427
14643  * 
14644  *         # reopen the file to avoid iterator conflict
14645  *         if reopen:             # <<<<<<<<<<<<<<
14646  *             store = StderrStore()
14647  *             self.fp = samopen( samfile._filename, mode, NULL )
14648  */
14649   if (__pyx_v_reopen) {
14650
14651     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1428
14652  *         # reopen the file to avoid iterator conflict
14653  *         if reopen:
14654  *             store = StderrStore()             # <<<<<<<<<<<<<<
14655  *             self.fp = samopen( samfile._filename, mode, NULL )
14656  *             store.release()
14657  */
14658     __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;}
14659     __Pyx_GOTREF(__pyx_t_1);
14660     __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;}
14661     __Pyx_GOTREF(__pyx_t_2);
14662     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
14663     __Pyx_DECREF(__pyx_v_store);
14664     __pyx_v_store = __pyx_t_2;
14665     __pyx_t_2 = 0;
14666
14667     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1429
14668  *         if reopen:
14669  *             store = StderrStore()
14670  *             self.fp = samopen( samfile._filename, mode, NULL )             # <<<<<<<<<<<<<<
14671  *             store.release()
14672  *             assert self.fp != NULL
14673  */
14674     __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;}
14675     ((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->fp = samopen(__pyx_v_samfile->_filename, __pyx_t_5, NULL);
14676
14677     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1430
14678  *             store = StderrStore()
14679  *             self.fp = samopen( samfile._filename, mode, NULL )
14680  *             store.release()             # <<<<<<<<<<<<<<
14681  *             assert self.fp != NULL
14682  *             self.owns_samfile = True
14683  */
14684     __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;}
14685     __Pyx_GOTREF(__pyx_t_2);
14686     __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;}
14687     __Pyx_GOTREF(__pyx_t_1);
14688     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
14689     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
14690
14691     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1431
14692  *             self.fp = samopen( samfile._filename, mode, NULL )
14693  *             store.release()
14694  *             assert self.fp != NULL             # <<<<<<<<<<<<<<
14695  *             self.owns_samfile = True
14696  *         else:
14697  */
14698     #ifndef PYREX_WITHOUT_ASSERTIONS
14699     if (unlikely(!(((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->fp != NULL))) {
14700       PyErr_SetNone(PyExc_AssertionError);
14701       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
14702     }
14703     #endif
14704
14705     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1432
14706  *             store.release()
14707  *             assert self.fp != NULL
14708  *             self.owns_samfile = True             # <<<<<<<<<<<<<<
14709  *         else:
14710  *             self.fp = samfile.samfile
14711  */
14712     ((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->owns_samfile = 1;
14713     goto __pyx_L8;
14714   }
14715   /*else*/ {
14716
14717     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1434
14718  *             self.owns_samfile = True
14719  *         else:
14720  *             self.fp = samfile.samfile             # <<<<<<<<<<<<<<
14721  *             self.owns_samfile = False
14722  * 
14723  */
14724     ((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->fp = __pyx_v_samfile->samfile;
14725
14726     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1435
14727  *         else:
14728  *             self.fp = samfile.samfile
14729  *             self.owns_samfile = False             # <<<<<<<<<<<<<<
14730  * 
14731  *         # allocate memory for alignment
14732  */
14733     ((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->owns_samfile = 0;
14734   }
14735   __pyx_L8:;
14736
14737   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1438
14738  * 
14739  *         # allocate memory for alignment
14740  *         self.b = <bam1_t*>calloc(1, sizeof(bam1_t))             # <<<<<<<<<<<<<<
14741  * 
14742  *         self.positions = positions
14743  */
14744   ((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->b = ((bam1_t *)calloc(1, (sizeof(bam1_t))));
14745
14746   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1440
14747  *         self.b = <bam1_t*>calloc(1, sizeof(bam1_t))
14748  * 
14749  *         self.positions = positions             # <<<<<<<<<<<<<<
14750  *         self.current_pos = 0
14751  * 
14752  */
14753   __Pyx_INCREF(__pyx_v_positions);
14754   __Pyx_GIVEREF(__pyx_v_positions);
14755   __Pyx_GOTREF(((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->positions);
14756   __Pyx_DECREF(((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->positions);
14757   ((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->positions = __pyx_v_positions;
14758
14759   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1441
14760  * 
14761  *         self.positions = positions
14762  *         self.current_pos = 0             # <<<<<<<<<<<<<<
14763  * 
14764  *     def __iter__(self):
14765  */
14766   ((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->current_pos = 0;
14767
14768   __pyx_r = 0;
14769   goto __pyx_L0;
14770   __pyx_L1_error:;
14771   __Pyx_XDECREF(__pyx_t_1);
14772   __Pyx_XDECREF(__pyx_t_2);
14773   __Pyx_AddTraceback("csamtools.IteratorRowSelection.__cinit__");
14774   __pyx_r = -1;
14775   __pyx_L0:;
14776   __Pyx_DECREF(__pyx_v_mode);
14777   __Pyx_DECREF(__pyx_v_store);
14778   __Pyx_TraceReturn(Py_None);
14779   __Pyx_RefNannyFinishContext();
14780   return __pyx_r;
14781 }
14782
14783 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1443
14784  *         self.current_pos = 0
14785  * 
14786  *     def __iter__(self):             # <<<<<<<<<<<<<<
14787  *         return self
14788  * 
14789  */
14790
14791 static PyObject *__pyx_pf_9csamtools_20IteratorRowSelection___iter__(PyObject *__pyx_v_self); /*proto*/
14792 static PyObject *__pyx_pf_9csamtools_20IteratorRowSelection___iter__(PyObject *__pyx_v_self) {
14793   PyObject *__pyx_r = NULL;
14794   __Pyx_TraceDeclarations
14795   __Pyx_RefNannySetupContext("__iter__");
14796   __Pyx_TraceCall("__iter__", __pyx_f[0], 1443);
14797
14798   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1444
14799  * 
14800  *     def __iter__(self):
14801  *         return self             # <<<<<<<<<<<<<<
14802  * 
14803  *     cdef bam1_t * getCurrent( self ):
14804  */
14805   __Pyx_XDECREF(__pyx_r);
14806   __Pyx_INCREF(__pyx_v_self);
14807   __pyx_r = __pyx_v_self;
14808   goto __pyx_L0;
14809
14810   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
14811   __pyx_L0:;
14812   __Pyx_XGIVEREF(__pyx_r);
14813   __Pyx_TraceReturn(__pyx_r);
14814   __Pyx_RefNannyFinishContext();
14815   return __pyx_r;
14816 }
14817
14818 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1446
14819  *         return self
14820  * 
14821  *     cdef bam1_t * getCurrent( self ):             # <<<<<<<<<<<<<<
14822  *         return self.b
14823  * 
14824  */
14825
14826 static  bam1_t *__pyx_f_9csamtools_20IteratorRowSelection_getCurrent(struct __pyx_obj_9csamtools_IteratorRowSelection *__pyx_v_self) {
14827   bam1_t *__pyx_r;
14828   __Pyx_TraceDeclarations
14829   __Pyx_RefNannySetupContext("getCurrent");
14830   __Pyx_TraceCall("getCurrent", __pyx_f[0], 1446);
14831
14832   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1447
14833  * 
14834  *     cdef bam1_t * getCurrent( self ):
14835  *         return self.b             # <<<<<<<<<<<<<<
14836  * 
14837  *     cdef int cnext(self):
14838  */
14839   __pyx_r = __pyx_v_self->b;
14840   goto __pyx_L0;
14841
14842   __pyx_r = 0;
14843   __pyx_L0:;
14844   __Pyx_TraceReturn(Py_None);
14845   __Pyx_RefNannyFinishContext();
14846   return __pyx_r;
14847 }
14848
14849 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1449
14850  *         return self.b
14851  * 
14852  *     cdef int cnext(self):             # <<<<<<<<<<<<<<
14853  *         '''cversion of iterator'''
14854  * 
14855  */
14856
14857 static  int __pyx_f_9csamtools_20IteratorRowSelection_cnext(struct __pyx_obj_9csamtools_IteratorRowSelection *__pyx_v_self) {
14858   int __pyx_r;
14859   Py_ssize_t __pyx_t_1;
14860   int __pyx_t_2;
14861   PyObject *__pyx_t_3 = NULL;
14862   uint64_t __pyx_t_4;
14863   __Pyx_TraceDeclarations
14864   __Pyx_RefNannySetupContext("cnext");
14865   __Pyx_TraceCall("cnext", __pyx_f[0], 1449);
14866
14867   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1453
14868  * 
14869  *         # end iteration if out of positions
14870  *         if self.current_pos >= len(self.positions): return -1             # <<<<<<<<<<<<<<
14871  * 
14872  *         bam_seek( self.fp.x.bam, self.positions[self.current_pos], 0 )
14873  */
14874   __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;}
14875   __pyx_t_2 = (__pyx_v_self->current_pos >= __pyx_t_1);
14876   if (__pyx_t_2) {
14877     __pyx_r = -1;
14878     goto __pyx_L0;
14879     goto __pyx_L3;
14880   }
14881   __pyx_L3:;
14882
14883   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1455
14884  *         if self.current_pos >= len(self.positions): return -1
14885  * 
14886  *         bam_seek( self.fp.x.bam, self.positions[self.current_pos], 0 )             # <<<<<<<<<<<<<<
14887  *         self.current_pos += 1
14888  *         return samread(self.fp, self.b)
14889  */
14890   __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;}
14891   __Pyx_GOTREF(__pyx_t_3);
14892   __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;}
14893   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
14894   bam_seek(__pyx_v_self->fp->x.bam, __pyx_t_4, 0);
14895
14896   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1456
14897  * 
14898  *         bam_seek( self.fp.x.bam, self.positions[self.current_pos], 0 )
14899  *         self.current_pos += 1             # <<<<<<<<<<<<<<
14900  *         return samread(self.fp, self.b)
14901  * 
14902  */
14903   __pyx_v_self->current_pos += 1;
14904
14905   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1457
14906  *         bam_seek( self.fp.x.bam, self.positions[self.current_pos], 0 )
14907  *         self.current_pos += 1
14908  *         return samread(self.fp, self.b)             # <<<<<<<<<<<<<<
14909  * 
14910  *     def __next__(self):
14911  */
14912   __pyx_r = samread(__pyx_v_self->fp, __pyx_v_self->b);
14913   goto __pyx_L0;
14914
14915   __pyx_r = 0;
14916   goto __pyx_L0;
14917   __pyx_L1_error:;
14918   __Pyx_XDECREF(__pyx_t_3);
14919   __Pyx_WriteUnraisable("csamtools.IteratorRowSelection.cnext");
14920   __pyx_r = 0;
14921   __pyx_L0:;
14922   __Pyx_TraceReturn(Py_None);
14923   __Pyx_RefNannyFinishContext();
14924   return __pyx_r;
14925 }
14926
14927 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1459
14928  *         return samread(self.fp, self.b)
14929  * 
14930  *     def __next__(self):             # <<<<<<<<<<<<<<
14931  *         """python version of next().
14932  * 
14933  */
14934
14935 static PyObject *__pyx_pf_9csamtools_20IteratorRowSelection___next__(PyObject *__pyx_v_self); /*proto*/
14936 static char __pyx_doc_9csamtools_20IteratorRowSelection___next__[] = "python version of next().\n\n        pyrex uses this non-standard name instead of next()\n        ";
14937 struct wrapperbase __pyx_wrapperbase_9csamtools_20IteratorRowSelection___next__;
14938 static PyObject *__pyx_pf_9csamtools_20IteratorRowSelection___next__(PyObject *__pyx_v_self) {
14939   int __pyx_v_ret;
14940   PyObject *__pyx_r = NULL;
14941   int __pyx_t_1;
14942   PyObject *__pyx_t_2 = NULL;
14943   __Pyx_TraceDeclarations
14944   __Pyx_RefNannySetupContext("__next__");
14945   __Pyx_TraceCall("__next__", __pyx_f[0], 1459);
14946
14947   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1465
14948  *         """
14949  * 
14950  *         cdef int ret = self.cnext()             # <<<<<<<<<<<<<<
14951  *         if (ret > 0):
14952  *             return makeAlignedRead( self.b )
14953  */
14954   __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));
14955
14956   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1466
14957  * 
14958  *         cdef int ret = self.cnext()
14959  *         if (ret > 0):             # <<<<<<<<<<<<<<
14960  *             return makeAlignedRead( self.b )
14961  *         else:
14962  */
14963   __pyx_t_1 = (__pyx_v_ret > 0);
14964   if (__pyx_t_1) {
14965
14966     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1467
14967  *         cdef int ret = self.cnext()
14968  *         if (ret > 0):
14969  *             return makeAlignedRead( self.b )             # <<<<<<<<<<<<<<
14970  *         else:
14971  *             raise StopIteration
14972  */
14973     __Pyx_XDECREF(__pyx_r);
14974     __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;}
14975     __Pyx_GOTREF(__pyx_t_2);
14976     __pyx_r = __pyx_t_2;
14977     __pyx_t_2 = 0;
14978     goto __pyx_L0;
14979     goto __pyx_L5;
14980   }
14981   /*else*/ {
14982
14983     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1469
14984  *             return makeAlignedRead( self.b )
14985  *         else:
14986  *             raise StopIteration             # <<<<<<<<<<<<<<
14987  * 
14988  *     def __dealloc__(self):
14989  */
14990     __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
14991     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
14992   }
14993   __pyx_L5:;
14994
14995   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
14996   goto __pyx_L0;
14997   __pyx_L1_error:;
14998   __Pyx_XDECREF(__pyx_t_2);
14999   __Pyx_AddTraceback("csamtools.IteratorRowSelection.__next__");
15000   __pyx_r = NULL;
15001   __pyx_L0:;
15002   __Pyx_XGIVEREF(__pyx_r);
15003   __Pyx_TraceReturn(__pyx_r);
15004   __Pyx_RefNannyFinishContext();
15005   return __pyx_r;
15006 }
15007
15008 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1471
15009  *             raise StopIteration
15010  * 
15011  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
15012  *         bam_destroy1(self.b)
15013  *         if self.owns_samfile: samclose( self.fp )
15014  */
15015
15016 static void __pyx_pf_9csamtools_20IteratorRowSelection___dealloc__(PyObject *__pyx_v_self); /*proto*/
15017 static void __pyx_pf_9csamtools_20IteratorRowSelection___dealloc__(PyObject *__pyx_v_self) {
15018   __Pyx_TraceDeclarations
15019   __Pyx_RefNannySetupContext("__dealloc__");
15020   __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1471);
15021
15022   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1472
15023  * 
15024  *     def __dealloc__(self):
15025  *         bam_destroy1(self.b)             # <<<<<<<<<<<<<<
15026  *         if self.owns_samfile: samclose( self.fp )
15027  * 
15028  */
15029   bam_destroy1(((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->b);
15030
15031   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1473
15032  *     def __dealloc__(self):
15033  *         bam_destroy1(self.b)
15034  *         if self.owns_samfile: samclose( self.fp )             # <<<<<<<<<<<<<<
15035  * 
15036  * ##-------------------------------------------------------------------
15037  */
15038   if (((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->owns_samfile) {
15039     samclose(((struct __pyx_obj_9csamtools_IteratorRowSelection *)__pyx_v_self)->fp);
15040     goto __pyx_L5;
15041   }
15042   __pyx_L5:;
15043
15044   __Pyx_TraceReturn(Py_None);
15045   __Pyx_RefNannyFinishContext();
15046 }
15047
15048 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1486
15049  *     int seq_len
15050  * 
15051  * cdef int __advance_all( void * data, bam1_t * b ):             # <<<<<<<<<<<<<<
15052  *     '''advance without any read filtering.
15053  *     '''
15054  */
15055
15056 static  int __pyx_f_9csamtools___advance_all(void *__pyx_v_data, bam1_t *__pyx_v_b) {
15057   __pyx_t_9csamtools___iterdata *__pyx_v_d;
15058   int __pyx_r;
15059   __Pyx_TraceDeclarations
15060   __Pyx_RefNannySetupContext("__advance_all");
15061   __Pyx_TraceCall("__advance_all", __pyx_f[0], 1486);
15062
15063   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1490
15064  *     '''
15065  *     cdef __iterdata * d
15066  *     d = <__iterdata*>data             # <<<<<<<<<<<<<<
15067  *     return bam_iter_read( d.samfile.x.bam, d.iter, b )
15068  * 
15069  */
15070   __pyx_v_d = ((__pyx_t_9csamtools___iterdata *)__pyx_v_data);
15071
15072   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1491
15073  *     cdef __iterdata * d
15074  *     d = <__iterdata*>data
15075  *     return bam_iter_read( d.samfile.x.bam, d.iter, b )             # <<<<<<<<<<<<<<
15076  * 
15077  * cdef int __advance_snpcalls( void * data, bam1_t * b ):
15078  */
15079   __pyx_r = bam_iter_read(__pyx_v_d->samfile->x.bam, __pyx_v_d->iter, __pyx_v_b);
15080   goto __pyx_L0;
15081
15082   __pyx_r = 0;
15083   __pyx_L0:;
15084   __Pyx_TraceReturn(Py_None);
15085   __Pyx_RefNannyFinishContext();
15086   return __pyx_r;
15087 }
15088
15089 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1493
15090  *     return bam_iter_read( d.samfile.x.bam, d.iter, b )
15091  * 
15092  * cdef int __advance_snpcalls( void * data, bam1_t * b ):             # <<<<<<<<<<<<<<
15093  *     '''advance using same filter and read processing as in
15094  *     the samtools pileup.
15095  */
15096
15097 static  int __pyx_f_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1_t *__pyx_v_b) {
15098   __pyx_t_9csamtools___iterdata *__pyx_v_d;
15099   int __pyx_v_ret;
15100   int __pyx_v_skip;
15101   int __pyx_v_q;
15102   int __pyx_v_is_cns;
15103   int __pyx_v_is_nobaq;
15104   int __pyx_v_capQ_thres;
15105   int __pyx_r;
15106   int __pyx_t_1;
15107   int __pyx_t_2;
15108   int __pyx_t_3;
15109   PyObject *__pyx_t_4 = NULL;
15110   PyObject *__pyx_t_5 = NULL;
15111   PyObject *__pyx_t_6 = NULL;
15112   long __pyx_t_7;
15113   __Pyx_TraceDeclarations
15114   __Pyx_RefNannySetupContext("__advance_snpcalls");
15115   __Pyx_TraceCall("__advance_snpcalls", __pyx_f[0], 1493);
15116
15117   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1498
15118  *     '''
15119  *     cdef __iterdata * d
15120  *     d = <__iterdata*>data             # <<<<<<<<<<<<<<
15121  * 
15122  *     cdef int ret = bam_iter_read( d.samfile.x.bam, d.iter, b )
15123  */
15124   __pyx_v_d = ((__pyx_t_9csamtools___iterdata *)__pyx_v_data);
15125
15126   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1500
15127  *     d = <__iterdata*>data
15128  * 
15129  *     cdef int ret = bam_iter_read( d.samfile.x.bam, d.iter, b )             # <<<<<<<<<<<<<<
15130  *     cdef int skip = 0
15131  *     cdef int q
15132  */
15133   __pyx_v_ret = bam_iter_read(__pyx_v_d->samfile->x.bam, __pyx_v_d->iter, __pyx_v_b);
15134
15135   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1501
15136  * 
15137  *     cdef int ret = bam_iter_read( d.samfile.x.bam, d.iter, b )
15138  *     cdef int skip = 0             # <<<<<<<<<<<<<<
15139  *     cdef int q
15140  *     cdef int is_cns = 1
15141  */
15142   __pyx_v_skip = 0;
15143
15144   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1503
15145  *     cdef int skip = 0
15146  *     cdef int q
15147  *     cdef int is_cns = 1             # <<<<<<<<<<<<<<
15148  *     cdef int is_nobaq = 0
15149  *     cdef int capQ_thres = 0
15150  */
15151   __pyx_v_is_cns = 1;
15152
15153   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1504
15154  *     cdef int q
15155  *     cdef int is_cns = 1
15156  *     cdef int is_nobaq = 0             # <<<<<<<<<<<<<<
15157  *     cdef int capQ_thres = 0
15158  * 
15159  */
15160   __pyx_v_is_nobaq = 0;
15161
15162   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1505
15163  *     cdef int is_cns = 1
15164  *     cdef int is_nobaq = 0
15165  *     cdef int capQ_thres = 0             # <<<<<<<<<<<<<<
15166  * 
15167  *     # reload sequence
15168  */
15169   __pyx_v_capQ_thres = 0;
15170
15171   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1508
15172  * 
15173  *     # reload sequence
15174  *     if d.fastafile != NULL and b.core.tid != d.tid:             # <<<<<<<<<<<<<<
15175  *         if d.seq != NULL: free(d.seq)
15176  *         d.tid = b.core.tid
15177  */
15178   __pyx_t_1 = (__pyx_v_d->fastafile != NULL);
15179   if (__pyx_t_1) {
15180     __pyx_t_2 = (__pyx_v_b->core.tid != __pyx_v_d->tid);
15181     __pyx_t_3 = __pyx_t_2;
15182   } else {
15183     __pyx_t_3 = __pyx_t_1;
15184   }
15185   if (__pyx_t_3) {
15186
15187     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1509
15188  *     # reload sequence
15189  *     if d.fastafile != NULL and b.core.tid != d.tid:
15190  *         if d.seq != NULL: free(d.seq)             # <<<<<<<<<<<<<<
15191  *         d.tid = b.core.tid
15192  *         d.seq = faidx_fetch_seq(d.fastafile,
15193  */
15194     __pyx_t_3 = (__pyx_v_d->seq != NULL);
15195     if (__pyx_t_3) {
15196       free(__pyx_v_d->seq);
15197       goto __pyx_L4;
15198     }
15199     __pyx_L4:;
15200
15201     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1510
15202  *     if d.fastafile != NULL and b.core.tid != d.tid:
15203  *         if d.seq != NULL: free(d.seq)
15204  *         d.tid = b.core.tid             # <<<<<<<<<<<<<<
15205  *         d.seq = faidx_fetch_seq(d.fastafile,
15206  *                                 d.samfile.header.target_name[d.tid],
15207  */
15208     __pyx_v_d->tid = __pyx_v_b->core.tid;
15209
15210     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1511
15211  *         if d.seq != NULL: free(d.seq)
15212  *         d.tid = b.core.tid
15213  *         d.seq = faidx_fetch_seq(d.fastafile,             # <<<<<<<<<<<<<<
15214  *                                 d.samfile.header.target_name[d.tid],
15215  *                                 0, max_pos,
15216  */
15217     __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));
15218
15219     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1515
15220  *                                 0, max_pos,
15221  *                                 &d.seq_len)
15222  *         if d.seq == NULL:             # <<<<<<<<<<<<<<
15223  *             raise ValueError( "reference sequence for '%s' (tid=%i) not found" % \
15224  *                                   (d.samfile.header.target_name[d.tid],
15225  */
15226     __pyx_t_3 = (__pyx_v_d->seq == NULL);
15227     if (__pyx_t_3) {
15228
15229       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1517
15230  *         if d.seq == NULL:
15231  *             raise ValueError( "reference sequence for '%s' (tid=%i) not found" % \
15232  *                                   (d.samfile.header.target_name[d.tid],             # <<<<<<<<<<<<<<
15233  *                                    d.tid))
15234  * 
15235  */
15236       __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;}
15237       __Pyx_GOTREF(((PyObject *)__pyx_t_4));
15238
15239       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1518
15240  *             raise ValueError( "reference sequence for '%s' (tid=%i) not found" % \
15241  *                                   (d.samfile.header.target_name[d.tid],
15242  *                                    d.tid))             # <<<<<<<<<<<<<<
15243  * 
15244  * 
15245  */
15246       __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;}
15247       __Pyx_GOTREF(__pyx_t_5);
15248       __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;}
15249       __Pyx_GOTREF(__pyx_t_6);
15250       PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_4));
15251       __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
15252       PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5);
15253       __Pyx_GIVEREF(__pyx_t_5);
15254       __pyx_t_4 = 0;
15255       __pyx_t_5 = 0;
15256       __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;}
15257       __Pyx_GOTREF(((PyObject *)__pyx_t_5));
15258       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
15259       __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;}
15260       __Pyx_GOTREF(__pyx_t_6);
15261       PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_5));
15262       __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
15263       __pyx_t_5 = 0;
15264       __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;}
15265       __Pyx_GOTREF(__pyx_t_5);
15266       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
15267       __Pyx_Raise(__pyx_t_5, 0, 0);
15268       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
15269       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
15270       goto __pyx_L5;
15271     }
15272     __pyx_L5:;
15273     goto __pyx_L3;
15274   }
15275   __pyx_L3:;
15276
15277   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1521
15278  * 
15279  * 
15280  *     while ret >= 0:             # <<<<<<<<<<<<<<
15281  * 
15282  *         skip = 0
15283  */
15284   while (1) {
15285     __pyx_t_3 = (__pyx_v_ret >= 0);
15286     if (!__pyx_t_3) break;
15287
15288     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1523
15289  *     while ret >= 0:
15290  * 
15291  *         skip = 0             # <<<<<<<<<<<<<<
15292  * 
15293  *         # realign read - changes base qualities
15294  */
15295     __pyx_v_skip = 0;
15296
15297     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1526
15298  * 
15299  *         # realign read - changes base qualities
15300  *         if d.seq != NULL and is_cns and not is_nobaq: bam_prob_realn( b, d.seq )             # <<<<<<<<<<<<<<
15301  * 
15302  *         if d.seq != NULL and capQ_thres > 10:
15303  */
15304     __pyx_t_3 = (__pyx_v_d->seq != NULL);
15305     if (__pyx_t_3) {
15306       if (__pyx_v_is_cns) {
15307         __pyx_t_1 = (!__pyx_v_is_nobaq);
15308         __pyx_t_2 = __pyx_t_1;
15309       } else {
15310         __pyx_t_2 = __pyx_v_is_cns;
15311       }
15312       __pyx_t_1 = __pyx_t_2;
15313     } else {
15314       __pyx_t_1 = __pyx_t_3;
15315     }
15316     if (__pyx_t_1) {
15317       bam_prob_realn(__pyx_v_b, __pyx_v_d->seq);
15318       goto __pyx_L8;
15319     }
15320     __pyx_L8:;
15321
15322     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1528
15323  *         if d.seq != NULL and is_cns and not is_nobaq: bam_prob_realn( b, d.seq )
15324  * 
15325  *         if d.seq != NULL and capQ_thres > 10:             # <<<<<<<<<<<<<<
15326  *             q = bam_cap_mapQ(b, d.seq, capQ_thres)
15327  *             if q < 0: skip = 1
15328  */
15329     __pyx_t_1 = (__pyx_v_d->seq != NULL);
15330     if (__pyx_t_1) {
15331       __pyx_t_3 = (__pyx_v_capQ_thres > 10);
15332       __pyx_t_2 = __pyx_t_3;
15333     } else {
15334       __pyx_t_2 = __pyx_t_1;
15335     }
15336     if (__pyx_t_2) {
15337
15338       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1529
15339  * 
15340  *         if d.seq != NULL and capQ_thres > 10:
15341  *             q = bam_cap_mapQ(b, d.seq, capQ_thres)             # <<<<<<<<<<<<<<
15342  *             if q < 0: skip = 1
15343  *             elif b.core.qual > q: b.core.qual = q
15344  */
15345       __pyx_v_q = bam_cap_mapQ(__pyx_v_b, __pyx_v_d->seq, __pyx_v_capQ_thres);
15346
15347       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1530
15348  *         if d.seq != NULL and capQ_thres > 10:
15349  *             q = bam_cap_mapQ(b, d.seq, capQ_thres)
15350  *             if q < 0: skip = 1             # <<<<<<<<<<<<<<
15351  *             elif b.core.qual > q: b.core.qual = q
15352  *         if b.core.flag & BAM_FUNMAP: skip = 1
15353  */
15354       __pyx_t_2 = (__pyx_v_q < 0);
15355       if (__pyx_t_2) {
15356         __pyx_v_skip = 1;
15357         goto __pyx_L10;
15358       }
15359
15360       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1531
15361  *             q = bam_cap_mapQ(b, d.seq, capQ_thres)
15362  *             if q < 0: skip = 1
15363  *             elif b.core.qual > q: b.core.qual = q             # <<<<<<<<<<<<<<
15364  *         if b.core.flag & BAM_FUNMAP: skip = 1
15365  *         elif b.core.flag & 1 and not b.core.flag & 2: skip = 1
15366  */
15367       __pyx_t_2 = (__pyx_v_b->core.qual > __pyx_v_q);
15368       if (__pyx_t_2) {
15369         __pyx_v_b->core.qual = __pyx_v_q;
15370         goto __pyx_L10;
15371       }
15372       __pyx_L10:;
15373       goto __pyx_L9;
15374     }
15375     __pyx_L9:;
15376
15377     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1532
15378  *             if q < 0: skip = 1
15379  *             elif b.core.qual > q: b.core.qual = q
15380  *         if b.core.flag & BAM_FUNMAP: skip = 1             # <<<<<<<<<<<<<<
15381  *         elif b.core.flag & 1 and not b.core.flag & 2: skip = 1
15382  * 
15383  */
15384     __pyx_t_7 = (__pyx_v_b->core.flag & 4);
15385     if (__pyx_t_7) {
15386       __pyx_v_skip = 1;
15387       goto __pyx_L11;
15388     }
15389
15390     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1533
15391  *             elif b.core.qual > q: b.core.qual = q
15392  *         if b.core.flag & BAM_FUNMAP: skip = 1
15393  *         elif b.core.flag & 1 and not b.core.flag & 2: skip = 1             # <<<<<<<<<<<<<<
15394  * 
15395  *         if not skip: break
15396  */
15397     if ((__pyx_v_b->core.flag & 1)) {
15398       __pyx_t_2 = (!(__pyx_v_b->core.flag & 2));
15399       __pyx_t_1 = __pyx_t_2;
15400     } else {
15401       __pyx_t_1 = (__pyx_v_b->core.flag & 1);
15402     }
15403     if (__pyx_t_1) {
15404       __pyx_v_skip = 1;
15405       goto __pyx_L11;
15406     }
15407     __pyx_L11:;
15408
15409     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1535
15410  *         elif b.core.flag & 1 and not b.core.flag & 2: skip = 1
15411  * 
15412  *         if not skip: break             # <<<<<<<<<<<<<<
15413  *         # additional filters
15414  * 
15415  */
15416     __pyx_t_1 = (!__pyx_v_skip);
15417     if (__pyx_t_1) {
15418       goto __pyx_L7_break;
15419       goto __pyx_L12;
15420     }
15421     __pyx_L12:;
15422
15423     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1538
15424  *         # additional filters
15425  * 
15426  *         ret = bam_iter_read( d.samfile.x.bam, d.iter, b )             # <<<<<<<<<<<<<<
15427  * 
15428  *     return ret
15429  */
15430     __pyx_v_ret = bam_iter_read(__pyx_v_d->samfile->x.bam, __pyx_v_d->iter, __pyx_v_b);
15431   }
15432   __pyx_L7_break:;
15433
15434   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1540
15435  *         ret = bam_iter_read( d.samfile.x.bam, d.iter, b )
15436  * 
15437  *     return ret             # <<<<<<<<<<<<<<
15438  * 
15439  * cdef class IteratorColumn:
15440  */
15441   __pyx_r = __pyx_v_ret;
15442   goto __pyx_L0;
15443
15444   __pyx_r = 0;
15445   goto __pyx_L0;
15446   __pyx_L1_error:;
15447   __Pyx_XDECREF(__pyx_t_4);
15448   __Pyx_XDECREF(__pyx_t_5);
15449   __Pyx_XDECREF(__pyx_t_6);
15450   __Pyx_WriteUnraisable("csamtools.__advance_snpcalls");
15451   __pyx_r = 0;
15452   __pyx_L0:;
15453   __Pyx_TraceReturn(Py_None);
15454   __Pyx_RefNannyFinishContext();
15455   return __pyx_r;
15456 }
15457
15458 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1599
15459  *     cdef stepper
15460  * 
15461  *     def __cinit__( self, Samfile samfile, **kwargs ):             # <<<<<<<<<<<<<<
15462  *         self.samfile = samfile
15463  *         self.mask = kwargs.get("mask", BAM_DEF_MASK )
15464  */
15465
15466 static int __pyx_pf_9csamtools_14IteratorColumn___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
15467 static int __pyx_pf_9csamtools_14IteratorColumn___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
15468   struct __pyx_obj_9csamtools_Samfile *__pyx_v_samfile = 0;
15469   PyObject *__pyx_v_kwargs = 0;
15470   int __pyx_r;
15471   PyObject *__pyx_t_1 = NULL;
15472   PyObject *__pyx_t_2 = NULL;
15473   int __pyx_t_3;
15474   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__samfile,0};
15475   __Pyx_TraceDeclarations
15476   __Pyx_RefNannySetupContext("__cinit__");
15477   __Pyx_TraceCall("__cinit__", __pyx_f[0], 1599);
15478   __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
15479   __Pyx_GOTREF(__pyx_v_kwargs);
15480   if (unlikely(__pyx_kwds)) {
15481     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
15482     PyObject* values[1] = {0};
15483     switch (PyTuple_GET_SIZE(__pyx_args)) {
15484       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
15485       case  0: break;
15486       default: goto __pyx_L5_argtuple_error;
15487     }
15488     switch (PyTuple_GET_SIZE(__pyx_args)) {
15489       case  0:
15490       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__samfile);
15491       if (likely(values[0])) kw_args--;
15492       else goto __pyx_L5_argtuple_error;
15493     }
15494     if (unlikely(kw_args > 0)) {
15495       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;}
15496     }
15497     __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)values[0]);
15498   } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
15499     goto __pyx_L5_argtuple_error;
15500   } else {
15501     __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)PyTuple_GET_ITEM(__pyx_args, 0));
15502   }
15503   goto __pyx_L4_argument_unpacking_done;
15504   __pyx_L5_argtuple_error:;
15505   __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;}
15506   __pyx_L3_error:;
15507   __Pyx_DECREF(__pyx_v_kwargs);
15508   __Pyx_AddTraceback("csamtools.IteratorColumn.__cinit__");
15509   __Pyx_RefNannyFinishContext();
15510   return -1;
15511   __pyx_L4_argument_unpacking_done:;
15512   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;}
15513
15514   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1600
15515  * 
15516  *     def __cinit__( self, Samfile samfile, **kwargs ):
15517  *         self.samfile = samfile             # <<<<<<<<<<<<<<
15518  *         self.mask = kwargs.get("mask", BAM_DEF_MASK )
15519  *         self.fastafile = kwargs.get( "fastafile", None )
15520  */
15521   __Pyx_INCREF(((PyObject *)__pyx_v_samfile));
15522   __Pyx_GIVEREF(((PyObject *)__pyx_v_samfile));
15523   __Pyx_GOTREF(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->samfile);
15524   __Pyx_DECREF(((PyObject *)((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->samfile));
15525   ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->samfile = __pyx_v_samfile;
15526
15527   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1601
15528  *     def __cinit__( self, Samfile samfile, **kwargs ):
15529  *         self.samfile = samfile
15530  *         self.mask = kwargs.get("mask", BAM_DEF_MASK )             # <<<<<<<<<<<<<<
15531  *         self.fastafile = kwargs.get( "fastafile", None )
15532  *         self.stepper = kwargs.get( "stepper", None )
15533  */
15534   if (unlikely(__pyx_v_kwargs == Py_None)) {
15535     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;} 
15536   }
15537   __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;}
15538   __Pyx_GOTREF(__pyx_t_1);
15539   __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;}
15540   __Pyx_GOTREF(__pyx_t_2);
15541   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
15542   __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;}
15543   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
15544   ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->mask = __pyx_t_3;
15545
15546   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1602
15547  *         self.samfile = samfile
15548  *         self.mask = kwargs.get("mask", BAM_DEF_MASK )
15549  *         self.fastafile = kwargs.get( "fastafile", None )             # <<<<<<<<<<<<<<
15550  *         self.stepper = kwargs.get( "stepper", None )
15551  *         self.iterdata.seq = NULL
15552  */
15553   if (unlikely(__pyx_v_kwargs == Py_None)) {
15554     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;} 
15555   }
15556   __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;}
15557   __Pyx_GOTREF(__pyx_t_2);
15558   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;}
15559   __Pyx_GIVEREF(__pyx_t_2);
15560   __Pyx_GOTREF(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->fastafile);
15561   __Pyx_DECREF(((PyObject *)((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->fastafile));
15562   ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->fastafile = ((struct __pyx_obj_9csamtools_Fastafile *)__pyx_t_2);
15563   __pyx_t_2 = 0;
15564
15565   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1603
15566  *         self.mask = kwargs.get("mask", BAM_DEF_MASK )
15567  *         self.fastafile = kwargs.get( "fastafile", None )
15568  *         self.stepper = kwargs.get( "stepper", None )             # <<<<<<<<<<<<<<
15569  *         self.iterdata.seq = NULL
15570  *         self.tid = 0
15571  */
15572   if (unlikely(__pyx_v_kwargs == Py_None)) {
15573     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;} 
15574   }
15575   __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;}
15576   __Pyx_GOTREF(__pyx_t_2);
15577   __Pyx_GIVEREF(__pyx_t_2);
15578   __Pyx_GOTREF(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->stepper);
15579   __Pyx_DECREF(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->stepper);
15580   ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->stepper = __pyx_t_2;
15581   __pyx_t_2 = 0;
15582
15583   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1604
15584  *         self.fastafile = kwargs.get( "fastafile", None )
15585  *         self.stepper = kwargs.get( "stepper", None )
15586  *         self.iterdata.seq = NULL             # <<<<<<<<<<<<<<
15587  *         self.tid = 0
15588  *         self.pos = 0
15589  */
15590   ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->iterdata.seq = NULL;
15591
15592   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1605
15593  *         self.stepper = kwargs.get( "stepper", None )
15594  *         self.iterdata.seq = NULL
15595  *         self.tid = 0             # <<<<<<<<<<<<<<
15596  *         self.pos = 0
15597  *         self.n_plp = 0
15598  */
15599   ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->tid = 0;
15600
15601   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1606
15602  *         self.iterdata.seq = NULL
15603  *         self.tid = 0
15604  *         self.pos = 0             # <<<<<<<<<<<<<<
15605  *         self.n_plp = 0
15606  *         self.plp = NULL
15607  */
15608   ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->pos = 0;
15609
15610   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1607
15611  *         self.tid = 0
15612  *         self.pos = 0
15613  *         self.n_plp = 0             # <<<<<<<<<<<<<<
15614  *         self.plp = NULL
15615  *         self.pileup_iter = <bam_plp_t>NULL
15616  */
15617   ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->n_plp = 0;
15618
15619   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1608
15620  *         self.pos = 0
15621  *         self.n_plp = 0
15622  *         self.plp = NULL             # <<<<<<<<<<<<<<
15623  *         self.pileup_iter = <bam_plp_t>NULL
15624  * 
15625  */
15626   ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->plp = NULL;
15627
15628   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1609
15629  *         self.n_plp = 0
15630  *         self.plp = NULL
15631  *         self.pileup_iter = <bam_plp_t>NULL             # <<<<<<<<<<<<<<
15632  * 
15633  *     def __iter__(self):
15634  */
15635   ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->pileup_iter = ((bam_plp_t)NULL);
15636
15637   __pyx_r = 0;
15638   goto __pyx_L0;
15639   __pyx_L1_error:;
15640   __Pyx_XDECREF(__pyx_t_1);
15641   __Pyx_XDECREF(__pyx_t_2);
15642   __Pyx_AddTraceback("csamtools.IteratorColumn.__cinit__");
15643   __pyx_r = -1;
15644   __pyx_L0:;
15645   __Pyx_DECREF(__pyx_v_kwargs);
15646   __Pyx_TraceReturn(Py_None);
15647   __Pyx_RefNannyFinishContext();
15648   return __pyx_r;
15649 }
15650
15651 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1611
15652  *         self.pileup_iter = <bam_plp_t>NULL
15653  * 
15654  *     def __iter__(self):             # <<<<<<<<<<<<<<
15655  *         return self
15656  * 
15657  */
15658
15659 static PyObject *__pyx_pf_9csamtools_14IteratorColumn___iter__(PyObject *__pyx_v_self); /*proto*/
15660 static PyObject *__pyx_pf_9csamtools_14IteratorColumn___iter__(PyObject *__pyx_v_self) {
15661   PyObject *__pyx_r = NULL;
15662   __Pyx_TraceDeclarations
15663   __Pyx_RefNannySetupContext("__iter__");
15664   __Pyx_TraceCall("__iter__", __pyx_f[0], 1611);
15665
15666   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1612
15667  * 
15668  *     def __iter__(self):
15669  *         return self             # <<<<<<<<<<<<<<
15670  * 
15671  *     cdef int cnext(self):
15672  */
15673   __Pyx_XDECREF(__pyx_r);
15674   __Pyx_INCREF(__pyx_v_self);
15675   __pyx_r = __pyx_v_self;
15676   goto __pyx_L0;
15677
15678   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
15679   __pyx_L0:;
15680   __Pyx_XGIVEREF(__pyx_r);
15681   __Pyx_TraceReturn(__pyx_r);
15682   __Pyx_RefNannyFinishContext();
15683   return __pyx_r;
15684 }
15685
15686 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1614
15687  *         return self
15688  * 
15689  *     cdef int cnext(self):             # <<<<<<<<<<<<<<
15690  *         '''perform next iteration.
15691  * 
15692  */
15693
15694 static  int __pyx_f_9csamtools_14IteratorColumn_cnext(struct __pyx_obj_9csamtools_IteratorColumn *__pyx_v_self) {
15695   int __pyx_r;
15696   __Pyx_TraceDeclarations
15697   __Pyx_RefNannySetupContext("cnext");
15698   __Pyx_TraceCall("cnext", __pyx_f[0], 1614);
15699
15700   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1620
15701  *         It has been re-implemented to permit for filtering.
15702  *         '''
15703  *         self.plp = bam_plp_auto( self.pileup_iter,             # <<<<<<<<<<<<<<
15704  *                                  &self.tid,
15705  *                                  &self.pos,
15706  */
15707   __pyx_v_self->plp = bam_plp_auto(__pyx_v_self->pileup_iter, (&__pyx_v_self->tid), (&__pyx_v_self->pos), (&__pyx_v_self->n_plp));
15708
15709   __pyx_r = 0;
15710   __Pyx_TraceReturn(Py_None);
15711   __Pyx_RefNannyFinishContext();
15712   return __pyx_r;
15713 }
15714
15715 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1625
15716  *                                  &self.n_plp )
15717  * 
15718  *     cdef char * getSequence( self ):             # <<<<<<<<<<<<<<
15719  *         '''return current reference sequence underlying the iterator.
15720  *         '''
15721  */
15722
15723 static  char *__pyx_f_9csamtools_14IteratorColumn_getSequence(struct __pyx_obj_9csamtools_IteratorColumn *__pyx_v_self) {
15724   char *__pyx_r;
15725   __Pyx_TraceDeclarations
15726   __Pyx_RefNannySetupContext("getSequence");
15727   __Pyx_TraceCall("getSequence", __pyx_f[0], 1625);
15728
15729   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1628
15730  *         '''return current reference sequence underlying the iterator.
15731  *         '''
15732  *         return self.iterdata.seq             # <<<<<<<<<<<<<<
15733  * 
15734  *     property seq_len:
15735  */
15736   __pyx_r = __pyx_v_self->iterdata.seq;
15737   goto __pyx_L0;
15738
15739   __pyx_r = 0;
15740   __pyx_L0:;
15741   __Pyx_TraceReturn(Py_None);
15742   __Pyx_RefNannyFinishContext();
15743   return __pyx_r;
15744 }
15745
15746 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1632
15747  *     property seq_len:
15748  *         '''current sequence length.'''
15749  *         def __get__(self): return self.iterdata.seq_len             # <<<<<<<<<<<<<<
15750  * 
15751  *     def addReference( self, Fastafile fastafile ):
15752  */
15753
15754 static PyObject *__pyx_pf_9csamtools_14IteratorColumn_7seq_len___get__(PyObject *__pyx_v_self); /*proto*/
15755 static PyObject *__pyx_pf_9csamtools_14IteratorColumn_7seq_len___get__(PyObject *__pyx_v_self) {
15756   PyObject *__pyx_r = NULL;
15757   PyObject *__pyx_t_1 = NULL;
15758   __Pyx_TraceDeclarations
15759   __Pyx_RefNannySetupContext("__get__");
15760   __Pyx_TraceCall("__get__", __pyx_f[0], 1632);
15761   __Pyx_XDECREF(__pyx_r);
15762   __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;}
15763   __Pyx_GOTREF(__pyx_t_1);
15764   __pyx_r = __pyx_t_1;
15765   __pyx_t_1 = 0;
15766   goto __pyx_L0;
15767
15768   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
15769   goto __pyx_L0;
15770   __pyx_L1_error:;
15771   __Pyx_XDECREF(__pyx_t_1);
15772   __Pyx_AddTraceback("csamtools.IteratorColumn.seq_len.__get__");
15773   __pyx_r = NULL;
15774   __pyx_L0:;
15775   __Pyx_XGIVEREF(__pyx_r);
15776   __Pyx_TraceReturn(__pyx_r);
15777   __Pyx_RefNannyFinishContext();
15778   return __pyx_r;
15779 }
15780
15781 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1634
15782  *         def __get__(self): return self.iterdata.seq_len
15783  * 
15784  *     def addReference( self, Fastafile fastafile ):             # <<<<<<<<<<<<<<
15785  *        '''
15786  *        add reference sequences in *fastafile* to iterator.'''
15787  */
15788
15789 static PyObject *__pyx_pf_9csamtools_14IteratorColumn_addReference(PyObject *__pyx_v_self, PyObject *__pyx_v_fastafile); /*proto*/
15790 static char __pyx_doc_9csamtools_14IteratorColumn_addReference[] = "IteratorColumn.addReference(self, Fastafile fastafile)\n\n       add reference sequences in *fastafile* to iterator.";
15791 static PyObject *__pyx_pf_9csamtools_14IteratorColumn_addReference(PyObject *__pyx_v_self, PyObject *__pyx_v_fastafile) {
15792   PyObject *__pyx_r = NULL;
15793   int __pyx_t_1;
15794   __Pyx_TraceDeclarations
15795   __Pyx_RefNannySetupContext("addReference");
15796   __Pyx_TraceCall("addReference", __pyx_f[0], 1634);
15797   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;}
15798
15799   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1637
15800  *        '''
15801  *        add reference sequences in *fastafile* to iterator.'''
15802  *        self.fastafile = fastafile             # <<<<<<<<<<<<<<
15803  *        if self.iterdata.seq != NULL: free(self.iterdata.seq)
15804  *        self.iterdata.tid = -1
15805  */
15806   __Pyx_INCREF(__pyx_v_fastafile);
15807   __Pyx_GIVEREF(__pyx_v_fastafile);
15808   __Pyx_GOTREF(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->fastafile);
15809   __Pyx_DECREF(((PyObject *)((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->fastafile));
15810   ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->fastafile = ((struct __pyx_obj_9csamtools_Fastafile *)__pyx_v_fastafile);
15811
15812   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1638
15813  *        add reference sequences in *fastafile* to iterator.'''
15814  *        self.fastafile = fastafile
15815  *        if self.iterdata.seq != NULL: free(self.iterdata.seq)             # <<<<<<<<<<<<<<
15816  *        self.iterdata.tid = -1
15817  *        self.iterdata.fastafile = self.fastafile.fastafile
15818  */
15819   __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->iterdata.seq != NULL);
15820   if (__pyx_t_1) {
15821     free(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->iterdata.seq);
15822     goto __pyx_L5;
15823   }
15824   __pyx_L5:;
15825
15826   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1639
15827  *        self.fastafile = fastafile
15828  *        if self.iterdata.seq != NULL: free(self.iterdata.seq)
15829  *        self.iterdata.tid = -1             # <<<<<<<<<<<<<<
15830  *        self.iterdata.fastafile = self.fastafile.fastafile
15831  * 
15832  */
15833   ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->iterdata.tid = -1;
15834
15835   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1640
15836  *        if self.iterdata.seq != NULL: free(self.iterdata.seq)
15837  *        self.iterdata.tid = -1
15838  *        self.iterdata.fastafile = self.fastafile.fastafile             # <<<<<<<<<<<<<<
15839  * 
15840  *     def hasReference( self ):
15841  */
15842   ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->iterdata.fastafile = ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->fastafile->fastafile;
15843
15844   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
15845   goto __pyx_L0;
15846   __pyx_L1_error:;
15847   __Pyx_AddTraceback("csamtools.IteratorColumn.addReference");
15848   __pyx_r = NULL;
15849   __pyx_L0:;
15850   __Pyx_XGIVEREF(__pyx_r);
15851   __Pyx_TraceReturn(__pyx_r);
15852   __Pyx_RefNannyFinishContext();
15853   return __pyx_r;
15854 }
15855
15856 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1642
15857  *        self.iterdata.fastafile = self.fastafile.fastafile
15858  * 
15859  *     def hasReference( self ):             # <<<<<<<<<<<<<<
15860  *         '''
15861  *         return true if iterator is associated with a reference'''
15862  */
15863
15864 static PyObject *__pyx_pf_9csamtools_14IteratorColumn_hasReference(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
15865 static char __pyx_doc_9csamtools_14IteratorColumn_hasReference[] = "IteratorColumn.hasReference(self)\n\n        return true if iterator is associated with a reference";
15866 static PyObject *__pyx_pf_9csamtools_14IteratorColumn_hasReference(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
15867   PyObject *__pyx_r = NULL;
15868   __Pyx_TraceDeclarations
15869   __Pyx_RefNannySetupContext("hasReference");
15870   __Pyx_TraceCall("hasReference", __pyx_f[0], 1642);
15871
15872   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1645
15873  *         '''
15874  *         return true if iterator is associated with a reference'''
15875  *         return self.fastafile             # <<<<<<<<<<<<<<
15876  * 
15877  *     cdef setMask( self, mask ):
15878  */
15879   __Pyx_XDECREF(__pyx_r);
15880   __Pyx_INCREF(((PyObject *)((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->fastafile));
15881   __pyx_r = ((PyObject *)((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->fastafile);
15882   goto __pyx_L0;
15883
15884   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
15885   __pyx_L0:;
15886   __Pyx_XGIVEREF(__pyx_r);
15887   __Pyx_TraceReturn(__pyx_r);
15888   __Pyx_RefNannyFinishContext();
15889   return __pyx_r;
15890 }
15891
15892 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1647
15893  *         return self.fastafile
15894  * 
15895  *     cdef setMask( self, mask ):             # <<<<<<<<<<<<<<
15896  *         '''set masking flag in iterator.
15897  * 
15898  */
15899
15900 static  PyObject *__pyx_f_9csamtools_14IteratorColumn_setMask(struct __pyx_obj_9csamtools_IteratorColumn *__pyx_v_self, PyObject *__pyx_v_mask) {
15901   PyObject *__pyx_r = NULL;
15902   int __pyx_t_1;
15903   __Pyx_TraceDeclarations
15904   __Pyx_RefNannySetupContext("setMask");
15905   __Pyx_TraceCall("setMask", __pyx_f[0], 1647);
15906
15907   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1652
15908  *         reads with bits set in *mask* will be skipped.
15909  *         '''
15910  *         self.mask = mask             # <<<<<<<<<<<<<<
15911  *         bam_plp_set_mask( self.pileup_iter, self.mask )
15912  * 
15913  */
15914   __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;}
15915   __pyx_v_self->mask = __pyx_t_1;
15916
15917   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1653
15918  *         '''
15919  *         self.mask = mask
15920  *         bam_plp_set_mask( self.pileup_iter, self.mask )             # <<<<<<<<<<<<<<
15921  * 
15922  *     cdef setupIteratorData( self,
15923  */
15924   bam_plp_set_mask(__pyx_v_self->pileup_iter, __pyx_v_self->mask);
15925
15926   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
15927   goto __pyx_L0;
15928   __pyx_L1_error:;
15929   __Pyx_AddTraceback("csamtools.IteratorColumn.setMask");
15930   __pyx_r = 0;
15931   __pyx_L0:;
15932   __Pyx_XGIVEREF(__pyx_r);
15933   __Pyx_TraceReturn(__pyx_r);
15934   __Pyx_RefNannyFinishContext();
15935   return __pyx_r;
15936 }
15937
15938 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1655
15939  *         bam_plp_set_mask( self.pileup_iter, self.mask )
15940  * 
15941  *     cdef setupIteratorData( self,             # <<<<<<<<<<<<<<
15942  *                             int tid,
15943  *                             int start,
15944  */
15945
15946 static  PyObject *__pyx_f_9csamtools_14IteratorColumn_setupIteratorData(struct __pyx_obj_9csamtools_IteratorColumn *__pyx_v_self, int __pyx_v_tid, int __pyx_v_start, int __pyx_v_end, struct __pyx_opt_args_9csamtools_14IteratorColumn_setupIteratorData *__pyx_optional_args) {
15947   int __pyx_v_reopen = ((int)0);
15948   PyObject *__pyx_r = NULL;
15949   PyObject *__pyx_t_1 = NULL;
15950   PyObject *__pyx_t_2 = NULL;
15951   PyObject *__pyx_t_3 = NULL;
15952   PyObject *__pyx_t_4 = NULL;
15953   PyObject *__pyx_t_5 = NULL;
15954   int __pyx_t_6;
15955   int __pyx_t_7;
15956   int __pyx_t_8;
15957   __Pyx_TraceDeclarations
15958   __Pyx_RefNannySetupContext("setupIteratorData");
15959   __Pyx_TraceCall("setupIteratorData", __pyx_f[0], 1655);
15960   if (__pyx_optional_args) {
15961     if (__pyx_optional_args->__pyx_n > 0) {
15962       __pyx_v_reopen = __pyx_optional_args->reopen;
15963     }
15964   }
15965
15966   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1662
15967  *         '''setup the iterator structure'''
15968  * 
15969  *         self.iter = IteratorRowRegion( self.samfile, tid, start, end, reopen )             # <<<<<<<<<<<<<<
15970  *         self.iterdata.samfile = self.samfile.samfile
15971  *         self.iterdata.iter = self.iter.iter
15972  */
15973   __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;}
15974   __Pyx_GOTREF(__pyx_t_1);
15975   __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;}
15976   __Pyx_GOTREF(__pyx_t_2);
15977   __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;}
15978   __Pyx_GOTREF(__pyx_t_3);
15979   __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;}
15980   __Pyx_GOTREF(__pyx_t_4);
15981   __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;}
15982   __Pyx_GOTREF(__pyx_t_5);
15983   __Pyx_INCREF(((PyObject *)__pyx_v_self->samfile));
15984   PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_self->samfile));
15985   __Pyx_GIVEREF(((PyObject *)__pyx_v_self->samfile));
15986   PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
15987   __Pyx_GIVEREF(__pyx_t_1);
15988   PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_2);
15989   __Pyx_GIVEREF(__pyx_t_2);
15990   PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_3);
15991   __Pyx_GIVEREF(__pyx_t_3);
15992   PyTuple_SET_ITEM(__pyx_t_5, 4, __pyx_t_4);
15993   __Pyx_GIVEREF(__pyx_t_4);
15994   __pyx_t_1 = 0;
15995   __pyx_t_2 = 0;
15996   __pyx_t_3 = 0;
15997   __pyx_t_4 = 0;
15998   __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;}
15999   __Pyx_GOTREF(__pyx_t_4);
16000   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
16001   __Pyx_GIVEREF(__pyx_t_4);
16002   __Pyx_GOTREF(__pyx_v_self->iter);
16003   __Pyx_DECREF(((PyObject *)__pyx_v_self->iter));
16004   __pyx_v_self->iter = ((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_t_4);
16005   __pyx_t_4 = 0;
16006
16007   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1663
16008  * 
16009  *         self.iter = IteratorRowRegion( self.samfile, tid, start, end, reopen )
16010  *         self.iterdata.samfile = self.samfile.samfile             # <<<<<<<<<<<<<<
16011  *         self.iterdata.iter = self.iter.iter
16012  *         self.iterdata.seq = NULL
16013  */
16014   __pyx_v_self->iterdata.samfile = __pyx_v_self->samfile->samfile;
16015
16016   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1664
16017  *         self.iter = IteratorRowRegion( self.samfile, tid, start, end, reopen )
16018  *         self.iterdata.samfile = self.samfile.samfile
16019  *         self.iterdata.iter = self.iter.iter             # <<<<<<<<<<<<<<
16020  *         self.iterdata.seq = NULL
16021  *         self.iterdata.tid = -1
16022  */
16023   __pyx_v_self->iterdata.iter = __pyx_v_self->iter->iter;
16024
16025   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1665
16026  *         self.iterdata.samfile = self.samfile.samfile
16027  *         self.iterdata.iter = self.iter.iter
16028  *         self.iterdata.seq = NULL             # <<<<<<<<<<<<<<
16029  *         self.iterdata.tid = -1
16030  * 
16031  */
16032   __pyx_v_self->iterdata.seq = NULL;
16033
16034   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1666
16035  *         self.iterdata.iter = self.iter.iter
16036  *         self.iterdata.seq = NULL
16037  *         self.iterdata.tid = -1             # <<<<<<<<<<<<<<
16038  * 
16039  *         if self.fastafile != None:
16040  */
16041   __pyx_v_self->iterdata.tid = -1;
16042
16043   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1668
16044  *         self.iterdata.tid = -1
16045  * 
16046  *         if self.fastafile != None:             # <<<<<<<<<<<<<<
16047  *             self.iterdata.fastafile = self.fastafile.fastafile
16048  *         else:
16049  */
16050   __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;}
16051   __Pyx_GOTREF(__pyx_t_4);
16052   __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;}
16053   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
16054   if (__pyx_t_6) {
16055
16056     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1669
16057  * 
16058  *         if self.fastafile != None:
16059  *             self.iterdata.fastafile = self.fastafile.fastafile             # <<<<<<<<<<<<<<
16060  *         else:
16061  *             self.iterdata.fastafile = NULL
16062  */
16063     __pyx_v_self->iterdata.fastafile = __pyx_v_self->fastafile->fastafile;
16064     goto __pyx_L3;
16065   }
16066   /*else*/ {
16067
16068     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1671
16069  *             self.iterdata.fastafile = self.fastafile.fastafile
16070  *         else:
16071  *             self.iterdata.fastafile = NULL             # <<<<<<<<<<<<<<
16072  * 
16073  *         if self.stepper == None or self.stepper == "all":
16074  */
16075     __pyx_v_self->iterdata.fastafile = NULL;
16076   }
16077   __pyx_L3:;
16078
16079   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1673
16080  *             self.iterdata.fastafile = NULL
16081  * 
16082  *         if self.stepper == None or self.stepper == "all":             # <<<<<<<<<<<<<<
16083  *             self.pileup_iter = bam_plp_init( &__advance_all, &self.iterdata )
16084  *         elif self.stepper == "samtools":
16085  */
16086   __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;}
16087   __Pyx_GOTREF(__pyx_t_4);
16088   __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;}
16089   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
16090   if (!__pyx_t_6) {
16091     __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;}
16092     __Pyx_GOTREF(__pyx_t_4);
16093     __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;}
16094     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
16095     __pyx_t_8 = __pyx_t_7;
16096   } else {
16097     __pyx_t_8 = __pyx_t_6;
16098   }
16099   if (__pyx_t_8) {
16100
16101     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1674
16102  * 
16103  *         if self.stepper == None or self.stepper == "all":
16104  *             self.pileup_iter = bam_plp_init( &__advance_all, &self.iterdata )             # <<<<<<<<<<<<<<
16105  *         elif self.stepper == "samtools":
16106  *             self.pileup_iter = bam_plp_init( &__advance_snpcalls, &self.iterdata )
16107  */
16108     __pyx_v_self->pileup_iter = bam_plp_init((&__pyx_f_9csamtools___advance_all), (&__pyx_v_self->iterdata));
16109     goto __pyx_L4;
16110   }
16111
16112   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1675
16113  *         if self.stepper == None or self.stepper == "all":
16114  *             self.pileup_iter = bam_plp_init( &__advance_all, &self.iterdata )
16115  *         elif self.stepper == "samtools":             # <<<<<<<<<<<<<<
16116  *             self.pileup_iter = bam_plp_init( &__advance_snpcalls, &self.iterdata )
16117  *         else:
16118  */
16119   __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;}
16120   __Pyx_GOTREF(__pyx_t_4);
16121   __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;}
16122   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
16123   if (__pyx_t_8) {
16124
16125     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1676
16126  *             self.pileup_iter = bam_plp_init( &__advance_all, &self.iterdata )
16127  *         elif self.stepper == "samtools":
16128  *             self.pileup_iter = bam_plp_init( &__advance_snpcalls, &self.iterdata )             # <<<<<<<<<<<<<<
16129  *         else:
16130  *             raise ValueError( "unknown stepper option `%s` in IteratorColumn" % self.stepper)
16131  */
16132     __pyx_v_self->pileup_iter = bam_plp_init((&__pyx_f_9csamtools___advance_snpcalls), (&__pyx_v_self->iterdata));
16133     goto __pyx_L4;
16134   }
16135   /*else*/ {
16136
16137     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1678
16138  *             self.pileup_iter = bam_plp_init( &__advance_snpcalls, &self.iterdata )
16139  *         else:
16140  *             raise ValueError( "unknown stepper option `%s` in IteratorColumn" % self.stepper)             # <<<<<<<<<<<<<<
16141  * 
16142  *         bam_plp_set_mask( self.pileup_iter, self.mask )
16143  */
16144     __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;}
16145     __Pyx_GOTREF(((PyObject *)__pyx_t_4));
16146     __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;}
16147     __Pyx_GOTREF(__pyx_t_5);
16148     PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_4));
16149     __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
16150     __pyx_t_4 = 0;
16151     __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;}
16152     __Pyx_GOTREF(__pyx_t_4);
16153     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
16154     __Pyx_Raise(__pyx_t_4, 0, 0);
16155     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
16156     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1678; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
16157   }
16158   __pyx_L4:;
16159
16160   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1680
16161  *             raise ValueError( "unknown stepper option `%s` in IteratorColumn" % self.stepper)
16162  * 
16163  *         bam_plp_set_mask( self.pileup_iter, self.mask )             # <<<<<<<<<<<<<<
16164  * 
16165  *     cdef reset( self, tid, start, end ):
16166  */
16167   bam_plp_set_mask(__pyx_v_self->pileup_iter, __pyx_v_self->mask);
16168
16169   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
16170   goto __pyx_L0;
16171   __pyx_L1_error:;
16172   __Pyx_XDECREF(__pyx_t_1);
16173   __Pyx_XDECREF(__pyx_t_2);
16174   __Pyx_XDECREF(__pyx_t_3);
16175   __Pyx_XDECREF(__pyx_t_4);
16176   __Pyx_XDECREF(__pyx_t_5);
16177   __Pyx_AddTraceback("csamtools.IteratorColumn.setupIteratorData");
16178   __pyx_r = 0;
16179   __pyx_L0:;
16180   __Pyx_XGIVEREF(__pyx_r);
16181   __Pyx_TraceReturn(__pyx_r);
16182   __Pyx_RefNannyFinishContext();
16183   return __pyx_r;
16184 }
16185
16186 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1682
16187  *         bam_plp_set_mask( self.pileup_iter, self.mask )
16188  * 
16189  *     cdef reset( self, tid, start, end ):             # <<<<<<<<<<<<<<
16190  *         '''reset iterator position.
16191  * 
16192  */
16193
16194 static  PyObject *__pyx_f_9csamtools_14IteratorColumn_reset(struct __pyx_obj_9csamtools_IteratorColumn *__pyx_v_self, PyObject *__pyx_v_tid, PyObject *__pyx_v_start, PyObject *__pyx_v_end) {
16195   PyObject *__pyx_r = NULL;
16196   PyObject *__pyx_t_1 = NULL;
16197   PyObject *__pyx_t_2 = NULL;
16198   PyObject *__pyx_t_3 = NULL;
16199   int __pyx_t_4;
16200   __Pyx_TraceDeclarations
16201   __Pyx_RefNannySetupContext("reset");
16202   __Pyx_TraceCall("reset", __pyx_f[0], 1682);
16203
16204   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1688
16205  *         having to incur the full set-up costs.
16206  *         '''
16207  *         self.iter = IteratorRowRegion( self.samfile, tid, start, end, reopen = 0 )             # <<<<<<<<<<<<<<
16208  *         self.iterdata.iter = self.iter.iter
16209  * 
16210  */
16211   __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;}
16212   __Pyx_GOTREF(__pyx_t_1);
16213   __Pyx_INCREF(((PyObject *)__pyx_v_self->samfile));
16214   PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self->samfile));
16215   __Pyx_GIVEREF(((PyObject *)__pyx_v_self->samfile));
16216   __Pyx_INCREF(__pyx_v_tid);
16217   PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_tid);
16218   __Pyx_GIVEREF(__pyx_v_tid);
16219   __Pyx_INCREF(__pyx_v_start);
16220   PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_start);
16221   __Pyx_GIVEREF(__pyx_v_start);
16222   __Pyx_INCREF(__pyx_v_end);
16223   PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_v_end);
16224   __Pyx_GIVEREF(__pyx_v_end);
16225   __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;}
16226   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
16227   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;}
16228   __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;}
16229   __Pyx_GOTREF(__pyx_t_3);
16230   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
16231   __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
16232   __Pyx_GIVEREF(__pyx_t_3);
16233   __Pyx_GOTREF(__pyx_v_self->iter);
16234   __Pyx_DECREF(((PyObject *)__pyx_v_self->iter));
16235   __pyx_v_self->iter = ((struct __pyx_obj_9csamtools_IteratorRowRegion *)__pyx_t_3);
16236   __pyx_t_3 = 0;
16237
16238   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1689
16239  *         '''
16240  *         self.iter = IteratorRowRegion( self.samfile, tid, start, end, reopen = 0 )
16241  *         self.iterdata.iter = self.iter.iter             # <<<<<<<<<<<<<<
16242  * 
16243  *         # invalidate sequence if different tid
16244  */
16245   __pyx_v_self->iterdata.iter = __pyx_v_self->iter->iter;
16246
16247   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1692
16248  * 
16249  *         # invalidate sequence if different tid
16250  *         if self.tid != tid:             # <<<<<<<<<<<<<<
16251  *             if self.iterdata.seq != NULL: free( self.iterdata.seq )
16252  *             self.iterdata.seq = NULL
16253  */
16254   __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;}
16255   __Pyx_GOTREF(__pyx_t_3);
16256   __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;}
16257   __Pyx_GOTREF(__pyx_t_2);
16258   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
16259   __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;}
16260   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
16261   if (__pyx_t_4) {
16262
16263     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1693
16264  *         # invalidate sequence if different tid
16265  *         if self.tid != tid:
16266  *             if self.iterdata.seq != NULL: free( self.iterdata.seq )             # <<<<<<<<<<<<<<
16267  *             self.iterdata.seq = NULL
16268  *             self.iterdata.tid = -1
16269  */
16270     __pyx_t_4 = (__pyx_v_self->iterdata.seq != NULL);
16271     if (__pyx_t_4) {
16272       free(__pyx_v_self->iterdata.seq);
16273       goto __pyx_L4;
16274     }
16275     __pyx_L4:;
16276
16277     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1694
16278  *         if self.tid != tid:
16279  *             if self.iterdata.seq != NULL: free( self.iterdata.seq )
16280  *             self.iterdata.seq = NULL             # <<<<<<<<<<<<<<
16281  *             self.iterdata.tid = -1
16282  * 
16283  */
16284     __pyx_v_self->iterdata.seq = NULL;
16285
16286     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1695
16287  *             if self.iterdata.seq != NULL: free( self.iterdata.seq )
16288  *             self.iterdata.seq = NULL
16289  *             self.iterdata.tid = -1             # <<<<<<<<<<<<<<
16290  * 
16291  *         # self.pileup_iter = bam_plp_init( &__advancepileup, &self.iterdata )
16292  */
16293     __pyx_v_self->iterdata.tid = -1;
16294     goto __pyx_L3;
16295   }
16296   __pyx_L3:;
16297
16298   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1698
16299  * 
16300  *         # self.pileup_iter = bam_plp_init( &__advancepileup, &self.iterdata )
16301  *         bam_plp_reset(self.pileup_iter)             # <<<<<<<<<<<<<<
16302  * 
16303  *     def __dealloc__(self):
16304  */
16305   bam_plp_reset(__pyx_v_self->pileup_iter);
16306
16307   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
16308   goto __pyx_L0;
16309   __pyx_L1_error:;
16310   __Pyx_XDECREF(__pyx_t_1);
16311   __Pyx_XDECREF(__pyx_t_2);
16312   __Pyx_XDECREF(__pyx_t_3);
16313   __Pyx_AddTraceback("csamtools.IteratorColumn.reset");
16314   __pyx_r = 0;
16315   __pyx_L0:;
16316   __Pyx_XGIVEREF(__pyx_r);
16317   __Pyx_TraceReturn(__pyx_r);
16318   __Pyx_RefNannyFinishContext();
16319   return __pyx_r;
16320 }
16321
16322 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1700
16323  *         bam_plp_reset(self.pileup_iter)
16324  * 
16325  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
16326  *         # reset in order to avoid memory leak messages for iterators that have
16327  *         # not been fully consumed
16328  */
16329
16330 static void __pyx_pf_9csamtools_14IteratorColumn___dealloc__(PyObject *__pyx_v_self); /*proto*/
16331 static void __pyx_pf_9csamtools_14IteratorColumn___dealloc__(PyObject *__pyx_v_self) {
16332   int __pyx_t_1;
16333   __Pyx_TraceDeclarations
16334   __Pyx_RefNannySetupContext("__dealloc__");
16335   __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1700);
16336
16337   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1703
16338  *         # reset in order to avoid memory leak messages for iterators that have
16339  *         # not been fully consumed
16340  *         if self.pileup_iter != <bam_plp_t>NULL:             # <<<<<<<<<<<<<<
16341  *             bam_plp_reset(self.pileup_iter)
16342  *             bam_plp_destroy(self.pileup_iter)
16343  */
16344   __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->pileup_iter != ((bam_plp_t)NULL));
16345   if (__pyx_t_1) {
16346
16347     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1704
16348  *         # not been fully consumed
16349  *         if self.pileup_iter != <bam_plp_t>NULL:
16350  *             bam_plp_reset(self.pileup_iter)             # <<<<<<<<<<<<<<
16351  *             bam_plp_destroy(self.pileup_iter)
16352  *             self.pileup_iter = <bam_plp_t>NULL
16353  */
16354     bam_plp_reset(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->pileup_iter);
16355
16356     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1705
16357  *         if self.pileup_iter != <bam_plp_t>NULL:
16358  *             bam_plp_reset(self.pileup_iter)
16359  *             bam_plp_destroy(self.pileup_iter)             # <<<<<<<<<<<<<<
16360  *             self.pileup_iter = <bam_plp_t>NULL
16361  * 
16362  */
16363     bam_plp_destroy(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->pileup_iter);
16364
16365     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1706
16366  *             bam_plp_reset(self.pileup_iter)
16367  *             bam_plp_destroy(self.pileup_iter)
16368  *             self.pileup_iter = <bam_plp_t>NULL             # <<<<<<<<<<<<<<
16369  * 
16370  *         if self.iterdata.seq != NULL:
16371  */
16372     ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->pileup_iter = ((bam_plp_t)NULL);
16373     goto __pyx_L5;
16374   }
16375   __pyx_L5:;
16376
16377   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1708
16378  *             self.pileup_iter = <bam_plp_t>NULL
16379  * 
16380  *         if self.iterdata.seq != NULL:             # <<<<<<<<<<<<<<
16381  *             free(self.iterdata.seq)
16382  *             self.iterdata.seq = NULL
16383  */
16384   __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->iterdata.seq != NULL);
16385   if (__pyx_t_1) {
16386
16387     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1709
16388  * 
16389  *         if self.iterdata.seq != NULL:
16390  *             free(self.iterdata.seq)             # <<<<<<<<<<<<<<
16391  *             self.iterdata.seq = NULL
16392  * 
16393  */
16394     free(((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->iterdata.seq);
16395
16396     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1710
16397  *         if self.iterdata.seq != NULL:
16398  *             free(self.iterdata.seq)
16399  *             self.iterdata.seq = NULL             # <<<<<<<<<<<<<<
16400  * 
16401  * cdef class IteratorColumnRegion(IteratorColumn):
16402  */
16403     ((struct __pyx_obj_9csamtools_IteratorColumn *)__pyx_v_self)->iterdata.seq = NULL;
16404     goto __pyx_L6;
16405   }
16406   __pyx_L6:;
16407
16408   __Pyx_TraceReturn(Py_None);
16409   __Pyx_RefNannyFinishContext();
16410 }
16411
16412 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1715
16413  *     '''iterates over a region only.
16414  *     '''
16415  *     def __cinit__(self, Samfile samfile,             # <<<<<<<<<<<<<<
16416  *                   int tid = 0,
16417  *                   int start = 0,
16418  */
16419
16420 static int __pyx_pf_9csamtools_20IteratorColumnRegion___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
16421 static int __pyx_pf_9csamtools_20IteratorColumnRegion___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
16422   struct __pyx_obj_9csamtools_Samfile *__pyx_v_samfile = 0;
16423   int __pyx_v_tid;
16424   int __pyx_v_start;
16425   int __pyx_v_end;
16426   PyObject *__pyx_v_kwargs = 0;
16427   int __pyx_r;
16428   PyObject *__pyx_t_1 = NULL;
16429   struct __pyx_opt_args_9csamtools_14IteratorColumn_setupIteratorData __pyx_t_2;
16430   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__samfile,&__pyx_n_s__tid,&__pyx_n_s__start,&__pyx_n_s__end,0};
16431   __Pyx_TraceDeclarations
16432   __Pyx_RefNannySetupContext("__cinit__");
16433   __Pyx_TraceCall("__cinit__", __pyx_f[0], 1715);
16434   __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
16435   __Pyx_GOTREF(__pyx_v_kwargs);
16436   if (unlikely(__pyx_kwds)) {
16437     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
16438     PyObject* values[4] = {0,0,0,0};
16439     switch (PyTuple_GET_SIZE(__pyx_args)) {
16440       case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
16441       case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
16442       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
16443       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
16444       case  0: break;
16445       default: goto __pyx_L5_argtuple_error;
16446     }
16447     switch (PyTuple_GET_SIZE(__pyx_args)) {
16448       case  0:
16449       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__samfile);
16450       if (likely(values[0])) kw_args--;
16451       else goto __pyx_L5_argtuple_error;
16452       case  1:
16453       if (kw_args > 0) {
16454         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__tid);
16455         if (value) { values[1] = value; kw_args--; }
16456       }
16457       case  2:
16458       if (kw_args > 0) {
16459         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start);
16460         if (value) { values[2] = value; kw_args--; }
16461       }
16462       case  3:
16463       if (kw_args > 0) {
16464         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end);
16465         if (value) { values[3] = value; kw_args--; }
16466       }
16467     }
16468     if (unlikely(kw_args > 0)) {
16469       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;}
16470     }
16471     __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)values[0]);
16472     if (values[1]) {
16473       __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;}
16474     } else {
16475       __pyx_v_tid = ((int)0);
16476     }
16477     if (values[2]) {
16478       __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;}
16479     } else {
16480       __pyx_v_start = ((int)0);
16481     }
16482     if (values[3]) {
16483       __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;}
16484     } else {
16485       __pyx_v_end = __pyx_k_58;
16486     }
16487   } else {
16488     __pyx_v_tid = ((int)0);
16489     __pyx_v_start = ((int)0);
16490     __pyx_v_end = __pyx_k_58;
16491     switch (PyTuple_GET_SIZE(__pyx_args)) {
16492       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;}
16493       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;}
16494       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;}
16495       case  1: __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)PyTuple_GET_ITEM(__pyx_args, 0));
16496       break;
16497       default: goto __pyx_L5_argtuple_error;
16498     }
16499   }
16500   goto __pyx_L4_argument_unpacking_done;
16501   __pyx_L5_argtuple_error:;
16502   __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;}
16503   __pyx_L3_error:;
16504   __Pyx_DECREF(__pyx_v_kwargs);
16505   __Pyx_AddTraceback("csamtools.IteratorColumnRegion.__cinit__");
16506   __Pyx_RefNannyFinishContext();
16507   return -1;
16508   __pyx_L4_argument_unpacking_done:;
16509   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;}
16510
16511   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1722
16512  * 
16513  *         # initialize iterator
16514  *         self.setupIteratorData( tid, start, end, 1 )             # <<<<<<<<<<<<<<
16515  * 
16516  *     def __next__(self):
16517  */
16518   __pyx_t_2.__pyx_n = 1;
16519   __pyx_t_2.reopen = 1;
16520   __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;}
16521   __Pyx_GOTREF(__pyx_t_1);
16522   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
16523
16524   __pyx_r = 0;
16525   goto __pyx_L0;
16526   __pyx_L1_error:;
16527   __Pyx_XDECREF(__pyx_t_1);
16528   __Pyx_AddTraceback("csamtools.IteratorColumnRegion.__cinit__");
16529   __pyx_r = -1;
16530   __pyx_L0:;
16531   __Pyx_DECREF(__pyx_v_kwargs);
16532   __Pyx_TraceReturn(Py_None);
16533   __Pyx_RefNannyFinishContext();
16534   return __pyx_r;
16535 }
16536
16537 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1724
16538  *         self.setupIteratorData( tid, start, end, 1 )
16539  * 
16540  *     def __next__(self):             # <<<<<<<<<<<<<<
16541  *         """python version of next().
16542  *         """
16543  */
16544
16545 static PyObject *__pyx_pf_9csamtools_20IteratorColumnRegion___next__(PyObject *__pyx_v_self); /*proto*/
16546 static char __pyx_doc_9csamtools_20IteratorColumnRegion___next__[] = "python version of next().\n        ";
16547 struct wrapperbase __pyx_wrapperbase_9csamtools_20IteratorColumnRegion___next__;
16548 static PyObject *__pyx_pf_9csamtools_20IteratorColumnRegion___next__(PyObject *__pyx_v_self) {
16549   PyObject *__pyx_r = NULL;
16550   int __pyx_t_1;
16551   PyObject *__pyx_t_2 = NULL;
16552   PyObject *__pyx_t_3 = NULL;
16553   __Pyx_TraceDeclarations
16554   __Pyx_RefNannySetupContext("__next__");
16555   __Pyx_TraceCall("__next__", __pyx_f[0], 1724);
16556
16557   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1728
16558  *         """
16559  * 
16560  *         while 1:             # <<<<<<<<<<<<<<
16561  *             self.cnext()
16562  *             if self.n_plp < 0:
16563  */
16564   while (1) {
16565     if (!1) break;
16566
16567     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1729
16568  * 
16569  *         while 1:
16570  *             self.cnext()             # <<<<<<<<<<<<<<
16571  *             if self.n_plp < 0:
16572  *                 raise ValueError("error during iteration" )
16573  */
16574     ((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));
16575
16576     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1730
16577  *         while 1:
16578  *             self.cnext()
16579  *             if self.n_plp < 0:             # <<<<<<<<<<<<<<
16580  *                 raise ValueError("error during iteration" )
16581  * 
16582  */
16583     __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorColumnRegion *)__pyx_v_self)->__pyx_base.n_plp < 0);
16584     if (__pyx_t_1) {
16585
16586       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1731
16587  *             self.cnext()
16588  *             if self.n_plp < 0:
16589  *                 raise ValueError("error during iteration" )             # <<<<<<<<<<<<<<
16590  * 
16591  *             if self.plp == NULL:
16592  */
16593       __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;}
16594       __Pyx_GOTREF(__pyx_t_2);
16595       __Pyx_INCREF(((PyObject *)__pyx_kp_s_59));
16596       PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_59));
16597       __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_59));
16598       __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;}
16599       __Pyx_GOTREF(__pyx_t_3);
16600       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
16601       __Pyx_Raise(__pyx_t_3, 0, 0);
16602       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
16603       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
16604       goto __pyx_L7;
16605     }
16606     __pyx_L7:;
16607
16608     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1733
16609  *                 raise ValueError("error during iteration" )
16610  * 
16611  *             if self.plp == NULL:             # <<<<<<<<<<<<<<
16612  *                 raise StopIteration
16613  * 
16614  */
16615     __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorColumnRegion *)__pyx_v_self)->__pyx_base.plp == NULL);
16616     if (__pyx_t_1) {
16617
16618       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1734
16619  * 
16620  *             if self.plp == NULL:
16621  *                 raise StopIteration             # <<<<<<<<<<<<<<
16622  * 
16623  *             return makePileupProxy( <bam_pileup1_t*>self.plp,
16624  */
16625       __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
16626       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1734; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
16627       goto __pyx_L8;
16628     }
16629     __pyx_L8:;
16630
16631     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1736
16632  *                 raise StopIteration
16633  * 
16634  *             return makePileupProxy( <bam_pileup1_t*>self.plp,             # <<<<<<<<<<<<<<
16635  *                                      self.tid,
16636  *                                      self.pos,
16637  */
16638     __Pyx_XDECREF(__pyx_r);
16639
16640     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1739
16641  *                                      self.tid,
16642  *                                      self.pos,
16643  *                                      self.n_plp )             # <<<<<<<<<<<<<<
16644  * 
16645  * cdef class IteratorColumnAllRefs(IteratorColumn):
16646  */
16647     __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;}
16648     __Pyx_GOTREF(__pyx_t_3);
16649     __pyx_r = __pyx_t_3;
16650     __pyx_t_3 = 0;
16651     goto __pyx_L0;
16652   }
16653
16654   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
16655   goto __pyx_L0;
16656   __pyx_L1_error:;
16657   __Pyx_XDECREF(__pyx_t_2);
16658   __Pyx_XDECREF(__pyx_t_3);
16659   __Pyx_AddTraceback("csamtools.IteratorColumnRegion.__next__");
16660   __pyx_r = NULL;
16661   __pyx_L0:;
16662   __Pyx_XGIVEREF(__pyx_r);
16663   __Pyx_TraceReturn(__pyx_r);
16664   __Pyx_RefNannyFinishContext();
16665   return __pyx_r;
16666 }
16667
16668 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1745
16669  *     """
16670  * 
16671  *     def __cinit__(self,             # <<<<<<<<<<<<<<
16672  *                   Samfile samfile,
16673  *                   **kwargs ):
16674  */
16675
16676 static int __pyx_pf_9csamtools_21IteratorColumnAllRefs___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
16677 static int __pyx_pf_9csamtools_21IteratorColumnAllRefs___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
16678   struct __pyx_obj_9csamtools_Samfile *__pyx_v_samfile = 0;
16679   PyObject *__pyx_v_kwargs = 0;
16680   int __pyx_r;
16681   PyObject *__pyx_t_1 = NULL;
16682   int __pyx_t_2;
16683   int __pyx_t_3;
16684   struct __pyx_opt_args_9csamtools_14IteratorColumn_setupIteratorData __pyx_t_4;
16685   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__samfile,0};
16686   __Pyx_TraceDeclarations
16687   __Pyx_RefNannySetupContext("__cinit__");
16688   __Pyx_TraceCall("__cinit__", __pyx_f[0], 1745);
16689   __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
16690   __Pyx_GOTREF(__pyx_v_kwargs);
16691   if (unlikely(__pyx_kwds)) {
16692     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
16693     PyObject* values[1] = {0};
16694     switch (PyTuple_GET_SIZE(__pyx_args)) {
16695       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
16696       case  0: break;
16697       default: goto __pyx_L5_argtuple_error;
16698     }
16699     switch (PyTuple_GET_SIZE(__pyx_args)) {
16700       case  0:
16701       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__samfile);
16702       if (likely(values[0])) kw_args--;
16703       else goto __pyx_L5_argtuple_error;
16704     }
16705     if (unlikely(kw_args > 0)) {
16706       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;}
16707     }
16708     __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)values[0]);
16709   } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
16710     goto __pyx_L5_argtuple_error;
16711   } else {
16712     __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)PyTuple_GET_ITEM(__pyx_args, 0));
16713   }
16714   goto __pyx_L4_argument_unpacking_done;
16715   __pyx_L5_argtuple_error:;
16716   __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;}
16717   __pyx_L3_error:;
16718   __Pyx_DECREF(__pyx_v_kwargs);
16719   __Pyx_AddTraceback("csamtools.IteratorColumnAllRefs.__cinit__");
16720   __Pyx_RefNannyFinishContext();
16721   return -1;
16722   __pyx_L4_argument_unpacking_done:;
16723   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;}
16724
16725   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1750
16726  * 
16727  *         # no iteration over empty files
16728  *         if not samfile.nreferences: raise StopIteration             # <<<<<<<<<<<<<<
16729  * 
16730  *         # initialize iterator
16731  */
16732   __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;}
16733   __Pyx_GOTREF(__pyx_t_1);
16734   __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;}
16735   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
16736   __pyx_t_3 = (!__pyx_t_2);
16737   if (__pyx_t_3) {
16738     __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
16739     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1750; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
16740     goto __pyx_L6;
16741   }
16742   __pyx_L6:;
16743
16744   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1753
16745  * 
16746  *         # initialize iterator
16747  *         self.setupIteratorData( self.tid, 0, max_pos, 1 )             # <<<<<<<<<<<<<<
16748  * 
16749  *     def __next__(self):
16750  */
16751   __pyx_t_4.__pyx_n = 1;
16752   __pyx_t_4.reopen = 1;
16753   __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;}
16754   __Pyx_GOTREF(__pyx_t_1);
16755   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
16756
16757   __pyx_r = 0;
16758   goto __pyx_L0;
16759   __pyx_L1_error:;
16760   __Pyx_XDECREF(__pyx_t_1);
16761   __Pyx_AddTraceback("csamtools.IteratorColumnAllRefs.__cinit__");
16762   __pyx_r = -1;
16763   __pyx_L0:;
16764   __Pyx_DECREF(__pyx_v_kwargs);
16765   __Pyx_TraceReturn(Py_None);
16766   __Pyx_RefNannyFinishContext();
16767   return __pyx_r;
16768 }
16769
16770 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1755
16771  *         self.setupIteratorData( self.tid, 0, max_pos, 1 )
16772  * 
16773  *     def __next__(self):             # <<<<<<<<<<<<<<
16774  *         """python version of next().
16775  *         """
16776  */
16777
16778 static PyObject *__pyx_pf_9csamtools_21IteratorColumnAllRefs___next__(PyObject *__pyx_v_self); /*proto*/
16779 static char __pyx_doc_9csamtools_21IteratorColumnAllRefs___next__[] = "python version of next().\n        ";
16780 struct wrapperbase __pyx_wrapperbase_9csamtools_21IteratorColumnAllRefs___next__;
16781 static PyObject *__pyx_pf_9csamtools_21IteratorColumnAllRefs___next__(PyObject *__pyx_v_self) {
16782   PyObject *__pyx_r = NULL;
16783   int __pyx_t_1;
16784   PyObject *__pyx_t_2 = NULL;
16785   PyObject *__pyx_t_3 = NULL;
16786   PyObject *__pyx_t_4 = NULL;
16787   struct __pyx_opt_args_9csamtools_14IteratorColumn_setupIteratorData __pyx_t_5;
16788   __Pyx_TraceDeclarations
16789   __Pyx_RefNannySetupContext("__next__");
16790   __Pyx_TraceCall("__next__", __pyx_f[0], 1755);
16791
16792   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1759
16793  *         """
16794  * 
16795  *         while 1:             # <<<<<<<<<<<<<<
16796  *             self.cnext()
16797  * 
16798  */
16799   while (1) {
16800     if (!1) break;
16801
16802     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1760
16803  * 
16804  *         while 1:
16805  *             self.cnext()             # <<<<<<<<<<<<<<
16806  * 
16807  *             if self.n_plp < 0:
16808  */
16809     ((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));
16810
16811     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1762
16812  *             self.cnext()
16813  * 
16814  *             if self.n_plp < 0:             # <<<<<<<<<<<<<<
16815  *                 raise ValueError("error during iteration" )
16816  * 
16817  */
16818     __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.n_plp < 0);
16819     if (__pyx_t_1) {
16820
16821       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1763
16822  * 
16823  *             if self.n_plp < 0:
16824  *                 raise ValueError("error during iteration" )             # <<<<<<<<<<<<<<
16825  * 
16826  *             # return result, if within same reference
16827  */
16828       __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;}
16829       __Pyx_GOTREF(__pyx_t_2);
16830       __Pyx_INCREF(((PyObject *)__pyx_kp_s_59));
16831       PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_59));
16832       __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_59));
16833       __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;}
16834       __Pyx_GOTREF(__pyx_t_3);
16835       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
16836       __Pyx_Raise(__pyx_t_3, 0, 0);
16837       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
16838       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
16839       goto __pyx_L7;
16840     }
16841     __pyx_L7:;
16842
16843     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1766
16844  * 
16845  *             # return result, if within same reference
16846  *             if self.plp != NULL:             # <<<<<<<<<<<<<<
16847  *                 return makePileupProxy( <bam_pileup1_t*>self.plp,
16848  *                                          self.tid,
16849  */
16850     __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.plp != NULL);
16851     if (__pyx_t_1) {
16852
16853       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1767
16854  *             # return result, if within same reference
16855  *             if self.plp != NULL:
16856  *                 return makePileupProxy( <bam_pileup1_t*>self.plp,             # <<<<<<<<<<<<<<
16857  *                                          self.tid,
16858  *                                          self.pos,
16859  */
16860       __Pyx_XDECREF(__pyx_r);
16861
16862       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1770
16863  *                                          self.tid,
16864  *                                          self.pos,
16865  *                                          self.n_plp )             # <<<<<<<<<<<<<<
16866  * 
16867  *             # otherwise, proceed to next reference or stop
16868  */
16869       __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;}
16870       __Pyx_GOTREF(__pyx_t_3);
16871       __pyx_r = __pyx_t_3;
16872       __pyx_t_3 = 0;
16873       goto __pyx_L0;
16874       goto __pyx_L8;
16875     }
16876     __pyx_L8:;
16877
16878     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1773
16879  * 
16880  *             # otherwise, proceed to next reference or stop
16881  *             self.tid += 1             # <<<<<<<<<<<<<<
16882  *             if self.tid < self.samfile.nreferences:
16883  *                 self.setupIteratorData( self.tid, 0, max_pos, 0 )
16884  */
16885     ((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)__pyx_v_self)->__pyx_base.tid += 1;
16886
16887     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1774
16888  *             # otherwise, proceed to next reference or stop
16889  *             self.tid += 1
16890  *             if self.tid < self.samfile.nreferences:             # <<<<<<<<<<<<<<
16891  *                 self.setupIteratorData( self.tid, 0, max_pos, 0 )
16892  *             else:
16893  */
16894     __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;}
16895     __Pyx_GOTREF(__pyx_t_3);
16896     __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;}
16897     __Pyx_GOTREF(__pyx_t_2);
16898     __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;}
16899     __Pyx_GOTREF(__pyx_t_4);
16900     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
16901     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
16902     __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;}
16903     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
16904     if (__pyx_t_1) {
16905
16906       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1775
16907  *             self.tid += 1
16908  *             if self.tid < self.samfile.nreferences:
16909  *                 self.setupIteratorData( self.tid, 0, max_pos, 0 )             # <<<<<<<<<<<<<<
16910  *             else:
16911  *                 raise StopIteration
16912  */
16913       __pyx_t_5.__pyx_n = 1;
16914       __pyx_t_5.reopen = 0;
16915       __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;}
16916       __Pyx_GOTREF(__pyx_t_4);
16917       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
16918       goto __pyx_L9;
16919     }
16920     /*else*/ {
16921
16922       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1777
16923  *                 self.setupIteratorData( self.tid, 0, max_pos, 0 )
16924  *             else:
16925  *                 raise StopIteration             # <<<<<<<<<<<<<<
16926  * 
16927  * ##-------------------------------------------------------------------
16928  */
16929       __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
16930       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
16931     }
16932     __pyx_L9:;
16933   }
16934
16935   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
16936   goto __pyx_L0;
16937   __pyx_L1_error:;
16938   __Pyx_XDECREF(__pyx_t_2);
16939   __Pyx_XDECREF(__pyx_t_3);
16940   __Pyx_XDECREF(__pyx_t_4);
16941   __Pyx_AddTraceback("csamtools.IteratorColumnAllRefs.__next__");
16942   __pyx_r = NULL;
16943   __pyx_L0:;
16944   __Pyx_XGIVEREF(__pyx_r);
16945   __Pyx_TraceReturn(__pyx_r);
16946   __Pyx_RefNannyFinishContext();
16947   return __pyx_r;
16948 }
16949
16950 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1782
16951  * ##-------------------------------------------------------------------
16952  * ##-------------------------------------------------------------------
16953  * cdef inline int32_t query_start(bam1_t *src) except -1:             # <<<<<<<<<<<<<<
16954  *     cdef uint32_t * cigar_p, op
16955  *     cdef uint32_t k
16956  */
16957
16958 static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_start(bam1_t *__pyx_v_src) {
16959   uint32_t *__pyx_v_cigar_p;
16960   uint32_t __pyx_v_op;
16961   uint32_t __pyx_v_k;
16962   uint32_t __pyx_v_start_offset;
16963   int32_t __pyx_r;
16964   uint32_t __pyx_t_1;
16965   int __pyx_t_2;
16966   int __pyx_t_3;
16967   int __pyx_t_4;
16968   __Pyx_TraceDeclarations
16969   __Pyx_RefNannySetupContext("query_start");
16970   __Pyx_TraceCall("query_start", __pyx_f[0], 1782);
16971
16972   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1785
16973  *     cdef uint32_t * cigar_p, op
16974  *     cdef uint32_t k
16975  *     cdef uint32_t start_offset = 0             # <<<<<<<<<<<<<<
16976  * 
16977  *     if src.core.n_cigar:
16978  */
16979   __pyx_v_start_offset = 0;
16980
16981   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1787
16982  *     cdef uint32_t start_offset = 0
16983  * 
16984  *     if src.core.n_cigar:             # <<<<<<<<<<<<<<
16985  *         cigar_p = bam1_cigar(src);
16986  *         for k from 0 <= k < src.core.n_cigar:
16987  */
16988   if (__pyx_v_src->core.n_cigar) {
16989
16990     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1788
16991  * 
16992  *     if src.core.n_cigar:
16993  *         cigar_p = bam1_cigar(src);             # <<<<<<<<<<<<<<
16994  *         for k from 0 <= k < src.core.n_cigar:
16995  *             op = cigar_p[k] & BAM_CIGAR_MASK
16996  */
16997     __pyx_v_cigar_p = bam1_cigar(__pyx_v_src);
16998
16999     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1789
17000  *     if src.core.n_cigar:
17001  *         cigar_p = bam1_cigar(src);
17002  *         for k from 0 <= k < src.core.n_cigar:             # <<<<<<<<<<<<<<
17003  *             op = cigar_p[k] & BAM_CIGAR_MASK
17004  *             if op==BAM_CHARD_CLIP:
17005  */
17006     __pyx_t_1 = __pyx_v_src->core.n_cigar;
17007     for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_1; __pyx_v_k++) {
17008
17009       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1790
17010  *         cigar_p = bam1_cigar(src);
17011  *         for k from 0 <= k < src.core.n_cigar:
17012  *             op = cigar_p[k] & BAM_CIGAR_MASK             # <<<<<<<<<<<<<<
17013  *             if op==BAM_CHARD_CLIP:
17014  *                 if start_offset!=0 and start_offset!=src.core.l_qseq:
17015  */
17016       __pyx_v_op = ((__pyx_v_cigar_p[__pyx_v_k]) & 15);
17017
17018       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1791
17019  *         for k from 0 <= k < src.core.n_cigar:
17020  *             op = cigar_p[k] & BAM_CIGAR_MASK
17021  *             if op==BAM_CHARD_CLIP:             # <<<<<<<<<<<<<<
17022  *                 if start_offset!=0 and start_offset!=src.core.l_qseq:
17023  *                     PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string')
17024  */
17025       switch (__pyx_v_op) {
17026         case 5:
17027
17028         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1792
17029  *             op = cigar_p[k] & BAM_CIGAR_MASK
17030  *             if op==BAM_CHARD_CLIP:
17031  *                 if start_offset!=0 and start_offset!=src.core.l_qseq:             # <<<<<<<<<<<<<<
17032  *                     PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string')
17033  *                     return -1
17034  */
17035         __pyx_t_2 = (__pyx_v_start_offset != 0);
17036         if (__pyx_t_2) {
17037           __pyx_t_3 = (__pyx_v_start_offset != __pyx_v_src->core.l_qseq);
17038           __pyx_t_4 = __pyx_t_3;
17039         } else {
17040           __pyx_t_4 = __pyx_t_2;
17041         }
17042         if (__pyx_t_4) {
17043
17044           /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1793
17045  *             if op==BAM_CHARD_CLIP:
17046  *                 if start_offset!=0 and start_offset!=src.core.l_qseq:
17047  *                     PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string')             # <<<<<<<<<<<<<<
17048  *                     return -1
17049  *             elif op==BAM_CSOFT_CLIP:
17050  */
17051           PyErr_SetString(__pyx_builtin_ValueError, __pyx_k_60);
17052
17053           /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1794
17054  *                 if start_offset!=0 and start_offset!=src.core.l_qseq:
17055  *                     PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string')
17056  *                     return -1             # <<<<<<<<<<<<<<
17057  *             elif op==BAM_CSOFT_CLIP:
17058  *                 start_offset += cigar_p[k] >> BAM_CIGAR_SHIFT
17059  */
17060           __pyx_r = -1;
17061           goto __pyx_L0;
17062           goto __pyx_L6;
17063         }
17064         __pyx_L6:;
17065         break;
17066
17067         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1795
17068  *                     PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string')
17069  *                     return -1
17070  *             elif op==BAM_CSOFT_CLIP:             # <<<<<<<<<<<<<<
17071  *                 start_offset += cigar_p[k] >> BAM_CIGAR_SHIFT
17072  *             else:
17073  */
17074         case 4:
17075
17076         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1796
17077  *                     return -1
17078  *             elif op==BAM_CSOFT_CLIP:
17079  *                 start_offset += cigar_p[k] >> BAM_CIGAR_SHIFT             # <<<<<<<<<<<<<<
17080  *             else:
17081  *                 break
17082  */
17083         __pyx_v_start_offset += ((__pyx_v_cigar_p[__pyx_v_k]) >> 4);
17084         break;
17085         default:
17086
17087         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1798
17088  *                 start_offset += cigar_p[k] >> BAM_CIGAR_SHIFT
17089  *             else:
17090  *                 break             # <<<<<<<<<<<<<<
17091  * 
17092  *     return start_offset
17093  */
17094         goto __pyx_L5_break;
17095         break;
17096       }
17097     }
17098     __pyx_L5_break:;
17099     goto __pyx_L3;
17100   }
17101   __pyx_L3:;
17102
17103   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1800
17104  *                 break
17105  * 
17106  *     return start_offset             # <<<<<<<<<<<<<<
17107  * 
17108  * ##-------------------------------------------------------------------
17109  */
17110   __pyx_r = __pyx_v_start_offset;
17111   goto __pyx_L0;
17112
17113   __pyx_r = 0;
17114   __pyx_L0:;
17115   __Pyx_TraceReturn(Py_None);
17116   __Pyx_RefNannyFinishContext();
17117   return __pyx_r;
17118 }
17119
17120 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1805
17121  * ##-------------------------------------------------------------------
17122  * ##-------------------------------------------------------------------
17123  * cdef inline int32_t query_end(bam1_t *src) except -1:             # <<<<<<<<<<<<<<
17124  *     cdef uint32_t * cigar_p, op
17125  *     cdef uint32_t k
17126  */
17127
17128 static CYTHON_INLINE int32_t __pyx_f_9csamtools_query_end(bam1_t *__pyx_v_src) {
17129   uint32_t *__pyx_v_cigar_p;
17130   uint32_t __pyx_v_op;
17131   uint32_t __pyx_v_k;
17132   uint32_t __pyx_v_end_offset;
17133   int32_t __pyx_r;
17134   int __pyx_t_1;
17135   int __pyx_t_2;
17136   int __pyx_t_3;
17137   __Pyx_TraceDeclarations
17138   __Pyx_RefNannySetupContext("query_end");
17139   __Pyx_TraceCall("query_end", __pyx_f[0], 1805);
17140
17141   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1808
17142  *     cdef uint32_t * cigar_p, op
17143  *     cdef uint32_t k
17144  *     cdef uint32_t end_offset = src.core.l_qseq             # <<<<<<<<<<<<<<
17145  * 
17146  *     if src.core.n_cigar>1:
17147  */
17148   __pyx_v_end_offset = __pyx_v_src->core.l_qseq;
17149
17150   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1810
17151  *     cdef uint32_t end_offset = src.core.l_qseq
17152  * 
17153  *     if src.core.n_cigar>1:             # <<<<<<<<<<<<<<
17154  *         cigar_p = bam1_cigar(src);
17155  *         for k from src.core.n_cigar > k >= 1:
17156  */
17157   __pyx_t_1 = (__pyx_v_src->core.n_cigar > 1);
17158   if (__pyx_t_1) {
17159
17160     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1811
17161  * 
17162  *     if src.core.n_cigar>1:
17163  *         cigar_p = bam1_cigar(src);             # <<<<<<<<<<<<<<
17164  *         for k from src.core.n_cigar > k >= 1:
17165  *             op = cigar_p[k] & BAM_CIGAR_MASK
17166  */
17167     __pyx_v_cigar_p = bam1_cigar(__pyx_v_src);
17168
17169     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1812
17170  *     if src.core.n_cigar>1:
17171  *         cigar_p = bam1_cigar(src);
17172  *         for k from src.core.n_cigar > k >= 1:             # <<<<<<<<<<<<<<
17173  *             op = cigar_p[k] & BAM_CIGAR_MASK
17174  *             if op==BAM_CHARD_CLIP:
17175  */
17176     for (__pyx_v_k = __pyx_v_src->core.n_cigar-1; __pyx_v_k >= 1; __pyx_v_k--) {
17177
17178       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1813
17179  *         cigar_p = bam1_cigar(src);
17180  *         for k from src.core.n_cigar > k >= 1:
17181  *             op = cigar_p[k] & BAM_CIGAR_MASK             # <<<<<<<<<<<<<<
17182  *             if op==BAM_CHARD_CLIP:
17183  *                 if end_offset!=0 and end_offset!=src.core.l_qseq:
17184  */
17185       __pyx_v_op = ((__pyx_v_cigar_p[__pyx_v_k]) & 15);
17186
17187       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1814
17188  *         for k from src.core.n_cigar > k >= 1:
17189  *             op = cigar_p[k] & BAM_CIGAR_MASK
17190  *             if op==BAM_CHARD_CLIP:             # <<<<<<<<<<<<<<
17191  *                 if end_offset!=0 and end_offset!=src.core.l_qseq:
17192  *                     PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string')
17193  */
17194       switch (__pyx_v_op) {
17195         case 5:
17196
17197         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1815
17198  *             op = cigar_p[k] & BAM_CIGAR_MASK
17199  *             if op==BAM_CHARD_CLIP:
17200  *                 if end_offset!=0 and end_offset!=src.core.l_qseq:             # <<<<<<<<<<<<<<
17201  *                     PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string')
17202  *                     return -1
17203  */
17204         __pyx_t_1 = (__pyx_v_end_offset != 0);
17205         if (__pyx_t_1) {
17206           __pyx_t_2 = (__pyx_v_end_offset != __pyx_v_src->core.l_qseq);
17207           __pyx_t_3 = __pyx_t_2;
17208         } else {
17209           __pyx_t_3 = __pyx_t_1;
17210         }
17211         if (__pyx_t_3) {
17212
17213           /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1816
17214  *             if op==BAM_CHARD_CLIP:
17215  *                 if end_offset!=0 and end_offset!=src.core.l_qseq:
17216  *                     PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string')             # <<<<<<<<<<<<<<
17217  *                     return -1
17218  *             elif op==BAM_CSOFT_CLIP:
17219  */
17220           PyErr_SetString(__pyx_builtin_ValueError, __pyx_k_60);
17221
17222           /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1817
17223  *                 if end_offset!=0 and end_offset!=src.core.l_qseq:
17224  *                     PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string')
17225  *                     return -1             # <<<<<<<<<<<<<<
17226  *             elif op==BAM_CSOFT_CLIP:
17227  *                 end_offset -= cigar_p[k] >> BAM_CIGAR_SHIFT
17228  */
17229           __pyx_r = -1;
17230           goto __pyx_L0;
17231           goto __pyx_L6;
17232         }
17233         __pyx_L6:;
17234         break;
17235
17236         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1818
17237  *                     PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string')
17238  *                     return -1
17239  *             elif op==BAM_CSOFT_CLIP:             # <<<<<<<<<<<<<<
17240  *                 end_offset -= cigar_p[k] >> BAM_CIGAR_SHIFT
17241  *             else:
17242  */
17243         case 4:
17244
17245         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1819
17246  *                     return -1
17247  *             elif op==BAM_CSOFT_CLIP:
17248  *                 end_offset -= cigar_p[k] >> BAM_CIGAR_SHIFT             # <<<<<<<<<<<<<<
17249  *             else:
17250  *                 break
17251  */
17252         __pyx_v_end_offset -= ((__pyx_v_cigar_p[__pyx_v_k]) >> 4);
17253         break;
17254         default:
17255
17256         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1821
17257  *                 end_offset -= cigar_p[k] >> BAM_CIGAR_SHIFT
17258  *             else:
17259  *                 break             # <<<<<<<<<<<<<<
17260  * 
17261  *     if end_offset==0:
17262  */
17263         goto __pyx_L5_break;
17264         break;
17265       }
17266     }
17267     __pyx_L5_break:;
17268     goto __pyx_L3;
17269   }
17270   __pyx_L3:;
17271
17272   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1823
17273  *                 break
17274  * 
17275  *     if end_offset==0:             # <<<<<<<<<<<<<<
17276  *         end_offset = src.core.l_qseq
17277  * 
17278  */
17279   __pyx_t_3 = (__pyx_v_end_offset == 0);
17280   if (__pyx_t_3) {
17281
17282     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1824
17283  * 
17284  *     if end_offset==0:
17285  *         end_offset = src.core.l_qseq             # <<<<<<<<<<<<<<
17286  * 
17287  *     return end_offset
17288  */
17289     __pyx_v_end_offset = __pyx_v_src->core.l_qseq;
17290     goto __pyx_L7;
17291   }
17292   __pyx_L7:;
17293
17294   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1826
17295  *         end_offset = src.core.l_qseq
17296  * 
17297  *     return end_offset             # <<<<<<<<<<<<<<
17298  * 
17299  * 
17300  */
17301   __pyx_r = __pyx_v_end_offset;
17302   goto __pyx_L0;
17303
17304   __pyx_r = 0;
17305   __pyx_L0:;
17306   __Pyx_TraceReturn(Py_None);
17307   __Pyx_RefNannyFinishContext();
17308   return __pyx_r;
17309 }
17310
17311 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1829
17312  * 
17313  * 
17314  * cdef inline object get_seq_range(bam1_t *src, uint32_t start, uint32_t end):             # <<<<<<<<<<<<<<
17315  *     cdef uint8_t * p
17316  *     cdef uint32_t k
17317  */
17318
17319 static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_seq_range(bam1_t *__pyx_v_src, uint32_t __pyx_v_start, uint32_t __pyx_v_end) {
17320   uint8_t *__pyx_v_p;
17321   uint32_t __pyx_v_k;
17322   char *__pyx_v_s;
17323   PyObject *__pyx_v_seq;
17324   PyObject *__pyx_r = NULL;
17325   int __pyx_t_1;
17326   PyObject *__pyx_t_2 = NULL;
17327   uint32_t __pyx_t_3;
17328   __Pyx_TraceDeclarations
17329   __Pyx_RefNannySetupContext("get_seq_range");
17330   __Pyx_TraceCall("get_seq_range", __pyx_f[0], 1829);
17331   __pyx_v_seq = Py_None; __Pyx_INCREF(Py_None);
17332
17333   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1834
17334  *     cdef char * s
17335  * 
17336  *     if not src.core.l_qseq:             # <<<<<<<<<<<<<<
17337  *         return None
17338  * 
17339  */
17340   __pyx_t_1 = (!__pyx_v_src->core.l_qseq);
17341   if (__pyx_t_1) {
17342
17343     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1835
17344  * 
17345  *     if not src.core.l_qseq:
17346  *         return None             # <<<<<<<<<<<<<<
17347  * 
17348  *     seq = PyString_FromStringAndSize(NULL, end-start)
17349  */
17350     __Pyx_XDECREF(__pyx_r);
17351     __Pyx_INCREF(Py_None);
17352     __pyx_r = Py_None;
17353     goto __pyx_L0;
17354     goto __pyx_L3;
17355   }
17356   __pyx_L3:;
17357
17358   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1837
17359  *         return None
17360  * 
17361  *     seq = PyString_FromStringAndSize(NULL, end-start)             # <<<<<<<<<<<<<<
17362  *     s   = PyString_AS_STRING(seq)
17363  *     p   = bam1_seq(src)
17364  */
17365   __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;}
17366   __Pyx_GOTREF(__pyx_t_2);
17367   __Pyx_DECREF(__pyx_v_seq);
17368   __pyx_v_seq = __pyx_t_2;
17369   __pyx_t_2 = 0;
17370
17371   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1838
17372  * 
17373  *     seq = PyString_FromStringAndSize(NULL, end-start)
17374  *     s   = PyString_AS_STRING(seq)             # <<<<<<<<<<<<<<
17375  *     p   = bam1_seq(src)
17376  * 
17377  */
17378   __pyx_v_s = PyString_AS_STRING(__pyx_v_seq);
17379
17380   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1839
17381  *     seq = PyString_FromStringAndSize(NULL, end-start)
17382  *     s   = PyString_AS_STRING(seq)
17383  *     p   = bam1_seq(src)             # <<<<<<<<<<<<<<
17384  * 
17385  *     for k from start <= k < end:
17386  */
17387   __pyx_v_p = bam1_seq(__pyx_v_src);
17388
17389   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1841
17390  *     p   = bam1_seq(src)
17391  * 
17392  *     for k from start <= k < end:             # <<<<<<<<<<<<<<
17393  *         # equivalent to bam_nt16_rev_table[bam1_seqi(s, i)] (see bam.c)
17394  *         # note: do not use string literal as it will be a python string
17395  */
17396   __pyx_t_3 = __pyx_v_end;
17397   for (__pyx_v_k = __pyx_v_start; __pyx_v_k < __pyx_t_3; __pyx_v_k++) {
17398
17399     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1844
17400  *         # equivalent to bam_nt16_rev_table[bam1_seqi(s, i)] (see bam.c)
17401  *         # note: do not use string literal as it will be a python string
17402  *         s[k-start] = bam_nt16_rev_table[p[k/2] >> 4 * (1 - k%2) & 0xf]             # <<<<<<<<<<<<<<
17403  * 
17404  *     return seq
17405  */
17406     (__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)]);
17407   }
17408
17409   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1846
17410  *         s[k-start] = bam_nt16_rev_table[p[k/2] >> 4 * (1 - k%2) & 0xf]
17411  * 
17412  *     return seq             # <<<<<<<<<<<<<<
17413  * 
17414  * 
17415  */
17416   __Pyx_XDECREF(__pyx_r);
17417   __Pyx_INCREF(__pyx_v_seq);
17418   __pyx_r = __pyx_v_seq;
17419   goto __pyx_L0;
17420
17421   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
17422   goto __pyx_L0;
17423   __pyx_L1_error:;
17424   __Pyx_XDECREF(__pyx_t_2);
17425   __Pyx_AddTraceback("csamtools.get_seq_range");
17426   __pyx_r = 0;
17427   __pyx_L0:;
17428   __Pyx_DECREF(__pyx_v_seq);
17429   __Pyx_XGIVEREF(__pyx_r);
17430   __Pyx_TraceReturn(__pyx_r);
17431   __Pyx_RefNannyFinishContext();
17432   return __pyx_r;
17433 }
17434
17435 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1849
17436  * 
17437  * 
17438  * cdef inline object get_qual_range(bam1_t *src, uint32_t start, uint32_t end):             # <<<<<<<<<<<<<<
17439  *     cdef uint8_t * p
17440  *     cdef uint32_t k
17441  */
17442
17443 static CYTHON_INLINE PyObject *__pyx_f_9csamtools_get_qual_range(bam1_t *__pyx_v_src, uint32_t __pyx_v_start, uint32_t __pyx_v_end) {
17444   uint8_t *__pyx_v_p;
17445   uint32_t __pyx_v_k;
17446   char *__pyx_v_q;
17447   PyObject *__pyx_v_qual;
17448   PyObject *__pyx_r = NULL;
17449   int __pyx_t_1;
17450   PyObject *__pyx_t_2 = NULL;
17451   uint32_t __pyx_t_3;
17452   __Pyx_TraceDeclarations
17453   __Pyx_RefNannySetupContext("get_qual_range");
17454   __Pyx_TraceCall("get_qual_range", __pyx_f[0], 1849);
17455   __pyx_v_qual = Py_None; __Pyx_INCREF(Py_None);
17456
17457   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1854
17458  *     cdef char * q
17459  * 
17460  *     p = bam1_qual(src)             # <<<<<<<<<<<<<<
17461  *     if p[0] == 0xff:
17462  *         return None
17463  */
17464   __pyx_v_p = bam1_qual(__pyx_v_src);
17465
17466   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1855
17467  * 
17468  *     p = bam1_qual(src)
17469  *     if p[0] == 0xff:             # <<<<<<<<<<<<<<
17470  *         return None
17471  * 
17472  */
17473   __pyx_t_1 = ((__pyx_v_p[0]) == 0xff);
17474   if (__pyx_t_1) {
17475
17476     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1856
17477  *     p = bam1_qual(src)
17478  *     if p[0] == 0xff:
17479  *         return None             # <<<<<<<<<<<<<<
17480  * 
17481  *     qual = PyString_FromStringAndSize(NULL, end-start)
17482  */
17483     __Pyx_XDECREF(__pyx_r);
17484     __Pyx_INCREF(Py_None);
17485     __pyx_r = Py_None;
17486     goto __pyx_L0;
17487     goto __pyx_L3;
17488   }
17489   __pyx_L3:;
17490
17491   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1858
17492  *         return None
17493  * 
17494  *     qual = PyString_FromStringAndSize(NULL, end-start)             # <<<<<<<<<<<<<<
17495  *     q    = PyString_AS_STRING(qual)
17496  * 
17497  */
17498   __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;}
17499   __Pyx_GOTREF(__pyx_t_2);
17500   __Pyx_DECREF(__pyx_v_qual);
17501   __pyx_v_qual = __pyx_t_2;
17502   __pyx_t_2 = 0;
17503
17504   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1859
17505  * 
17506  *     qual = PyString_FromStringAndSize(NULL, end-start)
17507  *     q    = PyString_AS_STRING(qual)             # <<<<<<<<<<<<<<
17508  * 
17509  *     for k from start <= k < end:
17510  */
17511   __pyx_v_q = PyString_AS_STRING(__pyx_v_qual);
17512
17513   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1861
17514  *     q    = PyString_AS_STRING(qual)
17515  * 
17516  *     for k from start <= k < end:             # <<<<<<<<<<<<<<
17517  *         ## equivalent to t[i] + 33 (see bam.c)
17518  *         q[k-start] = p[k] + 33
17519  */
17520   __pyx_t_3 = __pyx_v_end;
17521   for (__pyx_v_k = __pyx_v_start; __pyx_v_k < __pyx_t_3; __pyx_v_k++) {
17522
17523     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1863
17524  *     for k from start <= k < end:
17525  *         ## equivalent to t[i] + 33 (see bam.c)
17526  *         q[k-start] = p[k] + 33             # <<<<<<<<<<<<<<
17527  * 
17528  *     return qual
17529  */
17530     (__pyx_v_q[(__pyx_v_k - __pyx_v_start)]) = ((__pyx_v_p[__pyx_v_k]) + 33);
17531   }
17532
17533   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1865
17534  *         q[k-start] = p[k] + 33
17535  * 
17536  *     return qual             # <<<<<<<<<<<<<<
17537  * 
17538  * cdef class AlignedRead:
17539  */
17540   __Pyx_XDECREF(__pyx_r);
17541   __Pyx_INCREF(__pyx_v_qual);
17542   __pyx_r = __pyx_v_qual;
17543   goto __pyx_L0;
17544
17545   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
17546   goto __pyx_L0;
17547   __pyx_L1_error:;
17548   __Pyx_XDECREF(__pyx_t_2);
17549   __Pyx_AddTraceback("csamtools.get_qual_range");
17550   __pyx_r = 0;
17551   __pyx_L0:;
17552   __Pyx_DECREF(__pyx_v_qual);
17553   __Pyx_XGIVEREF(__pyx_r);
17554   __Pyx_TraceReturn(__pyx_r);
17555   __Pyx_RefNannyFinishContext();
17556   return __pyx_r;
17557 }
17558
17559 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1890
17560  * 
17561  *     # Now only called when instances are created from Python
17562  *     def __init__(self):             # <<<<<<<<<<<<<<
17563  *         # see bam_init1
17564  *         self._delegate = <bam1_t*>calloc( 1, sizeof( bam1_t) )
17565  */
17566
17567 static int __pyx_pf_9csamtools_11AlignedRead___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
17568 static int __pyx_pf_9csamtools_11AlignedRead___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
17569   int __pyx_r;
17570   __Pyx_TraceDeclarations
17571   __Pyx_RefNannySetupContext("__init__");
17572   __Pyx_TraceCall("__init__", __pyx_f[0], 1890);
17573   if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
17574     __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
17575   if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
17576
17577   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1892
17578  *     def __init__(self):
17579  *         # see bam_init1
17580  *         self._delegate = <bam1_t*>calloc( 1, sizeof( bam1_t) )             # <<<<<<<<<<<<<<
17581  *         # allocate some memory
17582  *         # If size is 0, calloc does not return a pointer that can be passed to free()
17583  */
17584   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate = ((bam1_t *)calloc(1, (sizeof(bam1_t))));
17585
17586   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1896
17587  *         # If size is 0, calloc does not return a pointer that can be passed to free()
17588  *         # so allocate 40 bytes for a new read
17589  *         self._delegate.m_data = 40             # <<<<<<<<<<<<<<
17590  *         self._delegate.data = <uint8_t *>calloc( self._delegate.m_data, 1 )
17591  *         self._delegate.data_len = 0
17592  */
17593   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->m_data = 40;
17594
17595   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1897
17596  *         # so allocate 40 bytes for a new read
17597  *         self._delegate.m_data = 40
17598  *         self._delegate.data = <uint8_t *>calloc( self._delegate.m_data, 1 )             # <<<<<<<<<<<<<<
17599  *         self._delegate.data_len = 0
17600  * 
17601  */
17602   ((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));
17603
17604   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1898
17605  *         self._delegate.m_data = 40
17606  *         self._delegate.data = <uint8_t *>calloc( self._delegate.m_data, 1 )
17607  *         self._delegate.data_len = 0             # <<<<<<<<<<<<<<
17608  * 
17609  *     def __dealloc__(self):
17610  */
17611   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->data_len = 0;
17612
17613   __pyx_r = 0;
17614   __Pyx_TraceReturn(Py_None);
17615   __Pyx_RefNannyFinishContext();
17616   return __pyx_r;
17617 }
17618
17619 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1900
17620  *         self._delegate.data_len = 0
17621  * 
17622  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
17623  *         bam_destroy1(self._delegate)
17624  * 
17625  */
17626
17627 static void __pyx_pf_9csamtools_11AlignedRead___dealloc__(PyObject *__pyx_v_self); /*proto*/
17628 static void __pyx_pf_9csamtools_11AlignedRead___dealloc__(PyObject *__pyx_v_self) {
17629   __Pyx_TraceDeclarations
17630   __Pyx_RefNannySetupContext("__dealloc__");
17631   __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1900);
17632
17633   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1901
17634  * 
17635  *     def __dealloc__(self):
17636  *         bam_destroy1(self._delegate)             # <<<<<<<<<<<<<<
17637  * 
17638  *     def __str__(self):
17639  */
17640   bam_destroy1(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate);
17641
17642   __Pyx_TraceReturn(Py_None);
17643   __Pyx_RefNannyFinishContext();
17644 }
17645
17646 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1903
17647  *         bam_destroy1(self._delegate)
17648  * 
17649  *     def __str__(self):             # <<<<<<<<<<<<<<
17650  *         """return string representation of alignment.
17651  * 
17652  */
17653
17654 static PyObject *__pyx_pf_9csamtools_11AlignedRead___str__(PyObject *__pyx_v_self); /*proto*/
17655 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        ";
17656 struct wrapperbase __pyx_wrapperbase_9csamtools_11AlignedRead___str__;
17657 static PyObject *__pyx_pf_9csamtools_11AlignedRead___str__(PyObject *__pyx_v_self) {
17658   PyObject *__pyx_r = NULL;
17659   PyObject *__pyx_t_1 = NULL;
17660   PyObject *__pyx_t_2 = NULL;
17661   PyObject *__pyx_t_3 = NULL;
17662   PyObject *__pyx_t_4 = NULL;
17663   PyObject *__pyx_t_5 = NULL;
17664   PyObject *__pyx_t_6 = NULL;
17665   PyObject *__pyx_t_7 = NULL;
17666   PyObject *__pyx_t_8 = NULL;
17667   PyObject *__pyx_t_9 = NULL;
17668   PyObject *__pyx_t_10 = NULL;
17669   PyObject *__pyx_t_11 = NULL;
17670   PyObject *__pyx_t_12 = NULL;
17671   PyObject *__pyx_t_13 = NULL;
17672   PyObject *__pyx_t_14 = NULL;
17673   __Pyx_TraceDeclarations
17674   __Pyx_RefNannySetupContext("__str__");
17675   __Pyx_TraceCall("__str__", __pyx_f[0], 1903);
17676
17677   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1915
17678  *         # sam-parsing is done in sam.c/bam_format1_core which
17679  *         # requires a valid header.
17680  *         return "\t".join(map(str, (self.qname,             # <<<<<<<<<<<<<<
17681  *                                    self.flag,
17682  *                                    self.rname,
17683  */
17684   __Pyx_XDECREF(__pyx_r);
17685   __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;}
17686   __Pyx_GOTREF(__pyx_t_1);
17687   __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;}
17688   __Pyx_GOTREF(__pyx_t_2);
17689
17690   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1916
17691  *         # requires a valid header.
17692  *         return "\t".join(map(str, (self.qname,
17693  *                                    self.flag,             # <<<<<<<<<<<<<<
17694  *                                    self.rname,
17695  *                                    self.pos,
17696  */
17697   __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;}
17698   __Pyx_GOTREF(__pyx_t_3);
17699
17700   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1917
17701  *         return "\t".join(map(str, (self.qname,
17702  *                                    self.flag,
17703  *                                    self.rname,             # <<<<<<<<<<<<<<
17704  *                                    self.pos,
17705  *                                    self.mapq,
17706  */
17707   __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;}
17708   __Pyx_GOTREF(__pyx_t_4);
17709
17710   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1918
17711  *                                    self.flag,
17712  *                                    self.rname,
17713  *                                    self.pos,             # <<<<<<<<<<<<<<
17714  *                                    self.mapq,
17715  *                                    self.cigar,
17716  */
17717   __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;}
17718   __Pyx_GOTREF(__pyx_t_5);
17719
17720   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1919
17721  *                                    self.rname,
17722  *                                    self.pos,
17723  *                                    self.mapq,             # <<<<<<<<<<<<<<
17724  *                                    self.cigar,
17725  *                                    self.mrnm,
17726  */
17727   __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;}
17728   __Pyx_GOTREF(__pyx_t_6);
17729
17730   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1920
17731  *                                    self.pos,
17732  *                                    self.mapq,
17733  *                                    self.cigar,             # <<<<<<<<<<<<<<
17734  *                                    self.mrnm,
17735  *                                    self.mpos,
17736  */
17737   __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;}
17738   __Pyx_GOTREF(__pyx_t_7);
17739
17740   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1921
17741  *                                    self.mapq,
17742  *                                    self.cigar,
17743  *                                    self.mrnm,             # <<<<<<<<<<<<<<
17744  *                                    self.mpos,
17745  *                                    self.rlen,
17746  */
17747   __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;}
17748   __Pyx_GOTREF(__pyx_t_8);
17749
17750   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1922
17751  *                                    self.cigar,
17752  *                                    self.mrnm,
17753  *                                    self.mpos,             # <<<<<<<<<<<<<<
17754  *                                    self.rlen,
17755  *                                    self.seq,
17756  */
17757   __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;}
17758   __Pyx_GOTREF(__pyx_t_9);
17759
17760   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1923
17761  *                                    self.mrnm,
17762  *                                    self.mpos,
17763  *                                    self.rlen,             # <<<<<<<<<<<<<<
17764  *                                    self.seq,
17765  *                                    self.qual,
17766  */
17767   __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;}
17768   __Pyx_GOTREF(__pyx_t_10);
17769
17770   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1924
17771  *                                    self.mpos,
17772  *                                    self.rlen,
17773  *                                    self.seq,             # <<<<<<<<<<<<<<
17774  *                                    self.qual,
17775  *                                    self.tags )))
17776  */
17777   __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;}
17778   __Pyx_GOTREF(__pyx_t_11);
17779
17780   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1925
17781  *                                    self.rlen,
17782  *                                    self.seq,
17783  *                                    self.qual,             # <<<<<<<<<<<<<<
17784  *                                    self.tags )))
17785  * 
17786  */
17787   __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;}
17788   __Pyx_GOTREF(__pyx_t_12);
17789
17790   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1926
17791  *                                    self.seq,
17792  *                                    self.qual,
17793  *                                    self.tags )))             # <<<<<<<<<<<<<<
17794  * 
17795  *     def compare(self, AlignedRead other):
17796  */
17797   __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;}
17798   __Pyx_GOTREF(__pyx_t_13);
17799   __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;}
17800   __Pyx_GOTREF(__pyx_t_14);
17801   PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_2);
17802   __Pyx_GIVEREF(__pyx_t_2);
17803   PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_3);
17804   __Pyx_GIVEREF(__pyx_t_3);
17805   PyTuple_SET_ITEM(__pyx_t_14, 2, __pyx_t_4);
17806   __Pyx_GIVEREF(__pyx_t_4);
17807   PyTuple_SET_ITEM(__pyx_t_14, 3, __pyx_t_5);
17808   __Pyx_GIVEREF(__pyx_t_5);
17809   PyTuple_SET_ITEM(__pyx_t_14, 4, __pyx_t_6);
17810   __Pyx_GIVEREF(__pyx_t_6);
17811   PyTuple_SET_ITEM(__pyx_t_14, 5, __pyx_t_7);
17812   __Pyx_GIVEREF(__pyx_t_7);
17813   PyTuple_SET_ITEM(__pyx_t_14, 6, __pyx_t_8);
17814   __Pyx_GIVEREF(__pyx_t_8);
17815   PyTuple_SET_ITEM(__pyx_t_14, 7, __pyx_t_9);
17816   __Pyx_GIVEREF(__pyx_t_9);
17817   PyTuple_SET_ITEM(__pyx_t_14, 8, __pyx_t_10);
17818   __Pyx_GIVEREF(__pyx_t_10);
17819   PyTuple_SET_ITEM(__pyx_t_14, 9, __pyx_t_11);
17820   __Pyx_GIVEREF(__pyx_t_11);
17821   PyTuple_SET_ITEM(__pyx_t_14, 10, __pyx_t_12);
17822   __Pyx_GIVEREF(__pyx_t_12);
17823   PyTuple_SET_ITEM(__pyx_t_14, 11, __pyx_t_13);
17824   __Pyx_GIVEREF(__pyx_t_13);
17825   __pyx_t_2 = 0;
17826   __pyx_t_3 = 0;
17827   __pyx_t_4 = 0;
17828   __pyx_t_5 = 0;
17829   __pyx_t_6 = 0;
17830   __pyx_t_7 = 0;
17831   __pyx_t_8 = 0;
17832   __pyx_t_9 = 0;
17833   __pyx_t_10 = 0;
17834   __pyx_t_11 = 0;
17835   __pyx_t_12 = 0;
17836   __pyx_t_13 = 0;
17837   __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;}
17838   __Pyx_GOTREF(__pyx_t_13);
17839   __Pyx_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
17840   PyTuple_SET_ITEM(__pyx_t_13, 0, ((PyObject *)((PyObject*)&PyString_Type)));
17841   __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
17842   PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_14);
17843   __Pyx_GIVEREF(__pyx_t_14);
17844   __pyx_t_14 = 0;
17845   __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;}
17846   __Pyx_GOTREF(__pyx_t_14);
17847   __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
17848   __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;}
17849   __Pyx_GOTREF(__pyx_t_13);
17850   PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_14);
17851   __Pyx_GIVEREF(__pyx_t_14);
17852   __pyx_t_14 = 0;
17853   __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;}
17854   __Pyx_GOTREF(__pyx_t_14);
17855   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
17856   __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
17857   __pyx_r = __pyx_t_14;
17858   __pyx_t_14 = 0;
17859   goto __pyx_L0;
17860
17861   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
17862   goto __pyx_L0;
17863   __pyx_L1_error:;
17864   __Pyx_XDECREF(__pyx_t_1);
17865   __Pyx_XDECREF(__pyx_t_2);
17866   __Pyx_XDECREF(__pyx_t_3);
17867   __Pyx_XDECREF(__pyx_t_4);
17868   __Pyx_XDECREF(__pyx_t_5);
17869   __Pyx_XDECREF(__pyx_t_6);
17870   __Pyx_XDECREF(__pyx_t_7);
17871   __Pyx_XDECREF(__pyx_t_8);
17872   __Pyx_XDECREF(__pyx_t_9);
17873   __Pyx_XDECREF(__pyx_t_10);
17874   __Pyx_XDECREF(__pyx_t_11);
17875   __Pyx_XDECREF(__pyx_t_12);
17876   __Pyx_XDECREF(__pyx_t_13);
17877   __Pyx_XDECREF(__pyx_t_14);
17878   __Pyx_AddTraceback("csamtools.AlignedRead.__str__");
17879   __pyx_r = NULL;
17880   __pyx_L0:;
17881   __Pyx_XGIVEREF(__pyx_r);
17882   __Pyx_TraceReturn(__pyx_r);
17883   __Pyx_RefNannyFinishContext();
17884   return __pyx_r;
17885 }
17886
17887 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1928
17888  *                                    self.tags )))
17889  * 
17890  *     def compare(self, AlignedRead other):             # <<<<<<<<<<<<<<
17891  *         '''return -1,0,1, if contents in this are binary <,=,> to *other*'''
17892  * 
17893  */
17894
17895 static PyObject *__pyx_pf_9csamtools_11AlignedRead_compare(PyObject *__pyx_v_self, PyObject *__pyx_v_other); /*proto*/
17896 static char __pyx_doc_9csamtools_11AlignedRead_compare[] = "AlignedRead.compare(self, AlignedRead other)\nreturn -1,0,1, if contents in this are binary <,=,> to *other*";
17897 static PyObject *__pyx_pf_9csamtools_11AlignedRead_compare(PyObject *__pyx_v_self, PyObject *__pyx_v_other) {
17898   int __pyx_v_retval;
17899   bam1_t *__pyx_v_t;
17900   bam1_t *__pyx_v_o;
17901   PyObject *__pyx_r = NULL;
17902   int __pyx_t_1;
17903   PyObject *__pyx_t_2 = NULL;
17904   PyObject *__pyx_t_3 = NULL;
17905   PyObject *__pyx_t_4 = NULL;
17906   int __pyx_t_5;
17907   __Pyx_TraceDeclarations
17908   __Pyx_RefNannySetupContext("compare");
17909   __Pyx_TraceCall("compare", __pyx_f[0], 1928);
17910   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;}
17911
17912   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1934
17913  *         cdef bam1_t *t, *o
17914  * 
17915  *         t = self._delegate             # <<<<<<<<<<<<<<
17916  *         o = other._delegate
17917  * 
17918  */
17919   __pyx_v_t = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
17920
17921   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1935
17922  * 
17923  *         t = self._delegate
17924  *         o = other._delegate             # <<<<<<<<<<<<<<
17925  * 
17926  *         # uncomment for debugging purposes
17927  */
17928   __pyx_v_o = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_other)->_delegate;
17929
17930   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1947
17931  * 
17932  *         # Fast-path test for object identity
17933  *         if t==o:             # <<<<<<<<<<<<<<
17934  *             return 0
17935  * 
17936  */
17937   __pyx_t_1 = (__pyx_v_t == __pyx_v_o);
17938   if (__pyx_t_1) {
17939
17940     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1948
17941  *         # Fast-path test for object identity
17942  *         if t==o:
17943  *             return 0             # <<<<<<<<<<<<<<
17944  * 
17945  *         retval = memcmp(&t.core, &o.core, sizeof(bam1_core_t))
17946  */
17947     __Pyx_XDECREF(__pyx_r);
17948     __Pyx_INCREF(__pyx_int_0);
17949     __pyx_r = __pyx_int_0;
17950     goto __pyx_L0;
17951     goto __pyx_L5;
17952   }
17953   __pyx_L5:;
17954
17955   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1950
17956  *             return 0
17957  * 
17958  *         retval = memcmp(&t.core, &o.core, sizeof(bam1_core_t))             # <<<<<<<<<<<<<<
17959  * 
17960  *         if retval: return retval
17961  */
17962   __pyx_v_retval = memcmp((&__pyx_v_t->core), (&__pyx_v_o->core), (sizeof(bam1_core_t)));
17963
17964   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1952
17965  *         retval = memcmp(&t.core, &o.core, sizeof(bam1_core_t))
17966  * 
17967  *         if retval: return retval             # <<<<<<<<<<<<<<
17968  *         retval = cmp(t.data_len, o.data_len)
17969  *         if retval: return retval
17970  */
17971   if (__pyx_v_retval) {
17972     __Pyx_XDECREF(__pyx_r);
17973     __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;}
17974     __Pyx_GOTREF(__pyx_t_2);
17975     __pyx_r = __pyx_t_2;
17976     __pyx_t_2 = 0;
17977     goto __pyx_L0;
17978     goto __pyx_L6;
17979   }
17980   __pyx_L6:;
17981
17982   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1953
17983  * 
17984  *         if retval: return retval
17985  *         retval = cmp(t.data_len, o.data_len)             # <<<<<<<<<<<<<<
17986  *         if retval: return retval
17987  *         return memcmp(t.data, o.data, t.data_len)
17988  */
17989   __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;}
17990   __Pyx_GOTREF(__pyx_t_2);
17991   __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;}
17992   __Pyx_GOTREF(__pyx_t_3);
17993   __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;}
17994   __Pyx_GOTREF(__pyx_t_4);
17995   PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
17996   __Pyx_GIVEREF(__pyx_t_2);
17997   PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
17998   __Pyx_GIVEREF(__pyx_t_3);
17999   __pyx_t_2 = 0;
18000   __pyx_t_3 = 0;
18001   __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;}
18002   __Pyx_GOTREF(__pyx_t_3);
18003   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
18004   __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;}
18005   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
18006   __pyx_v_retval = __pyx_t_5;
18007
18008   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1954
18009  *         if retval: return retval
18010  *         retval = cmp(t.data_len, o.data_len)
18011  *         if retval: return retval             # <<<<<<<<<<<<<<
18012  *         return memcmp(t.data, o.data, t.data_len)
18013  * 
18014  */
18015   if (__pyx_v_retval) {
18016     __Pyx_XDECREF(__pyx_r);
18017     __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;}
18018     __Pyx_GOTREF(__pyx_t_3);
18019     __pyx_r = __pyx_t_3;
18020     __pyx_t_3 = 0;
18021     goto __pyx_L0;
18022     goto __pyx_L7;
18023   }
18024   __pyx_L7:;
18025
18026   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1955
18027  *         retval = cmp(t.data_len, o.data_len)
18028  *         if retval: return retval
18029  *         return memcmp(t.data, o.data, t.data_len)             # <<<<<<<<<<<<<<
18030  * 
18031  *     # Disabled so long as __cmp__ is a special method
18032  */
18033   __Pyx_XDECREF(__pyx_r);
18034   __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;}
18035   __Pyx_GOTREF(__pyx_t_3);
18036   __pyx_r = __pyx_t_3;
18037   __pyx_t_3 = 0;
18038   goto __pyx_L0;
18039
18040   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
18041   goto __pyx_L0;
18042   __pyx_L1_error:;
18043   __Pyx_XDECREF(__pyx_t_2);
18044   __Pyx_XDECREF(__pyx_t_3);
18045   __Pyx_XDECREF(__pyx_t_4);
18046   __Pyx_AddTraceback("csamtools.AlignedRead.compare");
18047   __pyx_r = NULL;
18048   __pyx_L0:;
18049   __Pyx_XGIVEREF(__pyx_r);
18050   __Pyx_TraceReturn(__pyx_r);
18051   __Pyx_RefNannyFinishContext();
18052   return __pyx_r;
18053 }
18054
18055 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1958
18056  * 
18057  *     # Disabled so long as __cmp__ is a special method
18058  *     def __hash__(self):             # <<<<<<<<<<<<<<
18059  *         return _Py_HashPointer(<void *>self)
18060  * 
18061  */
18062
18063 static long __pyx_pf_9csamtools_11AlignedRead___hash__(PyObject *__pyx_v_self); /*proto*/
18064 static long __pyx_pf_9csamtools_11AlignedRead___hash__(PyObject *__pyx_v_self) {
18065   long __pyx_r;
18066   __Pyx_TraceDeclarations
18067   __Pyx_RefNannySetupContext("__hash__");
18068   __Pyx_TraceCall("__hash__", __pyx_f[0], 1958);
18069
18070   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1959
18071  *     # Disabled so long as __cmp__ is a special method
18072  *     def __hash__(self):
18073  *         return _Py_HashPointer(<void *>self)             # <<<<<<<<<<<<<<
18074  * 
18075  *     property qname:
18076  */
18077   __pyx_r = _Py_HashPointer(((void *)__pyx_v_self));
18078   goto __pyx_L0;
18079
18080   __pyx_r = 0;
18081   __pyx_L0:;
18082   if (unlikely(__pyx_r == -1) && !PyErr_Occurred()) __pyx_r = -2;
18083   __Pyx_TraceReturn(Py_None);
18084   __Pyx_RefNannyFinishContext();
18085   return __pyx_r;
18086 }
18087
18088 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1963
18089  *     property qname:
18090  *         """the query name (None if not present)"""
18091  *         def __get__(self):             # <<<<<<<<<<<<<<
18092  *             cdef bam1_t * src
18093  *             src = self._delegate
18094  */
18095
18096 static PyObject *__pyx_pf_9csamtools_11AlignedRead_5qname___get__(PyObject *__pyx_v_self); /*proto*/
18097 static PyObject *__pyx_pf_9csamtools_11AlignedRead_5qname___get__(PyObject *__pyx_v_self) {
18098   bam1_t *__pyx_v_src;
18099   PyObject *__pyx_r = NULL;
18100   int __pyx_t_1;
18101   PyObject *__pyx_t_2 = NULL;
18102   __Pyx_TraceDeclarations
18103   __Pyx_RefNannySetupContext("__get__");
18104   __Pyx_TraceCall("__get__", __pyx_f[0], 1963);
18105
18106   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1965
18107  *         def __get__(self):
18108  *             cdef bam1_t * src
18109  *             src = self._delegate             # <<<<<<<<<<<<<<
18110  *             if src.core.l_qname == 0: return None
18111  *             return <char *>bam1_qname( src )
18112  */
18113   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
18114
18115   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1966
18116  *             cdef bam1_t * src
18117  *             src = self._delegate
18118  *             if src.core.l_qname == 0: return None             # <<<<<<<<<<<<<<
18119  *             return <char *>bam1_qname( src )
18120  * 
18121  */
18122   __pyx_t_1 = (__pyx_v_src->core.l_qname == 0);
18123   if (__pyx_t_1) {
18124     __Pyx_XDECREF(__pyx_r);
18125     __Pyx_INCREF(Py_None);
18126     __pyx_r = Py_None;
18127     goto __pyx_L0;
18128     goto __pyx_L5;
18129   }
18130   __pyx_L5:;
18131
18132   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1967
18133  *             src = self._delegate
18134  *             if src.core.l_qname == 0: return None
18135  *             return <char *>bam1_qname( src )             # <<<<<<<<<<<<<<
18136  * 
18137  *         def __set__(self, qname ):
18138  */
18139   __Pyx_XDECREF(__pyx_r);
18140   __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;}
18141   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
18142   __pyx_r = ((PyObject *)__pyx_t_2);
18143   __pyx_t_2 = 0;
18144   goto __pyx_L0;
18145
18146   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
18147   goto __pyx_L0;
18148   __pyx_L1_error:;
18149   __Pyx_XDECREF(__pyx_t_2);
18150   __Pyx_AddTraceback("csamtools.AlignedRead.qname.__get__");
18151   __pyx_r = NULL;
18152   __pyx_L0:;
18153   __Pyx_XGIVEREF(__pyx_r);
18154   __Pyx_TraceReturn(__pyx_r);
18155   __Pyx_RefNannyFinishContext();
18156   return __pyx_r;
18157 }
18158
18159 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1969
18160  *             return <char *>bam1_qname( src )
18161  * 
18162  *         def __set__(self, qname ):             # <<<<<<<<<<<<<<
18163  *             if qname == None or len(qname) == 0: return
18164  *             cdef bam1_t * src
18165  */
18166
18167 static int __pyx_pf_9csamtools_11AlignedRead_5qname___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_qname); /*proto*/
18168 static int __pyx_pf_9csamtools_11AlignedRead_5qname___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_qname) {
18169   bam1_t *__pyx_v_src;
18170   int __pyx_v_l;
18171   char *__pyx_v_p;
18172   int __pyx_r;
18173   PyObject *__pyx_t_1 = NULL;
18174   int __pyx_t_2;
18175   Py_ssize_t __pyx_t_3;
18176   int __pyx_t_4;
18177   int __pyx_t_5;
18178   char *__pyx_t_6;
18179   __Pyx_TraceDeclarations
18180   __Pyx_RefNannySetupContext("__set__");
18181   __Pyx_TraceCall("__set__", __pyx_f[0], 1969);
18182
18183   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1970
18184  * 
18185  *         def __set__(self, qname ):
18186  *             if qname == None or len(qname) == 0: return             # <<<<<<<<<<<<<<
18187  *             cdef bam1_t * src
18188  *             cdef int l
18189  */
18190   __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;}
18191   __Pyx_GOTREF(__pyx_t_1);
18192   __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;}
18193   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
18194   if (!__pyx_t_2) {
18195     __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;}
18196     __pyx_t_4 = (__pyx_t_3 == 0);
18197     __pyx_t_5 = __pyx_t_4;
18198   } else {
18199     __pyx_t_5 = __pyx_t_2;
18200   }
18201   if (__pyx_t_5) {
18202     __pyx_r = 0;
18203     goto __pyx_L0;
18204     goto __pyx_L5;
18205   }
18206   __pyx_L5:;
18207
18208   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1975
18209  *             cdef char * p
18210  * 
18211  *             src = self._delegate             # <<<<<<<<<<<<<<
18212  *             p = bam1_qname( src )
18213  * 
18214  */
18215   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
18216
18217   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1976
18218  * 
18219  *             src = self._delegate
18220  *             p = bam1_qname( src )             # <<<<<<<<<<<<<<
18221  * 
18222  *             # the qname is \0 terminated
18223  */
18224   __pyx_v_p = bam1_qname(__pyx_v_src);
18225
18226   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1979
18227  * 
18228  *             # the qname is \0 terminated
18229  *             l = len(qname) + 1             # <<<<<<<<<<<<<<
18230  *             pysam_bam_update( src,
18231  *                               src.core.l_qname,
18232  */
18233   __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;}
18234   __pyx_v_l = (__pyx_t_3 + 1);
18235
18236   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1983
18237  *                               src.core.l_qname,
18238  *                               l,
18239  *                               <uint8_t*>p )             # <<<<<<<<<<<<<<
18240  * 
18241  *             src.core.l_qname = l
18242  */
18243   pysam_bam_update(__pyx_v_src, __pyx_v_src->core.l_qname, __pyx_v_l, ((uint8_t *)__pyx_v_p));
18244
18245   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1985
18246  *                               <uint8_t*>p )
18247  * 
18248  *             src.core.l_qname = l             # <<<<<<<<<<<<<<
18249  * 
18250  *             # re-acquire pointer to location in memory
18251  */
18252   __pyx_v_src->core.l_qname = __pyx_v_l;
18253
18254   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1989
18255  *             # re-acquire pointer to location in memory
18256  *             # as it might have moved
18257  *             p = bam1_qname(src)             # <<<<<<<<<<<<<<
18258  * 
18259  *             strncpy( p, qname, l )
18260  */
18261   __pyx_v_p = bam1_qname(__pyx_v_src);
18262
18263   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1991
18264  *             p = bam1_qname(src)
18265  * 
18266  *             strncpy( p, qname, l )             # <<<<<<<<<<<<<<
18267  * 
18268  *     property cigar:
18269  */
18270   __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;}
18271   strncpy(__pyx_v_p, __pyx_t_6, __pyx_v_l);
18272
18273   __pyx_r = 0;
18274   goto __pyx_L0;
18275   __pyx_L1_error:;
18276   __Pyx_XDECREF(__pyx_t_1);
18277   __Pyx_AddTraceback("csamtools.AlignedRead.qname.__set__");
18278   __pyx_r = -1;
18279   __pyx_L0:;
18280   __Pyx_TraceReturn(Py_None);
18281   __Pyx_RefNannyFinishContext();
18282   return __pyx_r;
18283 }
18284
18285 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1996
18286  *         """the :term:`cigar` alignment (None if not present).
18287  *         """
18288  *         def __get__(self):             # <<<<<<<<<<<<<<
18289  *             cdef uint32_t * cigar_p
18290  *             cdef bam1_t * src
18291  */
18292
18293 static PyObject *__pyx_pf_9csamtools_11AlignedRead_5cigar___get__(PyObject *__pyx_v_self); /*proto*/
18294 static PyObject *__pyx_pf_9csamtools_11AlignedRead_5cigar___get__(PyObject *__pyx_v_self) {
18295   uint32_t *__pyx_v_cigar_p;
18296   bam1_t *__pyx_v_src;
18297   PyObject *__pyx_v_op;
18298   PyObject *__pyx_v_l;
18299   PyObject *__pyx_v_cigar;
18300   int __pyx_v_k;
18301   PyObject *__pyx_r = NULL;
18302   int __pyx_t_1;
18303   PyObject *__pyx_t_2 = NULL;
18304   uint32_t __pyx_t_3;
18305   PyObject *__pyx_t_4 = NULL;
18306   __Pyx_TraceDeclarations
18307   __Pyx_RefNannySetupContext("__get__");
18308   __Pyx_TraceCall("__get__", __pyx_f[0], 1996);
18309   __pyx_v_op = Py_None; __Pyx_INCREF(Py_None);
18310   __pyx_v_l = Py_None; __Pyx_INCREF(Py_None);
18311   __pyx_v_cigar = Py_None; __Pyx_INCREF(Py_None);
18312
18313   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2002
18314  *             cdef int k
18315  * 
18316  *             src = self._delegate             # <<<<<<<<<<<<<<
18317  *             if src.core.n_cigar == 0: return None
18318  * 
18319  */
18320   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
18321
18322   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2003
18323  * 
18324  *             src = self._delegate
18325  *             if src.core.n_cigar == 0: return None             # <<<<<<<<<<<<<<
18326  * 
18327  *             cigar = []
18328  */
18329   __pyx_t_1 = (__pyx_v_src->core.n_cigar == 0);
18330   if (__pyx_t_1) {
18331     __Pyx_XDECREF(__pyx_r);
18332     __Pyx_INCREF(Py_None);
18333     __pyx_r = Py_None;
18334     goto __pyx_L0;
18335     goto __pyx_L5;
18336   }
18337   __pyx_L5:;
18338
18339   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2005
18340  *             if src.core.n_cigar == 0: return None
18341  * 
18342  *             cigar = []             # <<<<<<<<<<<<<<
18343  *             cigar_p = bam1_cigar(src);
18344  *             for k from 0 <= k < src.core.n_cigar:
18345  */
18346   __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;}
18347   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
18348   __Pyx_DECREF(__pyx_v_cigar);
18349   __pyx_v_cigar = ((PyObject *)__pyx_t_2);
18350   __pyx_t_2 = 0;
18351
18352   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2006
18353  * 
18354  *             cigar = []
18355  *             cigar_p = bam1_cigar(src);             # <<<<<<<<<<<<<<
18356  *             for k from 0 <= k < src.core.n_cigar:
18357  *                 op = cigar_p[k] & BAM_CIGAR_MASK
18358  */
18359   __pyx_v_cigar_p = bam1_cigar(__pyx_v_src);
18360
18361   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2007
18362  *             cigar = []
18363  *             cigar_p = bam1_cigar(src);
18364  *             for k from 0 <= k < src.core.n_cigar:             # <<<<<<<<<<<<<<
18365  *                 op = cigar_p[k] & BAM_CIGAR_MASK
18366  *                 l = cigar_p[k] >> BAM_CIGAR_SHIFT
18367  */
18368   __pyx_t_3 = __pyx_v_src->core.n_cigar;
18369   for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_3; __pyx_v_k++) {
18370
18371     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2008
18372  *             cigar_p = bam1_cigar(src);
18373  *             for k from 0 <= k < src.core.n_cigar:
18374  *                 op = cigar_p[k] & BAM_CIGAR_MASK             # <<<<<<<<<<<<<<
18375  *                 l = cigar_p[k] >> BAM_CIGAR_SHIFT
18376  *                 cigar.append((op, l))
18377  */
18378     __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;}
18379     __Pyx_GOTREF(__pyx_t_2);
18380     __Pyx_DECREF(__pyx_v_op);
18381     __pyx_v_op = __pyx_t_2;
18382     __pyx_t_2 = 0;
18383
18384     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2009
18385  *             for k from 0 <= k < src.core.n_cigar:
18386  *                 op = cigar_p[k] & BAM_CIGAR_MASK
18387  *                 l = cigar_p[k] >> BAM_CIGAR_SHIFT             # <<<<<<<<<<<<<<
18388  *                 cigar.append((op, l))
18389  *             return cigar
18390  */
18391     __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;}
18392     __Pyx_GOTREF(__pyx_t_2);
18393     __Pyx_DECREF(__pyx_v_l);
18394     __pyx_v_l = __pyx_t_2;
18395     __pyx_t_2 = 0;
18396
18397     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2010
18398  *                 op = cigar_p[k] & BAM_CIGAR_MASK
18399  *                 l = cigar_p[k] >> BAM_CIGAR_SHIFT
18400  *                 cigar.append((op, l))             # <<<<<<<<<<<<<<
18401  *             return cigar
18402  * 
18403  */
18404     __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;}
18405     __Pyx_GOTREF(__pyx_t_2);
18406     __Pyx_INCREF(__pyx_v_op);
18407     PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_op);
18408     __Pyx_GIVEREF(__pyx_v_op);
18409     __Pyx_INCREF(__pyx_v_l);
18410     PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_l);
18411     __Pyx_GIVEREF(__pyx_v_l);
18412     __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;}
18413     __Pyx_GOTREF(__pyx_t_4);
18414     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
18415     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
18416   }
18417
18418   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2011
18419  *                 l = cigar_p[k] >> BAM_CIGAR_SHIFT
18420  *                 cigar.append((op, l))
18421  *             return cigar             # <<<<<<<<<<<<<<
18422  * 
18423  *         def __set__(self, values ):
18424  */
18425   __Pyx_XDECREF(__pyx_r);
18426   __Pyx_INCREF(__pyx_v_cigar);
18427   __pyx_r = __pyx_v_cigar;
18428   goto __pyx_L0;
18429
18430   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
18431   goto __pyx_L0;
18432   __pyx_L1_error:;
18433   __Pyx_XDECREF(__pyx_t_2);
18434   __Pyx_XDECREF(__pyx_t_4);
18435   __Pyx_AddTraceback("csamtools.AlignedRead.cigar.__get__");
18436   __pyx_r = NULL;
18437   __pyx_L0:;
18438   __Pyx_DECREF(__pyx_v_op);
18439   __Pyx_DECREF(__pyx_v_l);
18440   __Pyx_DECREF(__pyx_v_cigar);
18441   __Pyx_XGIVEREF(__pyx_r);
18442   __Pyx_TraceReturn(__pyx_r);
18443   __Pyx_RefNannyFinishContext();
18444   return __pyx_r;
18445 }
18446
18447 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2013
18448  *             return cigar
18449  * 
18450  *         def __set__(self, values ):             # <<<<<<<<<<<<<<
18451  *             if values == None or len(values) == 0: return
18452  *             cdef uint32_t * p
18453  */
18454
18455 static int __pyx_pf_9csamtools_11AlignedRead_5cigar___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_values); /*proto*/
18456 static int __pyx_pf_9csamtools_11AlignedRead_5cigar___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_values) {
18457   uint32_t *__pyx_v_p;
18458   bam1_t *__pyx_v_src;
18459   PyObject *__pyx_v_op;
18460   PyObject *__pyx_v_l;
18461   int __pyx_v_k;
18462   int __pyx_r;
18463   PyObject *__pyx_t_1 = NULL;
18464   int __pyx_t_2;
18465   Py_ssize_t __pyx_t_3;
18466   int __pyx_t_4;
18467   int __pyx_t_5;
18468   PyObject *__pyx_t_6 = NULL;
18469   PyObject *__pyx_t_7 = NULL;
18470   PyObject *__pyx_t_8 = NULL;
18471   PyObject *__pyx_t_9 = NULL;
18472   uint32_t __pyx_t_10;
18473   __Pyx_TraceDeclarations
18474   __Pyx_RefNannySetupContext("__set__");
18475   __Pyx_TraceCall("__set__", __pyx_f[0], 2013);
18476   __pyx_v_op = Py_None; __Pyx_INCREF(Py_None);
18477   __pyx_v_l = Py_None; __Pyx_INCREF(Py_None);
18478
18479   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2014
18480  * 
18481  *         def __set__(self, values ):
18482  *             if values == None or len(values) == 0: return             # <<<<<<<<<<<<<<
18483  *             cdef uint32_t * p
18484  *             cdef bam1_t * src
18485  */
18486   __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;}
18487   __Pyx_GOTREF(__pyx_t_1);
18488   __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;}
18489   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
18490   if (!__pyx_t_2) {
18491     __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;}
18492     __pyx_t_4 = (__pyx_t_3 == 0);
18493     __pyx_t_5 = __pyx_t_4;
18494   } else {
18495     __pyx_t_5 = __pyx_t_2;
18496   }
18497   if (__pyx_t_5) {
18498     __pyx_r = 0;
18499     goto __pyx_L0;
18500     goto __pyx_L5;
18501   }
18502   __pyx_L5:;
18503
18504   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2020
18505  *             cdef int k
18506  * 
18507  *             k = 0             # <<<<<<<<<<<<<<
18508  * 
18509  *             src = self._delegate
18510  */
18511   __pyx_v_k = 0;
18512
18513   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2022
18514  *             k = 0
18515  * 
18516  *             src = self._delegate             # <<<<<<<<<<<<<<
18517  * 
18518  *             # get location of cigar string
18519  */
18520   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
18521
18522   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2025
18523  * 
18524  *             # get location of cigar string
18525  *             p = bam1_cigar(src)             # <<<<<<<<<<<<<<
18526  * 
18527  *             # create space for cigar data within src.data
18528  */
18529   __pyx_v_p = bam1_cigar(__pyx_v_src);
18530
18531   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2030
18532  *             pysam_bam_update( src,
18533  *                               src.core.n_cigar * 4,
18534  *                               len(values) * 4,             # <<<<<<<<<<<<<<
18535  *                               <uint8_t*>p )
18536  * 
18537  */
18538   __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;}
18539
18540   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2031
18541  *                               src.core.n_cigar * 4,
18542  *                               len(values) * 4,
18543  *                               <uint8_t*>p )             # <<<<<<<<<<<<<<
18544  * 
18545  *             # length is number of cigar operations, not bytes
18546  */
18547   pysam_bam_update(__pyx_v_src, (__pyx_v_src->core.n_cigar * 4), (__pyx_t_3 * 4), ((uint8_t *)__pyx_v_p));
18548
18549   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2034
18550  * 
18551  *             # length is number of cigar operations, not bytes
18552  *             src.core.n_cigar = len(values)             # <<<<<<<<<<<<<<
18553  * 
18554  *             # re-acquire pointer to location in memory
18555  */
18556   __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;}
18557   __pyx_v_src->core.n_cigar = __pyx_t_3;
18558
18559   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2038
18560  *             # re-acquire pointer to location in memory
18561  *             # as it might have moved
18562  *             p = bam1_cigar(src)             # <<<<<<<<<<<<<<
18563  * 
18564  *             # insert cigar operations
18565  */
18566   __pyx_v_p = bam1_cigar(__pyx_v_src);
18567
18568   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2041
18569  * 
18570  *             # insert cigar operations
18571  *             for op, l in values:             # <<<<<<<<<<<<<<
18572  *                 p[k] = l << BAM_CIGAR_SHIFT | op
18573  *                 k += 1
18574  */
18575   if (PyList_CheckExact(__pyx_v_values) || PyTuple_CheckExact(__pyx_v_values)) {
18576     __pyx_t_3 = 0; __pyx_t_1 = __pyx_v_values; __Pyx_INCREF(__pyx_t_1);
18577   } else {
18578     __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;}
18579     __Pyx_GOTREF(__pyx_t_1);
18580   }
18581   for (;;) {
18582     if (likely(PyList_CheckExact(__pyx_t_1))) {
18583       if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
18584       __pyx_t_6 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++;
18585     } else if (likely(PyTuple_CheckExact(__pyx_t_1))) {
18586       if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
18587       __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++;
18588     } else {
18589       __pyx_t_6 = PyIter_Next(__pyx_t_1);
18590       if (!__pyx_t_6) {
18591         if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
18592         break;
18593       }
18594       __Pyx_GOTREF(__pyx_t_6);
18595     }
18596     if (PyTuple_CheckExact(__pyx_t_6) && likely(PyTuple_GET_SIZE(__pyx_t_6) == 2)) {
18597       PyObject* tuple = __pyx_t_6;
18598       __pyx_t_7 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_7);
18599       __pyx_t_8 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_8);
18600       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
18601       __Pyx_DECREF(__pyx_v_op);
18602       __pyx_v_op = __pyx_t_7;
18603       __pyx_t_7 = 0;
18604       __Pyx_DECREF(__pyx_v_l);
18605       __pyx_v_l = __pyx_t_8;
18606       __pyx_t_8 = 0;
18607     } else {
18608       __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;}
18609       __Pyx_GOTREF(__pyx_t_9);
18610       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
18611       __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;}
18612       __Pyx_GOTREF(__pyx_t_7);
18613       __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;}
18614       __Pyx_GOTREF(__pyx_t_8);
18615       if (__Pyx_EndUnpack(__pyx_t_9, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
18616       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
18617       __Pyx_DECREF(__pyx_v_op);
18618       __pyx_v_op = __pyx_t_7;
18619       __pyx_t_7 = 0;
18620       __Pyx_DECREF(__pyx_v_l);
18621       __pyx_v_l = __pyx_t_8;
18622       __pyx_t_8 = 0;
18623     }
18624
18625     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2042
18626  *             # insert cigar operations
18627  *             for op, l in values:
18628  *                 p[k] = l << BAM_CIGAR_SHIFT | op             # <<<<<<<<<<<<<<
18629  *                 k += 1
18630  * 
18631  */
18632     __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;}
18633     __Pyx_GOTREF(__pyx_t_6);
18634     __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;}
18635     __Pyx_GOTREF(__pyx_t_8);
18636     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
18637     __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;}
18638     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
18639     (__pyx_v_p[__pyx_v_k]) = __pyx_t_10;
18640
18641     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2043
18642  *             for op, l in values:
18643  *                 p[k] = l << BAM_CIGAR_SHIFT | op
18644  *                 k += 1             # <<<<<<<<<<<<<<
18645  * 
18646  *             ## setting the cigar string also updates the "bin" attribute
18647  */
18648     __pyx_v_k += 1;
18649   }
18650   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
18651
18652   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2046
18653  * 
18654  *             ## setting the cigar string also updates the "bin" attribute
18655  *             src.core.bin = bam_reg2bin( src.core.pos, bam_calend( &src.core, p))             # <<<<<<<<<<<<<<
18656  * 
18657  *     property seq:
18658  */
18659   __pyx_v_src->core.bin = bam_reg2bin(__pyx_v_src->core.pos, bam_calend((&__pyx_v_src->core), __pyx_v_p));
18660
18661   __pyx_r = 0;
18662   goto __pyx_L0;
18663   __pyx_L1_error:;
18664   __Pyx_XDECREF(__pyx_t_1);
18665   __Pyx_XDECREF(__pyx_t_6);
18666   __Pyx_XDECREF(__pyx_t_7);
18667   __Pyx_XDECREF(__pyx_t_8);
18668   __Pyx_XDECREF(__pyx_t_9);
18669   __Pyx_AddTraceback("csamtools.AlignedRead.cigar.__set__");
18670   __pyx_r = -1;
18671   __pyx_L0:;
18672   __Pyx_DECREF(__pyx_v_op);
18673   __Pyx_DECREF(__pyx_v_l);
18674   __Pyx_TraceReturn(Py_None);
18675   __Pyx_RefNannyFinishContext();
18676   return __pyx_r;
18677 }
18678
18679 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2050
18680  *     property seq:
18681  *         """read sequence bases, including :term:`soft clipped` bases (None if not present)"""
18682  *         def __get__(self):             # <<<<<<<<<<<<<<
18683  *             cdef bam1_t * src
18684  *             cdef char * s
18685  */
18686
18687 static PyObject *__pyx_pf_9csamtools_11AlignedRead_3seq___get__(PyObject *__pyx_v_self); /*proto*/
18688 static PyObject *__pyx_pf_9csamtools_11AlignedRead_3seq___get__(PyObject *__pyx_v_self) {
18689   bam1_t *__pyx_v_src;
18690   PyObject *__pyx_r = NULL;
18691   int __pyx_t_1;
18692   PyObject *__pyx_t_2 = NULL;
18693   __Pyx_TraceDeclarations
18694   __Pyx_RefNannySetupContext("__get__");
18695   __Pyx_TraceCall("__get__", __pyx_f[0], 2050);
18696
18697   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2053
18698  *             cdef bam1_t * src
18699  *             cdef char * s
18700  *             src = self._delegate             # <<<<<<<<<<<<<<
18701  * 
18702  *             if src.core.l_qseq == 0: return None
18703  */
18704   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
18705
18706   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2055
18707  *             src = self._delegate
18708  * 
18709  *             if src.core.l_qseq == 0: return None             # <<<<<<<<<<<<<<
18710  * 
18711  *             return get_seq_range(src, 0, src.core.l_qseq)
18712  */
18713   __pyx_t_1 = (__pyx_v_src->core.l_qseq == 0);
18714   if (__pyx_t_1) {
18715     __Pyx_XDECREF(__pyx_r);
18716     __Pyx_INCREF(Py_None);
18717     __pyx_r = Py_None;
18718     goto __pyx_L0;
18719     goto __pyx_L5;
18720   }
18721   __pyx_L5:;
18722
18723   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2057
18724  *             if src.core.l_qseq == 0: return None
18725  * 
18726  *             return get_seq_range(src, 0, src.core.l_qseq)             # <<<<<<<<<<<<<<
18727  * 
18728  *         def __set__(self,seq):
18729  */
18730   __Pyx_XDECREF(__pyx_r);
18731   __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;}
18732   __Pyx_GOTREF(__pyx_t_2);
18733   __pyx_r = __pyx_t_2;
18734   __pyx_t_2 = 0;
18735   goto __pyx_L0;
18736
18737   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
18738   goto __pyx_L0;
18739   __pyx_L1_error:;
18740   __Pyx_XDECREF(__pyx_t_2);
18741   __Pyx_AddTraceback("csamtools.AlignedRead.seq.__get__");
18742   __pyx_r = NULL;
18743   __pyx_L0:;
18744   __Pyx_XGIVEREF(__pyx_r);
18745   __Pyx_TraceReturn(__pyx_r);
18746   __Pyx_RefNannyFinishContext();
18747   return __pyx_r;
18748 }
18749
18750 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2059
18751  *             return get_seq_range(src, 0, src.core.l_qseq)
18752  * 
18753  *         def __set__(self,seq):             # <<<<<<<<<<<<<<
18754  *             # samtools manages sequence and quality length memory together
18755  *             # if no quality information is present, the first byte says 0xff.
18756  */
18757
18758 static int __pyx_pf_9csamtools_11AlignedRead_3seq___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_seq); /*proto*/
18759 static int __pyx_pf_9csamtools_11AlignedRead_3seq___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_seq) {
18760   bam1_t *__pyx_v_src;
18761   uint8_t *__pyx_v_p;
18762   char *__pyx_v_s;
18763   int __pyx_v_l;
18764   int __pyx_v_k;
18765   int __pyx_v_nbytes_new;
18766   int __pyx_v_nbytes_old;
18767   int __pyx_r;
18768   PyObject *__pyx_t_1 = NULL;
18769   int __pyx_t_2;
18770   Py_ssize_t __pyx_t_3;
18771   int __pyx_t_4;
18772   int __pyx_t_5;
18773   int __pyx_t_6;
18774   char *__pyx_t_7;
18775   __Pyx_TraceDeclarations
18776   __Pyx_RefNannySetupContext("__set__");
18777   __Pyx_TraceCall("__set__", __pyx_f[0], 2059);
18778
18779   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2063
18780  *             # if no quality information is present, the first byte says 0xff.
18781  * 
18782  *             if seq == None or len(seq) == 0: return             # <<<<<<<<<<<<<<
18783  *             cdef bam1_t * src
18784  *             cdef uint8_t * p
18785  */
18786   __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;}
18787   __Pyx_GOTREF(__pyx_t_1);
18788   __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;}
18789   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
18790   if (!__pyx_t_2) {
18791     __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;}
18792     __pyx_t_4 = (__pyx_t_3 == 0);
18793     __pyx_t_5 = __pyx_t_4;
18794   } else {
18795     __pyx_t_5 = __pyx_t_2;
18796   }
18797   if (__pyx_t_5) {
18798     __pyx_r = 0;
18799     goto __pyx_L0;
18800     goto __pyx_L5;
18801   }
18802   __pyx_L5:;
18803
18804   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2069
18805  *             cdef int l, k, nbytes_new, nbytes_old
18806  * 
18807  *             src = self._delegate             # <<<<<<<<<<<<<<
18808  * 
18809  *             l = len(seq)
18810  */
18811   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
18812
18813   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2071
18814  *             src = self._delegate
18815  * 
18816  *             l = len(seq)             # <<<<<<<<<<<<<<
18817  * 
18818  *             # as the sequence is stored in half-bytes, the total length (sequence
18819  */
18820   __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;}
18821   __pyx_v_l = __pyx_t_3;
18822
18823   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2075
18824  *             # as the sequence is stored in half-bytes, the total length (sequence
18825  *             # plus quality scores) is (l+1)/2 + l
18826  *             nbytes_new = (l+1)/2 + l             # <<<<<<<<<<<<<<
18827  *             nbytes_old = (src.core.l_qseq+1)/2 + src.core.l_qseq
18828  *             # acquire pointer to location in memory
18829  */
18830   __pyx_v_nbytes_new = (__Pyx_div_long((__pyx_v_l + 1), 2) + __pyx_v_l);
18831
18832   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2076
18833  *             # plus quality scores) is (l+1)/2 + l
18834  *             nbytes_new = (l+1)/2 + l
18835  *             nbytes_old = (src.core.l_qseq+1)/2 + src.core.l_qseq             # <<<<<<<<<<<<<<
18836  *             # acquire pointer to location in memory
18837  *             p = bam1_seq( src )
18838  */
18839   __pyx_v_nbytes_old = (__Pyx_div_long((__pyx_v_src->core.l_qseq + 1), 2) + __pyx_v_src->core.l_qseq);
18840
18841   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2078
18842  *             nbytes_old = (src.core.l_qseq+1)/2 + src.core.l_qseq
18843  *             # acquire pointer to location in memory
18844  *             p = bam1_seq( src )             # <<<<<<<<<<<<<<
18845  *             src.core.l_qseq = l
18846  * 
18847  */
18848   __pyx_v_p = bam1_seq(__pyx_v_src);
18849
18850   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2079
18851  *             # acquire pointer to location in memory
18852  *             p = bam1_seq( src )
18853  *             src.core.l_qseq = l             # <<<<<<<<<<<<<<
18854  * 
18855  *             pysam_bam_update( src,
18856  */
18857   __pyx_v_src->core.l_qseq = __pyx_v_l;
18858
18859   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2084
18860  *                               nbytes_old,
18861  *                               nbytes_new,
18862  *                               p)             # <<<<<<<<<<<<<<
18863  *             # re-acquire pointer to location in memory
18864  *             # as it might have moved
18865  */
18866   pysam_bam_update(__pyx_v_src, __pyx_v_nbytes_old, __pyx_v_nbytes_new, __pyx_v_p);
18867
18868   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2087
18869  *             # re-acquire pointer to location in memory
18870  *             # as it might have moved
18871  *             p = bam1_seq( src )             # <<<<<<<<<<<<<<
18872  *             for k from 0 <= k < nbytes_new: p[k] = 0
18873  *             # convert to C string
18874  */
18875   __pyx_v_p = bam1_seq(__pyx_v_src);
18876
18877   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2088
18878  *             # as it might have moved
18879  *             p = bam1_seq( src )
18880  *             for k from 0 <= k < nbytes_new: p[k] = 0             # <<<<<<<<<<<<<<
18881  *             # convert to C string
18882  *             s = seq
18883  */
18884   __pyx_t_6 = __pyx_v_nbytes_new;
18885   for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_6; __pyx_v_k++) {
18886     (__pyx_v_p[__pyx_v_k]) = 0;
18887   }
18888
18889   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2090
18890  *             for k from 0 <= k < nbytes_new: p[k] = 0
18891  *             # convert to C string
18892  *             s = seq             # <<<<<<<<<<<<<<
18893  *             for k from 0 <= k < l:
18894  *                 p[k/2] |= pysam_translate_sequence(s[k]) << 4 * (1 - k % 2)
18895  */
18896   __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;}
18897   __pyx_v_s = __pyx_t_7;
18898
18899   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2091
18900  *             # convert to C string
18901  *             s = seq
18902  *             for k from 0 <= k < l:             # <<<<<<<<<<<<<<
18903  *                 p[k/2] |= pysam_translate_sequence(s[k]) << 4 * (1 - k % 2)
18904  * 
18905  */
18906   __pyx_t_6 = __pyx_v_l;
18907   for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_6; __pyx_v_k++) {
18908
18909     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2092
18910  *             s = seq
18911  *             for k from 0 <= k < l:
18912  *                 p[k/2] |= pysam_translate_sequence(s[k]) << 4 * (1 - k % 2)             # <<<<<<<<<<<<<<
18913  * 
18914  *             # erase qualities
18915  */
18916     (__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))));
18917   }
18918
18919   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2095
18920  * 
18921  *             # erase qualities
18922  *             p = bam1_qual( src )             # <<<<<<<<<<<<<<
18923  *             p[0] = 0xff
18924  * 
18925  */
18926   __pyx_v_p = bam1_qual(__pyx_v_src);
18927
18928   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2096
18929  *             # erase qualities
18930  *             p = bam1_qual( src )
18931  *             p[0] = 0xff             # <<<<<<<<<<<<<<
18932  * 
18933  * 
18934  */
18935   (__pyx_v_p[0]) = 0xff;
18936
18937   __pyx_r = 0;
18938   goto __pyx_L0;
18939   __pyx_L1_error:;
18940   __Pyx_XDECREF(__pyx_t_1);
18941   __Pyx_AddTraceback("csamtools.AlignedRead.seq.__set__");
18942   __pyx_r = -1;
18943   __pyx_L0:;
18944   __Pyx_TraceReturn(Py_None);
18945   __Pyx_RefNannyFinishContext();
18946   return __pyx_r;
18947 }
18948
18949 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2101
18950  *     property qual:
18951  *         """read sequence base qualities, including :term:`soft clipped` bases (None if not present)"""
18952  *         def __get__(self):             # <<<<<<<<<<<<<<
18953  * 
18954  *             cdef bam1_t * src
18955  */
18956
18957 static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qual___get__(PyObject *__pyx_v_self); /*proto*/
18958 static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qual___get__(PyObject *__pyx_v_self) {
18959   bam1_t *__pyx_v_src;
18960   PyObject *__pyx_r = NULL;
18961   int __pyx_t_1;
18962   PyObject *__pyx_t_2 = NULL;
18963   __Pyx_TraceDeclarations
18964   __Pyx_RefNannySetupContext("__get__");
18965   __Pyx_TraceCall("__get__", __pyx_f[0], 2101);
18966
18967   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2106
18968  *             cdef char * q
18969  * 
18970  *             src = self._delegate             # <<<<<<<<<<<<<<
18971  * 
18972  *             if src.core.l_qseq == 0: return None
18973  */
18974   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
18975
18976   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2108
18977  *             src = self._delegate
18978  * 
18979  *             if src.core.l_qseq == 0: return None             # <<<<<<<<<<<<<<
18980  * 
18981  *             return get_qual_range(src, 0, src.core.l_qseq)
18982  */
18983   __pyx_t_1 = (__pyx_v_src->core.l_qseq == 0);
18984   if (__pyx_t_1) {
18985     __Pyx_XDECREF(__pyx_r);
18986     __Pyx_INCREF(Py_None);
18987     __pyx_r = Py_None;
18988     goto __pyx_L0;
18989     goto __pyx_L5;
18990   }
18991   __pyx_L5:;
18992
18993   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2110
18994  *             if src.core.l_qseq == 0: return None
18995  * 
18996  *             return get_qual_range(src, 0, src.core.l_qseq)             # <<<<<<<<<<<<<<
18997  * 
18998  *         def __set__(self,qual):
18999  */
19000   __Pyx_XDECREF(__pyx_r);
19001   __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;}
19002   __Pyx_GOTREF(__pyx_t_2);
19003   __pyx_r = __pyx_t_2;
19004   __pyx_t_2 = 0;
19005   goto __pyx_L0;
19006
19007   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
19008   goto __pyx_L0;
19009   __pyx_L1_error:;
19010   __Pyx_XDECREF(__pyx_t_2);
19011   __Pyx_AddTraceback("csamtools.AlignedRead.qual.__get__");
19012   __pyx_r = NULL;
19013   __pyx_L0:;
19014   __Pyx_XGIVEREF(__pyx_r);
19015   __Pyx_TraceReturn(__pyx_r);
19016   __Pyx_RefNannyFinishContext();
19017   return __pyx_r;
19018 }
19019
19020 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2112
19021  *             return get_qual_range(src, 0, src.core.l_qseq)
19022  * 
19023  *         def __set__(self,qual):             # <<<<<<<<<<<<<<
19024  *             # note that space is already allocated via the sequences
19025  *             cdef bam1_t * src
19026  */
19027
19028 static int __pyx_pf_9csamtools_11AlignedRead_4qual___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_qual); /*proto*/
19029 static int __pyx_pf_9csamtools_11AlignedRead_4qual___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_qual) {
19030   bam1_t *__pyx_v_src;
19031   uint8_t *__pyx_v_p;
19032   char *__pyx_v_q;
19033   int __pyx_v_k;
19034   int __pyx_v_l;
19035   int __pyx_r;
19036   PyObject *__pyx_t_1 = NULL;
19037   int __pyx_t_2;
19038   Py_ssize_t __pyx_t_3;
19039   int __pyx_t_4;
19040   int __pyx_t_5;
19041   char *__pyx_t_6;
19042   PyObject *__pyx_t_7 = NULL;
19043   PyObject *__pyx_t_8 = NULL;
19044   int __pyx_t_9;
19045   __Pyx_TraceDeclarations
19046   __Pyx_RefNannySetupContext("__set__");
19047   __Pyx_TraceCall("__set__", __pyx_f[0], 2112);
19048
19049   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2119
19050  *             cdef int k
19051  * 
19052  *             src = self._delegate             # <<<<<<<<<<<<<<
19053  *             p = bam1_qual( src )
19054  *             if qual == None or len(qual) == 0:
19055  */
19056   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
19057
19058   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2120
19059  * 
19060  *             src = self._delegate
19061  *             p = bam1_qual( src )             # <<<<<<<<<<<<<<
19062  *             if qual == None or len(qual) == 0:
19063  *                 # if absent - set to 0xff
19064  */
19065   __pyx_v_p = bam1_qual(__pyx_v_src);
19066
19067   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2121
19068  *             src = self._delegate
19069  *             p = bam1_qual( src )
19070  *             if qual == None or len(qual) == 0:             # <<<<<<<<<<<<<<
19071  *                 # if absent - set to 0xff
19072  *                 p[0] = 0xff
19073  */
19074   __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;}
19075   __Pyx_GOTREF(__pyx_t_1);
19076   __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;}
19077   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
19078   if (!__pyx_t_2) {
19079     __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;}
19080     __pyx_t_4 = (__pyx_t_3 == 0);
19081     __pyx_t_5 = __pyx_t_4;
19082   } else {
19083     __pyx_t_5 = __pyx_t_2;
19084   }
19085   if (__pyx_t_5) {
19086
19087     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2123
19088  *             if qual == None or len(qual) == 0:
19089  *                 # if absent - set to 0xff
19090  *                 p[0] = 0xff             # <<<<<<<<<<<<<<
19091  *                 return
19092  *             cdef int l
19093  */
19094     (__pyx_v_p[0]) = 0xff;
19095
19096     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2124
19097  *                 # if absent - set to 0xff
19098  *                 p[0] = 0xff
19099  *                 return             # <<<<<<<<<<<<<<
19100  *             cdef int l
19101  *             # convert to C string
19102  */
19103     __pyx_r = 0;
19104     goto __pyx_L0;
19105     goto __pyx_L5;
19106   }
19107   __pyx_L5:;
19108
19109   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2127
19110  *             cdef int l
19111  *             # convert to C string
19112  *             q = qual             # <<<<<<<<<<<<<<
19113  *             l = len(qual)
19114  *             if src.core.l_qseq != l:
19115  */
19116   __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;}
19117   __pyx_v_q = __pyx_t_6;
19118
19119   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2128
19120  *             # convert to C string
19121  *             q = qual
19122  *             l = len(qual)             # <<<<<<<<<<<<<<
19123  *             if src.core.l_qseq != l:
19124  *                 raise ValueError("quality and sequence mismatch: %i != %i" % (l, src.core.l_qseq))
19125  */
19126   __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;}
19127   __pyx_v_l = __pyx_t_3;
19128
19129   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2129
19130  *             q = qual
19131  *             l = len(qual)
19132  *             if src.core.l_qseq != l:             # <<<<<<<<<<<<<<
19133  *                 raise ValueError("quality and sequence mismatch: %i != %i" % (l, src.core.l_qseq))
19134  *             assert src.core.l_qseq == l
19135  */
19136   __pyx_t_5 = (__pyx_v_src->core.l_qseq != __pyx_v_l);
19137   if (__pyx_t_5) {
19138
19139     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2130
19140  *             l = len(qual)
19141  *             if src.core.l_qseq != l:
19142  *                 raise ValueError("quality and sequence mismatch: %i != %i" % (l, src.core.l_qseq))             # <<<<<<<<<<<<<<
19143  *             assert src.core.l_qseq == l
19144  *             for k from 0 <= k < l:
19145  */
19146     __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;}
19147     __Pyx_GOTREF(__pyx_t_1);
19148     __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;}
19149     __Pyx_GOTREF(__pyx_t_7);
19150     __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;}
19151     __Pyx_GOTREF(__pyx_t_8);
19152     PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1);
19153     __Pyx_GIVEREF(__pyx_t_1);
19154     PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7);
19155     __Pyx_GIVEREF(__pyx_t_7);
19156     __pyx_t_1 = 0;
19157     __pyx_t_7 = 0;
19158     __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;}
19159     __Pyx_GOTREF(((PyObject *)__pyx_t_7));
19160     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
19161     __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;}
19162     __Pyx_GOTREF(__pyx_t_8);
19163     PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_t_7));
19164     __Pyx_GIVEREF(((PyObject *)__pyx_t_7));
19165     __pyx_t_7 = 0;
19166     __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;}
19167     __Pyx_GOTREF(__pyx_t_7);
19168     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
19169     __Pyx_Raise(__pyx_t_7, 0, 0);
19170     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
19171     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
19172     goto __pyx_L6;
19173   }
19174   __pyx_L6:;
19175
19176   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2131
19177  *             if src.core.l_qseq != l:
19178  *                 raise ValueError("quality and sequence mismatch: %i != %i" % (l, src.core.l_qseq))
19179  *             assert src.core.l_qseq == l             # <<<<<<<<<<<<<<
19180  *             for k from 0 <= k < l:
19181  *                 p[k] = <uint8_t>q[k] - 33
19182  */
19183   #ifndef PYREX_WITHOUT_ASSERTIONS
19184   if (unlikely(!(__pyx_v_src->core.l_qseq == __pyx_v_l))) {
19185     PyErr_SetNone(PyExc_AssertionError);
19186     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
19187   }
19188   #endif
19189
19190   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2132
19191  *                 raise ValueError("quality and sequence mismatch: %i != %i" % (l, src.core.l_qseq))
19192  *             assert src.core.l_qseq == l
19193  *             for k from 0 <= k < l:             # <<<<<<<<<<<<<<
19194  *                 p[k] = <uint8_t>q[k] - 33
19195  * 
19196  */
19197   __pyx_t_9 = __pyx_v_l;
19198   for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_9; __pyx_v_k++) {
19199
19200     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2133
19201  *             assert src.core.l_qseq == l
19202  *             for k from 0 <= k < l:
19203  *                 p[k] = <uint8_t>q[k] - 33             # <<<<<<<<<<<<<<
19204  * 
19205  *     property query:
19206  */
19207     (__pyx_v_p[__pyx_v_k]) = (((uint8_t)(__pyx_v_q[__pyx_v_k])) - 33);
19208   }
19209
19210   __pyx_r = 0;
19211   goto __pyx_L0;
19212   __pyx_L1_error:;
19213   __Pyx_XDECREF(__pyx_t_1);
19214   __Pyx_XDECREF(__pyx_t_7);
19215   __Pyx_XDECREF(__pyx_t_8);
19216   __Pyx_AddTraceback("csamtools.AlignedRead.qual.__set__");
19217   __pyx_r = -1;
19218   __pyx_L0:;
19219   __Pyx_TraceReturn(Py_None);
19220   __Pyx_RefNannyFinishContext();
19221   return __pyx_r;
19222 }
19223
19224 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2145
19225  *         were not considered for alignment may have been retained."""
19226  * 
19227  *         def __get__(self):             # <<<<<<<<<<<<<<
19228  *             cdef bam1_t * src
19229  *             cdef uint32_t start, end
19230  */
19231
19232 static PyObject *__pyx_pf_9csamtools_11AlignedRead_5query___get__(PyObject *__pyx_v_self); /*proto*/
19233 static PyObject *__pyx_pf_9csamtools_11AlignedRead_5query___get__(PyObject *__pyx_v_self) {
19234   bam1_t *__pyx_v_src;
19235   uint32_t __pyx_v_start;
19236   uint32_t __pyx_v_end;
19237   PyObject *__pyx_r = NULL;
19238   int __pyx_t_1;
19239   int32_t __pyx_t_2;
19240   PyObject *__pyx_t_3 = NULL;
19241   __Pyx_TraceDeclarations
19242   __Pyx_RefNannySetupContext("__get__");
19243   __Pyx_TraceCall("__get__", __pyx_f[0], 2145);
19244
19245   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2150
19246  *             cdef char * s
19247  * 
19248  *             src = self._delegate             # <<<<<<<<<<<<<<
19249  * 
19250  *             if src.core.l_qseq == 0: return None
19251  */
19252   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
19253
19254   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2152
19255  *             src = self._delegate
19256  * 
19257  *             if src.core.l_qseq == 0: return None             # <<<<<<<<<<<<<<
19258  * 
19259  *             start = query_start(src)
19260  */
19261   __pyx_t_1 = (__pyx_v_src->core.l_qseq == 0);
19262   if (__pyx_t_1) {
19263     __Pyx_XDECREF(__pyx_r);
19264     __Pyx_INCREF(Py_None);
19265     __pyx_r = Py_None;
19266     goto __pyx_L0;
19267     goto __pyx_L5;
19268   }
19269   __pyx_L5:;
19270
19271   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2154
19272  *             if src.core.l_qseq == 0: return None
19273  * 
19274  *             start = query_start(src)             # <<<<<<<<<<<<<<
19275  *             end   = query_end(src)
19276  * 
19277  */
19278   __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;}
19279   __pyx_v_start = __pyx_t_2;
19280
19281   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2155
19282  * 
19283  *             start = query_start(src)
19284  *             end   = query_end(src)             # <<<<<<<<<<<<<<
19285  * 
19286  *             return get_seq_range(src, start, end)
19287  */
19288   __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;}
19289   __pyx_v_end = __pyx_t_2;
19290
19291   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2157
19292  *             end   = query_end(src)
19293  * 
19294  *             return get_seq_range(src, start, end)             # <<<<<<<<<<<<<<
19295  * 
19296  *     property qqual:
19297  */
19298   __Pyx_XDECREF(__pyx_r);
19299   __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;}
19300   __Pyx_GOTREF(__pyx_t_3);
19301   __pyx_r = __pyx_t_3;
19302   __pyx_t_3 = 0;
19303   goto __pyx_L0;
19304
19305   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
19306   goto __pyx_L0;
19307   __pyx_L1_error:;
19308   __Pyx_XDECREF(__pyx_t_3);
19309   __Pyx_AddTraceback("csamtools.AlignedRead.query.__get__");
19310   __pyx_r = NULL;
19311   __pyx_L0:;
19312   __Pyx_XGIVEREF(__pyx_r);
19313   __Pyx_TraceReturn(__pyx_r);
19314   __Pyx_RefNannyFinishContext();
19315   return __pyx_r;
19316 }
19317
19318 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2161
19319  *     property qqual:
19320  *         """aligned query sequence quality values (None if not present)"""
19321  *         def __get__(self):             # <<<<<<<<<<<<<<
19322  *             cdef bam1_t * src
19323  *             cdef uint32_t start, end
19324  */
19325
19326 static PyObject *__pyx_pf_9csamtools_11AlignedRead_5qqual___get__(PyObject *__pyx_v_self); /*proto*/
19327 static PyObject *__pyx_pf_9csamtools_11AlignedRead_5qqual___get__(PyObject *__pyx_v_self) {
19328   bam1_t *__pyx_v_src;
19329   uint32_t __pyx_v_start;
19330   uint32_t __pyx_v_end;
19331   PyObject *__pyx_r = NULL;
19332   int __pyx_t_1;
19333   int32_t __pyx_t_2;
19334   PyObject *__pyx_t_3 = NULL;
19335   __Pyx_TraceDeclarations
19336   __Pyx_RefNannySetupContext("__get__");
19337   __Pyx_TraceCall("__get__", __pyx_f[0], 2161);
19338
19339   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2166
19340  *             cdef char * q
19341  * 
19342  *             src = self._delegate             # <<<<<<<<<<<<<<
19343  * 
19344  *             if src.core.l_qseq == 0: return None
19345  */
19346   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
19347
19348   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2168
19349  *             src = self._delegate
19350  * 
19351  *             if src.core.l_qseq == 0: return None             # <<<<<<<<<<<<<<
19352  * 
19353  *             start = query_start(src)
19354  */
19355   __pyx_t_1 = (__pyx_v_src->core.l_qseq == 0);
19356   if (__pyx_t_1) {
19357     __Pyx_XDECREF(__pyx_r);
19358     __Pyx_INCREF(Py_None);
19359     __pyx_r = Py_None;
19360     goto __pyx_L0;
19361     goto __pyx_L5;
19362   }
19363   __pyx_L5:;
19364
19365   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2170
19366  *             if src.core.l_qseq == 0: return None
19367  * 
19368  *             start = query_start(src)             # <<<<<<<<<<<<<<
19369  *             end   = query_end(src)
19370  * 
19371  */
19372   __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;}
19373   __pyx_v_start = __pyx_t_2;
19374
19375   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2171
19376  * 
19377  *             start = query_start(src)
19378  *             end   = query_end(src)             # <<<<<<<<<<<<<<
19379  * 
19380  *             return get_qual_range(src, start, end)
19381  */
19382   __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;}
19383   __pyx_v_end = __pyx_t_2;
19384
19385   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2173
19386  *             end   = query_end(src)
19387  * 
19388  *             return get_qual_range(src, start, end)             # <<<<<<<<<<<<<<
19389  * 
19390  *     property qstart:
19391  */
19392   __Pyx_XDECREF(__pyx_r);
19393   __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;}
19394   __Pyx_GOTREF(__pyx_t_3);
19395   __pyx_r = __pyx_t_3;
19396   __pyx_t_3 = 0;
19397   goto __pyx_L0;
19398
19399   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
19400   goto __pyx_L0;
19401   __pyx_L1_error:;
19402   __Pyx_XDECREF(__pyx_t_3);
19403   __Pyx_AddTraceback("csamtools.AlignedRead.qqual.__get__");
19404   __pyx_r = NULL;
19405   __pyx_L0:;
19406   __Pyx_XGIVEREF(__pyx_r);
19407   __Pyx_TraceReturn(__pyx_r);
19408   __Pyx_RefNannyFinishContext();
19409   return __pyx_r;
19410 }
19411
19412 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2177
19413  *     property qstart:
19414  *         """start index of the aligned query portion of the sequence (0-based, inclusive)"""
19415  *         def __get__(self):             # <<<<<<<<<<<<<<
19416  *             return query_start(self._delegate)
19417  * 
19418  */
19419
19420 static PyObject *__pyx_pf_9csamtools_11AlignedRead_6qstart___get__(PyObject *__pyx_v_self); /*proto*/
19421 static PyObject *__pyx_pf_9csamtools_11AlignedRead_6qstart___get__(PyObject *__pyx_v_self) {
19422   PyObject *__pyx_r = NULL;
19423   int32_t __pyx_t_1;
19424   PyObject *__pyx_t_2 = NULL;
19425   __Pyx_TraceDeclarations
19426   __Pyx_RefNannySetupContext("__get__");
19427   __Pyx_TraceCall("__get__", __pyx_f[0], 2177);
19428
19429   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2178
19430  *         """start index of the aligned query portion of the sequence (0-based, inclusive)"""
19431  *         def __get__(self):
19432  *             return query_start(self._delegate)             # <<<<<<<<<<<<<<
19433  * 
19434  *     property qend:
19435  */
19436   __Pyx_XDECREF(__pyx_r);
19437   __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;}
19438   __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;}
19439   __Pyx_GOTREF(__pyx_t_2);
19440   __pyx_r = __pyx_t_2;
19441   __pyx_t_2 = 0;
19442   goto __pyx_L0;
19443
19444   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
19445   goto __pyx_L0;
19446   __pyx_L1_error:;
19447   __Pyx_XDECREF(__pyx_t_2);
19448   __Pyx_AddTraceback("csamtools.AlignedRead.qstart.__get__");
19449   __pyx_r = NULL;
19450   __pyx_L0:;
19451   __Pyx_XGIVEREF(__pyx_r);
19452   __Pyx_TraceReturn(__pyx_r);
19453   __Pyx_RefNannyFinishContext();
19454   return __pyx_r;
19455 }
19456
19457 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2182
19458  *     property qend:
19459  *         """end index of the aligned query portion of the sequence (0-based, exclusive)"""
19460  *         def __get__(self):             # <<<<<<<<<<<<<<
19461  *             return query_end(self._delegate)
19462  * 
19463  */
19464
19465 static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qend___get__(PyObject *__pyx_v_self); /*proto*/
19466 static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qend___get__(PyObject *__pyx_v_self) {
19467   PyObject *__pyx_r = NULL;
19468   int32_t __pyx_t_1;
19469   PyObject *__pyx_t_2 = NULL;
19470   __Pyx_TraceDeclarations
19471   __Pyx_RefNannySetupContext("__get__");
19472   __Pyx_TraceCall("__get__", __pyx_f[0], 2182);
19473
19474   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2183
19475  *         """end index of the aligned query portion of the sequence (0-based, exclusive)"""
19476  *         def __get__(self):
19477  *             return query_end(self._delegate)             # <<<<<<<<<<<<<<
19478  * 
19479  *     property qlen:
19480  */
19481   __Pyx_XDECREF(__pyx_r);
19482   __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;}
19483   __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;}
19484   __Pyx_GOTREF(__pyx_t_2);
19485   __pyx_r = __pyx_t_2;
19486   __pyx_t_2 = 0;
19487   goto __pyx_L0;
19488
19489   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
19490   goto __pyx_L0;
19491   __pyx_L1_error:;
19492   __Pyx_XDECREF(__pyx_t_2);
19493   __Pyx_AddTraceback("csamtools.AlignedRead.qend.__get__");
19494   __pyx_r = NULL;
19495   __pyx_L0:;
19496   __Pyx_XGIVEREF(__pyx_r);
19497   __Pyx_TraceReturn(__pyx_r);
19498   __Pyx_RefNannyFinishContext();
19499   return __pyx_r;
19500 }
19501
19502 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2187
19503  *     property qlen:
19504  *         """Length of the aligned query sequence"""
19505  *         def __get__(self):             # <<<<<<<<<<<<<<
19506  *             cdef bam1_t * src
19507  *             src = self._delegate
19508  */
19509
19510 static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qlen___get__(PyObject *__pyx_v_self); /*proto*/
19511 static PyObject *__pyx_pf_9csamtools_11AlignedRead_4qlen___get__(PyObject *__pyx_v_self) {
19512   bam1_t *__pyx_v_src;
19513   PyObject *__pyx_r = NULL;
19514   int32_t __pyx_t_1;
19515   int32_t __pyx_t_2;
19516   PyObject *__pyx_t_3 = NULL;
19517   __Pyx_TraceDeclarations
19518   __Pyx_RefNannySetupContext("__get__");
19519   __Pyx_TraceCall("__get__", __pyx_f[0], 2187);
19520
19521   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2189
19522  *         def __get__(self):
19523  *             cdef bam1_t * src
19524  *             src = self._delegate             # <<<<<<<<<<<<<<
19525  *             return query_end(src)-query_start(src)
19526  * 
19527  */
19528   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
19529
19530   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2190
19531  *             cdef bam1_t * src
19532  *             src = self._delegate
19533  *             return query_end(src)-query_start(src)             # <<<<<<<<<<<<<<
19534  * 
19535  *     property tags:
19536  */
19537   __Pyx_XDECREF(__pyx_r);
19538   __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;}
19539   __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;}
19540   __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;}
19541   __Pyx_GOTREF(__pyx_t_3);
19542   __pyx_r = __pyx_t_3;
19543   __pyx_t_3 = 0;
19544   goto __pyx_L0;
19545
19546   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
19547   goto __pyx_L0;
19548   __pyx_L1_error:;
19549   __Pyx_XDECREF(__pyx_t_3);
19550   __Pyx_AddTraceback("csamtools.AlignedRead.qlen.__get__");
19551   __pyx_r = NULL;
19552   __pyx_L0:;
19553   __Pyx_XGIVEREF(__pyx_r);
19554   __Pyx_TraceReturn(__pyx_r);
19555   __Pyx_RefNannyFinishContext();
19556   return __pyx_r;
19557 }
19558
19559 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2204
19560  * 
19561  *         """
19562  *         def __get__(self):             # <<<<<<<<<<<<<<
19563  *             cdef char * ctag
19564  *             cdef bam1_t * src
19565  */
19566
19567 static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx_v_self); /*proto*/
19568 static PyObject *__pyx_pf_9csamtools_11AlignedRead_4tags___get__(PyObject *__pyx_v_self) {
19569   bam1_t *__pyx_v_src;
19570   uint8_t *__pyx_v_s;
19571   char __pyx_v_auxtag[3];
19572   char __pyx_v_auxtype;
19573   PyObject *__pyx_v_result;
19574   PyObject *__pyx_v_value;
19575   PyObject *__pyx_r = NULL;
19576   int __pyx_t_1;
19577   PyObject *__pyx_t_2 = NULL;
19578   char __pyx_t_3;
19579   int __pyx_t_4;
19580   int __pyx_t_5;
19581   PyObject *__pyx_t_6 = NULL;
19582   Py_ssize_t __pyx_t_7;
19583   int __pyx_t_8;
19584   __Pyx_TraceDeclarations
19585   __Pyx_RefNannySetupContext("__get__");
19586   __Pyx_TraceCall("__get__", __pyx_f[0], 2204);
19587   __pyx_v_result = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
19588   __pyx_v_value = Py_None; __Pyx_INCREF(Py_None);
19589
19590   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2211
19591  *             cdef char auxtype
19592  * 
19593  *             src = self._delegate             # <<<<<<<<<<<<<<
19594  *             if src.l_aux == 0: return None
19595  * 
19596  */
19597   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
19598
19599   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2212
19600  * 
19601  *             src = self._delegate
19602  *             if src.l_aux == 0: return None             # <<<<<<<<<<<<<<
19603  * 
19604  *             s = bam1_aux( src )
19605  */
19606   __pyx_t_1 = (__pyx_v_src->l_aux == 0);
19607   if (__pyx_t_1) {
19608     __Pyx_XDECREF(__pyx_r);
19609     __Pyx_INCREF(Py_None);
19610     __pyx_r = Py_None;
19611     goto __pyx_L0;
19612     goto __pyx_L5;
19613   }
19614   __pyx_L5:;
19615
19616   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2214
19617  *             if src.l_aux == 0: return None
19618  * 
19619  *             s = bam1_aux( src )             # <<<<<<<<<<<<<<
19620  *             result = []
19621  *             auxtag[2] = 0
19622  */
19623   __pyx_v_s = bam1_aux(__pyx_v_src);
19624
19625   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2215
19626  * 
19627  *             s = bam1_aux( src )
19628  *             result = []             # <<<<<<<<<<<<<<
19629  *             auxtag[2] = 0
19630  *             while s < (src.data + src.data_len):
19631  */
19632   __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;}
19633   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
19634   __Pyx_DECREF(((PyObject *)__pyx_v_result));
19635   __pyx_v_result = __pyx_t_2;
19636   __pyx_t_2 = 0;
19637
19638   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2216
19639  *             s = bam1_aux( src )
19640  *             result = []
19641  *             auxtag[2] = 0             # <<<<<<<<<<<<<<
19642  *             while s < (src.data + src.data_len):
19643  *                 # get tag
19644  */
19645   (__pyx_v_auxtag[2]) = 0;
19646
19647   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2217
19648  *             result = []
19649  *             auxtag[2] = 0
19650  *             while s < (src.data + src.data_len):             # <<<<<<<<<<<<<<
19651  *                 # get tag
19652  *                 auxtag[0] = s[0]
19653  */
19654   while (1) {
19655     __pyx_t_1 = (__pyx_v_s < (__pyx_v_src->data + __pyx_v_src->data_len));
19656     if (!__pyx_t_1) break;
19657
19658     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2219
19659  *             while s < (src.data + src.data_len):
19660  *                 # get tag
19661  *                 auxtag[0] = s[0]             # <<<<<<<<<<<<<<
19662  *                 auxtag[1] = s[1]
19663  *                 s += 2
19664  */
19665     (__pyx_v_auxtag[0]) = (__pyx_v_s[0]);
19666
19667     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2220
19668  *                 # get tag
19669  *                 auxtag[0] = s[0]
19670  *                 auxtag[1] = s[1]             # <<<<<<<<<<<<<<
19671  *                 s += 2
19672  *                 auxtype = s[0]
19673  */
19674     (__pyx_v_auxtag[1]) = (__pyx_v_s[1]);
19675
19676     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2221
19677  *                 auxtag[0] = s[0]
19678  *                 auxtag[1] = s[1]
19679  *                 s += 2             # <<<<<<<<<<<<<<
19680  *                 auxtype = s[0]
19681  * 
19682  */
19683     __pyx_v_s += 2;
19684
19685     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2222
19686  *                 auxtag[1] = s[1]
19687  *                 s += 2
19688  *                 auxtype = s[0]             # <<<<<<<<<<<<<<
19689  * 
19690  *                 if auxtype in ('c', 'C'):
19691  */
19692     __pyx_v_auxtype = (__pyx_v_s[0]);
19693
19694     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2224
19695  *                 auxtype = s[0]
19696  * 
19697  *                 if auxtype in ('c', 'C'):             # <<<<<<<<<<<<<<
19698  *                     value = <int>bam_aux2i(s)
19699  *                     s += 1
19700  */
19701     __pyx_t_3 = __pyx_v_auxtype;
19702     __pyx_t_1 = (__pyx_t_3 == 'c');
19703     if (!__pyx_t_1) {
19704       __pyx_t_4 = (__pyx_t_3 == 'C');
19705       __pyx_t_5 = __pyx_t_4;
19706     } else {
19707       __pyx_t_5 = __pyx_t_1;
19708     }
19709     __pyx_t_1 = __pyx_t_5;
19710     if (__pyx_t_1) {
19711
19712       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2225
19713  * 
19714  *                 if auxtype in ('c', 'C'):
19715  *                     value = <int>bam_aux2i(s)             # <<<<<<<<<<<<<<
19716  *                     s += 1
19717  *                 elif auxtype in ('s', 'S'):
19718  */
19719       __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;}
19720       __Pyx_GOTREF(__pyx_t_2);
19721       __Pyx_DECREF(__pyx_v_value);
19722       __pyx_v_value = __pyx_t_2;
19723       __pyx_t_2 = 0;
19724
19725       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2226
19726  *                 if auxtype in ('c', 'C'):
19727  *                     value = <int>bam_aux2i(s)
19728  *                     s += 1             # <<<<<<<<<<<<<<
19729  *                 elif auxtype in ('s', 'S'):
19730  *                     value = <int>bam_aux2i(s)
19731  */
19732       __pyx_v_s += 1;
19733       goto __pyx_L8;
19734     }
19735
19736     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2227
19737  *                     value = <int>bam_aux2i(s)
19738  *                     s += 1
19739  *                 elif auxtype in ('s', 'S'):             # <<<<<<<<<<<<<<
19740  *                     value = <int>bam_aux2i(s)
19741  *                     s += 2
19742  */
19743     __pyx_t_3 = __pyx_v_auxtype;
19744     __pyx_t_1 = (__pyx_t_3 == 's');
19745     if (!__pyx_t_1) {
19746       __pyx_t_5 = (__pyx_t_3 == 'S');
19747       __pyx_t_4 = __pyx_t_5;
19748     } else {
19749       __pyx_t_4 = __pyx_t_1;
19750     }
19751     __pyx_t_1 = __pyx_t_4;
19752     if (__pyx_t_1) {
19753
19754       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2228
19755  *                     s += 1
19756  *                 elif auxtype in ('s', 'S'):
19757  *                     value = <int>bam_aux2i(s)             # <<<<<<<<<<<<<<
19758  *                     s += 2
19759  *                 elif auxtype in ('i', 'I'):
19760  */
19761       __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;}
19762       __Pyx_GOTREF(__pyx_t_2);
19763       __Pyx_DECREF(__pyx_v_value);
19764       __pyx_v_value = __pyx_t_2;
19765       __pyx_t_2 = 0;
19766
19767       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2229
19768  *                 elif auxtype in ('s', 'S'):
19769  *                     value = <int>bam_aux2i(s)
19770  *                     s += 2             # <<<<<<<<<<<<<<
19771  *                 elif auxtype in ('i', 'I'):
19772  *                     value = <float>bam_aux2i(s)
19773  */
19774       __pyx_v_s += 2;
19775       goto __pyx_L8;
19776     }
19777
19778     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2230
19779  *                     value = <int>bam_aux2i(s)
19780  *                     s += 2
19781  *                 elif auxtype in ('i', 'I'):             # <<<<<<<<<<<<<<
19782  *                     value = <float>bam_aux2i(s)
19783  *                     s += 4
19784  */
19785     __pyx_t_3 = __pyx_v_auxtype;
19786     __pyx_t_1 = (__pyx_t_3 == 'i');
19787     if (!__pyx_t_1) {
19788       __pyx_t_4 = (__pyx_t_3 == 'I');
19789       __pyx_t_5 = __pyx_t_4;
19790     } else {
19791       __pyx_t_5 = __pyx_t_1;
19792     }
19793     __pyx_t_1 = __pyx_t_5;
19794     if (__pyx_t_1) {
19795
19796       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2231
19797  *                     s += 2
19798  *                 elif auxtype in ('i', 'I'):
19799  *                     value = <float>bam_aux2i(s)             # <<<<<<<<<<<<<<
19800  *                     s += 4
19801  *                 elif auxtype == 'f':
19802  */
19803       __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;}
19804       __Pyx_GOTREF(__pyx_t_2);
19805       __Pyx_DECREF(__pyx_v_value);
19806       __pyx_v_value = __pyx_t_2;
19807       __pyx_t_2 = 0;
19808
19809       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2232
19810  *                 elif auxtype in ('i', 'I'):
19811  *                     value = <float>bam_aux2i(s)
19812  *                     s += 4             # <<<<<<<<<<<<<<
19813  *                 elif auxtype == 'f':
19814  *                     value = <float>bam_aux2f(s)
19815  */
19816       __pyx_v_s += 4;
19817       goto __pyx_L8;
19818     }
19819
19820     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2233
19821  *                     value = <float>bam_aux2i(s)
19822  *                     s += 4
19823  *                 elif auxtype == 'f':             # <<<<<<<<<<<<<<
19824  *                     value = <float>bam_aux2f(s)
19825  *                     s += 4
19826  */
19827     __pyx_t_1 = (__pyx_v_auxtype == 'f');
19828     if (__pyx_t_1) {
19829
19830       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2234
19831  *                     s += 4
19832  *                 elif auxtype == 'f':
19833  *                     value = <float>bam_aux2f(s)             # <<<<<<<<<<<<<<
19834  *                     s += 4
19835  *                 elif auxtype == 'd':
19836  */
19837       __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;}
19838       __Pyx_GOTREF(__pyx_t_2);
19839       __Pyx_DECREF(__pyx_v_value);
19840       __pyx_v_value = __pyx_t_2;
19841       __pyx_t_2 = 0;
19842
19843       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2235
19844  *                 elif auxtype == 'f':
19845  *                     value = <float>bam_aux2f(s)
19846  *                     s += 4             # <<<<<<<<<<<<<<
19847  *                 elif auxtype == 'd':
19848  *                     value = <double>bam_aux2d(s)
19849  */
19850       __pyx_v_s += 4;
19851       goto __pyx_L8;
19852     }
19853
19854     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2236
19855  *                     value = <float>bam_aux2f(s)
19856  *                     s += 4
19857  *                 elif auxtype == 'd':             # <<<<<<<<<<<<<<
19858  *                     value = <double>bam_aux2d(s)
19859  *                     s += 8
19860  */
19861     __pyx_t_1 = (__pyx_v_auxtype == 'd');
19862     if (__pyx_t_1) {
19863
19864       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2237
19865  *                     s += 4
19866  *                 elif auxtype == 'd':
19867  *                     value = <double>bam_aux2d(s)             # <<<<<<<<<<<<<<
19868  *                     s += 8
19869  *                 elif auxtype == 'A':
19870  */
19871       __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;}
19872       __Pyx_GOTREF(__pyx_t_2);
19873       __Pyx_DECREF(__pyx_v_value);
19874       __pyx_v_value = __pyx_t_2;
19875       __pyx_t_2 = 0;
19876
19877       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2238
19878  *                 elif auxtype == 'd':
19879  *                     value = <double>bam_aux2d(s)
19880  *                     s += 8             # <<<<<<<<<<<<<<
19881  *                 elif auxtype == 'A':
19882  *                     value = "%c" % <char>bam_aux2A(s)
19883  */
19884       __pyx_v_s += 8;
19885       goto __pyx_L8;
19886     }
19887
19888     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2239
19889  *                     value = <double>bam_aux2d(s)
19890  *                     s += 8
19891  *                 elif auxtype == 'A':             # <<<<<<<<<<<<<<
19892  *                     value = "%c" % <char>bam_aux2A(s)
19893  *                     s += 1
19894  */
19895     __pyx_t_1 = (__pyx_v_auxtype == 'A');
19896     if (__pyx_t_1) {
19897
19898       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2240
19899  *                     s += 8
19900  *                 elif auxtype == 'A':
19901  *                     value = "%c" % <char>bam_aux2A(s)             # <<<<<<<<<<<<<<
19902  *                     s += 1
19903  *                 elif auxtype in ('Z', 'H'):
19904  */
19905       __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;}
19906       __Pyx_GOTREF(__pyx_t_2);
19907       __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;}
19908       __Pyx_GOTREF(((PyObject *)__pyx_t_6));
19909       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
19910       __Pyx_DECREF(__pyx_v_value);
19911       __pyx_v_value = ((PyObject *)__pyx_t_6);
19912       __pyx_t_6 = 0;
19913
19914       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2241
19915  *                 elif auxtype == 'A':
19916  *                     value = "%c" % <char>bam_aux2A(s)
19917  *                     s += 1             # <<<<<<<<<<<<<<
19918  *                 elif auxtype in ('Z', 'H'):
19919  *                     value = <char*>bam_aux2Z(s)
19920  */
19921       __pyx_v_s += 1;
19922       goto __pyx_L8;
19923     }
19924
19925     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2242
19926  *                     value = "%c" % <char>bam_aux2A(s)
19927  *                     s += 1
19928  *                 elif auxtype in ('Z', 'H'):             # <<<<<<<<<<<<<<
19929  *                     value = <char*>bam_aux2Z(s)
19930  *                     # +1 for NULL terminated string
19931  */
19932     __pyx_t_3 = __pyx_v_auxtype;
19933     __pyx_t_1 = (__pyx_t_3 == 'Z');
19934     if (!__pyx_t_1) {
19935       __pyx_t_5 = (__pyx_t_3 == 'H');
19936       __pyx_t_4 = __pyx_t_5;
19937     } else {
19938       __pyx_t_4 = __pyx_t_1;
19939     }
19940     __pyx_t_1 = __pyx_t_4;
19941     if (__pyx_t_1) {
19942
19943       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2243
19944  *                     s += 1
19945  *                 elif auxtype in ('Z', 'H'):
19946  *                     value = <char*>bam_aux2Z(s)             # <<<<<<<<<<<<<<
19947  *                     # +1 for NULL terminated string
19948  *                     s += len(value) + 1
19949  */
19950       __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;}
19951       __Pyx_GOTREF(((PyObject *)__pyx_t_6));
19952       __Pyx_DECREF(__pyx_v_value);
19953       __pyx_v_value = ((PyObject *)__pyx_t_6);
19954       __pyx_t_6 = 0;
19955
19956       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2245
19957  *                     value = <char*>bam_aux2Z(s)
19958  *                     # +1 for NULL terminated string
19959  *                     s += len(value) + 1             # <<<<<<<<<<<<<<
19960  *                  #
19961  *                 s += 1
19962  */
19963       __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;}
19964       __pyx_v_s += (__pyx_t_7 + 1);
19965       goto __pyx_L8;
19966     }
19967     __pyx_L8:;
19968
19969     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2247
19970  *                     s += len(value) + 1
19971  *                  #
19972  *                 s += 1             # <<<<<<<<<<<<<<
19973  * 
19974  *                 result.append( (auxtag, value) )
19975  */
19976     __pyx_v_s += 1;
19977
19978     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2249
19979  *                 s += 1
19980  * 
19981  *                 result.append( (auxtag, value) )             # <<<<<<<<<<<<<<
19982  * 
19983  *             return result
19984  */
19985     if (unlikely(__pyx_v_result == Py_None)) {
19986       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;} 
19987     }
19988     __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;}
19989     __Pyx_GOTREF(((PyObject *)__pyx_t_6));
19990     __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;}
19991     __Pyx_GOTREF(__pyx_t_2);
19992     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_6));
19993     __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
19994     __Pyx_INCREF(__pyx_v_value);
19995     PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_value);
19996     __Pyx_GIVEREF(__pyx_v_value);
19997     __pyx_t_6 = 0;
19998     __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;}
19999     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
20000   }
20001
20002   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2251
20003  *                 result.append( (auxtag, value) )
20004  * 
20005  *             return result             # <<<<<<<<<<<<<<
20006  * 
20007  *         def __set__(self, tags):
20008  */
20009   __Pyx_XDECREF(__pyx_r);
20010   __Pyx_INCREF(((PyObject *)__pyx_v_result));
20011   __pyx_r = ((PyObject *)__pyx_v_result);
20012   goto __pyx_L0;
20013
20014   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
20015   goto __pyx_L0;
20016   __pyx_L1_error:;
20017   __Pyx_XDECREF(__pyx_t_2);
20018   __Pyx_XDECREF(__pyx_t_6);
20019   __Pyx_AddTraceback("csamtools.AlignedRead.tags.__get__");
20020   __pyx_r = NULL;
20021   __pyx_L0:;
20022   __Pyx_DECREF(__pyx_v_result);
20023   __Pyx_DECREF(__pyx_v_value);
20024   __Pyx_XGIVEREF(__pyx_r);
20025   __Pyx_TraceReturn(__pyx_r);
20026   __Pyx_RefNannyFinishContext();
20027   return __pyx_r;
20028 }
20029
20030 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2253
20031  *             return result
20032  * 
20033  *         def __set__(self, tags):             # <<<<<<<<<<<<<<
20034  *             cdef char * ctag
20035  *             cdef bam1_t * src
20036  */
20037
20038 static int __pyx_pf_9csamtools_11AlignedRead_4tags___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_tags); /*proto*/
20039 static int __pyx_pf_9csamtools_11AlignedRead_4tags___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_tags) {
20040   bam1_t *__pyx_v_src;
20041   uint8_t *__pyx_v_s;
20042   char *__pyx_v_temp;
20043   int __pyx_v_max_size;
20044   int __pyx_v_size;
20045   int __pyx_v_offset;
20046   PyObject *__pyx_v_buffer;
20047   PyObject *__pyx_v_pytag;
20048   PyObject *__pyx_v_value;
20049   PyObject *__pyx_v_t;
20050   PyObject *__pyx_v_fmt;
20051   PyObject *__pyx_v_pytype;
20052   int __pyx_r;
20053   PyObject *__pyx_t_1 = NULL;
20054   int __pyx_t_2;
20055   PyObject *__pyx_t_3 = NULL;
20056   PyObject *__pyx_t_4 = NULL;
20057   Py_ssize_t __pyx_t_5;
20058   PyObject *__pyx_t_6 = NULL;
20059   PyObject *__pyx_t_7 = NULL;
20060   Py_ssize_t __pyx_t_8;
20061   int __pyx_t_9;
20062   PyObject *__pyx_t_10 = NULL;
20063   char *__pyx_t_11;
20064   __Pyx_TraceDeclarations
20065   __Pyx_RefNannySetupContext("__set__");
20066   __Pyx_TraceCall("__set__", __pyx_f[0], 2253);
20067   __pyx_v_buffer = Py_None; __Pyx_INCREF(Py_None);
20068   __pyx_v_pytag = Py_None; __Pyx_INCREF(Py_None);
20069   __pyx_v_value = Py_None; __Pyx_INCREF(Py_None);
20070   __pyx_v_t = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
20071   __pyx_v_fmt = Py_None; __Pyx_INCREF(Py_None);
20072   __pyx_v_pytype = Py_None; __Pyx_INCREF(Py_None);
20073
20074   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2262
20075  *             cdef int max_size, size, offset
20076  * 
20077  *             src = self._delegate             # <<<<<<<<<<<<<<
20078  *             max_size = 4000
20079  *             offset = 0
20080  */
20081   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
20082
20083   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2263
20084  * 
20085  *             src = self._delegate
20086  *             max_size = 4000             # <<<<<<<<<<<<<<
20087  *             offset = 0
20088  * 
20089  */
20090   __pyx_v_max_size = 4000;
20091
20092   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2264
20093  *             src = self._delegate
20094  *             max_size = 4000
20095  *             offset = 0             # <<<<<<<<<<<<<<
20096  * 
20097  *             if tags != None:
20098  */
20099   __pyx_v_offset = 0;
20100
20101   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2266
20102  *             offset = 0
20103  * 
20104  *             if tags != None:             # <<<<<<<<<<<<<<
20105  * 
20106  *                 # map samtools code to python.struct code and byte size
20107  */
20108   __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;}
20109   __Pyx_GOTREF(__pyx_t_1);
20110   __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;}
20111   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20112   if (__pyx_t_2) {
20113
20114     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2269
20115  * 
20116  *                 # map samtools code to python.struct code and byte size
20117  *                 buffer = ctypes.create_string_buffer(max_size)             # <<<<<<<<<<<<<<
20118  * 
20119  *                 for pytag, value in tags:
20120  */
20121     __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;}
20122     __Pyx_GOTREF(__pyx_t_1);
20123     __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;}
20124     __Pyx_GOTREF(__pyx_t_3);
20125     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20126     __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;}
20127     __Pyx_GOTREF(__pyx_t_1);
20128     __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;}
20129     __Pyx_GOTREF(__pyx_t_4);
20130     PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
20131     __Pyx_GIVEREF(__pyx_t_1);
20132     __pyx_t_1 = 0;
20133     __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;}
20134     __Pyx_GOTREF(__pyx_t_1);
20135     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
20136     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
20137     __Pyx_DECREF(__pyx_v_buffer);
20138     __pyx_v_buffer = __pyx_t_1;
20139     __pyx_t_1 = 0;
20140
20141     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2271
20142  *                 buffer = ctypes.create_string_buffer(max_size)
20143  * 
20144  *                 for pytag, value in tags:             # <<<<<<<<<<<<<<
20145  *                     t = type(value)
20146  *                     if t == types.FloatType:
20147  */
20148     if (PyList_CheckExact(__pyx_v_tags) || PyTuple_CheckExact(__pyx_v_tags)) {
20149       __pyx_t_5 = 0; __pyx_t_1 = __pyx_v_tags; __Pyx_INCREF(__pyx_t_1);
20150     } else {
20151       __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;}
20152       __Pyx_GOTREF(__pyx_t_1);
20153     }
20154     for (;;) {
20155       if (likely(PyList_CheckExact(__pyx_t_1))) {
20156         if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_1)) break;
20157         __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++;
20158       } else if (likely(PyTuple_CheckExact(__pyx_t_1))) {
20159         if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
20160         __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_4); __pyx_t_5++;
20161       } else {
20162         __pyx_t_4 = PyIter_Next(__pyx_t_1);
20163         if (!__pyx_t_4) {
20164           if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
20165           break;
20166         }
20167         __Pyx_GOTREF(__pyx_t_4);
20168       }
20169       if (PyTuple_CheckExact(__pyx_t_4) && likely(PyTuple_GET_SIZE(__pyx_t_4) == 2)) {
20170         PyObject* tuple = __pyx_t_4;
20171         __pyx_t_3 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_3);
20172         __pyx_t_6 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_6);
20173         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
20174         __Pyx_DECREF(__pyx_v_pytag);
20175         __pyx_v_pytag = __pyx_t_3;
20176         __pyx_t_3 = 0;
20177         __Pyx_DECREF(__pyx_v_value);
20178         __pyx_v_value = __pyx_t_6;
20179         __pyx_t_6 = 0;
20180       } else {
20181         __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;}
20182         __Pyx_GOTREF(__pyx_t_7);
20183         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
20184         __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;}
20185         __Pyx_GOTREF(__pyx_t_3);
20186         __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;}
20187         __Pyx_GOTREF(__pyx_t_6);
20188         if (__Pyx_EndUnpack(__pyx_t_7, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
20189         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20190         __Pyx_DECREF(__pyx_v_pytag);
20191         __pyx_v_pytag = __pyx_t_3;
20192         __pyx_t_3 = 0;
20193         __Pyx_DECREF(__pyx_v_value);
20194         __pyx_v_value = __pyx_t_6;
20195         __pyx_t_6 = 0;
20196       }
20197
20198       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2272
20199  * 
20200  *                 for pytag, value in tags:
20201  *                     t = type(value)             # <<<<<<<<<<<<<<
20202  *                     if t == types.FloatType:
20203  *                         fmt, pytype = "<cccf", 'f'
20204  */
20205       __Pyx_INCREF(((PyObject *)Py_TYPE(__pyx_v_value)));
20206       __Pyx_DECREF(((PyObject *)__pyx_v_t));
20207       __pyx_v_t = ((PyObject *)((PyObject *)Py_TYPE(__pyx_v_value)));
20208
20209       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2273
20210  *                 for pytag, value in tags:
20211  *                     t = type(value)
20212  *                     if t == types.FloatType:             # <<<<<<<<<<<<<<
20213  *                         fmt, pytype = "<cccf", 'f'
20214  *                     elif t == types.IntType:
20215  */
20216       __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;}
20217       __Pyx_GOTREF(__pyx_t_4);
20218       __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;}
20219       __Pyx_GOTREF(__pyx_t_6);
20220       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
20221       __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;}
20222       __Pyx_GOTREF(__pyx_t_4);
20223       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
20224       __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;}
20225       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
20226       if (__pyx_t_2) {
20227
20228         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2274
20229  *                     t = type(value)
20230  *                     if t == types.FloatType:
20231  *                         fmt, pytype = "<cccf", 'f'             # <<<<<<<<<<<<<<
20232  *                     elif t == types.IntType:
20233  *                         if value < 0:
20234  */
20235         __pyx_t_4 = ((PyObject *)__pyx_kp_s_64);
20236         __Pyx_INCREF(__pyx_t_4);
20237         __pyx_t_6 = ((PyObject *)__pyx_n_s__f);
20238         __Pyx_INCREF(__pyx_t_6);
20239         __Pyx_DECREF(__pyx_v_fmt);
20240         __pyx_v_fmt = __pyx_t_4;
20241         __pyx_t_4 = 0;
20242         __Pyx_DECREF(__pyx_v_pytype);
20243         __pyx_v_pytype = __pyx_t_6;
20244         __pyx_t_6 = 0;
20245         goto __pyx_L8;
20246       }
20247
20248       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2275
20249  *                     if t == types.FloatType:
20250  *                         fmt, pytype = "<cccf", 'f'
20251  *                     elif t == types.IntType:             # <<<<<<<<<<<<<<
20252  *                         if value < 0:
20253  *                             if value >= -127: fmt, pytype = "<cccb", 'c'
20254  */
20255       __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;}
20256       __Pyx_GOTREF(__pyx_t_6);
20257       __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;}
20258       __Pyx_GOTREF(__pyx_t_4);
20259       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
20260       __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;}
20261       __Pyx_GOTREF(__pyx_t_6);
20262       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
20263       __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;}
20264       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
20265       if (__pyx_t_2) {
20266
20267         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2276
20268  *                         fmt, pytype = "<cccf", 'f'
20269  *                     elif t == types.IntType:
20270  *                         if value < 0:             # <<<<<<<<<<<<<<
20271  *                             if value >= -127: fmt, pytype = "<cccb", 'c'
20272  *                             elif value >= -32767: fmt, pytype = "<ccch", 's'
20273  */
20274         __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;}
20275         __Pyx_GOTREF(__pyx_t_6);
20276         __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;}
20277         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
20278         if (__pyx_t_2) {
20279
20280           /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2277
20281  *                     elif t == types.IntType:
20282  *                         if value < 0:
20283  *                             if value >= -127: fmt, pytype = "<cccb", 'c'             # <<<<<<<<<<<<<<
20284  *                             elif value >= -32767: fmt, pytype = "<ccch", 's'
20285  *                             elif value < -2147483648: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )
20286  */
20287           __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;}
20288           __Pyx_GOTREF(__pyx_t_6);
20289           __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;}
20290           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
20291           if (__pyx_t_2) {
20292             __pyx_t_6 = ((PyObject *)__pyx_kp_s_65);
20293             __Pyx_INCREF(__pyx_t_6);
20294             __pyx_t_4 = ((PyObject *)__pyx_n_s__c);
20295             __Pyx_INCREF(__pyx_t_4);
20296             __Pyx_DECREF(__pyx_v_fmt);
20297             __pyx_v_fmt = __pyx_t_6;
20298             __pyx_t_6 = 0;
20299             __Pyx_DECREF(__pyx_v_pytype);
20300             __pyx_v_pytype = __pyx_t_4;
20301             __pyx_t_4 = 0;
20302             goto __pyx_L10;
20303           }
20304
20305           /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2278
20306  *                         if value < 0:
20307  *                             if value >= -127: fmt, pytype = "<cccb", 'c'
20308  *                             elif value >= -32767: fmt, pytype = "<ccch", 's'             # <<<<<<<<<<<<<<
20309  *                             elif value < -2147483648: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )
20310  *                             else: fmt, pytype = "<ccci", 'i'[0]
20311  */
20312           __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;}
20313           __Pyx_GOTREF(__pyx_t_4);
20314           __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;}
20315           __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
20316           if (__pyx_t_2) {
20317             __pyx_t_4 = ((PyObject *)__pyx_kp_s_66);
20318             __Pyx_INCREF(__pyx_t_4);
20319             __pyx_t_6 = ((PyObject *)__pyx_n_s__s);
20320             __Pyx_INCREF(__pyx_t_6);
20321             __Pyx_DECREF(__pyx_v_fmt);
20322             __pyx_v_fmt = __pyx_t_4;
20323             __pyx_t_4 = 0;
20324             __Pyx_DECREF(__pyx_v_pytype);
20325             __pyx_v_pytype = __pyx_t_6;
20326             __pyx_t_6 = 0;
20327             goto __pyx_L10;
20328           }
20329
20330           /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2279
20331  *                             if value >= -127: fmt, pytype = "<cccb", 'c'
20332  *                             elif value >= -32767: fmt, pytype = "<ccch", 's'
20333  *                             elif value < -2147483648: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )             # <<<<<<<<<<<<<<
20334  *                             else: fmt, pytype = "<ccci", 'i'[0]
20335  *                         else:
20336  */
20337           __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;}
20338           __Pyx_GOTREF(__pyx_t_6);
20339           __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;}
20340           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
20341           if (__pyx_t_2) {
20342             __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;}
20343             __Pyx_GOTREF(((PyObject *)__pyx_t_6));
20344             __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;}
20345             __Pyx_GOTREF(__pyx_t_4);
20346             PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_6));
20347             __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
20348             __pyx_t_6 = 0;
20349             __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;}
20350             __Pyx_GOTREF(__pyx_t_6);
20351             __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
20352             __Pyx_Raise(__pyx_t_6, 0, 0);
20353             __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
20354             {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2279; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
20355             goto __pyx_L10;
20356           }
20357           /*else*/ {
20358
20359             /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2280
20360  *                             elif value >= -32767: fmt, pytype = "<ccch", 's'
20361  *                             elif value < -2147483648: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )
20362  *                             else: fmt, pytype = "<ccci", 'i'[0]             # <<<<<<<<<<<<<<
20363  *                         else:
20364  *                             if value <= 255: fmt, pytype = "<cccB", 'C'
20365  */
20366             __pyx_t_6 = ((PyObject *)__pyx_kp_s_68);
20367             __Pyx_INCREF(__pyx_t_6);
20368             __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;}
20369             __Pyx_GOTREF(__pyx_t_4);
20370             __Pyx_DECREF(__pyx_v_fmt);
20371             __pyx_v_fmt = __pyx_t_6;
20372             __pyx_t_6 = 0;
20373             __Pyx_DECREF(__pyx_v_pytype);
20374             __pyx_v_pytype = __pyx_t_4;
20375             __pyx_t_4 = 0;
20376           }
20377           __pyx_L10:;
20378           goto __pyx_L9;
20379         }
20380         /*else*/ {
20381
20382           /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2282
20383  *                             else: fmt, pytype = "<ccci", 'i'[0]
20384  *                         else:
20385  *                             if value <= 255: fmt, pytype = "<cccB", 'C'             # <<<<<<<<<<<<<<
20386  *                             elif value <= 65535: fmt, pytype = "<cccH", 'S'
20387  *                             elif value > 4294967295: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )
20388  */
20389           __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;}
20390           __Pyx_GOTREF(__pyx_t_4);
20391           __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;}
20392           __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
20393           if (__pyx_t_2) {
20394             __pyx_t_4 = ((PyObject *)__pyx_kp_s_69);
20395             __Pyx_INCREF(__pyx_t_4);
20396             __pyx_t_6 = ((PyObject *)__pyx_n_s__C);
20397             __Pyx_INCREF(__pyx_t_6);
20398             __Pyx_DECREF(__pyx_v_fmt);
20399             __pyx_v_fmt = __pyx_t_4;
20400             __pyx_t_4 = 0;
20401             __Pyx_DECREF(__pyx_v_pytype);
20402             __pyx_v_pytype = __pyx_t_6;
20403             __pyx_t_6 = 0;
20404             goto __pyx_L11;
20405           }
20406
20407           /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2283
20408  *                         else:
20409  *                             if value <= 255: fmt, pytype = "<cccB", 'C'
20410  *                             elif value <= 65535: fmt, pytype = "<cccH", 'S'             # <<<<<<<<<<<<<<
20411  *                             elif value > 4294967295: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )
20412  *                             else: fmt, pytype = "<cccI", 'I'
20413  */
20414           __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;}
20415           __Pyx_GOTREF(__pyx_t_6);
20416           __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;}
20417           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
20418           if (__pyx_t_2) {
20419             __pyx_t_6 = ((PyObject *)__pyx_kp_s_70);
20420             __Pyx_INCREF(__pyx_t_6);
20421             __pyx_t_4 = ((PyObject *)__pyx_n_s__S);
20422             __Pyx_INCREF(__pyx_t_4);
20423             __Pyx_DECREF(__pyx_v_fmt);
20424             __pyx_v_fmt = __pyx_t_6;
20425             __pyx_t_6 = 0;
20426             __Pyx_DECREF(__pyx_v_pytype);
20427             __pyx_v_pytype = __pyx_t_4;
20428             __pyx_t_4 = 0;
20429             goto __pyx_L11;
20430           }
20431
20432           /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2284
20433  *                             if value <= 255: fmt, pytype = "<cccB", 'C'
20434  *                             elif value <= 65535: fmt, pytype = "<cccH", 'S'
20435  *                             elif value > 4294967295: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )             # <<<<<<<<<<<<<<
20436  *                             else: fmt, pytype = "<cccI", 'I'
20437  *                     else:
20438  */
20439           __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;}
20440           __Pyx_GOTREF(__pyx_t_4);
20441           __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;}
20442           __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
20443           if (__pyx_t_2) {
20444             __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;}
20445             __Pyx_GOTREF(((PyObject *)__pyx_t_4));
20446             __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;}
20447             __Pyx_GOTREF(__pyx_t_6);
20448             PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_4));
20449             __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
20450             __pyx_t_4 = 0;
20451             __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;}
20452             __Pyx_GOTREF(__pyx_t_4);
20453             __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
20454             __Pyx_Raise(__pyx_t_4, 0, 0);
20455             __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
20456             {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
20457             goto __pyx_L11;
20458           }
20459           /*else*/ {
20460
20461             /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2285
20462  *                             elif value <= 65535: fmt, pytype = "<cccH", 'S'
20463  *                             elif value > 4294967295: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )
20464  *                             else: fmt, pytype = "<cccI", 'I'             # <<<<<<<<<<<<<<
20465  *                     else:
20466  *                         # Note: hex strings (H) are not supported yet
20467  */
20468             __pyx_t_4 = ((PyObject *)__pyx_kp_s_71);
20469             __Pyx_INCREF(__pyx_t_4);
20470             __pyx_t_6 = ((PyObject *)__pyx_n_s__I);
20471             __Pyx_INCREF(__pyx_t_6);
20472             __Pyx_DECREF(__pyx_v_fmt);
20473             __pyx_v_fmt = __pyx_t_4;
20474             __pyx_t_4 = 0;
20475             __Pyx_DECREF(__pyx_v_pytype);
20476             __pyx_v_pytype = __pyx_t_6;
20477             __pyx_t_6 = 0;
20478           }
20479           __pyx_L11:;
20480         }
20481         __pyx_L9:;
20482         goto __pyx_L8;
20483       }
20484       /*else*/ {
20485
20486         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2288
20487  *                     else:
20488  *                         # Note: hex strings (H) are not supported yet
20489  *                         if len(value) == 1:             # <<<<<<<<<<<<<<
20490  *                             fmt, pytype = "<cccc", 'A'
20491  *                         else:
20492  */
20493         __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;}
20494         __pyx_t_2 = (__pyx_t_8 == 1);
20495         if (__pyx_t_2) {
20496
20497           /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2289
20498  *                         # Note: hex strings (H) are not supported yet
20499  *                         if len(value) == 1:
20500  *                             fmt, pytype = "<cccc", 'A'             # <<<<<<<<<<<<<<
20501  *                         else:
20502  *                             fmt, pytype = "<ccc%is" % (len(value)+1), 'Z'
20503  */
20504           __pyx_t_6 = ((PyObject *)__pyx_kp_s_72);
20505           __Pyx_INCREF(__pyx_t_6);
20506           __pyx_t_4 = ((PyObject *)__pyx_n_s__A);
20507           __Pyx_INCREF(__pyx_t_4);
20508           __Pyx_DECREF(__pyx_v_fmt);
20509           __pyx_v_fmt = __pyx_t_6;
20510           __pyx_t_6 = 0;
20511           __Pyx_DECREF(__pyx_v_pytype);
20512           __pyx_v_pytype = __pyx_t_4;
20513           __pyx_t_4 = 0;
20514           goto __pyx_L12;
20515         }
20516         /*else*/ {
20517
20518           /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2291
20519  *                             fmt, pytype = "<cccc", 'A'
20520  *                         else:
20521  *                             fmt, pytype = "<ccc%is" % (len(value)+1), 'Z'             # <<<<<<<<<<<<<<
20522  * 
20523  *                     size = struct.calcsize(fmt)
20524  */
20525           __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;}
20526           __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;}
20527           __Pyx_GOTREF(__pyx_t_4);
20528           __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;}
20529           __Pyx_GOTREF(((PyObject *)__pyx_t_6));
20530           __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
20531           __pyx_t_4 = ((PyObject *)__pyx_n_s__Z);
20532           __Pyx_INCREF(__pyx_t_4);
20533           __Pyx_DECREF(__pyx_v_fmt);
20534           __pyx_v_fmt = ((PyObject *)__pyx_t_6);
20535           __pyx_t_6 = 0;
20536           __Pyx_DECREF(__pyx_v_pytype);
20537           __pyx_v_pytype = __pyx_t_4;
20538           __pyx_t_4 = 0;
20539         }
20540         __pyx_L12:;
20541       }
20542       __pyx_L8:;
20543
20544       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2293
20545  *                             fmt, pytype = "<ccc%is" % (len(value)+1), 'Z'
20546  * 
20547  *                     size = struct.calcsize(fmt)             # <<<<<<<<<<<<<<
20548  *                     if offset + size > max_size:
20549  *                         raise NotImplementedError("tags field too large")
20550  */
20551       __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;}
20552       __Pyx_GOTREF(__pyx_t_4);
20553       __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;}
20554       __Pyx_GOTREF(__pyx_t_6);
20555       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
20556       __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;}
20557       __Pyx_GOTREF(__pyx_t_4);
20558       __Pyx_INCREF(__pyx_v_fmt);
20559       PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_fmt);
20560       __Pyx_GIVEREF(__pyx_v_fmt);
20561       __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;}
20562       __Pyx_GOTREF(__pyx_t_3);
20563       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
20564       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
20565       __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;}
20566       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
20567       __pyx_v_size = __pyx_t_9;
20568
20569       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2294
20570  * 
20571  *                     size = struct.calcsize(fmt)
20572  *                     if offset + size > max_size:             # <<<<<<<<<<<<<<
20573  *                         raise NotImplementedError("tags field too large")
20574  * 
20575  */
20576       __pyx_t_2 = ((__pyx_v_offset + __pyx_v_size) > __pyx_v_max_size);
20577       if (__pyx_t_2) {
20578
20579         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2295
20580  *                     size = struct.calcsize(fmt)
20581  *                     if offset + size > max_size:
20582  *                         raise NotImplementedError("tags field too large")             # <<<<<<<<<<<<<<
20583  * 
20584  *                     struct.pack_into( fmt,
20585  */
20586         __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;}
20587         __Pyx_GOTREF(__pyx_t_3);
20588         __Pyx_INCREF(((PyObject *)__pyx_kp_s_74));
20589         PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_74));
20590         __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_74));
20591         __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;}
20592         __Pyx_GOTREF(__pyx_t_4);
20593         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
20594         __Pyx_Raise(__pyx_t_4, 0, 0);
20595         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
20596         {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
20597         goto __pyx_L13;
20598       }
20599       __pyx_L13:;
20600
20601       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2297
20602  *                         raise NotImplementedError("tags field too large")
20603  * 
20604  *                     struct.pack_into( fmt,             # <<<<<<<<<<<<<<
20605  *                                       buffer,
20606  *                                       offset,
20607  */
20608       __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;}
20609       __Pyx_GOTREF(__pyx_t_4);
20610       __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;}
20611       __Pyx_GOTREF(__pyx_t_3);
20612       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
20613
20614       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2299
20615  *                     struct.pack_into( fmt,
20616  *                                       buffer,
20617  *                                       offset,             # <<<<<<<<<<<<<<
20618  *                                       pytag[0],
20619  *                                       pytag[1],
20620  */
20621       __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;}
20622       __Pyx_GOTREF(__pyx_t_4);
20623
20624       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2300
20625  *                                       buffer,
20626  *                                       offset,
20627  *                                       pytag[0],             # <<<<<<<<<<<<<<
20628  *                                       pytag[1],
20629  *                                       pytype,
20630  */
20631       __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;}
20632       __Pyx_GOTREF(__pyx_t_6);
20633
20634       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2301
20635  *                                       offset,
20636  *                                       pytag[0],
20637  *                                       pytag[1],             # <<<<<<<<<<<<<<
20638  *                                       pytype,
20639  *                                       value )
20640  */
20641       __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;}
20642       __Pyx_GOTREF(__pyx_t_7);
20643
20644       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2303
20645  *                                       pytag[1],
20646  *                                       pytype,
20647  *                                       value )             # <<<<<<<<<<<<<<
20648  *                     offset += size
20649  * 
20650  */
20651       __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;}
20652       __Pyx_GOTREF(__pyx_t_10);
20653       __Pyx_INCREF(__pyx_v_fmt);
20654       PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_fmt);
20655       __Pyx_GIVEREF(__pyx_v_fmt);
20656       __Pyx_INCREF(__pyx_v_buffer);
20657       PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_v_buffer);
20658       __Pyx_GIVEREF(__pyx_v_buffer);
20659       PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_4);
20660       __Pyx_GIVEREF(__pyx_t_4);
20661       PyTuple_SET_ITEM(__pyx_t_10, 3, __pyx_t_6);
20662       __Pyx_GIVEREF(__pyx_t_6);
20663       PyTuple_SET_ITEM(__pyx_t_10, 4, __pyx_t_7);
20664       __Pyx_GIVEREF(__pyx_t_7);
20665       __Pyx_INCREF(__pyx_v_pytype);
20666       PyTuple_SET_ITEM(__pyx_t_10, 5, __pyx_v_pytype);
20667       __Pyx_GIVEREF(__pyx_v_pytype);
20668       __Pyx_INCREF(__pyx_v_value);
20669       PyTuple_SET_ITEM(__pyx_t_10, 6, __pyx_v_value);
20670       __Pyx_GIVEREF(__pyx_v_value);
20671       __pyx_t_4 = 0;
20672       __pyx_t_6 = 0;
20673       __pyx_t_7 = 0;
20674       __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;}
20675       __Pyx_GOTREF(__pyx_t_7);
20676       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
20677       __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
20678       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
20679
20680       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2304
20681  *                                       pytype,
20682  *                                       value )
20683  *                     offset += size             # <<<<<<<<<<<<<<
20684  * 
20685  *             # delete the old data and allocate new
20686  */
20687       __pyx_v_offset += __pyx_v_size;
20688     }
20689     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20690     goto __pyx_L5;
20691   }
20692   __pyx_L5:;
20693
20694   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2312
20695  *                               src.l_aux,
20696  *                               offset,
20697  *                               bam1_aux( src ) )             # <<<<<<<<<<<<<<
20698  * 
20699  *             src.l_aux = offset
20700  */
20701   pysam_bam_update(__pyx_v_src, __pyx_v_src->l_aux, __pyx_v_offset, bam1_aux(__pyx_v_src));
20702
20703   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2314
20704  *                               bam1_aux( src ) )
20705  * 
20706  *             src.l_aux = offset             # <<<<<<<<<<<<<<
20707  * 
20708  *             # copy data only if there is any
20709  */
20710   __pyx_v_src->l_aux = __pyx_v_offset;
20711
20712   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2317
20713  * 
20714  *             # copy data only if there is any
20715  *             if offset != 0:             # <<<<<<<<<<<<<<
20716  * 
20717  *                 # get location of new data
20718  */
20719   __pyx_t_2 = (__pyx_v_offset != 0);
20720   if (__pyx_t_2) {
20721
20722     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2320
20723  * 
20724  *                 # get location of new data
20725  *                 s = bam1_aux( src )             # <<<<<<<<<<<<<<
20726  * 
20727  *                 # check if there is direct path from buffer.raw to tmp
20728  */
20729     __pyx_v_s = bam1_aux(__pyx_v_src);
20730
20731     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2323
20732  * 
20733  *                 # check if there is direct path from buffer.raw to tmp
20734  *                 temp = buffer.raw             # <<<<<<<<<<<<<<
20735  *                 memcpy( s, temp, offset )
20736  * 
20737  */
20738     __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;}
20739     __Pyx_GOTREF(__pyx_t_1);
20740     __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;}
20741     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
20742     __pyx_v_temp = __pyx_t_11;
20743
20744     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2324
20745  *                 # check if there is direct path from buffer.raw to tmp
20746  *                 temp = buffer.raw
20747  *                 memcpy( s, temp, offset )             # <<<<<<<<<<<<<<
20748  * 
20749  *     property flag:
20750  */
20751     memcpy(__pyx_v_s, __pyx_v_temp, __pyx_v_offset);
20752     goto __pyx_L14;
20753   }
20754   __pyx_L14:;
20755
20756   __pyx_r = 0;
20757   goto __pyx_L0;
20758   __pyx_L1_error:;
20759   __Pyx_XDECREF(__pyx_t_1);
20760   __Pyx_XDECREF(__pyx_t_3);
20761   __Pyx_XDECREF(__pyx_t_4);
20762   __Pyx_XDECREF(__pyx_t_6);
20763   __Pyx_XDECREF(__pyx_t_7);
20764   __Pyx_XDECREF(__pyx_t_10);
20765   __Pyx_AddTraceback("csamtools.AlignedRead.tags.__set__");
20766   __pyx_r = -1;
20767   __pyx_L0:;
20768   __Pyx_DECREF(__pyx_v_buffer);
20769   __Pyx_DECREF(__pyx_v_pytag);
20770   __Pyx_DECREF(__pyx_v_value);
20771   __Pyx_DECREF(__pyx_v_t);
20772   __Pyx_DECREF(__pyx_v_fmt);
20773   __Pyx_DECREF(__pyx_v_pytype);
20774   __Pyx_TraceReturn(Py_None);
20775   __Pyx_RefNannyFinishContext();
20776   return __pyx_r;
20777 }
20778
20779 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2328
20780  *     property flag:
20781  *         """properties flag"""
20782  *         def __get__(self): return self._delegate.core.flag             # <<<<<<<<<<<<<<
20783  *         def __set__(self, flag): self._delegate.core.flag = flag
20784  * 
20785  */
20786
20787 static PyObject *__pyx_pf_9csamtools_11AlignedRead_4flag___get__(PyObject *__pyx_v_self); /*proto*/
20788 static PyObject *__pyx_pf_9csamtools_11AlignedRead_4flag___get__(PyObject *__pyx_v_self) {
20789   PyObject *__pyx_r = NULL;
20790   PyObject *__pyx_t_1 = NULL;
20791   __Pyx_TraceDeclarations
20792   __Pyx_RefNannySetupContext("__get__");
20793   __Pyx_TraceCall("__get__", __pyx_f[0], 2328);
20794   __Pyx_XDECREF(__pyx_r);
20795   __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;}
20796   __Pyx_GOTREF(__pyx_t_1);
20797   __pyx_r = __pyx_t_1;
20798   __pyx_t_1 = 0;
20799   goto __pyx_L0;
20800
20801   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
20802   goto __pyx_L0;
20803   __pyx_L1_error:;
20804   __Pyx_XDECREF(__pyx_t_1);
20805   __Pyx_AddTraceback("csamtools.AlignedRead.flag.__get__");
20806   __pyx_r = NULL;
20807   __pyx_L0:;
20808   __Pyx_XGIVEREF(__pyx_r);
20809   __Pyx_TraceReturn(__pyx_r);
20810   __Pyx_RefNannyFinishContext();
20811   return __pyx_r;
20812 }
20813
20814 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2329
20815  *         """properties flag"""
20816  *         def __get__(self): return self._delegate.core.flag
20817  *         def __set__(self, flag): self._delegate.core.flag = flag             # <<<<<<<<<<<<<<
20818  * 
20819  *     property rname:
20820  */
20821
20822 static int __pyx_pf_9csamtools_11AlignedRead_4flag___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_flag); /*proto*/
20823 static int __pyx_pf_9csamtools_11AlignedRead_4flag___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_flag) {
20824   int __pyx_r;
20825   uint32_t __pyx_t_1;
20826   __Pyx_TraceDeclarations
20827   __Pyx_RefNannySetupContext("__set__");
20828   __Pyx_TraceCall("__set__", __pyx_f[0], 2329);
20829   __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;}
20830   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag = __pyx_t_1;
20831
20832   __pyx_r = 0;
20833   goto __pyx_L0;
20834   __pyx_L1_error:;
20835   __Pyx_AddTraceback("csamtools.AlignedRead.flag.__set__");
20836   __pyx_r = -1;
20837   __pyx_L0:;
20838   __Pyx_TraceReturn(Py_None);
20839   __Pyx_RefNannyFinishContext();
20840   return __pyx_r;
20841 }
20842
20843 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2347
20844  * 
20845  *         """
20846  *         def __get__(self): return self._delegate.core.tid             # <<<<<<<<<<<<<<
20847  *         def __set__(self, tid): self._delegate.core.tid = tid
20848  * 
20849  */
20850
20851 static PyObject *__pyx_pf_9csamtools_11AlignedRead_5rname___get__(PyObject *__pyx_v_self); /*proto*/
20852 static PyObject *__pyx_pf_9csamtools_11AlignedRead_5rname___get__(PyObject *__pyx_v_self) {
20853   PyObject *__pyx_r = NULL;
20854   PyObject *__pyx_t_1 = NULL;
20855   __Pyx_TraceDeclarations
20856   __Pyx_RefNannySetupContext("__get__");
20857   __Pyx_TraceCall("__get__", __pyx_f[0], 2347);
20858   __Pyx_XDECREF(__pyx_r);
20859   __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;}
20860   __Pyx_GOTREF(__pyx_t_1);
20861   __pyx_r = __pyx_t_1;
20862   __pyx_t_1 = 0;
20863   goto __pyx_L0;
20864
20865   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
20866   goto __pyx_L0;
20867   __pyx_L1_error:;
20868   __Pyx_XDECREF(__pyx_t_1);
20869   __Pyx_AddTraceback("csamtools.AlignedRead.rname.__get__");
20870   __pyx_r = NULL;
20871   __pyx_L0:;
20872   __Pyx_XGIVEREF(__pyx_r);
20873   __Pyx_TraceReturn(__pyx_r);
20874   __Pyx_RefNannyFinishContext();
20875   return __pyx_r;
20876 }
20877
20878 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2348
20879  *         """
20880  *         def __get__(self): return self._delegate.core.tid
20881  *         def __set__(self, tid): self._delegate.core.tid = tid             # <<<<<<<<<<<<<<
20882  * 
20883  *     property tid:
20884  */
20885
20886 static int __pyx_pf_9csamtools_11AlignedRead_5rname___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_tid); /*proto*/
20887 static int __pyx_pf_9csamtools_11AlignedRead_5rname___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_tid) {
20888   int __pyx_r;
20889   int32_t __pyx_t_1;
20890   __Pyx_TraceDeclarations
20891   __Pyx_RefNannySetupContext("__set__");
20892   __Pyx_TraceCall("__set__", __pyx_f[0], 2348);
20893   __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;}
20894   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.tid = __pyx_t_1;
20895
20896   __pyx_r = 0;
20897   goto __pyx_L0;
20898   __pyx_L1_error:;
20899   __Pyx_AddTraceback("csamtools.AlignedRead.rname.__set__");
20900   __pyx_r = -1;
20901   __pyx_L0:;
20902   __Pyx_TraceReturn(Py_None);
20903   __Pyx_RefNannyFinishContext();
20904   return __pyx_r;
20905 }
20906
20907 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2361
20908  * 
20909  *         """
20910  *         def __get__(self): return self._delegate.core.tid             # <<<<<<<<<<<<<<
20911  *         def __set__(self, tid): self._delegate.core.tid = tid
20912  * 
20913  */
20914
20915 static PyObject *__pyx_pf_9csamtools_11AlignedRead_3tid___get__(PyObject *__pyx_v_self); /*proto*/
20916 static PyObject *__pyx_pf_9csamtools_11AlignedRead_3tid___get__(PyObject *__pyx_v_self) {
20917   PyObject *__pyx_r = NULL;
20918   PyObject *__pyx_t_1 = NULL;
20919   __Pyx_TraceDeclarations
20920   __Pyx_RefNannySetupContext("__get__");
20921   __Pyx_TraceCall("__get__", __pyx_f[0], 2361);
20922   __Pyx_XDECREF(__pyx_r);
20923   __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;}
20924   __Pyx_GOTREF(__pyx_t_1);
20925   __pyx_r = __pyx_t_1;
20926   __pyx_t_1 = 0;
20927   goto __pyx_L0;
20928
20929   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
20930   goto __pyx_L0;
20931   __pyx_L1_error:;
20932   __Pyx_XDECREF(__pyx_t_1);
20933   __Pyx_AddTraceback("csamtools.AlignedRead.tid.__get__");
20934   __pyx_r = NULL;
20935   __pyx_L0:;
20936   __Pyx_XGIVEREF(__pyx_r);
20937   __Pyx_TraceReturn(__pyx_r);
20938   __Pyx_RefNannyFinishContext();
20939   return __pyx_r;
20940 }
20941
20942 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2362
20943  *         """
20944  *         def __get__(self): return self._delegate.core.tid
20945  *         def __set__(self, tid): self._delegate.core.tid = tid             # <<<<<<<<<<<<<<
20946  * 
20947  *     property pos:
20948  */
20949
20950 static int __pyx_pf_9csamtools_11AlignedRead_3tid___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_tid); /*proto*/
20951 static int __pyx_pf_9csamtools_11AlignedRead_3tid___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_tid) {
20952   int __pyx_r;
20953   int32_t __pyx_t_1;
20954   __Pyx_TraceDeclarations
20955   __Pyx_RefNannySetupContext("__set__");
20956   __Pyx_TraceCall("__set__", __pyx_f[0], 2362);
20957   __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;}
20958   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.tid = __pyx_t_1;
20959
20960   __pyx_r = 0;
20961   goto __pyx_L0;
20962   __pyx_L1_error:;
20963   __Pyx_AddTraceback("csamtools.AlignedRead.tid.__set__");
20964   __pyx_r = -1;
20965   __pyx_L0:;
20966   __Pyx_TraceReturn(Py_None);
20967   __Pyx_RefNannyFinishContext();
20968   return __pyx_r;
20969 }
20970
20971 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2366
20972  *     property pos:
20973  *         """0-based leftmost coordinate"""
20974  *         def __get__(self): return self._delegate.core.pos             # <<<<<<<<<<<<<<
20975  *         def __set__(self, pos):
20976  *             ## setting the cigar string also updates the "bin" attribute
20977  */
20978
20979 static PyObject *__pyx_pf_9csamtools_11AlignedRead_3pos___get__(PyObject *__pyx_v_self); /*proto*/
20980 static PyObject *__pyx_pf_9csamtools_11AlignedRead_3pos___get__(PyObject *__pyx_v_self) {
20981   PyObject *__pyx_r = NULL;
20982   PyObject *__pyx_t_1 = NULL;
20983   __Pyx_TraceDeclarations
20984   __Pyx_RefNannySetupContext("__get__");
20985   __Pyx_TraceCall("__get__", __pyx_f[0], 2366);
20986   __Pyx_XDECREF(__pyx_r);
20987   __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;}
20988   __Pyx_GOTREF(__pyx_t_1);
20989   __pyx_r = __pyx_t_1;
20990   __pyx_t_1 = 0;
20991   goto __pyx_L0;
20992
20993   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
20994   goto __pyx_L0;
20995   __pyx_L1_error:;
20996   __Pyx_XDECREF(__pyx_t_1);
20997   __Pyx_AddTraceback("csamtools.AlignedRead.pos.__get__");
20998   __pyx_r = NULL;
20999   __pyx_L0:;
21000   __Pyx_XGIVEREF(__pyx_r);
21001   __Pyx_TraceReturn(__pyx_r);
21002   __Pyx_RefNannyFinishContext();
21003   return __pyx_r;
21004 }
21005
21006 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2367
21007  *         """0-based leftmost coordinate"""
21008  *         def __get__(self): return self._delegate.core.pos
21009  *         def __set__(self, pos):             # <<<<<<<<<<<<<<
21010  *             ## setting the cigar string also updates the "bin" attribute
21011  *             cdef bam1_t * src
21012  */
21013
21014 static int __pyx_pf_9csamtools_11AlignedRead_3pos___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_pos); /*proto*/
21015 static int __pyx_pf_9csamtools_11AlignedRead_3pos___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_pos) {
21016   bam1_t *__pyx_v_src;
21017   int __pyx_r;
21018   int32_t __pyx_t_1;
21019   __Pyx_TraceDeclarations
21020   __Pyx_RefNannySetupContext("__set__");
21021   __Pyx_TraceCall("__set__", __pyx_f[0], 2367);
21022
21023   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2370
21024  *             ## setting the cigar string also updates the "bin" attribute
21025  *             cdef bam1_t * src
21026  *             src = self._delegate             # <<<<<<<<<<<<<<
21027  *             if src.core.n_cigar:
21028  *                 src.core.bin = bam_reg2bin( src.core.pos, bam_calend( &src.core, bam1_cigar(src)) )
21029  */
21030   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
21031
21032   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2371
21033  *             cdef bam1_t * src
21034  *             src = self._delegate
21035  *             if src.core.n_cigar:             # <<<<<<<<<<<<<<
21036  *                 src.core.bin = bam_reg2bin( src.core.pos, bam_calend( &src.core, bam1_cigar(src)) )
21037  *             else:
21038  */
21039   if (__pyx_v_src->core.n_cigar) {
21040
21041     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2372
21042  *             src = self._delegate
21043  *             if src.core.n_cigar:
21044  *                 src.core.bin = bam_reg2bin( src.core.pos, bam_calend( &src.core, bam1_cigar(src)) )             # <<<<<<<<<<<<<<
21045  *             else:
21046  *                 src.core.bin = bam_reg2bin( src.core.pos, src.core.pos + 1)
21047  */
21048     __pyx_v_src->core.bin = bam_reg2bin(__pyx_v_src->core.pos, bam_calend((&__pyx_v_src->core), bam1_cigar(__pyx_v_src)));
21049     goto __pyx_L5;
21050   }
21051   /*else*/ {
21052
21053     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2374
21054  *                 src.core.bin = bam_reg2bin( src.core.pos, bam_calend( &src.core, bam1_cigar(src)) )
21055  *             else:
21056  *                 src.core.bin = bam_reg2bin( src.core.pos, src.core.pos + 1)             # <<<<<<<<<<<<<<
21057  *             self._delegate.core.pos = pos
21058  *     property bin:
21059  */
21060     __pyx_v_src->core.bin = bam_reg2bin(__pyx_v_src->core.pos, (__pyx_v_src->core.pos + 1));
21061   }
21062   __pyx_L5:;
21063
21064   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2375
21065  *             else:
21066  *                 src.core.bin = bam_reg2bin( src.core.pos, src.core.pos + 1)
21067  *             self._delegate.core.pos = pos             # <<<<<<<<<<<<<<
21068  *     property bin:
21069  *         """properties bin"""
21070  */
21071   __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;}
21072   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.pos = __pyx_t_1;
21073
21074   __pyx_r = 0;
21075   goto __pyx_L0;
21076   __pyx_L1_error:;
21077   __Pyx_AddTraceback("csamtools.AlignedRead.pos.__set__");
21078   __pyx_r = -1;
21079   __pyx_L0:;
21080   __Pyx_TraceReturn(Py_None);
21081   __Pyx_RefNannyFinishContext();
21082   return __pyx_r;
21083 }
21084
21085 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2378
21086  *     property bin:
21087  *         """properties bin"""
21088  *         def __get__(self): return self._delegate.core.bin             # <<<<<<<<<<<<<<
21089  *         def __set__(self, bin): self._delegate.core.bin = bin
21090  *     property rlen:
21091  */
21092
21093 static PyObject *__pyx_pf_9csamtools_11AlignedRead_3bin___get__(PyObject *__pyx_v_self); /*proto*/
21094 static PyObject *__pyx_pf_9csamtools_11AlignedRead_3bin___get__(PyObject *__pyx_v_self) {
21095   PyObject *__pyx_r = NULL;
21096   PyObject *__pyx_t_1 = NULL;
21097   __Pyx_TraceDeclarations
21098   __Pyx_RefNannySetupContext("__get__");
21099   __Pyx_TraceCall("__get__", __pyx_f[0], 2378);
21100   __Pyx_XDECREF(__pyx_r);
21101   __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;}
21102   __Pyx_GOTREF(__pyx_t_1);
21103   __pyx_r = __pyx_t_1;
21104   __pyx_t_1 = 0;
21105   goto __pyx_L0;
21106
21107   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
21108   goto __pyx_L0;
21109   __pyx_L1_error:;
21110   __Pyx_XDECREF(__pyx_t_1);
21111   __Pyx_AddTraceback("csamtools.AlignedRead.bin.__get__");
21112   __pyx_r = NULL;
21113   __pyx_L0:;
21114   __Pyx_XGIVEREF(__pyx_r);
21115   __Pyx_TraceReturn(__pyx_r);
21116   __Pyx_RefNannyFinishContext();
21117   return __pyx_r;
21118 }
21119
21120 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2379
21121  *         """properties bin"""
21122  *         def __get__(self): return self._delegate.core.bin
21123  *         def __set__(self, bin): self._delegate.core.bin = bin             # <<<<<<<<<<<<<<
21124  *     property rlen:
21125  *         '''length of the read (read only). Returns 0 if not given.'''
21126  */
21127
21128 static int __pyx_pf_9csamtools_11AlignedRead_3bin___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_bin); /*proto*/
21129 static int __pyx_pf_9csamtools_11AlignedRead_3bin___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_bin) {
21130   int __pyx_r;
21131   uint32_t __pyx_t_1;
21132   __Pyx_TraceDeclarations
21133   __Pyx_RefNannySetupContext("__set__");
21134   __Pyx_TraceCall("__set__", __pyx_f[0], 2379);
21135   __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;}
21136   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.bin = __pyx_t_1;
21137
21138   __pyx_r = 0;
21139   goto __pyx_L0;
21140   __pyx_L1_error:;
21141   __Pyx_AddTraceback("csamtools.AlignedRead.bin.__set__");
21142   __pyx_r = -1;
21143   __pyx_L0:;
21144   __Pyx_TraceReturn(Py_None);
21145   __Pyx_RefNannyFinishContext();
21146   return __pyx_r;
21147 }
21148
21149 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2382
21150  *     property rlen:
21151  *         '''length of the read (read only). Returns 0 if not given.'''
21152  *         def __get__(self): return self._delegate.core.l_qseq             # <<<<<<<<<<<<<<
21153  *     property aend:
21154  *         '''aligned end position of the read (read only).  Returns
21155  */
21156
21157 static PyObject *__pyx_pf_9csamtools_11AlignedRead_4rlen___get__(PyObject *__pyx_v_self); /*proto*/
21158 static PyObject *__pyx_pf_9csamtools_11AlignedRead_4rlen___get__(PyObject *__pyx_v_self) {
21159   PyObject *__pyx_r = NULL;
21160   PyObject *__pyx_t_1 = NULL;
21161   __Pyx_TraceDeclarations
21162   __Pyx_RefNannySetupContext("__get__");
21163   __Pyx_TraceCall("__get__", __pyx_f[0], 2382);
21164   __Pyx_XDECREF(__pyx_r);
21165   __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;}
21166   __Pyx_GOTREF(__pyx_t_1);
21167   __pyx_r = __pyx_t_1;
21168   __pyx_t_1 = 0;
21169   goto __pyx_L0;
21170
21171   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
21172   goto __pyx_L0;
21173   __pyx_L1_error:;
21174   __Pyx_XDECREF(__pyx_t_1);
21175   __Pyx_AddTraceback("csamtools.AlignedRead.rlen.__get__");
21176   __pyx_r = NULL;
21177   __pyx_L0:;
21178   __Pyx_XGIVEREF(__pyx_r);
21179   __Pyx_TraceReturn(__pyx_r);
21180   __Pyx_RefNannyFinishContext();
21181   return __pyx_r;
21182 }
21183
21184 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2386
21185  *         '''aligned end position of the read (read only).  Returns
21186  *         None if not available.'''
21187  *         def __get__(self):             # <<<<<<<<<<<<<<
21188  *             cdef bam1_t * src
21189  *             src = self._delegate
21190  */
21191
21192 static PyObject *__pyx_pf_9csamtools_11AlignedRead_4aend___get__(PyObject *__pyx_v_self); /*proto*/
21193 static PyObject *__pyx_pf_9csamtools_11AlignedRead_4aend___get__(PyObject *__pyx_v_self) {
21194   bam1_t *__pyx_v_src;
21195   PyObject *__pyx_r = NULL;
21196   PyObject *__pyx_t_1 = NULL;
21197   PyObject *__pyx_t_2 = NULL;
21198   int __pyx_t_3;
21199   int __pyx_t_4;
21200   int __pyx_t_5;
21201   __Pyx_TraceDeclarations
21202   __Pyx_RefNannySetupContext("__get__");
21203   __Pyx_TraceCall("__get__", __pyx_f[0], 2386);
21204
21205   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2388
21206  *         def __get__(self):
21207  *             cdef bam1_t * src
21208  *             src = self._delegate             # <<<<<<<<<<<<<<
21209  *             if (self.flag & BAM_FUNMAP) or src.core.n_cigar == 0:
21210  *                 return None
21211  */
21212   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
21213
21214   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2389
21215  *             cdef bam1_t * src
21216  *             src = self._delegate
21217  *             if (self.flag & BAM_FUNMAP) or src.core.n_cigar == 0:             # <<<<<<<<<<<<<<
21218  *                 return None
21219  *             return bam_calend(&src.core, bam1_cigar(src))
21220  */
21221   __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;}
21222   __Pyx_GOTREF(__pyx_t_1);
21223   __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;}
21224   __Pyx_GOTREF(__pyx_t_2);
21225   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
21226   __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;}
21227   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
21228   if (!__pyx_t_3) {
21229     __pyx_t_4 = (__pyx_v_src->core.n_cigar == 0);
21230     __pyx_t_5 = __pyx_t_4;
21231   } else {
21232     __pyx_t_5 = __pyx_t_3;
21233   }
21234   if (__pyx_t_5) {
21235
21236     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2390
21237  *             src = self._delegate
21238  *             if (self.flag & BAM_FUNMAP) or src.core.n_cigar == 0:
21239  *                 return None             # <<<<<<<<<<<<<<
21240  *             return bam_calend(&src.core, bam1_cigar(src))
21241  *     property alen:
21242  */
21243     __Pyx_XDECREF(__pyx_r);
21244     __Pyx_INCREF(Py_None);
21245     __pyx_r = Py_None;
21246     goto __pyx_L0;
21247     goto __pyx_L5;
21248   }
21249   __pyx_L5:;
21250
21251   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2391
21252  *             if (self.flag & BAM_FUNMAP) or src.core.n_cigar == 0:
21253  *                 return None
21254  *             return bam_calend(&src.core, bam1_cigar(src))             # <<<<<<<<<<<<<<
21255  *     property alen:
21256  *         '''aligned length of the read (read only).  Returns None if
21257  */
21258   __Pyx_XDECREF(__pyx_r);
21259   __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;}
21260   __Pyx_GOTREF(__pyx_t_2);
21261   __pyx_r = __pyx_t_2;
21262   __pyx_t_2 = 0;
21263   goto __pyx_L0;
21264
21265   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
21266   goto __pyx_L0;
21267   __pyx_L1_error:;
21268   __Pyx_XDECREF(__pyx_t_1);
21269   __Pyx_XDECREF(__pyx_t_2);
21270   __Pyx_AddTraceback("csamtools.AlignedRead.aend.__get__");
21271   __pyx_r = NULL;
21272   __pyx_L0:;
21273   __Pyx_XGIVEREF(__pyx_r);
21274   __Pyx_TraceReturn(__pyx_r);
21275   __Pyx_RefNannyFinishContext();
21276   return __pyx_r;
21277 }
21278
21279 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2395
21280  *         '''aligned length of the read (read only).  Returns None if
21281  *         not available.'''
21282  *         def __get__(self):             # <<<<<<<<<<<<<<
21283  *             cdef bam1_t * src
21284  *             src = self._delegate
21285  */
21286
21287 static PyObject *__pyx_pf_9csamtools_11AlignedRead_4alen___get__(PyObject *__pyx_v_self); /*proto*/
21288 static PyObject *__pyx_pf_9csamtools_11AlignedRead_4alen___get__(PyObject *__pyx_v_self) {
21289   bam1_t *__pyx_v_src;
21290   PyObject *__pyx_r = NULL;
21291   PyObject *__pyx_t_1 = NULL;
21292   PyObject *__pyx_t_2 = NULL;
21293   int __pyx_t_3;
21294   int __pyx_t_4;
21295   int __pyx_t_5;
21296   __Pyx_TraceDeclarations
21297   __Pyx_RefNannySetupContext("__get__");
21298   __Pyx_TraceCall("__get__", __pyx_f[0], 2395);
21299
21300   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2397
21301  *         def __get__(self):
21302  *             cdef bam1_t * src
21303  *             src = self._delegate             # <<<<<<<<<<<<<<
21304  *             if (self.flag & BAM_FUNMAP) or src.core.n_cigar == 0:
21305  *                 return None
21306  */
21307   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
21308
21309   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2398
21310  *             cdef bam1_t * src
21311  *             src = self._delegate
21312  *             if (self.flag & BAM_FUNMAP) or src.core.n_cigar == 0:             # <<<<<<<<<<<<<<
21313  *                 return None
21314  *             return bam_calend(&src.core,
21315  */
21316   __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;}
21317   __Pyx_GOTREF(__pyx_t_1);
21318   __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;}
21319   __Pyx_GOTREF(__pyx_t_2);
21320   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
21321   __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;}
21322   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
21323   if (!__pyx_t_3) {
21324     __pyx_t_4 = (__pyx_v_src->core.n_cigar == 0);
21325     __pyx_t_5 = __pyx_t_4;
21326   } else {
21327     __pyx_t_5 = __pyx_t_3;
21328   }
21329   if (__pyx_t_5) {
21330
21331     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2399
21332  *             src = self._delegate
21333  *             if (self.flag & BAM_FUNMAP) or src.core.n_cigar == 0:
21334  *                 return None             # <<<<<<<<<<<<<<
21335  *             return bam_calend(&src.core,
21336  *                                bam1_cigar(src)) - \
21337  */
21338     __Pyx_XDECREF(__pyx_r);
21339     __Pyx_INCREF(Py_None);
21340     __pyx_r = Py_None;
21341     goto __pyx_L0;
21342     goto __pyx_L5;
21343   }
21344   __pyx_L5:;
21345
21346   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2400
21347  *             if (self.flag & BAM_FUNMAP) or src.core.n_cigar == 0:
21348  *                 return None
21349  *             return bam_calend(&src.core,             # <<<<<<<<<<<<<<
21350  *                                bam1_cigar(src)) - \
21351  *                                self._delegate.core.pos
21352  */
21353   __Pyx_XDECREF(__pyx_r);
21354
21355   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2402
21356  *             return bam_calend(&src.core,
21357  *                                bam1_cigar(src)) - \
21358  *                                self._delegate.core.pos             # <<<<<<<<<<<<<<
21359  * 
21360  *     property mapq:
21361  */
21362   __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;}
21363   __Pyx_GOTREF(__pyx_t_2);
21364   __pyx_r = __pyx_t_2;
21365   __pyx_t_2 = 0;
21366   goto __pyx_L0;
21367
21368   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
21369   goto __pyx_L0;
21370   __pyx_L1_error:;
21371   __Pyx_XDECREF(__pyx_t_1);
21372   __Pyx_XDECREF(__pyx_t_2);
21373   __Pyx_AddTraceback("csamtools.AlignedRead.alen.__get__");
21374   __pyx_r = NULL;
21375   __pyx_L0:;
21376   __Pyx_XGIVEREF(__pyx_r);
21377   __Pyx_TraceReturn(__pyx_r);
21378   __Pyx_RefNannyFinishContext();
21379   return __pyx_r;
21380 }
21381
21382 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2406
21383  *     property mapq:
21384  *         """mapping quality"""
21385  *         def __get__(self): return self._delegate.core.qual             # <<<<<<<<<<<<<<
21386  *         def __set__(self, qual): self._delegate.core.qual = qual
21387  *     property mrnm:
21388  */
21389
21390 static PyObject *__pyx_pf_9csamtools_11AlignedRead_4mapq___get__(PyObject *__pyx_v_self); /*proto*/
21391 static PyObject *__pyx_pf_9csamtools_11AlignedRead_4mapq___get__(PyObject *__pyx_v_self) {
21392   PyObject *__pyx_r = NULL;
21393   PyObject *__pyx_t_1 = NULL;
21394   __Pyx_TraceDeclarations
21395   __Pyx_RefNannySetupContext("__get__");
21396   __Pyx_TraceCall("__get__", __pyx_f[0], 2406);
21397   __Pyx_XDECREF(__pyx_r);
21398   __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;}
21399   __Pyx_GOTREF(__pyx_t_1);
21400   __pyx_r = __pyx_t_1;
21401   __pyx_t_1 = 0;
21402   goto __pyx_L0;
21403
21404   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
21405   goto __pyx_L0;
21406   __pyx_L1_error:;
21407   __Pyx_XDECREF(__pyx_t_1);
21408   __Pyx_AddTraceback("csamtools.AlignedRead.mapq.__get__");
21409   __pyx_r = NULL;
21410   __pyx_L0:;
21411   __Pyx_XGIVEREF(__pyx_r);
21412   __Pyx_TraceReturn(__pyx_r);
21413   __Pyx_RefNannyFinishContext();
21414   return __pyx_r;
21415 }
21416
21417 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2407
21418  *         """mapping quality"""
21419  *         def __get__(self): return self._delegate.core.qual
21420  *         def __set__(self, qual): self._delegate.core.qual = qual             # <<<<<<<<<<<<<<
21421  *     property mrnm:
21422  *         """the :term:`reference` id of the mate """
21423  */
21424
21425 static int __pyx_pf_9csamtools_11AlignedRead_4mapq___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_qual); /*proto*/
21426 static int __pyx_pf_9csamtools_11AlignedRead_4mapq___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_qual) {
21427   int __pyx_r;
21428   uint32_t __pyx_t_1;
21429   __Pyx_TraceDeclarations
21430   __Pyx_RefNannySetupContext("__set__");
21431   __Pyx_TraceCall("__set__", __pyx_f[0], 2407);
21432   __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;}
21433   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.qual = __pyx_t_1;
21434
21435   __pyx_r = 0;
21436   goto __pyx_L0;
21437   __pyx_L1_error:;
21438   __Pyx_AddTraceback("csamtools.AlignedRead.mapq.__set__");
21439   __pyx_r = -1;
21440   __pyx_L0:;
21441   __Pyx_TraceReturn(Py_None);
21442   __Pyx_RefNannyFinishContext();
21443   return __pyx_r;
21444 }
21445
21446 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2410
21447  *     property mrnm:
21448  *         """the :term:`reference` id of the mate """
21449  *         def __get__(self): return self._delegate.core.mtid             # <<<<<<<<<<<<<<
21450  *         def __set__(self, mtid): self._delegate.core.mtid = mtid
21451  *     property mpos:
21452  */
21453
21454 static PyObject *__pyx_pf_9csamtools_11AlignedRead_4mrnm___get__(PyObject *__pyx_v_self); /*proto*/
21455 static PyObject *__pyx_pf_9csamtools_11AlignedRead_4mrnm___get__(PyObject *__pyx_v_self) {
21456   PyObject *__pyx_r = NULL;
21457   PyObject *__pyx_t_1 = NULL;
21458   __Pyx_TraceDeclarations
21459   __Pyx_RefNannySetupContext("__get__");
21460   __Pyx_TraceCall("__get__", __pyx_f[0], 2410);
21461   __Pyx_XDECREF(__pyx_r);
21462   __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;}
21463   __Pyx_GOTREF(__pyx_t_1);
21464   __pyx_r = __pyx_t_1;
21465   __pyx_t_1 = 0;
21466   goto __pyx_L0;
21467
21468   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
21469   goto __pyx_L0;
21470   __pyx_L1_error:;
21471   __Pyx_XDECREF(__pyx_t_1);
21472   __Pyx_AddTraceback("csamtools.AlignedRead.mrnm.__get__");
21473   __pyx_r = NULL;
21474   __pyx_L0:;
21475   __Pyx_XGIVEREF(__pyx_r);
21476   __Pyx_TraceReturn(__pyx_r);
21477   __Pyx_RefNannyFinishContext();
21478   return __pyx_r;
21479 }
21480
21481 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2411
21482  *         """the :term:`reference` id of the mate """
21483  *         def __get__(self): return self._delegate.core.mtid
21484  *         def __set__(self, mtid): self._delegate.core.mtid = mtid             # <<<<<<<<<<<<<<
21485  *     property mpos:
21486  *         """the position of the mate"""
21487  */
21488
21489 static int __pyx_pf_9csamtools_11AlignedRead_4mrnm___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_mtid); /*proto*/
21490 static int __pyx_pf_9csamtools_11AlignedRead_4mrnm___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_mtid) {
21491   int __pyx_r;
21492   int32_t __pyx_t_1;
21493   __Pyx_TraceDeclarations
21494   __Pyx_RefNannySetupContext("__set__");
21495   __Pyx_TraceCall("__set__", __pyx_f[0], 2411);
21496   __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;}
21497   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.mtid = __pyx_t_1;
21498
21499   __pyx_r = 0;
21500   goto __pyx_L0;
21501   __pyx_L1_error:;
21502   __Pyx_AddTraceback("csamtools.AlignedRead.mrnm.__set__");
21503   __pyx_r = -1;
21504   __pyx_L0:;
21505   __Pyx_TraceReturn(Py_None);
21506   __Pyx_RefNannyFinishContext();
21507   return __pyx_r;
21508 }
21509
21510 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2414
21511  *     property mpos:
21512  *         """the position of the mate"""
21513  *         def __get__(self): return self._delegate.core.mpos             # <<<<<<<<<<<<<<
21514  *         def __set__(self, mpos): self._delegate.core.mpos = mpos
21515  *     property isize:
21516  */
21517
21518 static PyObject *__pyx_pf_9csamtools_11AlignedRead_4mpos___get__(PyObject *__pyx_v_self); /*proto*/
21519 static PyObject *__pyx_pf_9csamtools_11AlignedRead_4mpos___get__(PyObject *__pyx_v_self) {
21520   PyObject *__pyx_r = NULL;
21521   PyObject *__pyx_t_1 = NULL;
21522   __Pyx_TraceDeclarations
21523   __Pyx_RefNannySetupContext("__get__");
21524   __Pyx_TraceCall("__get__", __pyx_f[0], 2414);
21525   __Pyx_XDECREF(__pyx_r);
21526   __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;}
21527   __Pyx_GOTREF(__pyx_t_1);
21528   __pyx_r = __pyx_t_1;
21529   __pyx_t_1 = 0;
21530   goto __pyx_L0;
21531
21532   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
21533   goto __pyx_L0;
21534   __pyx_L1_error:;
21535   __Pyx_XDECREF(__pyx_t_1);
21536   __Pyx_AddTraceback("csamtools.AlignedRead.mpos.__get__");
21537   __pyx_r = NULL;
21538   __pyx_L0:;
21539   __Pyx_XGIVEREF(__pyx_r);
21540   __Pyx_TraceReturn(__pyx_r);
21541   __Pyx_RefNannyFinishContext();
21542   return __pyx_r;
21543 }
21544
21545 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2415
21546  *         """the position of the mate"""
21547  *         def __get__(self): return self._delegate.core.mpos
21548  *         def __set__(self, mpos): self._delegate.core.mpos = mpos             # <<<<<<<<<<<<<<
21549  *     property isize:
21550  *         """the insert size"""
21551  */
21552
21553 static int __pyx_pf_9csamtools_11AlignedRead_4mpos___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_mpos); /*proto*/
21554 static int __pyx_pf_9csamtools_11AlignedRead_4mpos___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_mpos) {
21555   int __pyx_r;
21556   int32_t __pyx_t_1;
21557   __Pyx_TraceDeclarations
21558   __Pyx_RefNannySetupContext("__set__");
21559   __Pyx_TraceCall("__set__", __pyx_f[0], 2415);
21560   __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;}
21561   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.mpos = __pyx_t_1;
21562
21563   __pyx_r = 0;
21564   goto __pyx_L0;
21565   __pyx_L1_error:;
21566   __Pyx_AddTraceback("csamtools.AlignedRead.mpos.__set__");
21567   __pyx_r = -1;
21568   __pyx_L0:;
21569   __Pyx_TraceReturn(Py_None);
21570   __Pyx_RefNannyFinishContext();
21571   return __pyx_r;
21572 }
21573
21574 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2418
21575  *     property isize:
21576  *         """the insert size"""
21577  *         def __get__(self): return self._delegate.core.isize             # <<<<<<<<<<<<<<
21578  *         def __set__(self, isize): self._delegate.core.isize = isize
21579  *     property is_paired:
21580  */
21581
21582 static PyObject *__pyx_pf_9csamtools_11AlignedRead_5isize___get__(PyObject *__pyx_v_self); /*proto*/
21583 static PyObject *__pyx_pf_9csamtools_11AlignedRead_5isize___get__(PyObject *__pyx_v_self) {
21584   PyObject *__pyx_r = NULL;
21585   PyObject *__pyx_t_1 = NULL;
21586   __Pyx_TraceDeclarations
21587   __Pyx_RefNannySetupContext("__get__");
21588   __Pyx_TraceCall("__get__", __pyx_f[0], 2418);
21589   __Pyx_XDECREF(__pyx_r);
21590   __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;}
21591   __Pyx_GOTREF(__pyx_t_1);
21592   __pyx_r = __pyx_t_1;
21593   __pyx_t_1 = 0;
21594   goto __pyx_L0;
21595
21596   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
21597   goto __pyx_L0;
21598   __pyx_L1_error:;
21599   __Pyx_XDECREF(__pyx_t_1);
21600   __Pyx_AddTraceback("csamtools.AlignedRead.isize.__get__");
21601   __pyx_r = NULL;
21602   __pyx_L0:;
21603   __Pyx_XGIVEREF(__pyx_r);
21604   __Pyx_TraceReturn(__pyx_r);
21605   __Pyx_RefNannyFinishContext();
21606   return __pyx_r;
21607 }
21608
21609 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2419
21610  *         """the insert size"""
21611  *         def __get__(self): return self._delegate.core.isize
21612  *         def __set__(self, isize): self._delegate.core.isize = isize             # <<<<<<<<<<<<<<
21613  *     property is_paired:
21614  *         """true if read is paired in sequencing"""
21615  */
21616
21617 static int __pyx_pf_9csamtools_11AlignedRead_5isize___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_isize); /*proto*/
21618 static int __pyx_pf_9csamtools_11AlignedRead_5isize___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_isize) {
21619   int __pyx_r;
21620   int32_t __pyx_t_1;
21621   __Pyx_TraceDeclarations
21622   __Pyx_RefNannySetupContext("__set__");
21623   __Pyx_TraceCall("__set__", __pyx_f[0], 2419);
21624   __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;}
21625   ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.isize = __pyx_t_1;
21626
21627   __pyx_r = 0;
21628   goto __pyx_L0;
21629   __pyx_L1_error:;
21630   __Pyx_AddTraceback("csamtools.AlignedRead.isize.__set__");
21631   __pyx_r = -1;
21632   __pyx_L0:;
21633   __Pyx_TraceReturn(Py_None);
21634   __Pyx_RefNannyFinishContext();
21635   return __pyx_r;
21636 }
21637
21638 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2422
21639  *     property is_paired:
21640  *         """true if read is paired in sequencing"""
21641  *         def __get__(self): return (self._delegate.core.flag & BAM_FPAIRED) != 0             # <<<<<<<<<<<<<<
21642  *         def __set__(self,val):
21643  *             if val: self._delegate.core.flag |= BAM_FPAIRED
21644  */
21645
21646 static PyObject *__pyx_pf_9csamtools_11AlignedRead_9is_paired___get__(PyObject *__pyx_v_self); /*proto*/
21647 static PyObject *__pyx_pf_9csamtools_11AlignedRead_9is_paired___get__(PyObject *__pyx_v_self) {
21648   PyObject *__pyx_r = NULL;
21649   PyObject *__pyx_t_1 = NULL;
21650   __Pyx_TraceDeclarations
21651   __Pyx_RefNannySetupContext("__get__");
21652   __Pyx_TraceCall("__get__", __pyx_f[0], 2422);
21653   __Pyx_XDECREF(__pyx_r);
21654   __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;}
21655   __Pyx_GOTREF(__pyx_t_1);
21656   __pyx_r = __pyx_t_1;
21657   __pyx_t_1 = 0;
21658   goto __pyx_L0;
21659
21660   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
21661   goto __pyx_L0;
21662   __pyx_L1_error:;
21663   __Pyx_XDECREF(__pyx_t_1);
21664   __Pyx_AddTraceback("csamtools.AlignedRead.is_paired.__get__");
21665   __pyx_r = NULL;
21666   __pyx_L0:;
21667   __Pyx_XGIVEREF(__pyx_r);
21668   __Pyx_TraceReturn(__pyx_r);
21669   __Pyx_RefNannyFinishContext();
21670   return __pyx_r;
21671 }
21672
21673 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2423
21674  *         """true if read is paired in sequencing"""
21675  *         def __get__(self): return (self._delegate.core.flag & BAM_FPAIRED) != 0
21676  *         def __set__(self,val):             # <<<<<<<<<<<<<<
21677  *             if val: self._delegate.core.flag |= BAM_FPAIRED
21678  *             else: self._delegate.core.flag &= ~BAM_FPAIRED
21679  */
21680
21681 static int __pyx_pf_9csamtools_11AlignedRead_9is_paired___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
21682 static int __pyx_pf_9csamtools_11AlignedRead_9is_paired___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
21683   int __pyx_r;
21684   int __pyx_t_1;
21685   __Pyx_TraceDeclarations
21686   __Pyx_RefNannySetupContext("__set__");
21687   __Pyx_TraceCall("__set__", __pyx_f[0], 2423);
21688
21689   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2424
21690  *         def __get__(self): return (self._delegate.core.flag & BAM_FPAIRED) != 0
21691  *         def __set__(self,val):
21692  *             if val: self._delegate.core.flag |= BAM_FPAIRED             # <<<<<<<<<<<<<<
21693  *             else: self._delegate.core.flag &= ~BAM_FPAIRED
21694  *     property is_proper_pair:
21695  */
21696   __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;}
21697   if (__pyx_t_1) {
21698     ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 1;
21699     goto __pyx_L5;
21700   }
21701   /*else*/ {
21702
21703     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2425
21704  *         def __set__(self,val):
21705  *             if val: self._delegate.core.flag |= BAM_FPAIRED
21706  *             else: self._delegate.core.flag &= ~BAM_FPAIRED             # <<<<<<<<<<<<<<
21707  *     property is_proper_pair:
21708  *         """true if read is mapped in a proper pair"""
21709  */
21710     ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~1);
21711   }
21712   __pyx_L5:;
21713
21714   __pyx_r = 0;
21715   goto __pyx_L0;
21716   __pyx_L1_error:;
21717   __Pyx_AddTraceback("csamtools.AlignedRead.is_paired.__set__");
21718   __pyx_r = -1;
21719   __pyx_L0:;
21720   __Pyx_TraceReturn(Py_None);
21721   __Pyx_RefNannyFinishContext();
21722   return __pyx_r;
21723 }
21724
21725 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2428
21726  *     property is_proper_pair:
21727  *         """true if read is mapped in a proper pair"""
21728  *         def __get__(self): return (self.flag & BAM_FPROPER_PAIR) != 0             # <<<<<<<<<<<<<<
21729  *         def __set__(self,val):
21730  *             if val: self._delegate.core.flag |= BAM_FPROPER_PAIR
21731  */
21732
21733 static PyObject *__pyx_pf_9csamtools_11AlignedRead_14is_proper_pair___get__(PyObject *__pyx_v_self); /*proto*/
21734 static PyObject *__pyx_pf_9csamtools_11AlignedRead_14is_proper_pair___get__(PyObject *__pyx_v_self) {
21735   PyObject *__pyx_r = NULL;
21736   PyObject *__pyx_t_1 = NULL;
21737   PyObject *__pyx_t_2 = NULL;
21738   __Pyx_TraceDeclarations
21739   __Pyx_RefNannySetupContext("__get__");
21740   __Pyx_TraceCall("__get__", __pyx_f[0], 2428);
21741   __Pyx_XDECREF(__pyx_r);
21742   __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;}
21743   __Pyx_GOTREF(__pyx_t_1);
21744   __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;}
21745   __Pyx_GOTREF(__pyx_t_2);
21746   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
21747   __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;}
21748   __Pyx_GOTREF(__pyx_t_1);
21749   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
21750   __pyx_r = __pyx_t_1;
21751   __pyx_t_1 = 0;
21752   goto __pyx_L0;
21753
21754   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
21755   goto __pyx_L0;
21756   __pyx_L1_error:;
21757   __Pyx_XDECREF(__pyx_t_1);
21758   __Pyx_XDECREF(__pyx_t_2);
21759   __Pyx_AddTraceback("csamtools.AlignedRead.is_proper_pair.__get__");
21760   __pyx_r = NULL;
21761   __pyx_L0:;
21762   __Pyx_XGIVEREF(__pyx_r);
21763   __Pyx_TraceReturn(__pyx_r);
21764   __Pyx_RefNannyFinishContext();
21765   return __pyx_r;
21766 }
21767
21768 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2429
21769  *         """true if read is mapped in a proper pair"""
21770  *         def __get__(self): return (self.flag & BAM_FPROPER_PAIR) != 0
21771  *         def __set__(self,val):             # <<<<<<<<<<<<<<
21772  *             if val: self._delegate.core.flag |= BAM_FPROPER_PAIR
21773  *             else: self._delegate.core.flag &= ~BAM_FPROPER_PAIR
21774  */
21775
21776 static int __pyx_pf_9csamtools_11AlignedRead_14is_proper_pair___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
21777 static int __pyx_pf_9csamtools_11AlignedRead_14is_proper_pair___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
21778   int __pyx_r;
21779   int __pyx_t_1;
21780   __Pyx_TraceDeclarations
21781   __Pyx_RefNannySetupContext("__set__");
21782   __Pyx_TraceCall("__set__", __pyx_f[0], 2429);
21783
21784   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2430
21785  *         def __get__(self): return (self.flag & BAM_FPROPER_PAIR) != 0
21786  *         def __set__(self,val):
21787  *             if val: self._delegate.core.flag |= BAM_FPROPER_PAIR             # <<<<<<<<<<<<<<
21788  *             else: self._delegate.core.flag &= ~BAM_FPROPER_PAIR
21789  *     property is_unmapped:
21790  */
21791   __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;}
21792   if (__pyx_t_1) {
21793     ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 2;
21794     goto __pyx_L5;
21795   }
21796   /*else*/ {
21797
21798     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2431
21799  *         def __set__(self,val):
21800  *             if val: self._delegate.core.flag |= BAM_FPROPER_PAIR
21801  *             else: self._delegate.core.flag &= ~BAM_FPROPER_PAIR             # <<<<<<<<<<<<<<
21802  *     property is_unmapped:
21803  *         """true if read itself is unmapped"""
21804  */
21805     ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~2);
21806   }
21807   __pyx_L5:;
21808
21809   __pyx_r = 0;
21810   goto __pyx_L0;
21811   __pyx_L1_error:;
21812   __Pyx_AddTraceback("csamtools.AlignedRead.is_proper_pair.__set__");
21813   __pyx_r = -1;
21814   __pyx_L0:;
21815   __Pyx_TraceReturn(Py_None);
21816   __Pyx_RefNannyFinishContext();
21817   return __pyx_r;
21818 }
21819
21820 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2434
21821  *     property is_unmapped:
21822  *         """true if read itself is unmapped"""
21823  *         def __get__(self): return (self.flag & BAM_FUNMAP) != 0             # <<<<<<<<<<<<<<
21824  *         def __set__(self,val):
21825  *             if val: self._delegate.core.flag |= BAM_FUNMAP
21826  */
21827
21828 static PyObject *__pyx_pf_9csamtools_11AlignedRead_11is_unmapped___get__(PyObject *__pyx_v_self); /*proto*/
21829 static PyObject *__pyx_pf_9csamtools_11AlignedRead_11is_unmapped___get__(PyObject *__pyx_v_self) {
21830   PyObject *__pyx_r = NULL;
21831   PyObject *__pyx_t_1 = NULL;
21832   PyObject *__pyx_t_2 = NULL;
21833   __Pyx_TraceDeclarations
21834   __Pyx_RefNannySetupContext("__get__");
21835   __Pyx_TraceCall("__get__", __pyx_f[0], 2434);
21836   __Pyx_XDECREF(__pyx_r);
21837   __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;}
21838   __Pyx_GOTREF(__pyx_t_1);
21839   __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;}
21840   __Pyx_GOTREF(__pyx_t_2);
21841   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
21842   __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;}
21843   __Pyx_GOTREF(__pyx_t_1);
21844   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
21845   __pyx_r = __pyx_t_1;
21846   __pyx_t_1 = 0;
21847   goto __pyx_L0;
21848
21849   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
21850   goto __pyx_L0;
21851   __pyx_L1_error:;
21852   __Pyx_XDECREF(__pyx_t_1);
21853   __Pyx_XDECREF(__pyx_t_2);
21854   __Pyx_AddTraceback("csamtools.AlignedRead.is_unmapped.__get__");
21855   __pyx_r = NULL;
21856   __pyx_L0:;
21857   __Pyx_XGIVEREF(__pyx_r);
21858   __Pyx_TraceReturn(__pyx_r);
21859   __Pyx_RefNannyFinishContext();
21860   return __pyx_r;
21861 }
21862
21863 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2435
21864  *         """true if read itself is unmapped"""
21865  *         def __get__(self): return (self.flag & BAM_FUNMAP) != 0
21866  *         def __set__(self,val):             # <<<<<<<<<<<<<<
21867  *             if val: self._delegate.core.flag |= BAM_FUNMAP
21868  *             else: self._delegate.core.flag &= ~BAM_FUNMAP
21869  */
21870
21871 static int __pyx_pf_9csamtools_11AlignedRead_11is_unmapped___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
21872 static int __pyx_pf_9csamtools_11AlignedRead_11is_unmapped___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
21873   int __pyx_r;
21874   int __pyx_t_1;
21875   __Pyx_TraceDeclarations
21876   __Pyx_RefNannySetupContext("__set__");
21877   __Pyx_TraceCall("__set__", __pyx_f[0], 2435);
21878
21879   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2436
21880  *         def __get__(self): return (self.flag & BAM_FUNMAP) != 0
21881  *         def __set__(self,val):
21882  *             if val: self._delegate.core.flag |= BAM_FUNMAP             # <<<<<<<<<<<<<<
21883  *             else: self._delegate.core.flag &= ~BAM_FUNMAP
21884  *     property mate_is_unmapped:
21885  */
21886   __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;}
21887   if (__pyx_t_1) {
21888     ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 4;
21889     goto __pyx_L5;
21890   }
21891   /*else*/ {
21892
21893     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2437
21894  *         def __set__(self,val):
21895  *             if val: self._delegate.core.flag |= BAM_FUNMAP
21896  *             else: self._delegate.core.flag &= ~BAM_FUNMAP             # <<<<<<<<<<<<<<
21897  *     property mate_is_unmapped:
21898  *         """true if the mate is unmapped"""
21899  */
21900     ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~4);
21901   }
21902   __pyx_L5:;
21903
21904   __pyx_r = 0;
21905   goto __pyx_L0;
21906   __pyx_L1_error:;
21907   __Pyx_AddTraceback("csamtools.AlignedRead.is_unmapped.__set__");
21908   __pyx_r = -1;
21909   __pyx_L0:;
21910   __Pyx_TraceReturn(Py_None);
21911   __Pyx_RefNannyFinishContext();
21912   return __pyx_r;
21913 }
21914
21915 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2440
21916  *     property mate_is_unmapped:
21917  *         """true if the mate is unmapped"""
21918  *         def __get__(self): return (self.flag & BAM_FMUNMAP) != 0             # <<<<<<<<<<<<<<
21919  *         def __set__(self,val):
21920  *             if val: self._delegate.core.flag |= BAM_FMUNMAP
21921  */
21922
21923 static PyObject *__pyx_pf_9csamtools_11AlignedRead_16mate_is_unmapped___get__(PyObject *__pyx_v_self); /*proto*/
21924 static PyObject *__pyx_pf_9csamtools_11AlignedRead_16mate_is_unmapped___get__(PyObject *__pyx_v_self) {
21925   PyObject *__pyx_r = NULL;
21926   PyObject *__pyx_t_1 = NULL;
21927   PyObject *__pyx_t_2 = NULL;
21928   __Pyx_TraceDeclarations
21929   __Pyx_RefNannySetupContext("__get__");
21930   __Pyx_TraceCall("__get__", __pyx_f[0], 2440);
21931   __Pyx_XDECREF(__pyx_r);
21932   __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;}
21933   __Pyx_GOTREF(__pyx_t_1);
21934   __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;}
21935   __Pyx_GOTREF(__pyx_t_2);
21936   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
21937   __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;}
21938   __Pyx_GOTREF(__pyx_t_1);
21939   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
21940   __pyx_r = __pyx_t_1;
21941   __pyx_t_1 = 0;
21942   goto __pyx_L0;
21943
21944   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
21945   goto __pyx_L0;
21946   __pyx_L1_error:;
21947   __Pyx_XDECREF(__pyx_t_1);
21948   __Pyx_XDECREF(__pyx_t_2);
21949   __Pyx_AddTraceback("csamtools.AlignedRead.mate_is_unmapped.__get__");
21950   __pyx_r = NULL;
21951   __pyx_L0:;
21952   __Pyx_XGIVEREF(__pyx_r);
21953   __Pyx_TraceReturn(__pyx_r);
21954   __Pyx_RefNannyFinishContext();
21955   return __pyx_r;
21956 }
21957
21958 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2441
21959  *         """true if the mate is unmapped"""
21960  *         def __get__(self): return (self.flag & BAM_FMUNMAP) != 0
21961  *         def __set__(self,val):             # <<<<<<<<<<<<<<
21962  *             if val: self._delegate.core.flag |= BAM_FMUNMAP
21963  *             else: self._delegate.core.flag &= ~BAM_FMUNMAP
21964  */
21965
21966 static int __pyx_pf_9csamtools_11AlignedRead_16mate_is_unmapped___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
21967 static int __pyx_pf_9csamtools_11AlignedRead_16mate_is_unmapped___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
21968   int __pyx_r;
21969   int __pyx_t_1;
21970   __Pyx_TraceDeclarations
21971   __Pyx_RefNannySetupContext("__set__");
21972   __Pyx_TraceCall("__set__", __pyx_f[0], 2441);
21973
21974   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2442
21975  *         def __get__(self): return (self.flag & BAM_FMUNMAP) != 0
21976  *         def __set__(self,val):
21977  *             if val: self._delegate.core.flag |= BAM_FMUNMAP             # <<<<<<<<<<<<<<
21978  *             else: self._delegate.core.flag &= ~BAM_FMUNMAP
21979  *     property is_reverse:
21980  */
21981   __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;}
21982   if (__pyx_t_1) {
21983     ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 8;
21984     goto __pyx_L5;
21985   }
21986   /*else*/ {
21987
21988     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2443
21989  *         def __set__(self,val):
21990  *             if val: self._delegate.core.flag |= BAM_FMUNMAP
21991  *             else: self._delegate.core.flag &= ~BAM_FMUNMAP             # <<<<<<<<<<<<<<
21992  *     property is_reverse:
21993  *         """true if read is mapped to reverse strand"""
21994  */
21995     ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~8);
21996   }
21997   __pyx_L5:;
21998
21999   __pyx_r = 0;
22000   goto __pyx_L0;
22001   __pyx_L1_error:;
22002   __Pyx_AddTraceback("csamtools.AlignedRead.mate_is_unmapped.__set__");
22003   __pyx_r = -1;
22004   __pyx_L0:;
22005   __Pyx_TraceReturn(Py_None);
22006   __Pyx_RefNannyFinishContext();
22007   return __pyx_r;
22008 }
22009
22010 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2446
22011  *     property is_reverse:
22012  *         """true if read is mapped to reverse strand"""
22013  *         def __get__(self): return (self.flag & BAM_FREVERSE) != 0             # <<<<<<<<<<<<<<
22014  *         def __set__(self,val):
22015  *             if val: self._delegate.core.flag |= BAM_FREVERSE
22016  */
22017
22018 static PyObject *__pyx_pf_9csamtools_11AlignedRead_10is_reverse___get__(PyObject *__pyx_v_self); /*proto*/
22019 static PyObject *__pyx_pf_9csamtools_11AlignedRead_10is_reverse___get__(PyObject *__pyx_v_self) {
22020   PyObject *__pyx_r = NULL;
22021   PyObject *__pyx_t_1 = NULL;
22022   PyObject *__pyx_t_2 = NULL;
22023   __Pyx_TraceDeclarations
22024   __Pyx_RefNannySetupContext("__get__");
22025   __Pyx_TraceCall("__get__", __pyx_f[0], 2446);
22026   __Pyx_XDECREF(__pyx_r);
22027   __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;}
22028   __Pyx_GOTREF(__pyx_t_1);
22029   __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;}
22030   __Pyx_GOTREF(__pyx_t_2);
22031   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
22032   __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;}
22033   __Pyx_GOTREF(__pyx_t_1);
22034   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
22035   __pyx_r = __pyx_t_1;
22036   __pyx_t_1 = 0;
22037   goto __pyx_L0;
22038
22039   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
22040   goto __pyx_L0;
22041   __pyx_L1_error:;
22042   __Pyx_XDECREF(__pyx_t_1);
22043   __Pyx_XDECREF(__pyx_t_2);
22044   __Pyx_AddTraceback("csamtools.AlignedRead.is_reverse.__get__");
22045   __pyx_r = NULL;
22046   __pyx_L0:;
22047   __Pyx_XGIVEREF(__pyx_r);
22048   __Pyx_TraceReturn(__pyx_r);
22049   __Pyx_RefNannyFinishContext();
22050   return __pyx_r;
22051 }
22052
22053 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2447
22054  *         """true if read is mapped to reverse strand"""
22055  *         def __get__(self): return (self.flag & BAM_FREVERSE) != 0
22056  *         def __set__(self,val):             # <<<<<<<<<<<<<<
22057  *             if val: self._delegate.core.flag |= BAM_FREVERSE
22058  *             else: self._delegate.core.flag &= ~BAM_FREVERSE
22059  */
22060
22061 static int __pyx_pf_9csamtools_11AlignedRead_10is_reverse___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
22062 static int __pyx_pf_9csamtools_11AlignedRead_10is_reverse___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
22063   int __pyx_r;
22064   int __pyx_t_1;
22065   __Pyx_TraceDeclarations
22066   __Pyx_RefNannySetupContext("__set__");
22067   __Pyx_TraceCall("__set__", __pyx_f[0], 2447);
22068
22069   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2448
22070  *         def __get__(self): return (self.flag & BAM_FREVERSE) != 0
22071  *         def __set__(self,val):
22072  *             if val: self._delegate.core.flag |= BAM_FREVERSE             # <<<<<<<<<<<<<<
22073  *             else: self._delegate.core.flag &= ~BAM_FREVERSE
22074  *     property mate_is_reverse:
22075  */
22076   __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;}
22077   if (__pyx_t_1) {
22078     ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 16;
22079     goto __pyx_L5;
22080   }
22081   /*else*/ {
22082
22083     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2449
22084  *         def __set__(self,val):
22085  *             if val: self._delegate.core.flag |= BAM_FREVERSE
22086  *             else: self._delegate.core.flag &= ~BAM_FREVERSE             # <<<<<<<<<<<<<<
22087  *     property mate_is_reverse:
22088  *         """true is read is mapped to reverse strand"""
22089  */
22090     ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~16);
22091   }
22092   __pyx_L5:;
22093
22094   __pyx_r = 0;
22095   goto __pyx_L0;
22096   __pyx_L1_error:;
22097   __Pyx_AddTraceback("csamtools.AlignedRead.is_reverse.__set__");
22098   __pyx_r = -1;
22099   __pyx_L0:;
22100   __Pyx_TraceReturn(Py_None);
22101   __Pyx_RefNannyFinishContext();
22102   return __pyx_r;
22103 }
22104
22105 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2452
22106  *     property mate_is_reverse:
22107  *         """true is read is mapped to reverse strand"""
22108  *         def __get__(self): return (self.flag & BAM_FMREVERSE) != 0             # <<<<<<<<<<<<<<
22109  *         def __set__(self,val):
22110  *             if val: self._delegate.core.flag |= BAM_FMREVERSE
22111  */
22112
22113 static PyObject *__pyx_pf_9csamtools_11AlignedRead_15mate_is_reverse___get__(PyObject *__pyx_v_self); /*proto*/
22114 static PyObject *__pyx_pf_9csamtools_11AlignedRead_15mate_is_reverse___get__(PyObject *__pyx_v_self) {
22115   PyObject *__pyx_r = NULL;
22116   PyObject *__pyx_t_1 = NULL;
22117   PyObject *__pyx_t_2 = NULL;
22118   __Pyx_TraceDeclarations
22119   __Pyx_RefNannySetupContext("__get__");
22120   __Pyx_TraceCall("__get__", __pyx_f[0], 2452);
22121   __Pyx_XDECREF(__pyx_r);
22122   __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;}
22123   __Pyx_GOTREF(__pyx_t_1);
22124   __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;}
22125   __Pyx_GOTREF(__pyx_t_2);
22126   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
22127   __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;}
22128   __Pyx_GOTREF(__pyx_t_1);
22129   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
22130   __pyx_r = __pyx_t_1;
22131   __pyx_t_1 = 0;
22132   goto __pyx_L0;
22133
22134   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
22135   goto __pyx_L0;
22136   __pyx_L1_error:;
22137   __Pyx_XDECREF(__pyx_t_1);
22138   __Pyx_XDECREF(__pyx_t_2);
22139   __Pyx_AddTraceback("csamtools.AlignedRead.mate_is_reverse.__get__");
22140   __pyx_r = NULL;
22141   __pyx_L0:;
22142   __Pyx_XGIVEREF(__pyx_r);
22143   __Pyx_TraceReturn(__pyx_r);
22144   __Pyx_RefNannyFinishContext();
22145   return __pyx_r;
22146 }
22147
22148 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2453
22149  *         """true is read is mapped to reverse strand"""
22150  *         def __get__(self): return (self.flag & BAM_FMREVERSE) != 0
22151  *         def __set__(self,val):             # <<<<<<<<<<<<<<
22152  *             if val: self._delegate.core.flag |= BAM_FMREVERSE
22153  *             else: self._delegate.core.flag &= ~BAM_FMREVERSE
22154  */
22155
22156 static int __pyx_pf_9csamtools_11AlignedRead_15mate_is_reverse___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
22157 static int __pyx_pf_9csamtools_11AlignedRead_15mate_is_reverse___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
22158   int __pyx_r;
22159   int __pyx_t_1;
22160   __Pyx_TraceDeclarations
22161   __Pyx_RefNannySetupContext("__set__");
22162   __Pyx_TraceCall("__set__", __pyx_f[0], 2453);
22163
22164   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2454
22165  *         def __get__(self): return (self.flag & BAM_FMREVERSE) != 0
22166  *         def __set__(self,val):
22167  *             if val: self._delegate.core.flag |= BAM_FMREVERSE             # <<<<<<<<<<<<<<
22168  *             else: self._delegate.core.flag &= ~BAM_FMREVERSE
22169  *     property is_read1:
22170  */
22171   __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;}
22172   if (__pyx_t_1) {
22173     ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 32;
22174     goto __pyx_L5;
22175   }
22176   /*else*/ {
22177
22178     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2455
22179  *         def __set__(self,val):
22180  *             if val: self._delegate.core.flag |= BAM_FMREVERSE
22181  *             else: self._delegate.core.flag &= ~BAM_FMREVERSE             # <<<<<<<<<<<<<<
22182  *     property is_read1:
22183  *         """true if this is read1"""
22184  */
22185     ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~32);
22186   }
22187   __pyx_L5:;
22188
22189   __pyx_r = 0;
22190   goto __pyx_L0;
22191   __pyx_L1_error:;
22192   __Pyx_AddTraceback("csamtools.AlignedRead.mate_is_reverse.__set__");
22193   __pyx_r = -1;
22194   __pyx_L0:;
22195   __Pyx_TraceReturn(Py_None);
22196   __Pyx_RefNannyFinishContext();
22197   return __pyx_r;
22198 }
22199
22200 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2458
22201  *     property is_read1:
22202  *         """true if this is read1"""
22203  *         def __get__(self): return (self.flag & BAM_FREAD1) != 0             # <<<<<<<<<<<<<<
22204  *         def __set__(self,val):
22205  *             if val: self._delegate.core.flag |= BAM_FREAD1
22206  */
22207
22208 static PyObject *__pyx_pf_9csamtools_11AlignedRead_8is_read1___get__(PyObject *__pyx_v_self); /*proto*/
22209 static PyObject *__pyx_pf_9csamtools_11AlignedRead_8is_read1___get__(PyObject *__pyx_v_self) {
22210   PyObject *__pyx_r = NULL;
22211   PyObject *__pyx_t_1 = NULL;
22212   PyObject *__pyx_t_2 = NULL;
22213   __Pyx_TraceDeclarations
22214   __Pyx_RefNannySetupContext("__get__");
22215   __Pyx_TraceCall("__get__", __pyx_f[0], 2458);
22216   __Pyx_XDECREF(__pyx_r);
22217   __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;}
22218   __Pyx_GOTREF(__pyx_t_1);
22219   __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;}
22220   __Pyx_GOTREF(__pyx_t_2);
22221   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
22222   __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;}
22223   __Pyx_GOTREF(__pyx_t_1);
22224   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
22225   __pyx_r = __pyx_t_1;
22226   __pyx_t_1 = 0;
22227   goto __pyx_L0;
22228
22229   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
22230   goto __pyx_L0;
22231   __pyx_L1_error:;
22232   __Pyx_XDECREF(__pyx_t_1);
22233   __Pyx_XDECREF(__pyx_t_2);
22234   __Pyx_AddTraceback("csamtools.AlignedRead.is_read1.__get__");
22235   __pyx_r = NULL;
22236   __pyx_L0:;
22237   __Pyx_XGIVEREF(__pyx_r);
22238   __Pyx_TraceReturn(__pyx_r);
22239   __Pyx_RefNannyFinishContext();
22240   return __pyx_r;
22241 }
22242
22243 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2459
22244  *         """true if this is read1"""
22245  *         def __get__(self): return (self.flag & BAM_FREAD1) != 0
22246  *         def __set__(self,val):             # <<<<<<<<<<<<<<
22247  *             if val: self._delegate.core.flag |= BAM_FREAD1
22248  *             else: self._delegate.core.flag &= ~BAM_FREAD1
22249  */
22250
22251 static int __pyx_pf_9csamtools_11AlignedRead_8is_read1___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
22252 static int __pyx_pf_9csamtools_11AlignedRead_8is_read1___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
22253   int __pyx_r;
22254   int __pyx_t_1;
22255   __Pyx_TraceDeclarations
22256   __Pyx_RefNannySetupContext("__set__");
22257   __Pyx_TraceCall("__set__", __pyx_f[0], 2459);
22258
22259   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2460
22260  *         def __get__(self): return (self.flag & BAM_FREAD1) != 0
22261  *         def __set__(self,val):
22262  *             if val: self._delegate.core.flag |= BAM_FREAD1             # <<<<<<<<<<<<<<
22263  *             else: self._delegate.core.flag &= ~BAM_FREAD1
22264  *     property is_read2:
22265  */
22266   __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;}
22267   if (__pyx_t_1) {
22268     ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 64;
22269     goto __pyx_L5;
22270   }
22271   /*else*/ {
22272
22273     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2461
22274  *         def __set__(self,val):
22275  *             if val: self._delegate.core.flag |= BAM_FREAD1
22276  *             else: self._delegate.core.flag &= ~BAM_FREAD1             # <<<<<<<<<<<<<<
22277  *     property is_read2:
22278  *         """true if this is read2"""
22279  */
22280     ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~64);
22281   }
22282   __pyx_L5:;
22283
22284   __pyx_r = 0;
22285   goto __pyx_L0;
22286   __pyx_L1_error:;
22287   __Pyx_AddTraceback("csamtools.AlignedRead.is_read1.__set__");
22288   __pyx_r = -1;
22289   __pyx_L0:;
22290   __Pyx_TraceReturn(Py_None);
22291   __Pyx_RefNannyFinishContext();
22292   return __pyx_r;
22293 }
22294
22295 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2464
22296  *     property is_read2:
22297  *         """true if this is read2"""
22298  *         def __get__(self): return (self.flag & BAM_FREAD2) != 0             # <<<<<<<<<<<<<<
22299  *         def __set__(self,val):
22300  *             if val: self._delegate.core.flag |= BAM_FREAD2
22301  */
22302
22303 static PyObject *__pyx_pf_9csamtools_11AlignedRead_8is_read2___get__(PyObject *__pyx_v_self); /*proto*/
22304 static PyObject *__pyx_pf_9csamtools_11AlignedRead_8is_read2___get__(PyObject *__pyx_v_self) {
22305   PyObject *__pyx_r = NULL;
22306   PyObject *__pyx_t_1 = NULL;
22307   PyObject *__pyx_t_2 = NULL;
22308   __Pyx_TraceDeclarations
22309   __Pyx_RefNannySetupContext("__get__");
22310   __Pyx_TraceCall("__get__", __pyx_f[0], 2464);
22311   __Pyx_XDECREF(__pyx_r);
22312   __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;}
22313   __Pyx_GOTREF(__pyx_t_1);
22314   __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;}
22315   __Pyx_GOTREF(__pyx_t_2);
22316   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
22317   __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;}
22318   __Pyx_GOTREF(__pyx_t_1);
22319   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
22320   __pyx_r = __pyx_t_1;
22321   __pyx_t_1 = 0;
22322   goto __pyx_L0;
22323
22324   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
22325   goto __pyx_L0;
22326   __pyx_L1_error:;
22327   __Pyx_XDECREF(__pyx_t_1);
22328   __Pyx_XDECREF(__pyx_t_2);
22329   __Pyx_AddTraceback("csamtools.AlignedRead.is_read2.__get__");
22330   __pyx_r = NULL;
22331   __pyx_L0:;
22332   __Pyx_XGIVEREF(__pyx_r);
22333   __Pyx_TraceReturn(__pyx_r);
22334   __Pyx_RefNannyFinishContext();
22335   return __pyx_r;
22336 }
22337
22338 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2465
22339  *         """true if this is read2"""
22340  *         def __get__(self): return (self.flag & BAM_FREAD2) != 0
22341  *         def __set__(self,val):             # <<<<<<<<<<<<<<
22342  *             if val: self._delegate.core.flag |= BAM_FREAD2
22343  *             else: self._delegate.core.flag &= ~BAM_FREAD2
22344  */
22345
22346 static int __pyx_pf_9csamtools_11AlignedRead_8is_read2___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
22347 static int __pyx_pf_9csamtools_11AlignedRead_8is_read2___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
22348   int __pyx_r;
22349   int __pyx_t_1;
22350   __Pyx_TraceDeclarations
22351   __Pyx_RefNannySetupContext("__set__");
22352   __Pyx_TraceCall("__set__", __pyx_f[0], 2465);
22353
22354   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2466
22355  *         def __get__(self): return (self.flag & BAM_FREAD2) != 0
22356  *         def __set__(self,val):
22357  *             if val: self._delegate.core.flag |= BAM_FREAD2             # <<<<<<<<<<<<<<
22358  *             else: self._delegate.core.flag &= ~BAM_FREAD2
22359  *     property is_secondary:
22360  */
22361   __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;}
22362   if (__pyx_t_1) {
22363     ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 128;
22364     goto __pyx_L5;
22365   }
22366   /*else*/ {
22367
22368     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2467
22369  *         def __set__(self,val):
22370  *             if val: self._delegate.core.flag |= BAM_FREAD2
22371  *             else: self._delegate.core.flag &= ~BAM_FREAD2             # <<<<<<<<<<<<<<
22372  *     property is_secondary:
22373  *         """true if not primary alignment"""
22374  */
22375     ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~128);
22376   }
22377   __pyx_L5:;
22378
22379   __pyx_r = 0;
22380   goto __pyx_L0;
22381   __pyx_L1_error:;
22382   __Pyx_AddTraceback("csamtools.AlignedRead.is_read2.__set__");
22383   __pyx_r = -1;
22384   __pyx_L0:;
22385   __Pyx_TraceReturn(Py_None);
22386   __Pyx_RefNannyFinishContext();
22387   return __pyx_r;
22388 }
22389
22390 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2470
22391  *     property is_secondary:
22392  *         """true if not primary alignment"""
22393  *         def __get__(self): return (self.flag & BAM_FSECONDARY) != 0             # <<<<<<<<<<<<<<
22394  *         def __set__(self,val):
22395  *             if val: self._delegate.core.flag |= BAM_FSECONDARY
22396  */
22397
22398 static PyObject *__pyx_pf_9csamtools_11AlignedRead_12is_secondary___get__(PyObject *__pyx_v_self); /*proto*/
22399 static PyObject *__pyx_pf_9csamtools_11AlignedRead_12is_secondary___get__(PyObject *__pyx_v_self) {
22400   PyObject *__pyx_r = NULL;
22401   PyObject *__pyx_t_1 = NULL;
22402   PyObject *__pyx_t_2 = NULL;
22403   __Pyx_TraceDeclarations
22404   __Pyx_RefNannySetupContext("__get__");
22405   __Pyx_TraceCall("__get__", __pyx_f[0], 2470);
22406   __Pyx_XDECREF(__pyx_r);
22407   __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;}
22408   __Pyx_GOTREF(__pyx_t_1);
22409   __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;}
22410   __Pyx_GOTREF(__pyx_t_2);
22411   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
22412   __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;}
22413   __Pyx_GOTREF(__pyx_t_1);
22414   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
22415   __pyx_r = __pyx_t_1;
22416   __pyx_t_1 = 0;
22417   goto __pyx_L0;
22418
22419   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
22420   goto __pyx_L0;
22421   __pyx_L1_error:;
22422   __Pyx_XDECREF(__pyx_t_1);
22423   __Pyx_XDECREF(__pyx_t_2);
22424   __Pyx_AddTraceback("csamtools.AlignedRead.is_secondary.__get__");
22425   __pyx_r = NULL;
22426   __pyx_L0:;
22427   __Pyx_XGIVEREF(__pyx_r);
22428   __Pyx_TraceReturn(__pyx_r);
22429   __Pyx_RefNannyFinishContext();
22430   return __pyx_r;
22431 }
22432
22433 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2471
22434  *         """true if not primary alignment"""
22435  *         def __get__(self): return (self.flag & BAM_FSECONDARY) != 0
22436  *         def __set__(self,val):             # <<<<<<<<<<<<<<
22437  *             if val: self._delegate.core.flag |= BAM_FSECONDARY
22438  *             else: self._delegate.core.flag &= ~BAM_FSECONDARY
22439  */
22440
22441 static int __pyx_pf_9csamtools_11AlignedRead_12is_secondary___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
22442 static int __pyx_pf_9csamtools_11AlignedRead_12is_secondary___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
22443   int __pyx_r;
22444   int __pyx_t_1;
22445   __Pyx_TraceDeclarations
22446   __Pyx_RefNannySetupContext("__set__");
22447   __Pyx_TraceCall("__set__", __pyx_f[0], 2471);
22448
22449   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2472
22450  *         def __get__(self): return (self.flag & BAM_FSECONDARY) != 0
22451  *         def __set__(self,val):
22452  *             if val: self._delegate.core.flag |= BAM_FSECONDARY             # <<<<<<<<<<<<<<
22453  *             else: self._delegate.core.flag &= ~BAM_FSECONDARY
22454  *     property is_qcfail:
22455  */
22456   __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;}
22457   if (__pyx_t_1) {
22458     ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 256;
22459     goto __pyx_L5;
22460   }
22461   /*else*/ {
22462
22463     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2473
22464  *         def __set__(self,val):
22465  *             if val: self._delegate.core.flag |= BAM_FSECONDARY
22466  *             else: self._delegate.core.flag &= ~BAM_FSECONDARY             # <<<<<<<<<<<<<<
22467  *     property is_qcfail:
22468  *         """true if QC failure"""
22469  */
22470     ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~256);
22471   }
22472   __pyx_L5:;
22473
22474   __pyx_r = 0;
22475   goto __pyx_L0;
22476   __pyx_L1_error:;
22477   __Pyx_AddTraceback("csamtools.AlignedRead.is_secondary.__set__");
22478   __pyx_r = -1;
22479   __pyx_L0:;
22480   __Pyx_TraceReturn(Py_None);
22481   __Pyx_RefNannyFinishContext();
22482   return __pyx_r;
22483 }
22484
22485 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2476
22486  *     property is_qcfail:
22487  *         """true if QC failure"""
22488  *         def __get__(self): return (self.flag & BAM_FQCFAIL) != 0             # <<<<<<<<<<<<<<
22489  *         def __set__(self,val):
22490  *             if val: self._delegate.core.flag |= BAM_FQCFAIL
22491  */
22492
22493 static PyObject *__pyx_pf_9csamtools_11AlignedRead_9is_qcfail___get__(PyObject *__pyx_v_self); /*proto*/
22494 static PyObject *__pyx_pf_9csamtools_11AlignedRead_9is_qcfail___get__(PyObject *__pyx_v_self) {
22495   PyObject *__pyx_r = NULL;
22496   PyObject *__pyx_t_1 = NULL;
22497   PyObject *__pyx_t_2 = NULL;
22498   __Pyx_TraceDeclarations
22499   __Pyx_RefNannySetupContext("__get__");
22500   __Pyx_TraceCall("__get__", __pyx_f[0], 2476);
22501   __Pyx_XDECREF(__pyx_r);
22502   __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;}
22503   __Pyx_GOTREF(__pyx_t_1);
22504   __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;}
22505   __Pyx_GOTREF(__pyx_t_2);
22506   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
22507   __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;}
22508   __Pyx_GOTREF(__pyx_t_1);
22509   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
22510   __pyx_r = __pyx_t_1;
22511   __pyx_t_1 = 0;
22512   goto __pyx_L0;
22513
22514   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
22515   goto __pyx_L0;
22516   __pyx_L1_error:;
22517   __Pyx_XDECREF(__pyx_t_1);
22518   __Pyx_XDECREF(__pyx_t_2);
22519   __Pyx_AddTraceback("csamtools.AlignedRead.is_qcfail.__get__");
22520   __pyx_r = NULL;
22521   __pyx_L0:;
22522   __Pyx_XGIVEREF(__pyx_r);
22523   __Pyx_TraceReturn(__pyx_r);
22524   __Pyx_RefNannyFinishContext();
22525   return __pyx_r;
22526 }
22527
22528 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2477
22529  *         """true if QC failure"""
22530  *         def __get__(self): return (self.flag & BAM_FQCFAIL) != 0
22531  *         def __set__(self,val):             # <<<<<<<<<<<<<<
22532  *             if val: self._delegate.core.flag |= BAM_FQCFAIL
22533  *             else: self._delegate.core.flag &= ~BAM_FQCFAIL
22534  */
22535
22536 static int __pyx_pf_9csamtools_11AlignedRead_9is_qcfail___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
22537 static int __pyx_pf_9csamtools_11AlignedRead_9is_qcfail___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
22538   int __pyx_r;
22539   int __pyx_t_1;
22540   __Pyx_TraceDeclarations
22541   __Pyx_RefNannySetupContext("__set__");
22542   __Pyx_TraceCall("__set__", __pyx_f[0], 2477);
22543
22544   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2478
22545  *         def __get__(self): return (self.flag & BAM_FQCFAIL) != 0
22546  *         def __set__(self,val):
22547  *             if val: self._delegate.core.flag |= BAM_FQCFAIL             # <<<<<<<<<<<<<<
22548  *             else: self._delegate.core.flag &= ~BAM_FQCFAIL
22549  *     property is_duplicate:
22550  */
22551   __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;}
22552   if (__pyx_t_1) {
22553     ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 512;
22554     goto __pyx_L5;
22555   }
22556   /*else*/ {
22557
22558     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2479
22559  *         def __set__(self,val):
22560  *             if val: self._delegate.core.flag |= BAM_FQCFAIL
22561  *             else: self._delegate.core.flag &= ~BAM_FQCFAIL             # <<<<<<<<<<<<<<
22562  *     property is_duplicate:
22563  *         """true if optical or PCR duplicate"""
22564  */
22565     ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~512);
22566   }
22567   __pyx_L5:;
22568
22569   __pyx_r = 0;
22570   goto __pyx_L0;
22571   __pyx_L1_error:;
22572   __Pyx_AddTraceback("csamtools.AlignedRead.is_qcfail.__set__");
22573   __pyx_r = -1;
22574   __pyx_L0:;
22575   __Pyx_TraceReturn(Py_None);
22576   __Pyx_RefNannyFinishContext();
22577   return __pyx_r;
22578 }
22579
22580 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2482
22581  *     property is_duplicate:
22582  *         """true if optical or PCR duplicate"""
22583  *         def __get__(self): return (self.flag & BAM_FDUP) != 0             # <<<<<<<<<<<<<<
22584  *         def __set__(self,val):
22585  *             if val: self._delegate.core.flag |= BAM_FDUP
22586  */
22587
22588 static PyObject *__pyx_pf_9csamtools_11AlignedRead_12is_duplicate___get__(PyObject *__pyx_v_self); /*proto*/
22589 static PyObject *__pyx_pf_9csamtools_11AlignedRead_12is_duplicate___get__(PyObject *__pyx_v_self) {
22590   PyObject *__pyx_r = NULL;
22591   PyObject *__pyx_t_1 = NULL;
22592   PyObject *__pyx_t_2 = NULL;
22593   __Pyx_TraceDeclarations
22594   __Pyx_RefNannySetupContext("__get__");
22595   __Pyx_TraceCall("__get__", __pyx_f[0], 2482);
22596   __Pyx_XDECREF(__pyx_r);
22597   __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;}
22598   __Pyx_GOTREF(__pyx_t_1);
22599   __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;}
22600   __Pyx_GOTREF(__pyx_t_2);
22601   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
22602   __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;}
22603   __Pyx_GOTREF(__pyx_t_1);
22604   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
22605   __pyx_r = __pyx_t_1;
22606   __pyx_t_1 = 0;
22607   goto __pyx_L0;
22608
22609   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
22610   goto __pyx_L0;
22611   __pyx_L1_error:;
22612   __Pyx_XDECREF(__pyx_t_1);
22613   __Pyx_XDECREF(__pyx_t_2);
22614   __Pyx_AddTraceback("csamtools.AlignedRead.is_duplicate.__get__");
22615   __pyx_r = NULL;
22616   __pyx_L0:;
22617   __Pyx_XGIVEREF(__pyx_r);
22618   __Pyx_TraceReturn(__pyx_r);
22619   __Pyx_RefNannyFinishContext();
22620   return __pyx_r;
22621 }
22622
22623 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2483
22624  *         """true if optical or PCR duplicate"""
22625  *         def __get__(self): return (self.flag & BAM_FDUP) != 0
22626  *         def __set__(self,val):             # <<<<<<<<<<<<<<
22627  *             if val: self._delegate.core.flag |= BAM_FDUP
22628  *             else: self._delegate.core.flag &= ~BAM_FDUP
22629  */
22630
22631 static int __pyx_pf_9csamtools_11AlignedRead_12is_duplicate___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val); /*proto*/
22632 static int __pyx_pf_9csamtools_11AlignedRead_12is_duplicate___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_val) {
22633   int __pyx_r;
22634   int __pyx_t_1;
22635   __Pyx_TraceDeclarations
22636   __Pyx_RefNannySetupContext("__set__");
22637   __Pyx_TraceCall("__set__", __pyx_f[0], 2483);
22638
22639   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2484
22640  *         def __get__(self): return (self.flag & BAM_FDUP) != 0
22641  *         def __set__(self,val):
22642  *             if val: self._delegate.core.flag |= BAM_FDUP             # <<<<<<<<<<<<<<
22643  *             else: self._delegate.core.flag &= ~BAM_FDUP
22644  *     property positions:
22645  */
22646   __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;}
22647   if (__pyx_t_1) {
22648     ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag |= 1024;
22649     goto __pyx_L5;
22650   }
22651   /*else*/ {
22652
22653     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2485
22654  *         def __set__(self,val):
22655  *             if val: self._delegate.core.flag |= BAM_FDUP
22656  *             else: self._delegate.core.flag &= ~BAM_FDUP             # <<<<<<<<<<<<<<
22657  *     property positions:
22658  *         """a list of reference positions that this read aligns to."""
22659  */
22660     ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate->core.flag &= (~1024);
22661   }
22662   __pyx_L5:;
22663
22664   __pyx_r = 0;
22665   goto __pyx_L0;
22666   __pyx_L1_error:;
22667   __Pyx_AddTraceback("csamtools.AlignedRead.is_duplicate.__set__");
22668   __pyx_r = -1;
22669   __pyx_L0:;
22670   __Pyx_TraceReturn(Py_None);
22671   __Pyx_RefNannyFinishContext();
22672   return __pyx_r;
22673 }
22674
22675 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2488
22676  *     property positions:
22677  *         """a list of reference positions that this read aligns to."""
22678  *         def __get__(self):             # <<<<<<<<<<<<<<
22679  *             cdef uint32_t k, i, pos
22680  *             cdef int op
22681  */
22682
22683 static PyObject *__pyx_pf_9csamtools_11AlignedRead_9positions___get__(PyObject *__pyx_v_self); /*proto*/
22684 static PyObject *__pyx_pf_9csamtools_11AlignedRead_9positions___get__(PyObject *__pyx_v_self) {
22685   uint32_t __pyx_v_k;
22686   uint32_t __pyx_v_i;
22687   uint32_t __pyx_v_pos;
22688   int __pyx_v_op;
22689   uint32_t *__pyx_v_cigar_p;
22690   bam1_t *__pyx_v_src;
22691   PyObject *__pyx_v_result;
22692   PyObject *__pyx_v_l;
22693   PyObject *__pyx_r = NULL;
22694   PyObject *__pyx_t_1 = NULL;
22695   int __pyx_t_2;
22696   uint32_t __pyx_t_3;
22697   PyObject *__pyx_t_4 = NULL;
22698   uint32_t __pyx_t_5;
22699   int __pyx_t_6;
22700   __Pyx_TraceDeclarations
22701   __Pyx_RefNannySetupContext("__get__");
22702   __Pyx_TraceCall("__get__", __pyx_f[0], 2488);
22703   __pyx_v_result = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
22704   __pyx_v_l = Py_None; __Pyx_INCREF(Py_None);
22705
22706   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2494
22707  *             cdef bam1_t * src
22708  * 
22709  *             result = []             # <<<<<<<<<<<<<<
22710  *             src = self._delegate
22711  *             if src.core.n_cigar == 0: return []
22712  */
22713   __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;}
22714   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
22715   __Pyx_DECREF(((PyObject *)__pyx_v_result));
22716   __pyx_v_result = __pyx_t_1;
22717   __pyx_t_1 = 0;
22718
22719   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2495
22720  * 
22721  *             result = []
22722  *             src = self._delegate             # <<<<<<<<<<<<<<
22723  *             if src.core.n_cigar == 0: return []
22724  * 
22725  */
22726   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
22727
22728   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2496
22729  *             result = []
22730  *             src = self._delegate
22731  *             if src.core.n_cigar == 0: return []             # <<<<<<<<<<<<<<
22732  * 
22733  *             pos = src.core.pos
22734  */
22735   __pyx_t_2 = (__pyx_v_src->core.n_cigar == 0);
22736   if (__pyx_t_2) {
22737     __Pyx_XDECREF(__pyx_r);
22738     __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;}
22739     __Pyx_GOTREF(((PyObject *)__pyx_t_1));
22740     __pyx_r = ((PyObject *)__pyx_t_1);
22741     __pyx_t_1 = 0;
22742     goto __pyx_L0;
22743     goto __pyx_L5;
22744   }
22745   __pyx_L5:;
22746
22747   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2498
22748  *             if src.core.n_cigar == 0: return []
22749  * 
22750  *             pos = src.core.pos             # <<<<<<<<<<<<<<
22751  * 
22752  *             cigar_p = bam1_cigar(src)
22753  */
22754   __pyx_v_pos = __pyx_v_src->core.pos;
22755
22756   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2500
22757  *             pos = src.core.pos
22758  * 
22759  *             cigar_p = bam1_cigar(src)             # <<<<<<<<<<<<<<
22760  *             for k from 0 <= k < src.core.n_cigar:
22761  *                 op = cigar_p[k] & BAM_CIGAR_MASK
22762  */
22763   __pyx_v_cigar_p = bam1_cigar(__pyx_v_src);
22764
22765   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2501
22766  * 
22767  *             cigar_p = bam1_cigar(src)
22768  *             for k from 0 <= k < src.core.n_cigar:             # <<<<<<<<<<<<<<
22769  *                 op = cigar_p[k] & BAM_CIGAR_MASK
22770  *                 l = cigar_p[k] >> BAM_CIGAR_SHIFT
22771  */
22772   __pyx_t_3 = __pyx_v_src->core.n_cigar;
22773   for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_3; __pyx_v_k++) {
22774
22775     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2502
22776  *             cigar_p = bam1_cigar(src)
22777  *             for k from 0 <= k < src.core.n_cigar:
22778  *                 op = cigar_p[k] & BAM_CIGAR_MASK             # <<<<<<<<<<<<<<
22779  *                 l = cigar_p[k] >> BAM_CIGAR_SHIFT
22780  *                 if op == BAM_CMATCH:
22781  */
22782     __pyx_v_op = ((__pyx_v_cigar_p[__pyx_v_k]) & 15);
22783
22784     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2503
22785  *             for k from 0 <= k < src.core.n_cigar:
22786  *                 op = cigar_p[k] & BAM_CIGAR_MASK
22787  *                 l = cigar_p[k] >> BAM_CIGAR_SHIFT             # <<<<<<<<<<<<<<
22788  *                 if op == BAM_CMATCH:
22789  *                     for i from pos <= i < pos + l:
22790  */
22791     __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;}
22792     __Pyx_GOTREF(__pyx_t_1);
22793     __Pyx_DECREF(__pyx_v_l);
22794     __pyx_v_l = __pyx_t_1;
22795     __pyx_t_1 = 0;
22796
22797     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2504
22798  *                 op = cigar_p[k] & BAM_CIGAR_MASK
22799  *                 l = cigar_p[k] >> BAM_CIGAR_SHIFT
22800  *                 if op == BAM_CMATCH:             # <<<<<<<<<<<<<<
22801  *                     for i from pos <= i < pos + l:
22802  *                         result.append( i )
22803  */
22804     __pyx_t_2 = (__pyx_v_op == 0);
22805     if (__pyx_t_2) {
22806
22807       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2505
22808  *                 l = cigar_p[k] >> BAM_CIGAR_SHIFT
22809  *                 if op == BAM_CMATCH:
22810  *                     for i from pos <= i < pos + l:             # <<<<<<<<<<<<<<
22811  *                         result.append( i )
22812  * 
22813  */
22814       __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;}
22815       __Pyx_GOTREF(__pyx_t_1);
22816       __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;}
22817       __Pyx_GOTREF(__pyx_t_4);
22818       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
22819       __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;}
22820       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
22821       for (__pyx_v_i = __pyx_v_pos; __pyx_v_i < __pyx_t_5; __pyx_v_i++) {
22822
22823         /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2506
22824  *                 if op == BAM_CMATCH:
22825  *                     for i from pos <= i < pos + l:
22826  *                         result.append( i )             # <<<<<<<<<<<<<<
22827  * 
22828  *                 if op == BAM_CMATCH or op == BAM_CDEL or op == BAM_CREF_SKIP:
22829  */
22830         if (unlikely(__pyx_v_result == Py_None)) {
22831           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;} 
22832         }
22833         __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;}
22834         __Pyx_GOTREF(__pyx_t_4);
22835         __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;}
22836         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
22837       }
22838       goto __pyx_L8;
22839     }
22840     __pyx_L8:;
22841
22842     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2508
22843  *                         result.append( i )
22844  * 
22845  *                 if op == BAM_CMATCH or op == BAM_CDEL or op == BAM_CREF_SKIP:             # <<<<<<<<<<<<<<
22846  *                     pos += l
22847  * 
22848  */
22849     switch (__pyx_v_op) {
22850       case 0:
22851       case 2:
22852       case 3:
22853
22854       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2509
22855  * 
22856  *                 if op == BAM_CMATCH or op == BAM_CDEL or op == BAM_CREF_SKIP:
22857  *                     pos += l             # <<<<<<<<<<<<<<
22858  * 
22859  *             return result
22860  */
22861       __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;}
22862       __pyx_v_pos += __pyx_t_5;
22863       break;
22864     }
22865   }
22866
22867   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2511
22868  *                     pos += l
22869  * 
22870  *             return result             # <<<<<<<<<<<<<<
22871  *     def overlap( self, uint32_t start, uint32_t end ):
22872  *         """return number of bases on reference overlapping *start* and *end*
22873  */
22874   __Pyx_XDECREF(__pyx_r);
22875   __Pyx_INCREF(((PyObject *)__pyx_v_result));
22876   __pyx_r = ((PyObject *)__pyx_v_result);
22877   goto __pyx_L0;
22878
22879   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
22880   goto __pyx_L0;
22881   __pyx_L1_error:;
22882   __Pyx_XDECREF(__pyx_t_1);
22883   __Pyx_XDECREF(__pyx_t_4);
22884   __Pyx_AddTraceback("csamtools.AlignedRead.positions.__get__");
22885   __pyx_r = NULL;
22886   __pyx_L0:;
22887   __Pyx_DECREF(__pyx_v_result);
22888   __Pyx_DECREF(__pyx_v_l);
22889   __Pyx_XGIVEREF(__pyx_r);
22890   __Pyx_TraceReturn(__pyx_r);
22891   __Pyx_RefNannyFinishContext();
22892   return __pyx_r;
22893 }
22894
22895 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2512
22896  * 
22897  *             return result
22898  *     def overlap( self, uint32_t start, uint32_t end ):             # <<<<<<<<<<<<<<
22899  *         """return number of bases on reference overlapping *start* and *end*
22900  *         """
22901  */
22902
22903 static PyObject *__pyx_pf_9csamtools_11AlignedRead_overlap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
22904 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        ";
22905 static PyObject *__pyx_pf_9csamtools_11AlignedRead_overlap(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
22906   uint32_t __pyx_v_start;
22907   uint32_t __pyx_v_end;
22908   uint32_t __pyx_v_k;
22909   uint32_t __pyx_v_pos;
22910   uint32_t __pyx_v_overlap;
22911   int __pyx_v_op;
22912   int __pyx_v_o;
22913   uint32_t *__pyx_v_cigar_p;
22914   bam1_t *__pyx_v_src;
22915   PyObject *__pyx_v_l;
22916   PyObject *__pyx_r = NULL;
22917   int __pyx_t_1;
22918   uint32_t __pyx_t_2;
22919   PyObject *__pyx_t_3 = NULL;
22920   uint32_t __pyx_t_4;
22921   PyObject *__pyx_t_5 = NULL;
22922   PyObject *__pyx_t_6 = NULL;
22923   PyObject *__pyx_t_7 = NULL;
22924   uint32_t __pyx_t_8;
22925   uint32_t __pyx_t_9;
22926   int __pyx_t_10;
22927   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__start,&__pyx_n_s__end,0};
22928   __Pyx_TraceDeclarations
22929   __Pyx_RefNannySetupContext("overlap");
22930   __Pyx_TraceCall("overlap", __pyx_f[0], 2512);
22931   if (unlikely(__pyx_kwds)) {
22932     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
22933     PyObject* values[2] = {0,0};
22934     switch (PyTuple_GET_SIZE(__pyx_args)) {
22935       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
22936       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
22937       case  0: break;
22938       default: goto __pyx_L5_argtuple_error;
22939     }
22940     switch (PyTuple_GET_SIZE(__pyx_args)) {
22941       case  0:
22942       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start);
22943       if (likely(values[0])) kw_args--;
22944       else goto __pyx_L5_argtuple_error;
22945       case  1:
22946       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end);
22947       if (likely(values[1])) kw_args--;
22948       else {
22949         __Pyx_RaiseArgtupleInvalid("overlap", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2512; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
22950       }
22951     }
22952     if (unlikely(kw_args > 0)) {
22953       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;}
22954     }
22955     __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;}
22956     __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;}
22957   } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
22958     goto __pyx_L5_argtuple_error;
22959   } else {
22960     __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;}
22961     __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;}
22962   }
22963   goto __pyx_L4_argument_unpacking_done;
22964   __pyx_L5_argtuple_error:;
22965   __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;}
22966   __pyx_L3_error:;
22967   __Pyx_AddTraceback("csamtools.AlignedRead.overlap");
22968   __Pyx_RefNannyFinishContext();
22969   return NULL;
22970   __pyx_L4_argument_unpacking_done:;
22971   __pyx_v_l = Py_None; __Pyx_INCREF(Py_None);
22972
22973   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2520
22974  *         cdef bam1_t * src
22975  * 
22976  *         overlap = 0             # <<<<<<<<<<<<<<
22977  * 
22978  *         src = self._delegate
22979  */
22980   __pyx_v_overlap = 0;
22981
22982   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2522
22983  *         overlap = 0
22984  * 
22985  *         src = self._delegate             # <<<<<<<<<<<<<<
22986  *         if src.core.n_cigar == 0: return 0
22987  *         pos = src.core.pos
22988  */
22989   __pyx_v_src = ((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate;
22990
22991   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2523
22992  * 
22993  *         src = self._delegate
22994  *         if src.core.n_cigar == 0: return 0             # <<<<<<<<<<<<<<
22995  *         pos = src.core.pos
22996  *         o = 0
22997  */
22998   __pyx_t_1 = (__pyx_v_src->core.n_cigar == 0);
22999   if (__pyx_t_1) {
23000     __Pyx_XDECREF(__pyx_r);
23001     __Pyx_INCREF(__pyx_int_0);
23002     __pyx_r = __pyx_int_0;
23003     goto __pyx_L0;
23004     goto __pyx_L6;
23005   }
23006   __pyx_L6:;
23007
23008   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2524
23009  *         src = self._delegate
23010  *         if src.core.n_cigar == 0: return 0
23011  *         pos = src.core.pos             # <<<<<<<<<<<<<<
23012  *         o = 0
23013  * 
23014  */
23015   __pyx_v_pos = __pyx_v_src->core.pos;
23016
23017   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2525
23018  *         if src.core.n_cigar == 0: return 0
23019  *         pos = src.core.pos
23020  *         o = 0             # <<<<<<<<<<<<<<
23021  * 
23022  *         cigar_p = bam1_cigar(src)
23023  */
23024   __pyx_v_o = 0;
23025
23026   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2527
23027  *         o = 0
23028  * 
23029  *         cigar_p = bam1_cigar(src)             # <<<<<<<<<<<<<<
23030  *         for k from 0 <= k < src.core.n_cigar:
23031  *             op = cigar_p[k] & BAM_CIGAR_MASK
23032  */
23033   __pyx_v_cigar_p = bam1_cigar(__pyx_v_src);
23034
23035   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2528
23036  * 
23037  *         cigar_p = bam1_cigar(src)
23038  *         for k from 0 <= k < src.core.n_cigar:             # <<<<<<<<<<<<<<
23039  *             op = cigar_p[k] & BAM_CIGAR_MASK
23040  *             l = cigar_p[k] >> BAM_CIGAR_SHIFT
23041  */
23042   __pyx_t_2 = __pyx_v_src->core.n_cigar;
23043   for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_2; __pyx_v_k++) {
23044
23045     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2529
23046  *         cigar_p = bam1_cigar(src)
23047  *         for k from 0 <= k < src.core.n_cigar:
23048  *             op = cigar_p[k] & BAM_CIGAR_MASK             # <<<<<<<<<<<<<<
23049  *             l = cigar_p[k] >> BAM_CIGAR_SHIFT
23050  * 
23051  */
23052     __pyx_v_op = ((__pyx_v_cigar_p[__pyx_v_k]) & 15);
23053
23054     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2530
23055  *         for k from 0 <= k < src.core.n_cigar:
23056  *             op = cigar_p[k] & BAM_CIGAR_MASK
23057  *             l = cigar_p[k] >> BAM_CIGAR_SHIFT             # <<<<<<<<<<<<<<
23058  * 
23059  *             if op == BAM_CMATCH:
23060  */
23061     __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;}
23062     __Pyx_GOTREF(__pyx_t_3);
23063     __Pyx_DECREF(__pyx_v_l);
23064     __pyx_v_l = __pyx_t_3;
23065     __pyx_t_3 = 0;
23066
23067     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2532
23068  *             l = cigar_p[k] >> BAM_CIGAR_SHIFT
23069  * 
23070  *             if op == BAM_CMATCH:             # <<<<<<<<<<<<<<
23071  *                 o = min( pos + l, end) - max( pos, start )
23072  *                 if o > 0: overlap += o
23073  */
23074     __pyx_t_1 = (__pyx_v_op == 0);
23075     if (__pyx_t_1) {
23076
23077       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2533
23078  * 
23079  *             if op == BAM_CMATCH:
23080  *                 o = min( pos + l, end) - max( pos, start )             # <<<<<<<<<<<<<<
23081  *                 if o > 0: overlap += o
23082  * 
23083  */
23084       __pyx_t_4 = __pyx_v_end;
23085       __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;}
23086       __Pyx_GOTREF(__pyx_t_3);
23087       __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;}
23088       __Pyx_GOTREF(__pyx_t_5);
23089       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
23090       __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;}
23091       __Pyx_GOTREF(__pyx_t_6);
23092       __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;}
23093       __Pyx_GOTREF(__pyx_t_7);
23094       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
23095       __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;}
23096       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
23097       if (__pyx_t_1) {
23098         __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;}
23099         __Pyx_GOTREF(__pyx_t_7);
23100         __pyx_t_3 = __pyx_t_7;
23101         __pyx_t_7 = 0;
23102       } else {
23103         __Pyx_INCREF(__pyx_t_5);
23104         __pyx_t_3 = __pyx_t_5;
23105       }
23106       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
23107       __pyx_t_4 = __pyx_v_start;
23108       __pyx_t_8 = __pyx_v_pos;
23109       if ((__pyx_t_4 > __pyx_t_8)) {
23110         __pyx_t_9 = __pyx_t_4;
23111       } else {
23112         __pyx_t_9 = __pyx_t_8;
23113       }
23114       __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;}
23115       __Pyx_GOTREF(__pyx_t_5);
23116       __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;}
23117       __Pyx_GOTREF(__pyx_t_7);
23118       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
23119       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
23120       __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;}
23121       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
23122       __pyx_v_o = __pyx_t_10;
23123
23124       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2534
23125  *             if op == BAM_CMATCH:
23126  *                 o = min( pos + l, end) - max( pos, start )
23127  *                 if o > 0: overlap += o             # <<<<<<<<<<<<<<
23128  * 
23129  *             if op == BAM_CMATCH or op == BAM_CDEL or op == BAM_CREF_SKIP:
23130  */
23131       __pyx_t_1 = (__pyx_v_o > 0);
23132       if (__pyx_t_1) {
23133         __pyx_v_overlap += __pyx_v_o;
23134         goto __pyx_L10;
23135       }
23136       __pyx_L10:;
23137       goto __pyx_L9;
23138     }
23139     __pyx_L9:;
23140
23141     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2536
23142  *                 if o > 0: overlap += o
23143  * 
23144  *             if op == BAM_CMATCH or op == BAM_CDEL or op == BAM_CREF_SKIP:             # <<<<<<<<<<<<<<
23145  *                 pos += l
23146  * 
23147  */
23148     switch (__pyx_v_op) {
23149       case 0:
23150       case 2:
23151       case 3:
23152
23153       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2537
23154  * 
23155  *             if op == BAM_CMATCH or op == BAM_CDEL or op == BAM_CREF_SKIP:
23156  *                 pos += l             # <<<<<<<<<<<<<<
23157  * 
23158  *         return overlap
23159  */
23160       __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;}
23161       __pyx_v_pos += __pyx_t_9;
23162       break;
23163     }
23164   }
23165
23166   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2539
23167  *                 pos += l
23168  * 
23169  *         return overlap             # <<<<<<<<<<<<<<
23170  * 
23171  *     def opt(self, tag):
23172  */
23173   __Pyx_XDECREF(__pyx_r);
23174   __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;}
23175   __Pyx_GOTREF(__pyx_t_7);
23176   __pyx_r = __pyx_t_7;
23177   __pyx_t_7 = 0;
23178   goto __pyx_L0;
23179
23180   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
23181   goto __pyx_L0;
23182   __pyx_L1_error:;
23183   __Pyx_XDECREF(__pyx_t_3);
23184   __Pyx_XDECREF(__pyx_t_5);
23185   __Pyx_XDECREF(__pyx_t_6);
23186   __Pyx_XDECREF(__pyx_t_7);
23187   __Pyx_AddTraceback("csamtools.AlignedRead.overlap");
23188   __pyx_r = NULL;
23189   __pyx_L0:;
23190   __Pyx_DECREF(__pyx_v_l);
23191   __Pyx_XGIVEREF(__pyx_r);
23192   __Pyx_TraceReturn(__pyx_r);
23193   __Pyx_RefNannyFinishContext();
23194   return __pyx_r;
23195 }
23196
23197 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2541
23198  *         return overlap
23199  * 
23200  *     def opt(self, tag):             # <<<<<<<<<<<<<<
23201  *         """retrieves optional data given a two-letter *tag*"""
23202  *         #see bam_aux.c: bam_aux_get() and bam_aux2i() etc
23203  */
23204
23205 static PyObject *__pyx_pf_9csamtools_11AlignedRead_opt(PyObject *__pyx_v_self, PyObject *__pyx_v_tag); /*proto*/
23206 static char __pyx_doc_9csamtools_11AlignedRead_opt[] = "AlignedRead.opt(self, tag)\nretrieves optional data given a two-letter *tag*";
23207 static PyObject *__pyx_pf_9csamtools_11AlignedRead_opt(PyObject *__pyx_v_self, PyObject *__pyx_v_tag) {
23208   uint8_t *__pyx_v_v;
23209   PyObject *__pyx_v_type;
23210   PyObject *__pyx_r = NULL;
23211   char *__pyx_t_1;
23212   int __pyx_t_2;
23213   PyObject *__pyx_t_3 = NULL;
23214   PyObject *__pyx_t_4 = NULL;
23215   int __pyx_t_5;
23216   int __pyx_t_6;
23217   int __pyx_t_7;
23218   int __pyx_t_8;
23219   __Pyx_TraceDeclarations
23220   __Pyx_RefNannySetupContext("opt");
23221   __Pyx_TraceCall("opt", __pyx_f[0], 2541);
23222   __pyx_v_type = Py_None; __Pyx_INCREF(Py_None);
23223
23224   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2545
23225  *         #see bam_aux.c: bam_aux_get() and bam_aux2i() etc
23226  *         cdef uint8_t * v
23227  *         v = bam_aux_get(self._delegate, tag)             # <<<<<<<<<<<<<<
23228  *         if v == NULL: raise KeyError( "tag '%s' not present" % tag )
23229  *         type = chr(v[0])
23230  */
23231   __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;}
23232   __pyx_v_v = bam_aux_get(((struct __pyx_obj_9csamtools_AlignedRead *)__pyx_v_self)->_delegate, __pyx_t_1);
23233
23234   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2546
23235  *         cdef uint8_t * v
23236  *         v = bam_aux_get(self._delegate, tag)
23237  *         if v == NULL: raise KeyError( "tag '%s' not present" % tag )             # <<<<<<<<<<<<<<
23238  *         type = chr(v[0])
23239  *         if type == 'c' or type == 'C' or type == 's' or type == 'S':
23240  */
23241   __pyx_t_2 = (__pyx_v_v == NULL);
23242   if (__pyx_t_2) {
23243     __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;}
23244     __Pyx_GOTREF(((PyObject *)__pyx_t_3));
23245     __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;}
23246     __Pyx_GOTREF(__pyx_t_4);
23247     PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3));
23248     __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
23249     __pyx_t_3 = 0;
23250     __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;}
23251     __Pyx_GOTREF(__pyx_t_3);
23252     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
23253     __Pyx_Raise(__pyx_t_3, 0, 0);
23254     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
23255     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
23256     goto __pyx_L5;
23257   }
23258   __pyx_L5:;
23259
23260   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2547
23261  *         v = bam_aux_get(self._delegate, tag)
23262  *         if v == NULL: raise KeyError( "tag '%s' not present" % tag )
23263  *         type = chr(v[0])             # <<<<<<<<<<<<<<
23264  *         if type == 'c' or type == 'C' or type == 's' or type == 'S':
23265  *             return <int>bam_aux2i(v)
23266  */
23267   __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;}
23268   __Pyx_GOTREF(__pyx_t_3);
23269   __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;}
23270   __Pyx_GOTREF(__pyx_t_4);
23271   PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
23272   __Pyx_GIVEREF(__pyx_t_3);
23273   __pyx_t_3 = 0;
23274   __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;}
23275   __Pyx_GOTREF(__pyx_t_3);
23276   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
23277   __Pyx_DECREF(__pyx_v_type);
23278   __pyx_v_type = __pyx_t_3;
23279   __pyx_t_3 = 0;
23280
23281   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2548
23282  *         if v == NULL: raise KeyError( "tag '%s' not present" % tag )
23283  *         type = chr(v[0])
23284  *         if type == 'c' or type == 'C' or type == 's' or type == 'S':             # <<<<<<<<<<<<<<
23285  *             return <int>bam_aux2i(v)
23286  *         elif type == 'i' or type == 'I':
23287  */
23288   __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;}
23289   __Pyx_GOTREF(__pyx_t_3);
23290   __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;}
23291   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
23292   if (!__pyx_t_2) {
23293     __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;}
23294     __Pyx_GOTREF(__pyx_t_3);
23295     __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;}
23296     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
23297     if (!__pyx_t_5) {
23298       __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;}
23299       __Pyx_GOTREF(__pyx_t_3);
23300       __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;}
23301       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
23302       if (!__pyx_t_6) {
23303         __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;}
23304         __Pyx_GOTREF(__pyx_t_3);
23305         __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;}
23306         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
23307         __pyx_t_8 = __pyx_t_7;
23308       } else {
23309         __pyx_t_8 = __pyx_t_6;
23310       }
23311       __pyx_t_6 = __pyx_t_8;
23312     } else {
23313       __pyx_t_6 = __pyx_t_5;
23314     }
23315     __pyx_t_5 = __pyx_t_6;
23316   } else {
23317     __pyx_t_5 = __pyx_t_2;
23318   }
23319   if (__pyx_t_5) {
23320
23321     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2549
23322  *         type = chr(v[0])
23323  *         if type == 'c' or type == 'C' or type == 's' or type == 'S':
23324  *             return <int>bam_aux2i(v)             # <<<<<<<<<<<<<<
23325  *         elif type == 'i' or type == 'I':
23326  *             return <int32_t>bam_aux2i(v)
23327  */
23328     __Pyx_XDECREF(__pyx_r);
23329     __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;}
23330     __Pyx_GOTREF(__pyx_t_3);
23331     __pyx_r = __pyx_t_3;
23332     __pyx_t_3 = 0;
23333     goto __pyx_L0;
23334     goto __pyx_L6;
23335   }
23336
23337   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2550
23338  *         if type == 'c' or type == 'C' or type == 's' or type == 'S':
23339  *             return <int>bam_aux2i(v)
23340  *         elif type == 'i' or type == 'I':             # <<<<<<<<<<<<<<
23341  *             return <int32_t>bam_aux2i(v)
23342  *         elif type == 'f' or type == 'F':
23343  */
23344   __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;}
23345   __Pyx_GOTREF(__pyx_t_3);
23346   __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;}
23347   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
23348   if (!__pyx_t_5) {
23349     __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;}
23350     __Pyx_GOTREF(__pyx_t_3);
23351     __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;}
23352     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
23353     __pyx_t_6 = __pyx_t_2;
23354   } else {
23355     __pyx_t_6 = __pyx_t_5;
23356   }
23357   if (__pyx_t_6) {
23358
23359     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2551
23360  *             return <int>bam_aux2i(v)
23361  *         elif type == 'i' or type == 'I':
23362  *             return <int32_t>bam_aux2i(v)             # <<<<<<<<<<<<<<
23363  *         elif type == 'f' or type == 'F':
23364  *             return <float>bam_aux2f(v)
23365  */
23366     __Pyx_XDECREF(__pyx_r);
23367     __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;}
23368     __Pyx_GOTREF(__pyx_t_3);
23369     __pyx_r = __pyx_t_3;
23370     __pyx_t_3 = 0;
23371     goto __pyx_L0;
23372     goto __pyx_L6;
23373   }
23374
23375   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2552
23376  *         elif type == 'i' or type == 'I':
23377  *             return <int32_t>bam_aux2i(v)
23378  *         elif type == 'f' or type == 'F':             # <<<<<<<<<<<<<<
23379  *             return <float>bam_aux2f(v)
23380  *         elif type == 'd' or type == 'D':
23381  */
23382   __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;}
23383   __Pyx_GOTREF(__pyx_t_3);
23384   __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;}
23385   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
23386   if (!__pyx_t_6) {
23387     __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;}
23388     __Pyx_GOTREF(__pyx_t_3);
23389     __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;}
23390     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
23391     __pyx_t_2 = __pyx_t_5;
23392   } else {
23393     __pyx_t_2 = __pyx_t_6;
23394   }
23395   if (__pyx_t_2) {
23396
23397     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2553
23398  *             return <int32_t>bam_aux2i(v)
23399  *         elif type == 'f' or type == 'F':
23400  *             return <float>bam_aux2f(v)             # <<<<<<<<<<<<<<
23401  *         elif type == 'd' or type == 'D':
23402  *             return <double>bam_aux2d(v)
23403  */
23404     __Pyx_XDECREF(__pyx_r);
23405     __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;}
23406     __Pyx_GOTREF(__pyx_t_3);
23407     __pyx_r = __pyx_t_3;
23408     __pyx_t_3 = 0;
23409     goto __pyx_L0;
23410     goto __pyx_L6;
23411   }
23412
23413   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2554
23414  *         elif type == 'f' or type == 'F':
23415  *             return <float>bam_aux2f(v)
23416  *         elif type == 'd' or type == 'D':             # <<<<<<<<<<<<<<
23417  *             return <double>bam_aux2d(v)
23418  *         elif type == 'A':
23419  */
23420   __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;}
23421   __Pyx_GOTREF(__pyx_t_3);
23422   __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;}
23423   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
23424   if (!__pyx_t_2) {
23425     __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;}
23426     __Pyx_GOTREF(__pyx_t_3);
23427     __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;}
23428     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
23429     __pyx_t_5 = __pyx_t_6;
23430   } else {
23431     __pyx_t_5 = __pyx_t_2;
23432   }
23433   if (__pyx_t_5) {
23434
23435     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2555
23436  *             return <float>bam_aux2f(v)
23437  *         elif type == 'd' or type == 'D':
23438  *             return <double>bam_aux2d(v)             # <<<<<<<<<<<<<<
23439  *         elif type == 'A':
23440  *             # there might a more efficient way
23441  */
23442     __Pyx_XDECREF(__pyx_r);
23443     __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;}
23444     __Pyx_GOTREF(__pyx_t_3);
23445     __pyx_r = __pyx_t_3;
23446     __pyx_t_3 = 0;
23447     goto __pyx_L0;
23448     goto __pyx_L6;
23449   }
23450
23451   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2556
23452  *         elif type == 'd' or type == 'D':
23453  *             return <double>bam_aux2d(v)
23454  *         elif type == 'A':             # <<<<<<<<<<<<<<
23455  *             # there might a more efficient way
23456  *             # to convert a char into a string
23457  */
23458   __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;}
23459   __Pyx_GOTREF(__pyx_t_3);
23460   __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;}
23461   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
23462   if (__pyx_t_5) {
23463
23464     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2559
23465  *             # there might a more efficient way
23466  *             # to convert a char into a string
23467  *             return '%c' % <char>bam_aux2A(v)             # <<<<<<<<<<<<<<
23468  *         elif type == 'Z':
23469  *             return <char*>bam_aux2Z(v)
23470  */
23471     __Pyx_XDECREF(__pyx_r);
23472     __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;}
23473     __Pyx_GOTREF(__pyx_t_3);
23474     __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;}
23475     __Pyx_GOTREF(((PyObject *)__pyx_t_4));
23476     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
23477     __pyx_r = ((PyObject *)__pyx_t_4);
23478     __pyx_t_4 = 0;
23479     goto __pyx_L0;
23480     goto __pyx_L6;
23481   }
23482
23483   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2560
23484  *             # to convert a char into a string
23485  *             return '%c' % <char>bam_aux2A(v)
23486  *         elif type == 'Z':             # <<<<<<<<<<<<<<
23487  *             return <char*>bam_aux2Z(v)
23488  * 
23489  */
23490   __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;}
23491   __Pyx_GOTREF(__pyx_t_4);
23492   __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;}
23493   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
23494   if (__pyx_t_5) {
23495
23496     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2561
23497  *             return '%c' % <char>bam_aux2A(v)
23498  *         elif type == 'Z':
23499  *             return <char*>bam_aux2Z(v)             # <<<<<<<<<<<<<<
23500  * 
23501  *     def fancy_str (self):
23502  */
23503     __Pyx_XDECREF(__pyx_r);
23504     __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;}
23505     __Pyx_GOTREF(((PyObject *)__pyx_t_4));
23506     __pyx_r = ((PyObject *)__pyx_t_4);
23507     __pyx_t_4 = 0;
23508     goto __pyx_L0;
23509     goto __pyx_L6;
23510   }
23511   __pyx_L6:;
23512
23513   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
23514   goto __pyx_L0;
23515   __pyx_L1_error:;
23516   __Pyx_XDECREF(__pyx_t_3);
23517   __Pyx_XDECREF(__pyx_t_4);
23518   __Pyx_AddTraceback("csamtools.AlignedRead.opt");
23519   __pyx_r = NULL;
23520   __pyx_L0:;
23521   __Pyx_DECREF(__pyx_v_type);
23522   __Pyx_XGIVEREF(__pyx_r);
23523   __Pyx_TraceReturn(__pyx_r);
23524   __Pyx_RefNannyFinishContext();
23525   return __pyx_r;
23526 }
23527
23528 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2563
23529  *             return <char*>bam_aux2Z(v)
23530  * 
23531  *     def fancy_str (self):             # <<<<<<<<<<<<<<
23532  *         """returns list of fieldnames/values in pretty format for debugging
23533  *         """
23534  */
23535
23536 static PyObject *__pyx_pf_9csamtools_11AlignedRead_fancy_str(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
23537 static char __pyx_doc_9csamtools_11AlignedRead_fancy_str[] = "AlignedRead.fancy_str(self)\nreturns list of fieldnames/values in pretty format for debugging\n        ";
23538 static PyObject *__pyx_pf_9csamtools_11AlignedRead_fancy_str(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
23539   PyObject *__pyx_v_ret_string;
23540   PyObject *__pyx_v_field_names;
23541   PyObject *__pyx_v_fields_names_in_order;
23542   PyObject *__pyx_v_f;
23543   PyObject *__pyx_r = NULL;
23544   PyObject *__pyx_t_1 = NULL;
23545   Py_ssize_t __pyx_t_2;
23546   PyObject *__pyx_t_3 = NULL;
23547   int __pyx_t_4;
23548   int __pyx_t_5;
23549   PyObject *__pyx_t_6 = NULL;
23550   PyObject *__pyx_t_7 = NULL;
23551   PyObject *__pyx_t_8 = NULL;
23552   PyObject *__pyx_t_9 = NULL;
23553   int __pyx_t_10;
23554   __Pyx_TraceDeclarations
23555   __Pyx_RefNannySetupContext("fancy_str");
23556   __Pyx_TraceCall("fancy_str", __pyx_f[0], 2563);
23557   __pyx_v_ret_string = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
23558   __pyx_v_field_names = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
23559   __pyx_v_fields_names_in_order = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
23560   __pyx_v_f = Py_None; __Pyx_INCREF(Py_None);
23561
23562   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2566
23563  *         """returns list of fieldnames/values in pretty format for debugging
23564  *         """
23565  *         ret_string = []             # <<<<<<<<<<<<<<
23566  *         field_names = {
23567  *            "tid":           "Contig index",
23568  */
23569   __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;}
23570   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
23571   __Pyx_DECREF(((PyObject *)__pyx_v_ret_string));
23572   __pyx_v_ret_string = __pyx_t_1;
23573   __pyx_t_1 = 0;
23574
23575   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2567
23576  *         """
23577  *         ret_string = []
23578  *         field_names = {             # <<<<<<<<<<<<<<
23579  *            "tid":           "Contig index",
23580  *            "pos":           "Mapped position on contig",
23581  */
23582   __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;}
23583   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
23584   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;}
23585   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;}
23586   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;}
23587   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;}
23588   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;}
23589   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;}
23590   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;}
23591   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;}
23592   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;}
23593   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;}
23594   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;}
23595   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;}
23596   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;}
23597   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;}
23598   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;}
23599   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;}
23600   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;}
23601   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;}
23602   __Pyx_DECREF(((PyObject *)__pyx_v_field_names));
23603   __pyx_v_field_names = __pyx_t_1;
23604   __pyx_t_1 = 0;
23605
23606   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2587
23607  *            "data_len":      "Current data length",
23608  *            }
23609  *         fields_names_in_order = ["tid", "pos", "mtid", "mpos", "isize", "flag",             # <<<<<<<<<<<<<<
23610  *                                  "n_cigar", "cigar", "qual", "bin", "l_qname", "qname",
23611  *                                  "l_qseq", "qseq", "bqual", "l_aux", "m_data", "data_len"]
23612  */
23613   __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;}
23614   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
23615   __Pyx_INCREF(((PyObject *)__pyx_n_s__tid));
23616   PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__tid));
23617   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__tid));
23618   __Pyx_INCREF(((PyObject *)__pyx_n_s__pos));
23619   PyList_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__pos));
23620   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__pos));
23621   __Pyx_INCREF(((PyObject *)__pyx_n_s__mtid));
23622   PyList_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_n_s__mtid));
23623   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__mtid));
23624   __Pyx_INCREF(((PyObject *)__pyx_n_s__mpos));
23625   PyList_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_n_s__mpos));
23626   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__mpos));
23627   __Pyx_INCREF(((PyObject *)__pyx_n_s__isize));
23628   PyList_SET_ITEM(__pyx_t_1, 4, ((PyObject *)__pyx_n_s__isize));
23629   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__isize));
23630   __Pyx_INCREF(((PyObject *)__pyx_n_s__flag));
23631   PyList_SET_ITEM(__pyx_t_1, 5, ((PyObject *)__pyx_n_s__flag));
23632   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__flag));
23633   __Pyx_INCREF(((PyObject *)__pyx_n_s__n_cigar));
23634   PyList_SET_ITEM(__pyx_t_1, 6, ((PyObject *)__pyx_n_s__n_cigar));
23635   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__n_cigar));
23636   __Pyx_INCREF(((PyObject *)__pyx_n_s__cigar));
23637   PyList_SET_ITEM(__pyx_t_1, 7, ((PyObject *)__pyx_n_s__cigar));
23638   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__cigar));
23639   __Pyx_INCREF(((PyObject *)__pyx_n_s__qual));
23640   PyList_SET_ITEM(__pyx_t_1, 8, ((PyObject *)__pyx_n_s__qual));
23641   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__qual));
23642   __Pyx_INCREF(((PyObject *)__pyx_n_s__bin));
23643   PyList_SET_ITEM(__pyx_t_1, 9, ((PyObject *)__pyx_n_s__bin));
23644   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__bin));
23645   __Pyx_INCREF(((PyObject *)__pyx_n_s__l_qname));
23646   PyList_SET_ITEM(__pyx_t_1, 10, ((PyObject *)__pyx_n_s__l_qname));
23647   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__l_qname));
23648   __Pyx_INCREF(((PyObject *)__pyx_n_s__qname));
23649   PyList_SET_ITEM(__pyx_t_1, 11, ((PyObject *)__pyx_n_s__qname));
23650   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__qname));
23651   __Pyx_INCREF(((PyObject *)__pyx_n_s__l_qseq));
23652   PyList_SET_ITEM(__pyx_t_1, 12, ((PyObject *)__pyx_n_s__l_qseq));
23653   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__l_qseq));
23654   __Pyx_INCREF(((PyObject *)__pyx_n_s__qseq));
23655   PyList_SET_ITEM(__pyx_t_1, 13, ((PyObject *)__pyx_n_s__qseq));
23656   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__qseq));
23657   __Pyx_INCREF(((PyObject *)__pyx_n_s__bqual));
23658   PyList_SET_ITEM(__pyx_t_1, 14, ((PyObject *)__pyx_n_s__bqual));
23659   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__bqual));
23660   __Pyx_INCREF(((PyObject *)__pyx_n_s__l_aux));
23661   PyList_SET_ITEM(__pyx_t_1, 15, ((PyObject *)__pyx_n_s__l_aux));
23662   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__l_aux));
23663   __Pyx_INCREF(((PyObject *)__pyx_n_s__m_data));
23664   PyList_SET_ITEM(__pyx_t_1, 16, ((PyObject *)__pyx_n_s__m_data));
23665   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__m_data));
23666   __Pyx_INCREF(((PyObject *)__pyx_n_s__data_len));
23667   PyList_SET_ITEM(__pyx_t_1, 17, ((PyObject *)__pyx_n_s__data_len));
23668   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__data_len));
23669   __Pyx_DECREF(((PyObject *)__pyx_v_fields_names_in_order));
23670   __pyx_v_fields_names_in_order = __pyx_t_1;
23671   __pyx_t_1 = 0;
23672
23673   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2591
23674  *                                  "l_qseq", "qseq", "bqual", "l_aux", "m_data", "data_len"]
23675  * 
23676  *         for f in fields_names_in_order:             # <<<<<<<<<<<<<<
23677  *             if not f in self.__dict__:
23678  *                 continue
23679  */
23680   if (likely(((PyObject *)__pyx_v_fields_names_in_order) != Py_None)) {
23681     __pyx_t_2 = 0; __pyx_t_1 = ((PyObject *)__pyx_v_fields_names_in_order); __Pyx_INCREF(__pyx_t_1);
23682   } else {
23683     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2591; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
23684   }
23685   for (;;) {
23686     if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
23687     __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++;
23688     __Pyx_DECREF(__pyx_v_f);
23689     __pyx_v_f = __pyx_t_3;
23690     __pyx_t_3 = 0;
23691
23692     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2592
23693  * 
23694  *         for f in fields_names_in_order:
23695  *             if not f in self.__dict__:             # <<<<<<<<<<<<<<
23696  *                 continue
23697  *             ret_string.append("%-30s %-10s= %s" % (field_names[f], "(" + f + ")", self.__getattribute__(f)))
23698  */
23699     __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;}
23700     __Pyx_GOTREF(__pyx_t_3);
23701     __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;}
23702     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
23703     __pyx_t_5 = (!__pyx_t_4);
23704     if (__pyx_t_5) {
23705
23706       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2593
23707  *         for f in fields_names_in_order:
23708  *             if not f in self.__dict__:
23709  *                 continue             # <<<<<<<<<<<<<<
23710  *             ret_string.append("%-30s %-10s= %s" % (field_names[f], "(" + f + ")", self.__getattribute__(f)))
23711  * 
23712  */
23713       goto __pyx_L5_continue;
23714       goto __pyx_L7;
23715     }
23716     __pyx_L7:;
23717
23718     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2594
23719  *             if not f in self.__dict__:
23720  *                 continue
23721  *             ret_string.append("%-30s %-10s= %s" % (field_names[f], "(" + f + ")", self.__getattribute__(f)))             # <<<<<<<<<<<<<<
23722  * 
23723  *         for f in self.__dict__:
23724  */
23725     if (unlikely(__pyx_v_ret_string == Py_None)) {
23726       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;} 
23727     }
23728     __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;}
23729     __Pyx_GOTREF(__pyx_t_3);
23730     __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;}
23731     __Pyx_GOTREF(__pyx_t_6);
23732     __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;}
23733     __Pyx_GOTREF(__pyx_t_7);
23734     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
23735     __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;}
23736     __Pyx_GOTREF(__pyx_t_6);
23737     __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;}
23738     __Pyx_GOTREF(__pyx_t_8);
23739     __Pyx_INCREF(__pyx_v_f);
23740     PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_f);
23741     __Pyx_GIVEREF(__pyx_v_f);
23742     __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;}
23743     __Pyx_GOTREF(__pyx_t_9);
23744     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
23745     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
23746     __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;}
23747     __Pyx_GOTREF(__pyx_t_8);
23748     PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3);
23749     __Pyx_GIVEREF(__pyx_t_3);
23750     PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_7);
23751     __Pyx_GIVEREF(__pyx_t_7);
23752     PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_9);
23753     __Pyx_GIVEREF(__pyx_t_9);
23754     __pyx_t_3 = 0;
23755     __pyx_t_7 = 0;
23756     __pyx_t_9 = 0;
23757     __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;}
23758     __Pyx_GOTREF(((PyObject *)__pyx_t_9));
23759     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
23760     __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;}
23761     __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
23762     __pyx_L5_continue:;
23763   }
23764   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
23765
23766   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2596
23767  *             ret_string.append("%-30s %-10s= %s" % (field_names[f], "(" + f + ")", self.__getattribute__(f)))
23768  * 
23769  *         for f in self.__dict__:             # <<<<<<<<<<<<<<
23770  *             if not f in field_names:
23771  *                 ret_string.append("%-30s %-10s= %s" % (f, "", self.__getattribute__(f)))
23772  */
23773   __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;}
23774   __Pyx_GOTREF(__pyx_t_1);
23775   if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
23776     __pyx_t_2 = 0; __pyx_t_9 = __pyx_t_1; __Pyx_INCREF(__pyx_t_9);
23777   } else {
23778     __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;}
23779     __Pyx_GOTREF(__pyx_t_9);
23780   }
23781   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
23782   for (;;) {
23783     if (likely(PyList_CheckExact(__pyx_t_9))) {
23784       if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_9)) break;
23785       __pyx_t_1 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++;
23786     } else if (likely(PyTuple_CheckExact(__pyx_t_9))) {
23787       if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_9)) break;
23788       __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++;
23789     } else {
23790       __pyx_t_1 = PyIter_Next(__pyx_t_9);
23791       if (!__pyx_t_1) {
23792         if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
23793         break;
23794       }
23795       __Pyx_GOTREF(__pyx_t_1);
23796     }
23797     __Pyx_DECREF(__pyx_v_f);
23798     __pyx_v_f = __pyx_t_1;
23799     __pyx_t_1 = 0;
23800
23801     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2597
23802  * 
23803  *         for f in self.__dict__:
23804  *             if not f in field_names:             # <<<<<<<<<<<<<<
23805  *                 ret_string.append("%-30s %-10s= %s" % (f, "", self.__getattribute__(f)))
23806  *         return ret_string
23807  */
23808     if (unlikely(((PyObject *)__pyx_v_field_names) == Py_None)) {
23809       __Pyx_RaiseNoneNotIterableError(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
23810     } else {
23811       __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;}
23812     }
23813     __pyx_t_4 = (!__pyx_t_5);
23814     if (__pyx_t_4) {
23815
23816       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2598
23817  *         for f in self.__dict__:
23818  *             if not f in field_names:
23819  *                 ret_string.append("%-30s %-10s= %s" % (f, "", self.__getattribute__(f)))             # <<<<<<<<<<<<<<
23820  *         return ret_string
23821  * 
23822  */
23823       if (unlikely(__pyx_v_ret_string == Py_None)) {
23824         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;} 
23825       }
23826       __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;}
23827       __Pyx_GOTREF(__pyx_t_1);
23828       __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;}
23829       __Pyx_GOTREF(__pyx_t_8);
23830       __Pyx_INCREF(__pyx_v_f);
23831       PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_f);
23832       __Pyx_GIVEREF(__pyx_v_f);
23833       __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;}
23834       __Pyx_GOTREF(__pyx_t_7);
23835       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
23836       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
23837       __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;}
23838       __Pyx_GOTREF(__pyx_t_8);
23839       __Pyx_INCREF(__pyx_v_f);
23840       PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_f);
23841       __Pyx_GIVEREF(__pyx_v_f);
23842       __Pyx_INCREF(((PyObject *)__pyx_kp_s_8));
23843       PyTuple_SET_ITEM(__pyx_t_8, 1, ((PyObject *)__pyx_kp_s_8));
23844       __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_8));
23845       PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_7);
23846       __Pyx_GIVEREF(__pyx_t_7);
23847       __pyx_t_7 = 0;
23848       __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;}
23849       __Pyx_GOTREF(((PyObject *)__pyx_t_7));
23850       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
23851       __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;}
23852       __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
23853       goto __pyx_L10;
23854     }
23855     __pyx_L10:;
23856   }
23857   __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
23858
23859   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2599
23860  *             if not f in field_names:
23861  *                 ret_string.append("%-30s %-10s= %s" % (f, "", self.__getattribute__(f)))
23862  *         return ret_string             # <<<<<<<<<<<<<<
23863  * 
23864  * cdef class PileupProxy:
23865  */
23866   __Pyx_XDECREF(__pyx_r);
23867   __Pyx_INCREF(((PyObject *)__pyx_v_ret_string));
23868   __pyx_r = ((PyObject *)__pyx_v_ret_string);
23869   goto __pyx_L0;
23870
23871   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
23872   goto __pyx_L0;
23873   __pyx_L1_error:;
23874   __Pyx_XDECREF(__pyx_t_1);
23875   __Pyx_XDECREF(__pyx_t_3);
23876   __Pyx_XDECREF(__pyx_t_6);
23877   __Pyx_XDECREF(__pyx_t_7);
23878   __Pyx_XDECREF(__pyx_t_8);
23879   __Pyx_XDECREF(__pyx_t_9);
23880   __Pyx_AddTraceback("csamtools.AlignedRead.fancy_str");
23881   __pyx_r = NULL;
23882   __pyx_L0:;
23883   __Pyx_DECREF(__pyx_v_ret_string);
23884   __Pyx_DECREF(__pyx_v_field_names);
23885   __Pyx_DECREF(__pyx_v_fields_names_in_order);
23886   __Pyx_DECREF(__pyx_v_f);
23887   __Pyx_XGIVEREF(__pyx_r);
23888   __Pyx_TraceReturn(__pyx_r);
23889   __Pyx_RefNannyFinishContext();
23890   return __pyx_r;
23891 }
23892
23893 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2623
23894  *     cdef int n_pu
23895  * 
23896  *     def __init__(self):             # <<<<<<<<<<<<<<
23897  *         raise TypeError("This class cannot be instantiated from Python")
23898  * 
23899  */
23900
23901 static int __pyx_pf_9csamtools_11PileupProxy___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
23902 static int __pyx_pf_9csamtools_11PileupProxy___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
23903   int __pyx_r;
23904   PyObject *__pyx_t_1 = NULL;
23905   PyObject *__pyx_t_2 = NULL;
23906   __Pyx_TraceDeclarations
23907   __Pyx_RefNannySetupContext("__init__");
23908   __Pyx_TraceCall("__init__", __pyx_f[0], 2623);
23909   if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
23910     __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
23911   if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
23912
23913   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2624
23914  * 
23915  *     def __init__(self):
23916  *         raise TypeError("This class cannot be instantiated from Python")             # <<<<<<<<<<<<<<
23917  * 
23918  *     def __str__(self):
23919  */
23920   __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;}
23921   __Pyx_GOTREF(__pyx_t_1);
23922   __Pyx_INCREF(((PyObject *)__pyx_kp_s_97));
23923   PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_97));
23924   __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_97));
23925   __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;}
23926   __Pyx_GOTREF(__pyx_t_2);
23927   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
23928   __Pyx_Raise(__pyx_t_2, 0, 0);
23929   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
23930   {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
23931
23932   __pyx_r = 0;
23933   goto __pyx_L0;
23934   __pyx_L1_error:;
23935   __Pyx_XDECREF(__pyx_t_1);
23936   __Pyx_XDECREF(__pyx_t_2);
23937   __Pyx_AddTraceback("csamtools.PileupProxy.__init__");
23938   __pyx_r = -1;
23939   __pyx_L0:;
23940   __Pyx_TraceReturn(Py_None);
23941   __Pyx_RefNannyFinishContext();
23942   return __pyx_r;
23943 }
23944
23945 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2626
23946  *         raise TypeError("This class cannot be instantiated from Python")
23947  * 
23948  *     def __str__(self):             # <<<<<<<<<<<<<<
23949  *         return "\t".join( map(str, (self.tid, self.pos, self.n))) +\
23950  *             "\n" +\
23951  */
23952
23953 static PyObject *__pyx_pf_9csamtools_11PileupProxy___str__(PyObject *__pyx_v_self); /*proto*/
23954 static PyObject *__pyx_pf_9csamtools_11PileupProxy___str__(PyObject *__pyx_v_self) {
23955   PyObject *__pyx_r = NULL;
23956   PyObject *__pyx_t_1 = NULL;
23957   PyObject *__pyx_t_2 = NULL;
23958   PyObject *__pyx_t_3 = NULL;
23959   PyObject *__pyx_t_4 = NULL;
23960   PyObject *__pyx_t_5 = NULL;
23961   __Pyx_TraceDeclarations
23962   __Pyx_RefNannySetupContext("__str__");
23963   __Pyx_TraceCall("__str__", __pyx_f[0], 2626);
23964
23965   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2627
23966  * 
23967  *     def __str__(self):
23968  *         return "\t".join( map(str, (self.tid, self.pos, self.n))) +\             # <<<<<<<<<<<<<<
23969  *             "\n" +\
23970  *             "\n".join( map(str, self.pileups) )
23971  */
23972   __Pyx_XDECREF(__pyx_r);
23973
23974   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2628
23975  *     def __str__(self):
23976  *         return "\t".join( map(str, (self.tid, self.pos, self.n))) +\
23977  *             "\n" +\             # <<<<<<<<<<<<<<
23978  *             "\n".join( map(str, self.pileups) )
23979  * 
23980  */
23981   __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;}
23982   __Pyx_GOTREF(__pyx_t_1);
23983
23984   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2627
23985  * 
23986  *     def __str__(self):
23987  *         return "\t".join( map(str, (self.tid, self.pos, self.n))) +\             # <<<<<<<<<<<<<<
23988  *             "\n" +\
23989  *             "\n".join( map(str, self.pileups) )
23990  */
23991   __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;}
23992   __Pyx_GOTREF(__pyx_t_2);
23993   __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;}
23994   __Pyx_GOTREF(__pyx_t_3);
23995   __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;}
23996   __Pyx_GOTREF(__pyx_t_4);
23997   __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;}
23998   __Pyx_GOTREF(__pyx_t_5);
23999   PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
24000   __Pyx_GIVEREF(__pyx_t_2);
24001   PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
24002   __Pyx_GIVEREF(__pyx_t_3);
24003   PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_4);
24004   __Pyx_GIVEREF(__pyx_t_4);
24005   __pyx_t_2 = 0;
24006   __pyx_t_3 = 0;
24007   __pyx_t_4 = 0;
24008   __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;}
24009   __Pyx_GOTREF(__pyx_t_4);
24010   __Pyx_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
24011   PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)((PyObject*)&PyString_Type)));
24012   __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
24013   PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_5);
24014   __Pyx_GIVEREF(__pyx_t_5);
24015   __pyx_t_5 = 0;
24016   __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;}
24017   __Pyx_GOTREF(__pyx_t_5);
24018   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
24019   __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;}
24020   __Pyx_GOTREF(__pyx_t_4);
24021   PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
24022   __Pyx_GIVEREF(__pyx_t_5);
24023   __pyx_t_5 = 0;
24024   __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;}
24025   __Pyx_GOTREF(__pyx_t_5);
24026   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
24027   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
24028   __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;}
24029   __Pyx_GOTREF(__pyx_t_4);
24030   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
24031
24032   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2629
24033  *         return "\t".join( map(str, (self.tid, self.pos, self.n))) +\
24034  *             "\n" +\
24035  *             "\n".join( map(str, self.pileups) )             # <<<<<<<<<<<<<<
24036  * 
24037  *     property tid:
24038  */
24039   __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;}
24040   __Pyx_GOTREF(__pyx_t_5);
24041   __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;}
24042   __Pyx_GOTREF(__pyx_t_1);
24043   __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;}
24044   __Pyx_GOTREF(__pyx_t_3);
24045   __Pyx_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
24046   PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)((PyObject*)&PyString_Type)));
24047   __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
24048   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
24049   __Pyx_GIVEREF(__pyx_t_1);
24050   __pyx_t_1 = 0;
24051   __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;}
24052   __Pyx_GOTREF(__pyx_t_1);
24053   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
24054   __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;}
24055   __Pyx_GOTREF(__pyx_t_3);
24056   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
24057   __Pyx_GIVEREF(__pyx_t_1);
24058   __pyx_t_1 = 0;
24059   __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;}
24060   __Pyx_GOTREF(__pyx_t_1);
24061   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
24062   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
24063   __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;}
24064   __Pyx_GOTREF(__pyx_t_3);
24065   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
24066   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
24067   __pyx_r = __pyx_t_3;
24068   __pyx_t_3 = 0;
24069   goto __pyx_L0;
24070
24071   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
24072   goto __pyx_L0;
24073   __pyx_L1_error:;
24074   __Pyx_XDECREF(__pyx_t_1);
24075   __Pyx_XDECREF(__pyx_t_2);
24076   __Pyx_XDECREF(__pyx_t_3);
24077   __Pyx_XDECREF(__pyx_t_4);
24078   __Pyx_XDECREF(__pyx_t_5);
24079   __Pyx_AddTraceback("csamtools.PileupProxy.__str__");
24080   __pyx_r = NULL;
24081   __pyx_L0:;
24082   __Pyx_XGIVEREF(__pyx_r);
24083   __Pyx_TraceReturn(__pyx_r);
24084   __Pyx_RefNannyFinishContext();
24085   return __pyx_r;
24086 }
24087
24088 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2633
24089  *     property tid:
24090  *         '''the chromosome ID as is defined in the header'''
24091  *         def __get__(self): return self.tid             # <<<<<<<<<<<<<<
24092  * 
24093  *     property n:
24094  */
24095
24096 static PyObject *__pyx_pf_9csamtools_11PileupProxy_3tid___get__(PyObject *__pyx_v_self); /*proto*/
24097 static PyObject *__pyx_pf_9csamtools_11PileupProxy_3tid___get__(PyObject *__pyx_v_self) {
24098   PyObject *__pyx_r = NULL;
24099   PyObject *__pyx_t_1 = NULL;
24100   __Pyx_TraceDeclarations
24101   __Pyx_RefNannySetupContext("__get__");
24102   __Pyx_TraceCall("__get__", __pyx_f[0], 2633);
24103   __Pyx_XDECREF(__pyx_r);
24104   __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;}
24105   __Pyx_GOTREF(__pyx_t_1);
24106   __pyx_r = __pyx_t_1;
24107   __pyx_t_1 = 0;
24108   goto __pyx_L0;
24109
24110   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
24111   goto __pyx_L0;
24112   __pyx_L1_error:;
24113   __Pyx_XDECREF(__pyx_t_1);
24114   __Pyx_AddTraceback("csamtools.PileupProxy.tid.__get__");
24115   __pyx_r = NULL;
24116   __pyx_L0:;
24117   __Pyx_XGIVEREF(__pyx_r);
24118   __Pyx_TraceReturn(__pyx_r);
24119   __Pyx_RefNannyFinishContext();
24120   return __pyx_r;
24121 }
24122
24123 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2637
24124  *     property n:
24125  *         '''number of reads mapping to this column.'''
24126  *         def __get__(self): return self.n_pu             # <<<<<<<<<<<<<<
24127  *         def __set__(self, n): self.n_pu = n
24128  * 
24129  */
24130
24131 static PyObject *__pyx_pf_9csamtools_11PileupProxy_1n___get__(PyObject *__pyx_v_self); /*proto*/
24132 static PyObject *__pyx_pf_9csamtools_11PileupProxy_1n___get__(PyObject *__pyx_v_self) {
24133   PyObject *__pyx_r = NULL;
24134   PyObject *__pyx_t_1 = NULL;
24135   __Pyx_TraceDeclarations
24136   __Pyx_RefNannySetupContext("__get__");
24137   __Pyx_TraceCall("__get__", __pyx_f[0], 2637);
24138   __Pyx_XDECREF(__pyx_r);
24139   __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;}
24140   __Pyx_GOTREF(__pyx_t_1);
24141   __pyx_r = __pyx_t_1;
24142   __pyx_t_1 = 0;
24143   goto __pyx_L0;
24144
24145   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
24146   goto __pyx_L0;
24147   __pyx_L1_error:;
24148   __Pyx_XDECREF(__pyx_t_1);
24149   __Pyx_AddTraceback("csamtools.PileupProxy.n.__get__");
24150   __pyx_r = NULL;
24151   __pyx_L0:;
24152   __Pyx_XGIVEREF(__pyx_r);
24153   __Pyx_TraceReturn(__pyx_r);
24154   __Pyx_RefNannyFinishContext();
24155   return __pyx_r;
24156 }
24157
24158 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2638
24159  *         '''number of reads mapping to this column.'''
24160  *         def __get__(self): return self.n_pu
24161  *         def __set__(self, n): self.n_pu = n             # <<<<<<<<<<<<<<
24162  * 
24163  *     property pos:
24164  */
24165
24166 static int __pyx_pf_9csamtools_11PileupProxy_1n___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_n); /*proto*/
24167 static int __pyx_pf_9csamtools_11PileupProxy_1n___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_n) {
24168   int __pyx_r;
24169   int __pyx_t_1;
24170   __Pyx_TraceDeclarations
24171   __Pyx_RefNannySetupContext("__set__");
24172   __Pyx_TraceCall("__set__", __pyx_f[0], 2638);
24173   __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;}
24174   ((struct __pyx_obj_9csamtools_PileupProxy *)__pyx_v_self)->n_pu = __pyx_t_1;
24175
24176   __pyx_r = 0;
24177   goto __pyx_L0;
24178   __pyx_L1_error:;
24179   __Pyx_AddTraceback("csamtools.PileupProxy.n.__set__");
24180   __pyx_r = -1;
24181   __pyx_L0:;
24182   __Pyx_TraceReturn(Py_None);
24183   __Pyx_RefNannyFinishContext();
24184   return __pyx_r;
24185 }
24186
24187 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2641
24188  * 
24189  *     property pos:
24190  *         def __get__(self): return self.pos             # <<<<<<<<<<<<<<
24191  * 
24192  *     property pileups:
24193  */
24194
24195 static PyObject *__pyx_pf_9csamtools_11PileupProxy_3pos___get__(PyObject *__pyx_v_self); /*proto*/
24196 static PyObject *__pyx_pf_9csamtools_11PileupProxy_3pos___get__(PyObject *__pyx_v_self) {
24197   PyObject *__pyx_r = NULL;
24198   PyObject *__pyx_t_1 = NULL;
24199   __Pyx_TraceDeclarations
24200   __Pyx_RefNannySetupContext("__get__");
24201   __Pyx_TraceCall("__get__", __pyx_f[0], 2641);
24202   __Pyx_XDECREF(__pyx_r);
24203   __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;}
24204   __Pyx_GOTREF(__pyx_t_1);
24205   __pyx_r = __pyx_t_1;
24206   __pyx_t_1 = 0;
24207   goto __pyx_L0;
24208
24209   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
24210   goto __pyx_L0;
24211   __pyx_L1_error:;
24212   __Pyx_XDECREF(__pyx_t_1);
24213   __Pyx_AddTraceback("csamtools.PileupProxy.pos.__get__");
24214   __pyx_r = NULL;
24215   __pyx_L0:;
24216   __Pyx_XGIVEREF(__pyx_r);
24217   __Pyx_TraceReturn(__pyx_r);
24218   __Pyx_RefNannyFinishContext();
24219   return __pyx_r;
24220 }
24221
24222 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2645
24223  *     property pileups:
24224  *         '''list of reads (:class:`pysam.PileupRead`) aligned to this column'''
24225  *         def __get__(self):             # <<<<<<<<<<<<<<
24226  *             cdef int x
24227  *             pileups = []
24228  */
24229
24230 static PyObject *__pyx_pf_9csamtools_11PileupProxy_7pileups___get__(PyObject *__pyx_v_self); /*proto*/
24231 static PyObject *__pyx_pf_9csamtools_11PileupProxy_7pileups___get__(PyObject *__pyx_v_self) {
24232   int __pyx_v_x;
24233   PyObject *__pyx_v_pileups;
24234   PyObject *__pyx_r = NULL;
24235   PyObject *__pyx_t_1 = NULL;
24236   int __pyx_t_2;
24237   int __pyx_t_3;
24238   __Pyx_TraceDeclarations
24239   __Pyx_RefNannySetupContext("__get__");
24240   __Pyx_TraceCall("__get__", __pyx_f[0], 2645);
24241   __pyx_v_pileups = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
24242
24243   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2647
24244  *         def __get__(self):
24245  *             cdef int x
24246  *             pileups = []             # <<<<<<<<<<<<<<
24247  *             # warning: there could be problems if self.n and self.buf are
24248  *             # out of sync.
24249  */
24250   __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;}
24251   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
24252   __Pyx_DECREF(((PyObject *)__pyx_v_pileups));
24253   __pyx_v_pileups = __pyx_t_1;
24254   __pyx_t_1 = 0;
24255
24256   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2650
24257  *             # warning: there could be problems if self.n and self.buf are
24258  *             # out of sync.
24259  *             for x from 0 <= x < self.n_pu:             # <<<<<<<<<<<<<<
24260  *                 pileups.append( makePileupRead( &(self.plp[x])) )
24261  *             return pileups
24262  */
24263   __pyx_t_2 = ((struct __pyx_obj_9csamtools_PileupProxy *)__pyx_v_self)->n_pu;
24264   for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_2; __pyx_v_x++) {
24265
24266     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2651
24267  *             # out of sync.
24268  *             for x from 0 <= x < self.n_pu:
24269  *                 pileups.append( makePileupRead( &(self.plp[x])) )             # <<<<<<<<<<<<<<
24270  *             return pileups
24271  * 
24272  */
24273     if (unlikely(__pyx_v_pileups == Py_None)) {
24274       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;} 
24275     }
24276     __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;}
24277     __Pyx_GOTREF(__pyx_t_1);
24278     __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;}
24279     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
24280   }
24281
24282   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2652
24283  *             for x from 0 <= x < self.n_pu:
24284  *                 pileups.append( makePileupRead( &(self.plp[x])) )
24285  *             return pileups             # <<<<<<<<<<<<<<
24286  * 
24287  * cdef class PileupRead:
24288  */
24289   __Pyx_XDECREF(__pyx_r);
24290   __Pyx_INCREF(((PyObject *)__pyx_v_pileups));
24291   __pyx_r = ((PyObject *)__pyx_v_pileups);
24292   goto __pyx_L0;
24293
24294   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
24295   goto __pyx_L0;
24296   __pyx_L1_error:;
24297   __Pyx_XDECREF(__pyx_t_1);
24298   __Pyx_AddTraceback("csamtools.PileupProxy.pileups.__get__");
24299   __pyx_r = NULL;
24300   __pyx_L0:;
24301   __Pyx_DECREF(__pyx_v_pileups);
24302   __Pyx_XGIVEREF(__pyx_r);
24303   __Pyx_TraceReturn(__pyx_r);
24304   __Pyx_RefNannyFinishContext();
24305   return __pyx_r;
24306 }
24307
24308 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2667
24309  *          uint32_t _is_tail
24310  * 
24311  *     def __init__(self):             # <<<<<<<<<<<<<<
24312  *         raise TypeError("This class cannot be instantiated from Python")
24313  * 
24314  */
24315
24316 static int __pyx_pf_9csamtools_10PileupRead___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
24317 static int __pyx_pf_9csamtools_10PileupRead___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
24318   int __pyx_r;
24319   PyObject *__pyx_t_1 = NULL;
24320   PyObject *__pyx_t_2 = NULL;
24321   __Pyx_TraceDeclarations
24322   __Pyx_RefNannySetupContext("__init__");
24323   __Pyx_TraceCall("__init__", __pyx_f[0], 2667);
24324   if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
24325     __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
24326   if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
24327
24328   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2668
24329  * 
24330  *     def __init__(self):
24331  *         raise TypeError("This class cannot be instantiated from Python")             # <<<<<<<<<<<<<<
24332  * 
24333  *     def __str__(self):
24334  */
24335   __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;}
24336   __Pyx_GOTREF(__pyx_t_1);
24337   __Pyx_INCREF(((PyObject *)__pyx_kp_s_97));
24338   PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_97));
24339   __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_97));
24340   __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;}
24341   __Pyx_GOTREF(__pyx_t_2);
24342   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
24343   __Pyx_Raise(__pyx_t_2, 0, 0);
24344   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
24345   {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
24346
24347   __pyx_r = 0;
24348   goto __pyx_L0;
24349   __pyx_L1_error:;
24350   __Pyx_XDECREF(__pyx_t_1);
24351   __Pyx_XDECREF(__pyx_t_2);
24352   __Pyx_AddTraceback("csamtools.PileupRead.__init__");
24353   __pyx_r = -1;
24354   __pyx_L0:;
24355   __Pyx_TraceReturn(Py_None);
24356   __Pyx_RefNannyFinishContext();
24357   return __pyx_r;
24358 }
24359
24360 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2670
24361  *         raise TypeError("This class cannot be instantiated from Python")
24362  * 
24363  *     def __str__(self):             # <<<<<<<<<<<<<<
24364  *         return "\t".join( map(str, (self.alignment, self.qpos, self.indel, self.level, self.is_del, self.is_head, self.is_tail ) ) )
24365  * 
24366  */
24367
24368 static PyObject *__pyx_pf_9csamtools_10PileupRead___str__(PyObject *__pyx_v_self); /*proto*/
24369 static PyObject *__pyx_pf_9csamtools_10PileupRead___str__(PyObject *__pyx_v_self) {
24370   PyObject *__pyx_r = NULL;
24371   PyObject *__pyx_t_1 = NULL;
24372   PyObject *__pyx_t_2 = NULL;
24373   PyObject *__pyx_t_3 = NULL;
24374   PyObject *__pyx_t_4 = NULL;
24375   PyObject *__pyx_t_5 = NULL;
24376   PyObject *__pyx_t_6 = NULL;
24377   PyObject *__pyx_t_7 = NULL;
24378   PyObject *__pyx_t_8 = NULL;
24379   PyObject *__pyx_t_9 = NULL;
24380   __Pyx_TraceDeclarations
24381   __Pyx_RefNannySetupContext("__str__");
24382   __Pyx_TraceCall("__str__", __pyx_f[0], 2670);
24383
24384   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2671
24385  * 
24386  *     def __str__(self):
24387  *         return "\t".join( map(str, (self.alignment, self.qpos, self.indel, self.level, self.is_del, self.is_head, self.is_tail ) ) )             # <<<<<<<<<<<<<<
24388  * 
24389  *     property alignment:
24390  */
24391   __Pyx_XDECREF(__pyx_r);
24392   __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;}
24393   __Pyx_GOTREF(__pyx_t_1);
24394   __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;}
24395   __Pyx_GOTREF(__pyx_t_2);
24396   __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;}
24397   __Pyx_GOTREF(__pyx_t_3);
24398   __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;}
24399   __Pyx_GOTREF(__pyx_t_4);
24400   __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;}
24401   __Pyx_GOTREF(__pyx_t_5);
24402   __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;}
24403   __Pyx_GOTREF(__pyx_t_6);
24404   __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;}
24405   __Pyx_GOTREF(__pyx_t_7);
24406   __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;}
24407   __Pyx_GOTREF(__pyx_t_8);
24408   __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;}
24409   __Pyx_GOTREF(__pyx_t_9);
24410   PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_2);
24411   __Pyx_GIVEREF(__pyx_t_2);
24412   PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_3);
24413   __Pyx_GIVEREF(__pyx_t_3);
24414   PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_4);
24415   __Pyx_GIVEREF(__pyx_t_4);
24416   PyTuple_SET_ITEM(__pyx_t_9, 3, __pyx_t_5);
24417   __Pyx_GIVEREF(__pyx_t_5);
24418   PyTuple_SET_ITEM(__pyx_t_9, 4, __pyx_t_6);
24419   __Pyx_GIVEREF(__pyx_t_6);
24420   PyTuple_SET_ITEM(__pyx_t_9, 5, __pyx_t_7);
24421   __Pyx_GIVEREF(__pyx_t_7);
24422   PyTuple_SET_ITEM(__pyx_t_9, 6, __pyx_t_8);
24423   __Pyx_GIVEREF(__pyx_t_8);
24424   __pyx_t_2 = 0;
24425   __pyx_t_3 = 0;
24426   __pyx_t_4 = 0;
24427   __pyx_t_5 = 0;
24428   __pyx_t_6 = 0;
24429   __pyx_t_7 = 0;
24430   __pyx_t_8 = 0;
24431   __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;}
24432   __Pyx_GOTREF(__pyx_t_8);
24433   __Pyx_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
24434   PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)((PyObject*)&PyString_Type)));
24435   __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
24436   PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_9);
24437   __Pyx_GIVEREF(__pyx_t_9);
24438   __pyx_t_9 = 0;
24439   __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;}
24440   __Pyx_GOTREF(__pyx_t_9);
24441   __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
24442   __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;}
24443   __Pyx_GOTREF(__pyx_t_8);
24444   PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_9);
24445   __Pyx_GIVEREF(__pyx_t_9);
24446   __pyx_t_9 = 0;
24447   __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;}
24448   __Pyx_GOTREF(__pyx_t_9);
24449   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
24450   __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
24451   __pyx_r = __pyx_t_9;
24452   __pyx_t_9 = 0;
24453   goto __pyx_L0;
24454
24455   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
24456   goto __pyx_L0;
24457   __pyx_L1_error:;
24458   __Pyx_XDECREF(__pyx_t_1);
24459   __Pyx_XDECREF(__pyx_t_2);
24460   __Pyx_XDECREF(__pyx_t_3);
24461   __Pyx_XDECREF(__pyx_t_4);
24462   __Pyx_XDECREF(__pyx_t_5);
24463   __Pyx_XDECREF(__pyx_t_6);
24464   __Pyx_XDECREF(__pyx_t_7);
24465   __Pyx_XDECREF(__pyx_t_8);
24466   __Pyx_XDECREF(__pyx_t_9);
24467   __Pyx_AddTraceback("csamtools.PileupRead.__str__");
24468   __pyx_r = NULL;
24469   __pyx_L0:;
24470   __Pyx_XGIVEREF(__pyx_r);
24471   __Pyx_TraceReturn(__pyx_r);
24472   __Pyx_RefNannyFinishContext();
24473   return __pyx_r;
24474 }
24475
24476 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2675
24477  *     property alignment:
24478  *         """a :class:`pysam.AlignedRead` object of the aligned read"""
24479  *         def __get__(self):             # <<<<<<<<<<<<<<
24480  *             return self._alignment
24481  *     property qpos:
24482  */
24483
24484 static PyObject *__pyx_pf_9csamtools_10PileupRead_9alignment___get__(PyObject *__pyx_v_self); /*proto*/
24485 static PyObject *__pyx_pf_9csamtools_10PileupRead_9alignment___get__(PyObject *__pyx_v_self) {
24486   PyObject *__pyx_r = NULL;
24487   __Pyx_TraceDeclarations
24488   __Pyx_RefNannySetupContext("__get__");
24489   __Pyx_TraceCall("__get__", __pyx_f[0], 2675);
24490
24491   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2676
24492  *         """a :class:`pysam.AlignedRead` object of the aligned read"""
24493  *         def __get__(self):
24494  *             return self._alignment             # <<<<<<<<<<<<<<
24495  *     property qpos:
24496  *         """position of the read base at the pileup site, 0-based"""
24497  */
24498   __Pyx_XDECREF(__pyx_r);
24499   __Pyx_INCREF(((PyObject *)((struct __pyx_obj_9csamtools_PileupRead *)__pyx_v_self)->_alignment));
24500   __pyx_r = ((PyObject *)((struct __pyx_obj_9csamtools_PileupRead *)__pyx_v_self)->_alignment);
24501   goto __pyx_L0;
24502
24503   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
24504   __pyx_L0:;
24505   __Pyx_XGIVEREF(__pyx_r);
24506   __Pyx_TraceReturn(__pyx_r);
24507   __Pyx_RefNannyFinishContext();
24508   return __pyx_r;
24509 }
24510
24511 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2679
24512  *     property qpos:
24513  *         """position of the read base at the pileup site, 0-based"""
24514  *         def __get__(self):             # <<<<<<<<<<<<<<
24515  *             return self._qpos
24516  *     property indel:
24517  */
24518
24519 static PyObject *__pyx_pf_9csamtools_10PileupRead_4qpos___get__(PyObject *__pyx_v_self); /*proto*/
24520 static PyObject *__pyx_pf_9csamtools_10PileupRead_4qpos___get__(PyObject *__pyx_v_self) {
24521   PyObject *__pyx_r = NULL;
24522   PyObject *__pyx_t_1 = NULL;
24523   __Pyx_TraceDeclarations
24524   __Pyx_RefNannySetupContext("__get__");
24525   __Pyx_TraceCall("__get__", __pyx_f[0], 2679);
24526
24527   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2680
24528  *         """position of the read base at the pileup site, 0-based"""
24529  *         def __get__(self):
24530  *             return self._qpos             # <<<<<<<<<<<<<<
24531  *     property indel:
24532  *         """indel length; 0 for no indel, positive for ins and negative for del"""
24533  */
24534   __Pyx_XDECREF(__pyx_r);
24535   __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;}
24536   __Pyx_GOTREF(__pyx_t_1);
24537   __pyx_r = __pyx_t_1;
24538   __pyx_t_1 = 0;
24539   goto __pyx_L0;
24540
24541   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
24542   goto __pyx_L0;
24543   __pyx_L1_error:;
24544   __Pyx_XDECREF(__pyx_t_1);
24545   __Pyx_AddTraceback("csamtools.PileupRead.qpos.__get__");
24546   __pyx_r = NULL;
24547   __pyx_L0:;
24548   __Pyx_XGIVEREF(__pyx_r);
24549   __Pyx_TraceReturn(__pyx_r);
24550   __Pyx_RefNannyFinishContext();
24551   return __pyx_r;
24552 }
24553
24554 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2683
24555  *     property indel:
24556  *         """indel length; 0 for no indel, positive for ins and negative for del"""
24557  *         def __get__(self):             # <<<<<<<<<<<<<<
24558  *             return self._indel
24559  *     property is_del:
24560  */
24561
24562 static PyObject *__pyx_pf_9csamtools_10PileupRead_5indel___get__(PyObject *__pyx_v_self); /*proto*/
24563 static PyObject *__pyx_pf_9csamtools_10PileupRead_5indel___get__(PyObject *__pyx_v_self) {
24564   PyObject *__pyx_r = NULL;
24565   PyObject *__pyx_t_1 = NULL;
24566   __Pyx_TraceDeclarations
24567   __Pyx_RefNannySetupContext("__get__");
24568   __Pyx_TraceCall("__get__", __pyx_f[0], 2683);
24569
24570   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2684
24571  *         """indel length; 0 for no indel, positive for ins and negative for del"""
24572  *         def __get__(self):
24573  *             return self._indel             # <<<<<<<<<<<<<<
24574  *     property is_del:
24575  *         """1 iff the base on the padded read is a deletion"""
24576  */
24577   __Pyx_XDECREF(__pyx_r);
24578   __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;}
24579   __Pyx_GOTREF(__pyx_t_1);
24580   __pyx_r = __pyx_t_1;
24581   __pyx_t_1 = 0;
24582   goto __pyx_L0;
24583
24584   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
24585   goto __pyx_L0;
24586   __pyx_L1_error:;
24587   __Pyx_XDECREF(__pyx_t_1);
24588   __Pyx_AddTraceback("csamtools.PileupRead.indel.__get__");
24589   __pyx_r = NULL;
24590   __pyx_L0:;
24591   __Pyx_XGIVEREF(__pyx_r);
24592   __Pyx_TraceReturn(__pyx_r);
24593   __Pyx_RefNannyFinishContext();
24594   return __pyx_r;
24595 }
24596
24597 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2687
24598  *     property is_del:
24599  *         """1 iff the base on the padded read is a deletion"""
24600  *         def __get__(self):             # <<<<<<<<<<<<<<
24601  *             return self._is_del
24602  *     property is_head:
24603  */
24604
24605 static PyObject *__pyx_pf_9csamtools_10PileupRead_6is_del___get__(PyObject *__pyx_v_self); /*proto*/
24606 static PyObject *__pyx_pf_9csamtools_10PileupRead_6is_del___get__(PyObject *__pyx_v_self) {
24607   PyObject *__pyx_r = NULL;
24608   PyObject *__pyx_t_1 = NULL;
24609   __Pyx_TraceDeclarations
24610   __Pyx_RefNannySetupContext("__get__");
24611   __Pyx_TraceCall("__get__", __pyx_f[0], 2687);
24612
24613   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2688
24614  *         """1 iff the base on the padded read is a deletion"""
24615  *         def __get__(self):
24616  *             return self._is_del             # <<<<<<<<<<<<<<
24617  *     property is_head:
24618  *         def __get__(self):
24619  */
24620   __Pyx_XDECREF(__pyx_r);
24621   __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;}
24622   __Pyx_GOTREF(__pyx_t_1);
24623   __pyx_r = __pyx_t_1;
24624   __pyx_t_1 = 0;
24625   goto __pyx_L0;
24626
24627   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
24628   goto __pyx_L0;
24629   __pyx_L1_error:;
24630   __Pyx_XDECREF(__pyx_t_1);
24631   __Pyx_AddTraceback("csamtools.PileupRead.is_del.__get__");
24632   __pyx_r = NULL;
24633   __pyx_L0:;
24634   __Pyx_XGIVEREF(__pyx_r);
24635   __Pyx_TraceReturn(__pyx_r);
24636   __Pyx_RefNannyFinishContext();
24637   return __pyx_r;
24638 }
24639
24640 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2690
24641  *             return self._is_del
24642  *     property is_head:
24643  *         def __get__(self):             # <<<<<<<<<<<<<<
24644  *             return self._is_head
24645  *     property is_tail:
24646  */
24647
24648 static PyObject *__pyx_pf_9csamtools_10PileupRead_7is_head___get__(PyObject *__pyx_v_self); /*proto*/
24649 static PyObject *__pyx_pf_9csamtools_10PileupRead_7is_head___get__(PyObject *__pyx_v_self) {
24650   PyObject *__pyx_r = NULL;
24651   PyObject *__pyx_t_1 = NULL;
24652   __Pyx_TraceDeclarations
24653   __Pyx_RefNannySetupContext("__get__");
24654   __Pyx_TraceCall("__get__", __pyx_f[0], 2690);
24655
24656   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2691
24657  *     property is_head:
24658  *         def __get__(self):
24659  *             return self._is_head             # <<<<<<<<<<<<<<
24660  *     property is_tail:
24661  *         def __get__(self):
24662  */
24663   __Pyx_XDECREF(__pyx_r);
24664   __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;}
24665   __Pyx_GOTREF(__pyx_t_1);
24666   __pyx_r = __pyx_t_1;
24667   __pyx_t_1 = 0;
24668   goto __pyx_L0;
24669
24670   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
24671   goto __pyx_L0;
24672   __pyx_L1_error:;
24673   __Pyx_XDECREF(__pyx_t_1);
24674   __Pyx_AddTraceback("csamtools.PileupRead.is_head.__get__");
24675   __pyx_r = NULL;
24676   __pyx_L0:;
24677   __Pyx_XGIVEREF(__pyx_r);
24678   __Pyx_TraceReturn(__pyx_r);
24679   __Pyx_RefNannyFinishContext();
24680   return __pyx_r;
24681 }
24682
24683 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2693
24684  *             return self._is_head
24685  *     property is_tail:
24686  *         def __get__(self):             # <<<<<<<<<<<<<<
24687  *             return self._is_tail
24688  *     property level:
24689  */
24690
24691 static PyObject *__pyx_pf_9csamtools_10PileupRead_7is_tail___get__(PyObject *__pyx_v_self); /*proto*/
24692 static PyObject *__pyx_pf_9csamtools_10PileupRead_7is_tail___get__(PyObject *__pyx_v_self) {
24693   PyObject *__pyx_r = NULL;
24694   PyObject *__pyx_t_1 = NULL;
24695   __Pyx_TraceDeclarations
24696   __Pyx_RefNannySetupContext("__get__");
24697   __Pyx_TraceCall("__get__", __pyx_f[0], 2693);
24698
24699   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2694
24700  *     property is_tail:
24701  *         def __get__(self):
24702  *             return self._is_tail             # <<<<<<<<<<<<<<
24703  *     property level:
24704  *         def __get__(self):
24705  */
24706   __Pyx_XDECREF(__pyx_r);
24707   __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;}
24708   __Pyx_GOTREF(__pyx_t_1);
24709   __pyx_r = __pyx_t_1;
24710   __pyx_t_1 = 0;
24711   goto __pyx_L0;
24712
24713   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
24714   goto __pyx_L0;
24715   __pyx_L1_error:;
24716   __Pyx_XDECREF(__pyx_t_1);
24717   __Pyx_AddTraceback("csamtools.PileupRead.is_tail.__get__");
24718   __pyx_r = NULL;
24719   __pyx_L0:;
24720   __Pyx_XGIVEREF(__pyx_r);
24721   __Pyx_TraceReturn(__pyx_r);
24722   __Pyx_RefNannyFinishContext();
24723   return __pyx_r;
24724 }
24725
24726 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2696
24727  *             return self._is_tail
24728  *     property level:
24729  *         def __get__(self):             # <<<<<<<<<<<<<<
24730  *             return self._level
24731  * 
24732  */
24733
24734 static PyObject *__pyx_pf_9csamtools_10PileupRead_5level___get__(PyObject *__pyx_v_self); /*proto*/
24735 static PyObject *__pyx_pf_9csamtools_10PileupRead_5level___get__(PyObject *__pyx_v_self) {
24736   PyObject *__pyx_r = NULL;
24737   PyObject *__pyx_t_1 = NULL;
24738   __Pyx_TraceDeclarations
24739   __Pyx_RefNannySetupContext("__get__");
24740   __Pyx_TraceCall("__get__", __pyx_f[0], 2696);
24741
24742   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2697
24743  *     property level:
24744  *         def __get__(self):
24745  *             return self._level             # <<<<<<<<<<<<<<
24746  * 
24747  * class Outs:
24748  */
24749   __Pyx_XDECREF(__pyx_r);
24750   __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;}
24751   __Pyx_GOTREF(__pyx_t_1);
24752   __pyx_r = __pyx_t_1;
24753   __pyx_t_1 = 0;
24754   goto __pyx_L0;
24755
24756   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
24757   goto __pyx_L0;
24758   __pyx_L1_error:;
24759   __Pyx_XDECREF(__pyx_t_1);
24760   __Pyx_AddTraceback("csamtools.PileupRead.level.__get__");
24761   __pyx_r = NULL;
24762   __pyx_L0:;
24763   __Pyx_XGIVEREF(__pyx_r);
24764   __Pyx_TraceReturn(__pyx_r);
24765   __Pyx_RefNannyFinishContext();
24766   return __pyx_r;
24767 }
24768
24769 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2701
24770  * class Outs:
24771  *     '''http://mail.python.org/pipermail/python-list/2000-June/038406.html'''
24772  *     def __init__(self, id = 1):             # <<<<<<<<<<<<<<
24773  *         self.streams = []
24774  *         self.id = id
24775  */
24776
24777 static PyObject *__pyx_pf_9csamtools_4Outs___init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
24778 static char __pyx_doc_9csamtools_4Outs___init__[] = "Outs.__init__(self, id=1)";
24779 static PyMethodDef __pyx_mdef_9csamtools_4Outs___init__ = {__Pyx_NAMESTR("__init__"), (PyCFunction)__pyx_pf_9csamtools_4Outs___init__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_4Outs___init__)};
24780 static PyObject *__pyx_pf_9csamtools_4Outs___init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
24781   PyObject *__pyx_v_self = 0;
24782   PyObject *__pyx_v_id = 0;
24783   PyObject *__pyx_r = NULL;
24784   PyObject *__pyx_t_1 = NULL;
24785   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__id,0};
24786   __Pyx_TraceDeclarations
24787   __Pyx_RefNannySetupContext("__init__");
24788   __Pyx_TraceCall("__init__", __pyx_f[0], 2701);
24789   __pyx_self = __pyx_self;
24790   if (unlikely(__pyx_kwds)) {
24791     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
24792     PyObject* values[2] = {0,0};
24793     values[1] = ((PyObject *)__pyx_int_1);
24794     switch (PyTuple_GET_SIZE(__pyx_args)) {
24795       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
24796       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
24797       case  0: break;
24798       default: goto __pyx_L5_argtuple_error;
24799     }
24800     switch (PyTuple_GET_SIZE(__pyx_args)) {
24801       case  0:
24802       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
24803       if (likely(values[0])) kw_args--;
24804       else goto __pyx_L5_argtuple_error;
24805       case  1:
24806       if (kw_args > 0) {
24807         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__id);
24808         if (value) { values[1] = value; kw_args--; }
24809       }
24810     }
24811     if (unlikely(kw_args > 0)) {
24812       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;}
24813     }
24814     __pyx_v_self = values[0];
24815     __pyx_v_id = values[1];
24816   } else {
24817     __pyx_v_id = ((PyObject *)__pyx_int_1);
24818     switch (PyTuple_GET_SIZE(__pyx_args)) {
24819       case  2: __pyx_v_id = PyTuple_GET_ITEM(__pyx_args, 1);
24820       case  1: __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
24821       break;
24822       default: goto __pyx_L5_argtuple_error;
24823     }
24824   }
24825   goto __pyx_L4_argument_unpacking_done;
24826   __pyx_L5_argtuple_error:;
24827   __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;}
24828   __pyx_L3_error:;
24829   __Pyx_AddTraceback("csamtools.Outs.__init__");
24830   __Pyx_RefNannyFinishContext();
24831   return NULL;
24832   __pyx_L4_argument_unpacking_done:;
24833
24834   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2702
24835  *     '''http://mail.python.org/pipermail/python-list/2000-June/038406.html'''
24836  *     def __init__(self, id = 1):
24837  *         self.streams = []             # <<<<<<<<<<<<<<
24838  *         self.id = id
24839  * 
24840  */
24841   __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;}
24842   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
24843   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;}
24844   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
24845
24846   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2703
24847  *     def __init__(self, id = 1):
24848  *         self.streams = []
24849  *         self.id = id             # <<<<<<<<<<<<<<
24850  * 
24851  *     def setdevice(self, filename):
24852  */
24853   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;}
24854
24855   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
24856   goto __pyx_L0;
24857   __pyx_L1_error:;
24858   __Pyx_XDECREF(__pyx_t_1);
24859   __Pyx_AddTraceback("csamtools.Outs.__init__");
24860   __pyx_r = NULL;
24861   __pyx_L0:;
24862   __Pyx_XGIVEREF(__pyx_r);
24863   __Pyx_TraceReturn(__pyx_r);
24864   __Pyx_RefNannyFinishContext();
24865   return __pyx_r;
24866 }
24867
24868 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2705
24869  *         self.id = id
24870  * 
24871  *     def setdevice(self, filename):             # <<<<<<<<<<<<<<
24872  *         '''open an existing file, like "/dev/null"'''
24873  *         fd = os.open(filename, os.O_WRONLY)
24874  */
24875
24876 static PyObject *__pyx_pf_9csamtools_4Outs_setdevice(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
24877 static char __pyx_doc_9csamtools_4Outs_setdevice[] = "Outs.setdevice(self, filename)\nopen an existing file, like \"/dev/null\"";
24878 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)};
24879 static PyObject *__pyx_pf_9csamtools_4Outs_setdevice(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
24880   PyObject *__pyx_v_self = 0;
24881   PyObject *__pyx_v_filename = 0;
24882   PyObject *__pyx_v_fd;
24883   PyObject *__pyx_r = NULL;
24884   PyObject *__pyx_t_1 = NULL;
24885   PyObject *__pyx_t_2 = NULL;
24886   PyObject *__pyx_t_3 = NULL;
24887   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__filename,0};
24888   __Pyx_TraceDeclarations
24889   __Pyx_RefNannySetupContext("setdevice");
24890   __Pyx_TraceCall("setdevice", __pyx_f[0], 2705);
24891   __pyx_self = __pyx_self;
24892   if (unlikely(__pyx_kwds)) {
24893     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
24894     PyObject* values[2] = {0,0};
24895     switch (PyTuple_GET_SIZE(__pyx_args)) {
24896       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
24897       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
24898       case  0: break;
24899       default: goto __pyx_L5_argtuple_error;
24900     }
24901     switch (PyTuple_GET_SIZE(__pyx_args)) {
24902       case  0:
24903       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
24904       if (likely(values[0])) kw_args--;
24905       else goto __pyx_L5_argtuple_error;
24906       case  1:
24907       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filename);
24908       if (likely(values[1])) kw_args--;
24909       else {
24910         __Pyx_RaiseArgtupleInvalid("setdevice", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2705; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
24911       }
24912     }
24913     if (unlikely(kw_args > 0)) {
24914       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;}
24915     }
24916     __pyx_v_self = values[0];
24917     __pyx_v_filename = values[1];
24918   } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
24919     goto __pyx_L5_argtuple_error;
24920   } else {
24921     __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
24922     __pyx_v_filename = PyTuple_GET_ITEM(__pyx_args, 1);
24923   }
24924   goto __pyx_L4_argument_unpacking_done;
24925   __pyx_L5_argtuple_error:;
24926   __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;}
24927   __pyx_L3_error:;
24928   __Pyx_AddTraceback("csamtools.Outs.setdevice");
24929   __Pyx_RefNannyFinishContext();
24930   return NULL;
24931   __pyx_L4_argument_unpacking_done:;
24932   __pyx_v_fd = Py_None; __Pyx_INCREF(Py_None);
24933
24934   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2707
24935  *     def setdevice(self, filename):
24936  *         '''open an existing file, like "/dev/null"'''
24937  *         fd = os.open(filename, os.O_WRONLY)             # <<<<<<<<<<<<<<
24938  *         self.setfd(fd)
24939  * 
24940  */
24941   __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;}
24942   __Pyx_GOTREF(__pyx_t_1);
24943   __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;}
24944   __Pyx_GOTREF(__pyx_t_2);
24945   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
24946   __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;}
24947   __Pyx_GOTREF(__pyx_t_1);
24948   __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;}
24949   __Pyx_GOTREF(__pyx_t_3);
24950   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
24951   __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;}
24952   __Pyx_GOTREF(__pyx_t_1);
24953   __Pyx_INCREF(__pyx_v_filename);
24954   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_filename);
24955   __Pyx_GIVEREF(__pyx_v_filename);
24956   PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
24957   __Pyx_GIVEREF(__pyx_t_3);
24958   __pyx_t_3 = 0;
24959   __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;}
24960   __Pyx_GOTREF(__pyx_t_3);
24961   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
24962   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
24963   __Pyx_DECREF(__pyx_v_fd);
24964   __pyx_v_fd = __pyx_t_3;
24965   __pyx_t_3 = 0;
24966
24967   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2708
24968  *         '''open an existing file, like "/dev/null"'''
24969  *         fd = os.open(filename, os.O_WRONLY)
24970  *         self.setfd(fd)             # <<<<<<<<<<<<<<
24971  * 
24972  *     def setfile(self, filename):
24973  */
24974   __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;}
24975   __Pyx_GOTREF(__pyx_t_3);
24976   __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;}
24977   __Pyx_GOTREF(__pyx_t_1);
24978   __Pyx_INCREF(__pyx_v_fd);
24979   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_fd);
24980   __Pyx_GIVEREF(__pyx_v_fd);
24981   __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;}
24982   __Pyx_GOTREF(__pyx_t_2);
24983   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
24984   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
24985   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
24986
24987   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
24988   goto __pyx_L0;
24989   __pyx_L1_error:;
24990   __Pyx_XDECREF(__pyx_t_1);
24991   __Pyx_XDECREF(__pyx_t_2);
24992   __Pyx_XDECREF(__pyx_t_3);
24993   __Pyx_AddTraceback("csamtools.Outs.setdevice");
24994   __pyx_r = NULL;
24995   __pyx_L0:;
24996   __Pyx_DECREF(__pyx_v_fd);
24997   __Pyx_XGIVEREF(__pyx_r);
24998   __Pyx_TraceReturn(__pyx_r);
24999   __Pyx_RefNannyFinishContext();
25000   return __pyx_r;
25001 }
25002
25003 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2710
25004  *         self.setfd(fd)
25005  * 
25006  *     def setfile(self, filename):             # <<<<<<<<<<<<<<
25007  *         '''open a new file.'''
25008  *         fd = os.open(filename, os.O_WRONLY|os.O_CREAT, 0660);
25009  */
25010
25011 static PyObject *__pyx_pf_9csamtools_4Outs_setfile(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
25012 static char __pyx_doc_9csamtools_4Outs_setfile[] = "Outs.setfile(self, filename)\nopen a new file.";
25013 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)};
25014 static PyObject *__pyx_pf_9csamtools_4Outs_setfile(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
25015   PyObject *__pyx_v_self = 0;
25016   PyObject *__pyx_v_filename = 0;
25017   PyObject *__pyx_v_fd;
25018   PyObject *__pyx_r = NULL;
25019   PyObject *__pyx_t_1 = NULL;
25020   PyObject *__pyx_t_2 = NULL;
25021   PyObject *__pyx_t_3 = NULL;
25022   PyObject *__pyx_t_4 = NULL;
25023   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__filename,0};
25024   __Pyx_TraceDeclarations
25025   __Pyx_RefNannySetupContext("setfile");
25026   __Pyx_TraceCall("setfile", __pyx_f[0], 2710);
25027   __pyx_self = __pyx_self;
25028   if (unlikely(__pyx_kwds)) {
25029     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
25030     PyObject* values[2] = {0,0};
25031     switch (PyTuple_GET_SIZE(__pyx_args)) {
25032       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
25033       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
25034       case  0: break;
25035       default: goto __pyx_L5_argtuple_error;
25036     }
25037     switch (PyTuple_GET_SIZE(__pyx_args)) {
25038       case  0:
25039       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
25040       if (likely(values[0])) kw_args--;
25041       else goto __pyx_L5_argtuple_error;
25042       case  1:
25043       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filename);
25044       if (likely(values[1])) kw_args--;
25045       else {
25046         __Pyx_RaiseArgtupleInvalid("setfile", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2710; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
25047       }
25048     }
25049     if (unlikely(kw_args > 0)) {
25050       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;}
25051     }
25052     __pyx_v_self = values[0];
25053     __pyx_v_filename = values[1];
25054   } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
25055     goto __pyx_L5_argtuple_error;
25056   } else {
25057     __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
25058     __pyx_v_filename = PyTuple_GET_ITEM(__pyx_args, 1);
25059   }
25060   goto __pyx_L4_argument_unpacking_done;
25061   __pyx_L5_argtuple_error:;
25062   __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;}
25063   __pyx_L3_error:;
25064   __Pyx_AddTraceback("csamtools.Outs.setfile");
25065   __Pyx_RefNannyFinishContext();
25066   return NULL;
25067   __pyx_L4_argument_unpacking_done:;
25068   __pyx_v_fd = Py_None; __Pyx_INCREF(Py_None);
25069
25070   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2712
25071  *     def setfile(self, filename):
25072  *         '''open a new file.'''
25073  *         fd = os.open(filename, os.O_WRONLY|os.O_CREAT, 0660);             # <<<<<<<<<<<<<<
25074  *         self.setfd(fd)
25075  * 
25076  */
25077   __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;}
25078   __Pyx_GOTREF(__pyx_t_1);
25079   __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;}
25080   __Pyx_GOTREF(__pyx_t_2);
25081   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25082   __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;}
25083   __Pyx_GOTREF(__pyx_t_1);
25084   __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;}
25085   __Pyx_GOTREF(__pyx_t_3);
25086   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25087   __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;}
25088   __Pyx_GOTREF(__pyx_t_1);
25089   __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;}
25090   __Pyx_GOTREF(__pyx_t_4);
25091   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25092   __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;}
25093   __Pyx_GOTREF(__pyx_t_1);
25094   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25095   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
25096   __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;}
25097   __Pyx_GOTREF(__pyx_t_4);
25098   __Pyx_INCREF(__pyx_v_filename);
25099   PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_filename);
25100   __Pyx_GIVEREF(__pyx_v_filename);
25101   PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
25102   __Pyx_GIVEREF(__pyx_t_1);
25103   __Pyx_INCREF(__pyx_int_0660);
25104   PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_int_0660);
25105   __Pyx_GIVEREF(__pyx_int_0660);
25106   __pyx_t_1 = 0;
25107   __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;}
25108   __Pyx_GOTREF(__pyx_t_1);
25109   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
25110   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
25111   __Pyx_DECREF(__pyx_v_fd);
25112   __pyx_v_fd = __pyx_t_1;
25113   __pyx_t_1 = 0;
25114
25115   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2713
25116  *         '''open a new file.'''
25117  *         fd = os.open(filename, os.O_WRONLY|os.O_CREAT, 0660);
25118  *         self.setfd(fd)             # <<<<<<<<<<<<<<
25119  * 
25120  *     def setfd(self, fd):
25121  */
25122   __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;}
25123   __Pyx_GOTREF(__pyx_t_1);
25124   __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;}
25125   __Pyx_GOTREF(__pyx_t_4);
25126   __Pyx_INCREF(__pyx_v_fd);
25127   PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_fd);
25128   __Pyx_GIVEREF(__pyx_v_fd);
25129   __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;}
25130   __Pyx_GOTREF(__pyx_t_2);
25131   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25132   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
25133   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
25134
25135   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
25136   goto __pyx_L0;
25137   __pyx_L1_error:;
25138   __Pyx_XDECREF(__pyx_t_1);
25139   __Pyx_XDECREF(__pyx_t_2);
25140   __Pyx_XDECREF(__pyx_t_3);
25141   __Pyx_XDECREF(__pyx_t_4);
25142   __Pyx_AddTraceback("csamtools.Outs.setfile");
25143   __pyx_r = NULL;
25144   __pyx_L0:;
25145   __Pyx_DECREF(__pyx_v_fd);
25146   __Pyx_XGIVEREF(__pyx_r);
25147   __Pyx_TraceReturn(__pyx_r);
25148   __Pyx_RefNannyFinishContext();
25149   return __pyx_r;
25150 }
25151
25152 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2715
25153  *         self.setfd(fd)
25154  * 
25155  *     def setfd(self, fd):             # <<<<<<<<<<<<<<
25156  *         ofd = os.dup(self.id)      #  Save old stream on new unit.
25157  *         self.streams.append(ofd)
25158  */
25159
25160 static PyObject *__pyx_pf_9csamtools_4Outs_setfd(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
25161 static char __pyx_doc_9csamtools_4Outs_setfd[] = "Outs.setfd(self, fd)";
25162 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)};
25163 static PyObject *__pyx_pf_9csamtools_4Outs_setfd(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
25164   PyObject *__pyx_v_self = 0;
25165   PyObject *__pyx_v_fd = 0;
25166   PyObject *__pyx_v_ofd;
25167   PyObject *__pyx_r = NULL;
25168   PyObject *__pyx_t_1 = NULL;
25169   PyObject *__pyx_t_2 = NULL;
25170   PyObject *__pyx_t_3 = NULL;
25171   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__self,&__pyx_n_s__fd,0};
25172   __Pyx_TraceDeclarations
25173   __Pyx_RefNannySetupContext("setfd");
25174   __Pyx_TraceCall("setfd", __pyx_f[0], 2715);
25175   __pyx_self = __pyx_self;
25176   if (unlikely(__pyx_kwds)) {
25177     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
25178     PyObject* values[2] = {0,0};
25179     switch (PyTuple_GET_SIZE(__pyx_args)) {
25180       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
25181       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
25182       case  0: break;
25183       default: goto __pyx_L5_argtuple_error;
25184     }
25185     switch (PyTuple_GET_SIZE(__pyx_args)) {
25186       case  0:
25187       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__self);
25188       if (likely(values[0])) kw_args--;
25189       else goto __pyx_L5_argtuple_error;
25190       case  1:
25191       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fd);
25192       if (likely(values[1])) kw_args--;
25193       else {
25194         __Pyx_RaiseArgtupleInvalid("setfd", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2715; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
25195       }
25196     }
25197     if (unlikely(kw_args > 0)) {
25198       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;}
25199     }
25200     __pyx_v_self = values[0];
25201     __pyx_v_fd = values[1];
25202   } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
25203     goto __pyx_L5_argtuple_error;
25204   } else {
25205     __pyx_v_self = PyTuple_GET_ITEM(__pyx_args, 0);
25206     __pyx_v_fd = PyTuple_GET_ITEM(__pyx_args, 1);
25207   }
25208   goto __pyx_L4_argument_unpacking_done;
25209   __pyx_L5_argtuple_error:;
25210   __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;}
25211   __pyx_L3_error:;
25212   __Pyx_AddTraceback("csamtools.Outs.setfd");
25213   __Pyx_RefNannyFinishContext();
25214   return NULL;
25215   __pyx_L4_argument_unpacking_done:;
25216   __pyx_v_ofd = Py_None; __Pyx_INCREF(Py_None);
25217
25218   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2716
25219  * 
25220  *     def setfd(self, fd):
25221  *         ofd = os.dup(self.id)      #  Save old stream on new unit.             # <<<<<<<<<<<<<<
25222  *         self.streams.append(ofd)
25223  *         sys.stdout.flush()          #  Buffered data goes to old stream.
25224  */
25225   __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;}
25226   __Pyx_GOTREF(__pyx_t_1);
25227   __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;}
25228   __Pyx_GOTREF(__pyx_t_2);
25229   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25230   __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;}
25231   __Pyx_GOTREF(__pyx_t_1);
25232   __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;}
25233   __Pyx_GOTREF(__pyx_t_3);
25234   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
25235   __Pyx_GIVEREF(__pyx_t_1);
25236   __pyx_t_1 = 0;
25237   __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;}
25238   __Pyx_GOTREF(__pyx_t_1);
25239   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
25240   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25241   __Pyx_DECREF(__pyx_v_ofd);
25242   __pyx_v_ofd = __pyx_t_1;
25243   __pyx_t_1 = 0;
25244
25245   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2717
25246  *     def setfd(self, fd):
25247  *         ofd = os.dup(self.id)      #  Save old stream on new unit.
25248  *         self.streams.append(ofd)             # <<<<<<<<<<<<<<
25249  *         sys.stdout.flush()          #  Buffered data goes to old stream.
25250  *         sys.stderr.flush()          #  Buffered data goes to old stream.
25251  */
25252   __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;}
25253   __Pyx_GOTREF(__pyx_t_1);
25254   __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;}
25255   __Pyx_GOTREF(__pyx_t_3);
25256   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25257   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25258
25259   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2718
25260  *         ofd = os.dup(self.id)      #  Save old stream on new unit.
25261  *         self.streams.append(ofd)
25262  *         sys.stdout.flush()          #  Buffered data goes to old stream.             # <<<<<<<<<<<<<<
25263  *         sys.stderr.flush()          #  Buffered data goes to old stream.
25264  *         os.dup2(fd, self.id)        #  Open unit 1 on new stream.
25265  */
25266   __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;}
25267   __Pyx_GOTREF(__pyx_t_3);
25268   __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;}
25269   __Pyx_GOTREF(__pyx_t_1);
25270   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25271   __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;}
25272   __Pyx_GOTREF(__pyx_t_3);
25273   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25274   __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;}
25275   __Pyx_GOTREF(__pyx_t_1);
25276   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25277   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25278
25279   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2719
25280  *         self.streams.append(ofd)
25281  *         sys.stdout.flush()          #  Buffered data goes to old stream.
25282  *         sys.stderr.flush()          #  Buffered data goes to old stream.             # <<<<<<<<<<<<<<
25283  *         os.dup2(fd, self.id)        #  Open unit 1 on new stream.
25284  *         os.close(fd)                #  Close other unit (look out, caller.)
25285  */
25286   __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;}
25287   __Pyx_GOTREF(__pyx_t_1);
25288   __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;}
25289   __Pyx_GOTREF(__pyx_t_3);
25290   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25291   __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;}
25292   __Pyx_GOTREF(__pyx_t_1);
25293   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25294   __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;}
25295   __Pyx_GOTREF(__pyx_t_3);
25296   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25297   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25298
25299   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2720
25300  *         sys.stdout.flush()          #  Buffered data goes to old stream.
25301  *         sys.stderr.flush()          #  Buffered data goes to old stream.
25302  *         os.dup2(fd, self.id)        #  Open unit 1 on new stream.             # <<<<<<<<<<<<<<
25303  *         os.close(fd)                #  Close other unit (look out, caller.)
25304  * 
25305  */
25306   __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;}
25307   __Pyx_GOTREF(__pyx_t_3);
25308   __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;}
25309   __Pyx_GOTREF(__pyx_t_1);
25310   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25311   __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;}
25312   __Pyx_GOTREF(__pyx_t_3);
25313   __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;}
25314   __Pyx_GOTREF(__pyx_t_2);
25315   __Pyx_INCREF(__pyx_v_fd);
25316   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_fd);
25317   __Pyx_GIVEREF(__pyx_v_fd);
25318   PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
25319   __Pyx_GIVEREF(__pyx_t_3);
25320   __pyx_t_3 = 0;
25321   __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;}
25322   __Pyx_GOTREF(__pyx_t_3);
25323   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25324   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
25325   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25326
25327   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2721
25328  *         sys.stderr.flush()          #  Buffered data goes to old stream.
25329  *         os.dup2(fd, self.id)        #  Open unit 1 on new stream.
25330  *         os.close(fd)                #  Close other unit (look out, caller.)             # <<<<<<<<<<<<<<
25331  * 
25332  *     def restore(self):
25333  */
25334   __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;}
25335   __Pyx_GOTREF(__pyx_t_3);
25336   __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;}
25337   __Pyx_GOTREF(__pyx_t_2);
25338   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25339   __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;}
25340   __Pyx_GOTREF(__pyx_t_3);
25341   __Pyx_INCREF(__pyx_v_fd);
25342   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_fd);
25343   __Pyx_GIVEREF(__pyx_v_fd);
25344   __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;}
25345   __Pyx_GOTREF(__pyx_t_1);
25346   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
25347   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25348   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25349
25350   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
25351   goto __pyx_L0;
25352   __pyx_L1_error:;
25353   __Pyx_XDECREF(__pyx_t_1);
25354   __Pyx_XDECREF(__pyx_t_2);
25355   __Pyx_XDECREF(__pyx_t_3);
25356   __Pyx_AddTraceback("csamtools.Outs.setfd");
25357   __pyx_r = NULL;
25358   __pyx_L0:;
25359   __Pyx_DECREF(__pyx_v_ofd);
25360   __Pyx_XGIVEREF(__pyx_r);
25361   __Pyx_TraceReturn(__pyx_r);
25362   __Pyx_RefNannyFinishContext();
25363   return __pyx_r;
25364 }
25365
25366 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2723
25367  *         os.close(fd)                #  Close other unit (look out, caller.)
25368  * 
25369  *     def restore(self):             # <<<<<<<<<<<<<<
25370  *         '''restore previous output stream'''
25371  *         if self.streams:
25372  */
25373
25374 static PyObject *__pyx_pf_9csamtools_4Outs_restore(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
25375 static char __pyx_doc_9csamtools_4Outs_restore[] = "Outs.restore(self)\nrestore previous output stream";
25376 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)};
25377 static PyObject *__pyx_pf_9csamtools_4Outs_restore(PyObject *__pyx_self, PyObject *__pyx_v_self) {
25378   PyObject *__pyx_r = NULL;
25379   PyObject *__pyx_t_1 = NULL;
25380   int __pyx_t_2;
25381   PyObject *__pyx_t_3 = NULL;
25382   PyObject *__pyx_t_4 = NULL;
25383   PyObject *__pyx_t_5 = NULL;
25384   __Pyx_TraceDeclarations
25385   __Pyx_RefNannySetupContext("restore");
25386   __Pyx_TraceCall("restore", __pyx_f[0], 2723);
25387   __pyx_self = __pyx_self;
25388
25389   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2725
25390  *     def restore(self):
25391  *         '''restore previous output stream'''
25392  *         if self.streams:             # <<<<<<<<<<<<<<
25393  *             # the following was not sufficient, hence flush both stderr and stdout
25394  *             # os.fsync( self.id )
25395  */
25396   __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;}
25397   __Pyx_GOTREF(__pyx_t_1);
25398   __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;}
25399   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25400   if (__pyx_t_2) {
25401
25402     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2728
25403  *             # the following was not sufficient, hence flush both stderr and stdout
25404  *             # os.fsync( self.id )
25405  *             sys.stdout.flush()             # <<<<<<<<<<<<<<
25406  *             sys.stderr.flush()
25407  *             os.dup2(self.streams[-1], self.id)
25408  */
25409     __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;}
25410     __Pyx_GOTREF(__pyx_t_1);
25411     __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;}
25412     __Pyx_GOTREF(__pyx_t_3);
25413     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25414     __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;}
25415     __Pyx_GOTREF(__pyx_t_1);
25416     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25417     __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;}
25418     __Pyx_GOTREF(__pyx_t_3);
25419     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25420     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25421
25422     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2729
25423  *             # os.fsync( self.id )
25424  *             sys.stdout.flush()
25425  *             sys.stderr.flush()             # <<<<<<<<<<<<<<
25426  *             os.dup2(self.streams[-1], self.id)
25427  *             os.close(self.streams[-1])
25428  */
25429     __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;}
25430     __Pyx_GOTREF(__pyx_t_3);
25431     __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;}
25432     __Pyx_GOTREF(__pyx_t_1);
25433     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25434     __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;}
25435     __Pyx_GOTREF(__pyx_t_3);
25436     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25437     __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;}
25438     __Pyx_GOTREF(__pyx_t_1);
25439     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25440     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25441
25442     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2730
25443  *             sys.stdout.flush()
25444  *             sys.stderr.flush()
25445  *             os.dup2(self.streams[-1], self.id)             # <<<<<<<<<<<<<<
25446  *             os.close(self.streams[-1])
25447  *             del self.streams[-1]
25448  */
25449     __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;}
25450     __Pyx_GOTREF(__pyx_t_1);
25451     __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;}
25452     __Pyx_GOTREF(__pyx_t_3);
25453     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25454     __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;}
25455     __Pyx_GOTREF(__pyx_t_1);
25456     __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;}
25457     __Pyx_GOTREF(__pyx_t_4);
25458     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25459     __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;}
25460     __Pyx_GOTREF(__pyx_t_1);
25461     __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;}
25462     __Pyx_GOTREF(__pyx_t_5);
25463     PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
25464     __Pyx_GIVEREF(__pyx_t_4);
25465     PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
25466     __Pyx_GIVEREF(__pyx_t_1);
25467     __pyx_t_4 = 0;
25468     __pyx_t_1 = 0;
25469     __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;}
25470     __Pyx_GOTREF(__pyx_t_1);
25471     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25472     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
25473     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25474
25475     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2731
25476  *             sys.stderr.flush()
25477  *             os.dup2(self.streams[-1], self.id)
25478  *             os.close(self.streams[-1])             # <<<<<<<<<<<<<<
25479  *             del self.streams[-1]
25480  * 
25481  */
25482     __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;}
25483     __Pyx_GOTREF(__pyx_t_1);
25484     __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;}
25485     __Pyx_GOTREF(__pyx_t_5);
25486     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25487     __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;}
25488     __Pyx_GOTREF(__pyx_t_1);
25489     __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;}
25490     __Pyx_GOTREF(__pyx_t_3);
25491     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25492     __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;}
25493     __Pyx_GOTREF(__pyx_t_1);
25494     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
25495     __Pyx_GIVEREF(__pyx_t_3);
25496     __pyx_t_3 = 0;
25497     __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;}
25498     __Pyx_GOTREF(__pyx_t_3);
25499     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
25500     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25501     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25502
25503     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2732
25504  *             os.dup2(self.streams[-1], self.id)
25505  *             os.close(self.streams[-1])
25506  *             del self.streams[-1]             # <<<<<<<<<<<<<<
25507  * 
25508  * def _samtools_dispatch( method,
25509  */
25510     __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;}
25511     __Pyx_GOTREF(__pyx_t_3);
25512     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;}
25513     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25514     goto __pyx_L5;
25515   }
25516   __pyx_L5:;
25517
25518   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
25519   goto __pyx_L0;
25520   __pyx_L1_error:;
25521   __Pyx_XDECREF(__pyx_t_1);
25522   __Pyx_XDECREF(__pyx_t_3);
25523   __Pyx_XDECREF(__pyx_t_4);
25524   __Pyx_XDECREF(__pyx_t_5);
25525   __Pyx_AddTraceback("csamtools.Outs.restore");
25526   __pyx_r = NULL;
25527   __pyx_L0:;
25528   __Pyx_XGIVEREF(__pyx_r);
25529   __Pyx_TraceReturn(__pyx_r);
25530   __Pyx_RefNannyFinishContext();
25531   return __pyx_r;
25532 }
25533
25534 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2734
25535  *             del self.streams[-1]
25536  * 
25537  * def _samtools_dispatch( method,             # <<<<<<<<<<<<<<
25538  *                         args = (),
25539  *                         catch_stdout = True,
25540  */
25541
25542 static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
25543 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    ";
25544 static PyObject *__pyx_pf_9csamtools__samtools_dispatch(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
25545   PyObject *__pyx_v_method = 0;
25546   PyObject *__pyx_v_args = 0;
25547   PyObject *__pyx_v_catch_stdout = 0;
25548   PyObject *__pyx_v_catch_stderr = 0;
25549   PyObject *__pyx_v_stderr_h;
25550   PyObject *__pyx_v_stderr_f;
25551   PyObject *__pyx_v_stderr_save;
25552   PyObject *__pyx_v_stdout_h;
25553   PyObject *__pyx_v_stdout_f;
25554   PyObject *__pyx_v_stdout_save;
25555   char **__pyx_v_cargs;
25556   int __pyx_v_i;
25557   int __pyx_v_n;
25558   int __pyx_v_retval;
25559   PyObject *__pyx_v_out_stdout;
25560   PyObject *__pyx_v_out_stderr;
25561   PyObject *__pyx_r = NULL;
25562   PyObject *__pyx_t_1 = NULL;
25563   int __pyx_t_2;
25564   PyObject *__pyx_t_3 = NULL;
25565   PyObject *__pyx_t_4 = NULL;
25566   int __pyx_t_5;
25567   PyObject *__pyx_t_6 = NULL;
25568   Py_ssize_t __pyx_t_7;
25569   char *__pyx_t_8;
25570   int __pyx_t_9;
25571   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__method,&__pyx_n_s__args,&__pyx_n_s__catch_stdout,&__pyx_n_s__catch_stderr,0};
25572   __Pyx_TraceDeclarations
25573   __Pyx_RefNannySetupContext("_samtools_dispatch");
25574   __Pyx_TraceCall("_samtools_dispatch", __pyx_f[0], 2734);
25575   __pyx_self = __pyx_self;
25576   if (unlikely(__pyx_kwds)) {
25577     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
25578     PyObject* values[4] = {0,0,0,0};
25579
25580     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2735
25581  * 
25582  * def _samtools_dispatch( method,
25583  *                         args = (),             # <<<<<<<<<<<<<<
25584  *                         catch_stdout = True,
25585  *                         catch_stderr = False,
25586  */
25587     values[1] = ((PyObject *)__pyx_empty_tuple);
25588     values[2] = __pyx_k_98;
25589     values[3] = __pyx_k_99;
25590     switch (PyTuple_GET_SIZE(__pyx_args)) {
25591       case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
25592       case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
25593       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
25594       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
25595       case  0: break;
25596       default: goto __pyx_L5_argtuple_error;
25597     }
25598     switch (PyTuple_GET_SIZE(__pyx_args)) {
25599       case  0:
25600       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__method);
25601       if (likely(values[0])) kw_args--;
25602       else goto __pyx_L5_argtuple_error;
25603       case  1:
25604       if (kw_args > 0) {
25605         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__args);
25606         if (value) { values[1] = value; kw_args--; }
25607       }
25608       case  2:
25609       if (kw_args > 0) {
25610         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__catch_stdout);
25611         if (value) { values[2] = value; kw_args--; }
25612       }
25613       case  3:
25614       if (kw_args > 0) {
25615         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__catch_stderr);
25616         if (value) { values[3] = value; kw_args--; }
25617       }
25618     }
25619     if (unlikely(kw_args > 0)) {
25620       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;}
25621     }
25622     __pyx_v_method = values[0];
25623     __pyx_v_args = values[1];
25624     __pyx_v_catch_stdout = values[2];
25625     __pyx_v_catch_stderr = values[3];
25626   } else {
25627     __pyx_v_args = ((PyObject *)__pyx_empty_tuple);
25628     __pyx_v_catch_stdout = __pyx_k_98;
25629     __pyx_v_catch_stderr = __pyx_k_99;
25630     switch (PyTuple_GET_SIZE(__pyx_args)) {
25631       case  4: __pyx_v_catch_stderr = PyTuple_GET_ITEM(__pyx_args, 3);
25632       case  3: __pyx_v_catch_stdout = PyTuple_GET_ITEM(__pyx_args, 2);
25633       case  2: __pyx_v_args = PyTuple_GET_ITEM(__pyx_args, 1);
25634       case  1: __pyx_v_method = PyTuple_GET_ITEM(__pyx_args, 0);
25635       break;
25636       default: goto __pyx_L5_argtuple_error;
25637     }
25638   }
25639   goto __pyx_L4_argument_unpacking_done;
25640   __pyx_L5_argtuple_error:;
25641   __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;}
25642   __pyx_L3_error:;
25643   __Pyx_AddTraceback("csamtools._samtools_dispatch");
25644   __Pyx_RefNannyFinishContext();
25645   return NULL;
25646   __pyx_L4_argument_unpacking_done:;
25647   __Pyx_INCREF(__pyx_v_args);
25648   __pyx_v_stderr_h = Py_None; __Pyx_INCREF(Py_None);
25649   __pyx_v_stderr_f = Py_None; __Pyx_INCREF(Py_None);
25650   __pyx_v_stderr_save = Py_None; __Pyx_INCREF(Py_None);
25651   __pyx_v_stdout_h = Py_None; __Pyx_INCREF(Py_None);
25652   __pyx_v_stdout_f = Py_None; __Pyx_INCREF(Py_None);
25653   __pyx_v_stdout_save = Py_None; __Pyx_INCREF(Py_None);
25654   __pyx_v_out_stdout = Py_None; __Pyx_INCREF(Py_None);
25655   __pyx_v_out_stderr = Py_None; __Pyx_INCREF(Py_None);
25656
25657   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2762
25658  * 
25659  *     # some special cases
25660  *     if method == "index":             # <<<<<<<<<<<<<<
25661  *         if not os.path.exists( args[0] ):
25662  *             raise IOError( "No such file or directory: '%s'" % args[0] )
25663  */
25664   __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;}
25665   __Pyx_GOTREF(__pyx_t_1);
25666   __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;}
25667   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25668   if (__pyx_t_2) {
25669
25670     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2763
25671  *     # some special cases
25672  *     if method == "index":
25673  *         if not os.path.exists( args[0] ):             # <<<<<<<<<<<<<<
25674  *             raise IOError( "No such file or directory: '%s'" % args[0] )
25675  * 
25676  */
25677     __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;}
25678     __Pyx_GOTREF(__pyx_t_1);
25679     __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;}
25680     __Pyx_GOTREF(__pyx_t_3);
25681     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25682     __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;}
25683     __Pyx_GOTREF(__pyx_t_1);
25684     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25685     __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;}
25686     __Pyx_GOTREF(__pyx_t_3);
25687     __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;}
25688     __Pyx_GOTREF(__pyx_t_4);
25689     PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
25690     __Pyx_GIVEREF(__pyx_t_3);
25691     __pyx_t_3 = 0;
25692     __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;}
25693     __Pyx_GOTREF(__pyx_t_3);
25694     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25695     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
25696     __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;}
25697     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25698     __pyx_t_5 = (!__pyx_t_2);
25699     if (__pyx_t_5) {
25700
25701       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2764
25702  *     if method == "index":
25703  *         if not os.path.exists( args[0] ):
25704  *             raise IOError( "No such file or directory: '%s'" % args[0] )             # <<<<<<<<<<<<<<
25705  * 
25706  *     # redirect stderr and stdout to file
25707  */
25708       __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;}
25709       __Pyx_GOTREF(__pyx_t_3);
25710       __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;}
25711       __Pyx_GOTREF(((PyObject *)__pyx_t_4));
25712       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25713       __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;}
25714       __Pyx_GOTREF(__pyx_t_3);
25715       PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_4));
25716       __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
25717       __pyx_t_4 = 0;
25718       __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;}
25719       __Pyx_GOTREF(__pyx_t_4);
25720       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25721       __Pyx_Raise(__pyx_t_4, 0, 0);
25722       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
25723       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
25724       goto __pyx_L7;
25725     }
25726     __pyx_L7:;
25727     goto __pyx_L6;
25728   }
25729   __pyx_L6:;
25730
25731   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2767
25732  * 
25733  *     # redirect stderr and stdout to file
25734  *     if catch_stderr:             # <<<<<<<<<<<<<<
25735  *         stderr_h, stderr_f = tempfile.mkstemp()
25736  *         stderr_save = Outs( sys.stderr.fileno() )
25737  */
25738   __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;}
25739   if (__pyx_t_5) {
25740
25741     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2768
25742  *     # redirect stderr and stdout to file
25743  *     if catch_stderr:
25744  *         stderr_h, stderr_f = tempfile.mkstemp()             # <<<<<<<<<<<<<<
25745  *         stderr_save = Outs( sys.stderr.fileno() )
25746  *         stderr_save.setfd( stderr_h )
25747  */
25748     __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;}
25749     __Pyx_GOTREF(__pyx_t_4);
25750     __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;}
25751     __Pyx_GOTREF(__pyx_t_3);
25752     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
25753     __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;}
25754     __Pyx_GOTREF(__pyx_t_4);
25755     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25756     if (PyTuple_CheckExact(__pyx_t_4) && likely(PyTuple_GET_SIZE(__pyx_t_4) == 2)) {
25757       PyObject* tuple = __pyx_t_4;
25758       __pyx_t_3 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_3);
25759       __pyx_t_1 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_1);
25760       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
25761       __Pyx_DECREF(__pyx_v_stderr_h);
25762       __pyx_v_stderr_h = __pyx_t_3;
25763       __pyx_t_3 = 0;
25764       __Pyx_DECREF(__pyx_v_stderr_f);
25765       __pyx_v_stderr_f = __pyx_t_1;
25766       __pyx_t_1 = 0;
25767     } else {
25768       __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;}
25769       __Pyx_GOTREF(__pyx_t_6);
25770       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
25771       __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;}
25772       __Pyx_GOTREF(__pyx_t_3);
25773       __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;}
25774       __Pyx_GOTREF(__pyx_t_1);
25775       if (__Pyx_EndUnpack(__pyx_t_6, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
25776       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
25777       __Pyx_DECREF(__pyx_v_stderr_h);
25778       __pyx_v_stderr_h = __pyx_t_3;
25779       __pyx_t_3 = 0;
25780       __Pyx_DECREF(__pyx_v_stderr_f);
25781       __pyx_v_stderr_f = __pyx_t_1;
25782       __pyx_t_1 = 0;
25783     }
25784
25785     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2769
25786  *     if catch_stderr:
25787  *         stderr_h, stderr_f = tempfile.mkstemp()
25788  *         stderr_save = Outs( sys.stderr.fileno() )             # <<<<<<<<<<<<<<
25789  *         stderr_save.setfd( stderr_h )
25790  * 
25791  */
25792     __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;}
25793     __Pyx_GOTREF(__pyx_t_4);
25794     __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;}
25795     __Pyx_GOTREF(__pyx_t_1);
25796     __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;}
25797     __Pyx_GOTREF(__pyx_t_3);
25798     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25799     __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;}
25800     __Pyx_GOTREF(__pyx_t_1);
25801     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25802     __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;}
25803     __Pyx_GOTREF(__pyx_t_3);
25804     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25805     __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;}
25806     __Pyx_GOTREF(__pyx_t_1);
25807     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
25808     __Pyx_GIVEREF(__pyx_t_3);
25809     __pyx_t_3 = 0;
25810     __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;}
25811     __Pyx_GOTREF(__pyx_t_3);
25812     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
25813     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25814     __Pyx_DECREF(__pyx_v_stderr_save);
25815     __pyx_v_stderr_save = __pyx_t_3;
25816     __pyx_t_3 = 0;
25817
25818     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2770
25819  *         stderr_h, stderr_f = tempfile.mkstemp()
25820  *         stderr_save = Outs( sys.stderr.fileno() )
25821  *         stderr_save.setfd( stderr_h )             # <<<<<<<<<<<<<<
25822  * 
25823  *     if catch_stdout:
25824  */
25825     __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;}
25826     __Pyx_GOTREF(__pyx_t_3);
25827     __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;}
25828     __Pyx_GOTREF(__pyx_t_1);
25829     __Pyx_INCREF(__pyx_v_stderr_h);
25830     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_stderr_h);
25831     __Pyx_GIVEREF(__pyx_v_stderr_h);
25832     __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;}
25833     __Pyx_GOTREF(__pyx_t_4);
25834     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25835     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25836     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
25837     goto __pyx_L8;
25838   }
25839   __pyx_L8:;
25840
25841   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2772
25842  *         stderr_save.setfd( stderr_h )
25843  * 
25844  *     if catch_stdout:             # <<<<<<<<<<<<<<
25845  *         stdout_h, stdout_f = tempfile.mkstemp()
25846  *         stdout_save = Outs( sys.stdout.fileno() )
25847  */
25848   __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;}
25849   if (__pyx_t_5) {
25850
25851     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2773
25852  * 
25853  *     if catch_stdout:
25854  *         stdout_h, stdout_f = tempfile.mkstemp()             # <<<<<<<<<<<<<<
25855  *         stdout_save = Outs( sys.stdout.fileno() )
25856  *         stdout_save.setfd( stdout_h )
25857  */
25858     __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;}
25859     __Pyx_GOTREF(__pyx_t_4);
25860     __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;}
25861     __Pyx_GOTREF(__pyx_t_1);
25862     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
25863     __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;}
25864     __Pyx_GOTREF(__pyx_t_4);
25865     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25866     if (PyTuple_CheckExact(__pyx_t_4) && likely(PyTuple_GET_SIZE(__pyx_t_4) == 2)) {
25867       PyObject* tuple = __pyx_t_4;
25868       __pyx_t_1 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_1);
25869       __pyx_t_3 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_3);
25870       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
25871       __Pyx_DECREF(__pyx_v_stdout_h);
25872       __pyx_v_stdout_h = __pyx_t_1;
25873       __pyx_t_1 = 0;
25874       __Pyx_DECREF(__pyx_v_stdout_f);
25875       __pyx_v_stdout_f = __pyx_t_3;
25876       __pyx_t_3 = 0;
25877     } else {
25878       __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;}
25879       __Pyx_GOTREF(__pyx_t_6);
25880       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
25881       __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;}
25882       __Pyx_GOTREF(__pyx_t_1);
25883       __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;}
25884       __Pyx_GOTREF(__pyx_t_3);
25885       if (__Pyx_EndUnpack(__pyx_t_6, 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
25886       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
25887       __Pyx_DECREF(__pyx_v_stdout_h);
25888       __pyx_v_stdout_h = __pyx_t_1;
25889       __pyx_t_1 = 0;
25890       __Pyx_DECREF(__pyx_v_stdout_f);
25891       __pyx_v_stdout_f = __pyx_t_3;
25892       __pyx_t_3 = 0;
25893     }
25894
25895     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2774
25896  *     if catch_stdout:
25897  *         stdout_h, stdout_f = tempfile.mkstemp()
25898  *         stdout_save = Outs( sys.stdout.fileno() )             # <<<<<<<<<<<<<<
25899  *         stdout_save.setfd( stdout_h )
25900  * 
25901  */
25902     __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;}
25903     __Pyx_GOTREF(__pyx_t_4);
25904     __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;}
25905     __Pyx_GOTREF(__pyx_t_3);
25906     __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;}
25907     __Pyx_GOTREF(__pyx_t_1);
25908     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25909     __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;}
25910     __Pyx_GOTREF(__pyx_t_3);
25911     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25912     __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;}
25913     __Pyx_GOTREF(__pyx_t_1);
25914     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25915     __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;}
25916     __Pyx_GOTREF(__pyx_t_3);
25917     PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
25918     __Pyx_GIVEREF(__pyx_t_1);
25919     __pyx_t_1 = 0;
25920     __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;}
25921     __Pyx_GOTREF(__pyx_t_1);
25922     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
25923     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25924     __Pyx_DECREF(__pyx_v_stdout_save);
25925     __pyx_v_stdout_save = __pyx_t_1;
25926     __pyx_t_1 = 0;
25927
25928     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2775
25929  *         stdout_h, stdout_f = tempfile.mkstemp()
25930  *         stdout_save = Outs( sys.stdout.fileno() )
25931  *         stdout_save.setfd( stdout_h )             # <<<<<<<<<<<<<<
25932  * 
25933  *         # patch for `samtools view`
25934  */
25935     __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;}
25936     __Pyx_GOTREF(__pyx_t_1);
25937     __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;}
25938     __Pyx_GOTREF(__pyx_t_3);
25939     __Pyx_INCREF(__pyx_v_stdout_h);
25940     PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_stdout_h);
25941     __Pyx_GIVEREF(__pyx_v_stdout_h);
25942     __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;}
25943     __Pyx_GOTREF(__pyx_t_4);
25944     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
25945     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25946     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
25947
25948     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2780
25949  *         # samtools `view` closes stdout, from which I can not
25950  *         # recover. Thus redirect output to file with -o option.
25951  *         if method == "view":             # <<<<<<<<<<<<<<
25952  *             if "-o" in args: raise ValueError("option -o is forbidden in samtools view")
25953  *             args = ( "-o", stdout_f ) + args
25954  */
25955     __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;}
25956     __Pyx_GOTREF(__pyx_t_4);
25957     __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;}
25958     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
25959     if (__pyx_t_5) {
25960
25961       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2781
25962  *         # recover. Thus redirect output to file with -o option.
25963  *         if method == "view":
25964  *             if "-o" in args: raise ValueError("option -o is forbidden in samtools view")             # <<<<<<<<<<<<<<
25965  *             args = ( "-o", stdout_f ) + args
25966  * 
25967  */
25968       __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;}
25969       if (__pyx_t_5) {
25970         __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;}
25971         __Pyx_GOTREF(__pyx_t_4);
25972         __Pyx_INCREF(((PyObject *)__pyx_kp_s_102));
25973         PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_102));
25974         __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_102));
25975         __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;}
25976         __Pyx_GOTREF(__pyx_t_3);
25977         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
25978         __Pyx_Raise(__pyx_t_3, 0, 0);
25979         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
25980         {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
25981         goto __pyx_L11;
25982       }
25983       __pyx_L11:;
25984
25985       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2782
25986  *         if method == "view":
25987  *             if "-o" in args: raise ValueError("option -o is forbidden in samtools view")
25988  *             args = ( "-o", stdout_f ) + args             # <<<<<<<<<<<<<<
25989  * 
25990  * 
25991  */
25992       __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;}
25993       __Pyx_GOTREF(__pyx_t_3);
25994       __Pyx_INCREF(((PyObject *)__pyx_kp_s_101));
25995       PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_kp_s_101));
25996       __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_101));
25997       __Pyx_INCREF(__pyx_v_stdout_f);
25998       PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_stdout_f);
25999       __Pyx_GIVEREF(__pyx_v_stdout_f);
26000       __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;}
26001       __Pyx_GOTREF(__pyx_t_4);
26002       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
26003       __Pyx_DECREF(__pyx_v_args);
26004       __pyx_v_args = __pyx_t_4;
26005       __pyx_t_4 = 0;
26006       goto __pyx_L10;
26007     }
26008     __pyx_L10:;
26009     goto __pyx_L9;
26010   }
26011   __pyx_L9:;
26012
26013   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2789
26014  *     cdef int i, n, retval
26015  * 
26016  *     n = len(args)             # <<<<<<<<<<<<<<
26017  *     # allocate two more for first (dummy) argument (contains command)
26018  *     cargs = <char**>calloc( n+2, sizeof( char *) )
26019  */
26020   __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;}
26021   __pyx_v_n = __pyx_t_7;
26022
26023   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2791
26024  *     n = len(args)
26025  *     # allocate two more for first (dummy) argument (contains command)
26026  *     cargs = <char**>calloc( n+2, sizeof( char *) )             # <<<<<<<<<<<<<<
26027  *     cargs[0] = "samtools"
26028  *     cargs[1] = method
26029  */
26030   __pyx_v_cargs = ((char **)calloc((__pyx_v_n + 2), (sizeof(char *))));
26031
26032   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2792
26033  *     # allocate two more for first (dummy) argument (contains command)
26034  *     cargs = <char**>calloc( n+2, sizeof( char *) )
26035  *     cargs[0] = "samtools"             # <<<<<<<<<<<<<<
26036  *     cargs[1] = method
26037  *     for i from 0 <= i < n: cargs[i+2] = args[i]
26038  */
26039   (__pyx_v_cargs[0]) = __pyx_k__samtools;
26040
26041   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2793
26042  *     cargs = <char**>calloc( n+2, sizeof( char *) )
26043  *     cargs[0] = "samtools"
26044  *     cargs[1] = method             # <<<<<<<<<<<<<<
26045  *     for i from 0 <= i < n: cargs[i+2] = args[i]
26046  *     retval = pysam_dispatch(n+2, cargs)
26047  */
26048   __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;}
26049   (__pyx_v_cargs[1]) = __pyx_t_8;
26050
26051   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2794
26052  *     cargs[0] = "samtools"
26053  *     cargs[1] = method
26054  *     for i from 0 <= i < n: cargs[i+2] = args[i]             # <<<<<<<<<<<<<<
26055  *     retval = pysam_dispatch(n+2, cargs)
26056  *     free( cargs )
26057  */
26058   __pyx_t_9 = __pyx_v_n;
26059   for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_9; __pyx_v_i++) {
26060     __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;}
26061     __Pyx_GOTREF(__pyx_t_4);
26062     __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;}
26063     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
26064     (__pyx_v_cargs[(__pyx_v_i + 2)]) = __pyx_t_8;
26065   }
26066
26067   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2795
26068  *     cargs[1] = method
26069  *     for i from 0 <= i < n: cargs[i+2] = args[i]
26070  *     retval = pysam_dispatch(n+2, cargs)             # <<<<<<<<<<<<<<
26071  *     free( cargs )
26072  * 
26073  */
26074   __pyx_v_retval = pysam_dispatch((__pyx_v_n + 2), __pyx_v_cargs);
26075
26076   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2796
26077  *     for i from 0 <= i < n: cargs[i+2] = args[i]
26078  *     retval = pysam_dispatch(n+2, cargs)
26079  *     free( cargs )             # <<<<<<<<<<<<<<
26080  * 
26081  *     # restore stdout/stderr. This will also flush, so
26082  */
26083   free(__pyx_v_cargs);
26084
26085   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2800
26086  *     # restore stdout/stderr. This will also flush, so
26087  *     # needs to be before reading back the file contents
26088  *     if catch_stdout:             # <<<<<<<<<<<<<<
26089  *         stdout_save.restore()
26090  *         out_stdout = open( stdout_f, "r").readlines()
26091  */
26092   __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;}
26093   if (__pyx_t_5) {
26094
26095     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2801
26096  *     # needs to be before reading back the file contents
26097  *     if catch_stdout:
26098  *         stdout_save.restore()             # <<<<<<<<<<<<<<
26099  *         out_stdout = open( stdout_f, "r").readlines()
26100  *         os.remove( stdout_f )
26101  */
26102     __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;}
26103     __Pyx_GOTREF(__pyx_t_4);
26104     __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;}
26105     __Pyx_GOTREF(__pyx_t_3);
26106     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
26107     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
26108
26109     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2802
26110  *     if catch_stdout:
26111  *         stdout_save.restore()
26112  *         out_stdout = open( stdout_f, "r").readlines()             # <<<<<<<<<<<<<<
26113  *         os.remove( stdout_f )
26114  *     else:
26115  */
26116     __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;}
26117     __Pyx_GOTREF(__pyx_t_3);
26118     __Pyx_INCREF(__pyx_v_stdout_f);
26119     PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_stdout_f);
26120     __Pyx_GIVEREF(__pyx_v_stdout_f);
26121     __Pyx_INCREF(((PyObject *)__pyx_n_s__r));
26122     PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_n_s__r));
26123     __Pyx_GIVEREF(((PyObject *)__pyx_n_s__r));
26124     __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;}
26125     __Pyx_GOTREF(__pyx_t_4);
26126     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
26127     __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;}
26128     __Pyx_GOTREF(__pyx_t_3);
26129     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
26130     __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;}
26131     __Pyx_GOTREF(__pyx_t_4);
26132     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
26133     __Pyx_DECREF(__pyx_v_out_stdout);
26134     __pyx_v_out_stdout = __pyx_t_4;
26135     __pyx_t_4 = 0;
26136
26137     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2803
26138  *         stdout_save.restore()
26139  *         out_stdout = open( stdout_f, "r").readlines()
26140  *         os.remove( stdout_f )             # <<<<<<<<<<<<<<
26141  *     else:
26142  *         out_stdout = []
26143  */
26144     __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;}
26145     __Pyx_GOTREF(__pyx_t_4);
26146     __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;}
26147     __Pyx_GOTREF(__pyx_t_3);
26148     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
26149     __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;}
26150     __Pyx_GOTREF(__pyx_t_4);
26151     __Pyx_INCREF(__pyx_v_stdout_f);
26152     PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_stdout_f);
26153     __Pyx_GIVEREF(__pyx_v_stdout_f);
26154     __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;}
26155     __Pyx_GOTREF(__pyx_t_1);
26156     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
26157     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
26158     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
26159     goto __pyx_L14;
26160   }
26161   /*else*/ {
26162
26163     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2805
26164  *         os.remove( stdout_f )
26165  *     else:
26166  *         out_stdout = []             # <<<<<<<<<<<<<<
26167  * 
26168  *     if catch_stderr:
26169  */
26170     __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;}
26171     __Pyx_GOTREF(((PyObject *)__pyx_t_1));
26172     __Pyx_DECREF(__pyx_v_out_stdout);
26173     __pyx_v_out_stdout = ((PyObject *)__pyx_t_1);
26174     __pyx_t_1 = 0;
26175   }
26176   __pyx_L14:;
26177
26178   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2807
26179  *         out_stdout = []
26180  * 
26181  *     if catch_stderr:             # <<<<<<<<<<<<<<
26182  *         stderr_save.restore()
26183  *         out_stderr = open( stderr_f, "r").readlines()
26184  */
26185   __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;}
26186   if (__pyx_t_5) {
26187
26188     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2808
26189  * 
26190  *     if catch_stderr:
26191  *         stderr_save.restore()             # <<<<<<<<<<<<<<
26192  *         out_stderr = open( stderr_f, "r").readlines()
26193  *         os.remove( stderr_f )
26194  */
26195     __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;}
26196     __Pyx_GOTREF(__pyx_t_1);
26197     __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;}
26198     __Pyx_GOTREF(__pyx_t_4);
26199     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
26200     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
26201
26202     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2809
26203  *     if catch_stderr:
26204  *         stderr_save.restore()
26205  *         out_stderr = open( stderr_f, "r").readlines()             # <<<<<<<<<<<<<<
26206  *         os.remove( stderr_f )
26207  *     else:
26208  */
26209     __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;}
26210     __Pyx_GOTREF(__pyx_t_4);
26211     __Pyx_INCREF(__pyx_v_stderr_f);
26212     PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_stderr_f);
26213     __Pyx_GIVEREF(__pyx_v_stderr_f);
26214     __Pyx_INCREF(((PyObject *)__pyx_n_s__r));
26215     PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_n_s__r));
26216     __Pyx_GIVEREF(((PyObject *)__pyx_n_s__r));
26217     __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;}
26218     __Pyx_GOTREF(__pyx_t_1);
26219     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
26220     __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;}
26221     __Pyx_GOTREF(__pyx_t_4);
26222     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
26223     __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;}
26224     __Pyx_GOTREF(__pyx_t_1);
26225     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
26226     __Pyx_DECREF(__pyx_v_out_stderr);
26227     __pyx_v_out_stderr = __pyx_t_1;
26228     __pyx_t_1 = 0;
26229
26230     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2810
26231  *         stderr_save.restore()
26232  *         out_stderr = open( stderr_f, "r").readlines()
26233  *         os.remove( stderr_f )             # <<<<<<<<<<<<<<
26234  *     else:
26235  *         out_stderr = []
26236  */
26237     __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;}
26238     __Pyx_GOTREF(__pyx_t_1);
26239     __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;}
26240     __Pyx_GOTREF(__pyx_t_4);
26241     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
26242     __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;}
26243     __Pyx_GOTREF(__pyx_t_1);
26244     __Pyx_INCREF(__pyx_v_stderr_f);
26245     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_stderr_f);
26246     __Pyx_GIVEREF(__pyx_v_stderr_f);
26247     __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;}
26248     __Pyx_GOTREF(__pyx_t_3);
26249     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
26250     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
26251     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
26252     goto __pyx_L15;
26253   }
26254   /*else*/ {
26255
26256     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2812
26257  *         os.remove( stderr_f )
26258  *     else:
26259  *         out_stderr = []             # <<<<<<<<<<<<<<
26260  * 
26261  *     return retval, out_stderr, out_stdout
26262  */
26263     __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;}
26264     __Pyx_GOTREF(((PyObject *)__pyx_t_3));
26265     __Pyx_DECREF(__pyx_v_out_stderr);
26266     __pyx_v_out_stderr = ((PyObject *)__pyx_t_3);
26267     __pyx_t_3 = 0;
26268   }
26269   __pyx_L15:;
26270
26271   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2814
26272  *         out_stderr = []
26273  * 
26274  *     return retval, out_stderr, out_stdout             # <<<<<<<<<<<<<<
26275  * 
26276  * cdef class SNPCall:
26277  */
26278   __Pyx_XDECREF(__pyx_r);
26279   __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;}
26280   __Pyx_GOTREF(__pyx_t_3);
26281   __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;}
26282   __Pyx_GOTREF(__pyx_t_1);
26283   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
26284   __Pyx_GIVEREF(__pyx_t_3);
26285   __Pyx_INCREF(__pyx_v_out_stderr);
26286   PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_out_stderr);
26287   __Pyx_GIVEREF(__pyx_v_out_stderr);
26288   __Pyx_INCREF(__pyx_v_out_stdout);
26289   PyTuple_SET_ITEM(__pyx_t_1, 2, __pyx_v_out_stdout);
26290   __Pyx_GIVEREF(__pyx_v_out_stdout);
26291   __pyx_t_3 = 0;
26292   __pyx_r = __pyx_t_1;
26293   __pyx_t_1 = 0;
26294   goto __pyx_L0;
26295
26296   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
26297   goto __pyx_L0;
26298   __pyx_L1_error:;
26299   __Pyx_XDECREF(__pyx_t_1);
26300   __Pyx_XDECREF(__pyx_t_3);
26301   __Pyx_XDECREF(__pyx_t_4);
26302   __Pyx_XDECREF(__pyx_t_6);
26303   __Pyx_AddTraceback("csamtools._samtools_dispatch");
26304   __pyx_r = NULL;
26305   __pyx_L0:;
26306   __Pyx_DECREF(__pyx_v_stderr_h);
26307   __Pyx_DECREF(__pyx_v_stderr_f);
26308   __Pyx_DECREF(__pyx_v_stderr_save);
26309   __Pyx_DECREF(__pyx_v_stdout_h);
26310   __Pyx_DECREF(__pyx_v_stdout_f);
26311   __Pyx_DECREF(__pyx_v_stdout_save);
26312   __Pyx_DECREF(__pyx_v_out_stdout);
26313   __Pyx_DECREF(__pyx_v_out_stderr);
26314   __Pyx_DECREF(__pyx_v_args);
26315   __Pyx_XGIVEREF(__pyx_r);
26316   __Pyx_TraceReturn(__pyx_r);
26317   __Pyx_RefNannyFinishContext();
26318   return __pyx_r;
26319 }
26320
26321 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2829
26322  *     property tid:
26323  *         '''the chromosome ID as is defined in the header'''
26324  *         def __get__(self):             # <<<<<<<<<<<<<<
26325  *             return self._tid
26326  * 
26327  */
26328
26329 static PyObject *__pyx_pf_9csamtools_7SNPCall_3tid___get__(PyObject *__pyx_v_self); /*proto*/
26330 static PyObject *__pyx_pf_9csamtools_7SNPCall_3tid___get__(PyObject *__pyx_v_self) {
26331   PyObject *__pyx_r = NULL;
26332   PyObject *__pyx_t_1 = NULL;
26333   __Pyx_TraceDeclarations
26334   __Pyx_RefNannySetupContext("__get__");
26335   __Pyx_TraceCall("__get__", __pyx_f[0], 2829);
26336
26337   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2830
26338  *         '''the chromosome ID as is defined in the header'''
26339  *         def __get__(self):
26340  *             return self._tid             # <<<<<<<<<<<<<<
26341  * 
26342  *     property pos:
26343  */
26344   __Pyx_XDECREF(__pyx_r);
26345   __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;}
26346   __Pyx_GOTREF(__pyx_t_1);
26347   __pyx_r = __pyx_t_1;
26348   __pyx_t_1 = 0;
26349   goto __pyx_L0;
26350
26351   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
26352   goto __pyx_L0;
26353   __pyx_L1_error:;
26354   __Pyx_XDECREF(__pyx_t_1);
26355   __Pyx_AddTraceback("csamtools.SNPCall.tid.__get__");
26356   __pyx_r = NULL;
26357   __pyx_L0:;
26358   __Pyx_XGIVEREF(__pyx_r);
26359   __Pyx_TraceReturn(__pyx_r);
26360   __Pyx_RefNannyFinishContext();
26361   return __pyx_r;
26362 }
26363
26364 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2834
26365  *     property pos:
26366  *        '''nucleotide position of SNP.'''
26367  *        def __get__(self): return self._pos             # <<<<<<<<<<<<<<
26368  * 
26369  *     property reference_base:
26370  */
26371
26372 static PyObject *__pyx_pf_9csamtools_7SNPCall_3pos___get__(PyObject *__pyx_v_self); /*proto*/
26373 static PyObject *__pyx_pf_9csamtools_7SNPCall_3pos___get__(PyObject *__pyx_v_self) {
26374   PyObject *__pyx_r = NULL;
26375   PyObject *__pyx_t_1 = NULL;
26376   __Pyx_TraceDeclarations
26377   __Pyx_RefNannySetupContext("__get__");
26378   __Pyx_TraceCall("__get__", __pyx_f[0], 2834);
26379   __Pyx_XDECREF(__pyx_r);
26380   __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;}
26381   __Pyx_GOTREF(__pyx_t_1);
26382   __pyx_r = __pyx_t_1;
26383   __pyx_t_1 = 0;
26384   goto __pyx_L0;
26385
26386   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
26387   goto __pyx_L0;
26388   __pyx_L1_error:;
26389   __Pyx_XDECREF(__pyx_t_1);
26390   __Pyx_AddTraceback("csamtools.SNPCall.pos.__get__");
26391   __pyx_r = NULL;
26392   __pyx_L0:;
26393   __Pyx_XGIVEREF(__pyx_r);
26394   __Pyx_TraceReturn(__pyx_r);
26395   __Pyx_RefNannyFinishContext();
26396   return __pyx_r;
26397 }
26398
26399 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2838
26400  *     property reference_base:
26401  *        '''reference base at pos. ``N`` if no reference sequence supplied.'''
26402  *        def __get__(self): return PyString_FromStringAndSize( &self._reference_base, 1 )             # <<<<<<<<<<<<<<
26403  * 
26404  *     property genotype:
26405  */
26406
26407 static PyObject *__pyx_pf_9csamtools_7SNPCall_14reference_base___get__(PyObject *__pyx_v_self); /*proto*/
26408 static PyObject *__pyx_pf_9csamtools_7SNPCall_14reference_base___get__(PyObject *__pyx_v_self) {
26409   PyObject *__pyx_r = NULL;
26410   PyObject *__pyx_t_1 = NULL;
26411   __Pyx_TraceDeclarations
26412   __Pyx_RefNannySetupContext("__get__");
26413   __Pyx_TraceCall("__get__", __pyx_f[0], 2838);
26414   __Pyx_XDECREF(__pyx_r);
26415   __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;}
26416   __Pyx_GOTREF(__pyx_t_1);
26417   __pyx_r = __pyx_t_1;
26418   __pyx_t_1 = 0;
26419   goto __pyx_L0;
26420
26421   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
26422   goto __pyx_L0;
26423   __pyx_L1_error:;
26424   __Pyx_XDECREF(__pyx_t_1);
26425   __Pyx_AddTraceback("csamtools.SNPCall.reference_base.__get__");
26426   __pyx_r = NULL;
26427   __pyx_L0:;
26428   __Pyx_XGIVEREF(__pyx_r);
26429   __Pyx_TraceReturn(__pyx_r);
26430   __Pyx_RefNannyFinishContext();
26431   return __pyx_r;
26432 }
26433
26434 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2842
26435  *     property genotype:
26436  *        '''the genotype called.'''
26437  *        def __get__(self): return PyString_FromStringAndSize( &self._genotype, 1 )             # <<<<<<<<<<<<<<
26438  * 
26439  *     property consensus_quality:
26440  */
26441
26442 static PyObject *__pyx_pf_9csamtools_7SNPCall_8genotype___get__(PyObject *__pyx_v_self); /*proto*/
26443 static PyObject *__pyx_pf_9csamtools_7SNPCall_8genotype___get__(PyObject *__pyx_v_self) {
26444   PyObject *__pyx_r = NULL;
26445   PyObject *__pyx_t_1 = NULL;
26446   __Pyx_TraceDeclarations
26447   __Pyx_RefNannySetupContext("__get__");
26448   __Pyx_TraceCall("__get__", __pyx_f[0], 2842);
26449   __Pyx_XDECREF(__pyx_r);
26450   __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;}
26451   __Pyx_GOTREF(__pyx_t_1);
26452   __pyx_r = __pyx_t_1;
26453   __pyx_t_1 = 0;
26454   goto __pyx_L0;
26455
26456   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
26457   goto __pyx_L0;
26458   __pyx_L1_error:;
26459   __Pyx_XDECREF(__pyx_t_1);
26460   __Pyx_AddTraceback("csamtools.SNPCall.genotype.__get__");
26461   __pyx_r = NULL;
26462   __pyx_L0:;
26463   __Pyx_XGIVEREF(__pyx_r);
26464   __Pyx_TraceReturn(__pyx_r);
26465   __Pyx_RefNannyFinishContext();
26466   return __pyx_r;
26467 }
26468
26469 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2846
26470  *     property consensus_quality:
26471  *        '''the genotype quality (Phred-scaled).'''
26472  *        def __get__(self): return self._consensus_quality             # <<<<<<<<<<<<<<
26473  * 
26474  *     property snp_quality:
26475  */
26476
26477 static PyObject *__pyx_pf_9csamtools_7SNPCall_17consensus_quality___get__(PyObject *__pyx_v_self); /*proto*/
26478 static PyObject *__pyx_pf_9csamtools_7SNPCall_17consensus_quality___get__(PyObject *__pyx_v_self) {
26479   PyObject *__pyx_r = NULL;
26480   PyObject *__pyx_t_1 = NULL;
26481   __Pyx_TraceDeclarations
26482   __Pyx_RefNannySetupContext("__get__");
26483   __Pyx_TraceCall("__get__", __pyx_f[0], 2846);
26484   __Pyx_XDECREF(__pyx_r);
26485   __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;}
26486   __Pyx_GOTREF(__pyx_t_1);
26487   __pyx_r = __pyx_t_1;
26488   __pyx_t_1 = 0;
26489   goto __pyx_L0;
26490
26491   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
26492   goto __pyx_L0;
26493   __pyx_L1_error:;
26494   __Pyx_XDECREF(__pyx_t_1);
26495   __Pyx_AddTraceback("csamtools.SNPCall.consensus_quality.__get__");
26496   __pyx_r = NULL;
26497   __pyx_L0:;
26498   __Pyx_XGIVEREF(__pyx_r);
26499   __Pyx_TraceReturn(__pyx_r);
26500   __Pyx_RefNannyFinishContext();
26501   return __pyx_r;
26502 }
26503
26504 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2850
26505  *     property snp_quality:
26506  *        '''the snp quality (Phred scaled) - probability of consensus being identical to reference sequence.'''
26507  *        def __get__(self): return self._snp_quality             # <<<<<<<<<<<<<<
26508  * 
26509  *     property mapping_quality:
26510  */
26511
26512 static PyObject *__pyx_pf_9csamtools_7SNPCall_11snp_quality___get__(PyObject *__pyx_v_self); /*proto*/
26513 static PyObject *__pyx_pf_9csamtools_7SNPCall_11snp_quality___get__(PyObject *__pyx_v_self) {
26514   PyObject *__pyx_r = NULL;
26515   PyObject *__pyx_t_1 = NULL;
26516   __Pyx_TraceDeclarations
26517   __Pyx_RefNannySetupContext("__get__");
26518   __Pyx_TraceCall("__get__", __pyx_f[0], 2850);
26519   __Pyx_XDECREF(__pyx_r);
26520   __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;}
26521   __Pyx_GOTREF(__pyx_t_1);
26522   __pyx_r = __pyx_t_1;
26523   __pyx_t_1 = 0;
26524   goto __pyx_L0;
26525
26526   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
26527   goto __pyx_L0;
26528   __pyx_L1_error:;
26529   __Pyx_XDECREF(__pyx_t_1);
26530   __Pyx_AddTraceback("csamtools.SNPCall.snp_quality.__get__");
26531   __pyx_r = NULL;
26532   __pyx_L0:;
26533   __Pyx_XGIVEREF(__pyx_r);
26534   __Pyx_TraceReturn(__pyx_r);
26535   __Pyx_RefNannyFinishContext();
26536   return __pyx_r;
26537 }
26538
26539 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2854
26540  *     property mapping_quality:
26541  *        '''the root mean square (rms) of the mapping quality of all reads involved in the call.'''
26542  *        def __get__(self): return self._rms_mapping_quality             # <<<<<<<<<<<<<<
26543  * 
26544  *     property coverage:
26545  */
26546
26547 static PyObject *__pyx_pf_9csamtools_7SNPCall_15mapping_quality___get__(PyObject *__pyx_v_self); /*proto*/
26548 static PyObject *__pyx_pf_9csamtools_7SNPCall_15mapping_quality___get__(PyObject *__pyx_v_self) {
26549   PyObject *__pyx_r = NULL;
26550   PyObject *__pyx_t_1 = NULL;
26551   __Pyx_TraceDeclarations
26552   __Pyx_RefNannySetupContext("__get__");
26553   __Pyx_TraceCall("__get__", __pyx_f[0], 2854);
26554   __Pyx_XDECREF(__pyx_r);
26555   __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;}
26556   __Pyx_GOTREF(__pyx_t_1);
26557   __pyx_r = __pyx_t_1;
26558   __pyx_t_1 = 0;
26559   goto __pyx_L0;
26560
26561   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
26562   goto __pyx_L0;
26563   __pyx_L1_error:;
26564   __Pyx_XDECREF(__pyx_t_1);
26565   __Pyx_AddTraceback("csamtools.SNPCall.mapping_quality.__get__");
26566   __pyx_r = NULL;
26567   __pyx_L0:;
26568   __Pyx_XGIVEREF(__pyx_r);
26569   __Pyx_TraceReturn(__pyx_r);
26570   __Pyx_RefNannyFinishContext();
26571   return __pyx_r;
26572 }
26573
26574 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2858
26575  *     property coverage:
26576  *        '''coverage or read depth - the number of reads involved in the call.'''
26577  *        def __get__(self): return self._coverage             # <<<<<<<<<<<<<<
26578  * 
26579  *     def __str__(self):
26580  */
26581
26582 static PyObject *__pyx_pf_9csamtools_7SNPCall_8coverage___get__(PyObject *__pyx_v_self); /*proto*/
26583 static PyObject *__pyx_pf_9csamtools_7SNPCall_8coverage___get__(PyObject *__pyx_v_self) {
26584   PyObject *__pyx_r = NULL;
26585   PyObject *__pyx_t_1 = NULL;
26586   __Pyx_TraceDeclarations
26587   __Pyx_RefNannySetupContext("__get__");
26588   __Pyx_TraceCall("__get__", __pyx_f[0], 2858);
26589   __Pyx_XDECREF(__pyx_r);
26590   __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;}
26591   __Pyx_GOTREF(__pyx_t_1);
26592   __pyx_r = __pyx_t_1;
26593   __pyx_t_1 = 0;
26594   goto __pyx_L0;
26595
26596   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
26597   goto __pyx_L0;
26598   __pyx_L1_error:;
26599   __Pyx_XDECREF(__pyx_t_1);
26600   __Pyx_AddTraceback("csamtools.SNPCall.coverage.__get__");
26601   __pyx_r = NULL;
26602   __pyx_L0:;
26603   __Pyx_XGIVEREF(__pyx_r);
26604   __Pyx_TraceReturn(__pyx_r);
26605   __Pyx_RefNannyFinishContext();
26606   return __pyx_r;
26607 }
26608
26609 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2860
26610  *        def __get__(self): return self._coverage
26611  * 
26612  *     def __str__(self):             # <<<<<<<<<<<<<<
26613  * 
26614  *         return "\t".join( map(str, (
26615  */
26616
26617 static PyObject *__pyx_pf_9csamtools_7SNPCall___str__(PyObject *__pyx_v_self); /*proto*/
26618 static PyObject *__pyx_pf_9csamtools_7SNPCall___str__(PyObject *__pyx_v_self) {
26619   PyObject *__pyx_r = NULL;
26620   PyObject *__pyx_t_1 = NULL;
26621   PyObject *__pyx_t_2 = NULL;
26622   PyObject *__pyx_t_3 = NULL;
26623   PyObject *__pyx_t_4 = NULL;
26624   PyObject *__pyx_t_5 = NULL;
26625   PyObject *__pyx_t_6 = NULL;
26626   PyObject *__pyx_t_7 = NULL;
26627   PyObject *__pyx_t_8 = NULL;
26628   PyObject *__pyx_t_9 = NULL;
26629   PyObject *__pyx_t_10 = NULL;
26630   __Pyx_TraceDeclarations
26631   __Pyx_RefNannySetupContext("__str__");
26632   __Pyx_TraceCall("__str__", __pyx_f[0], 2860);
26633
26634   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2862
26635  *     def __str__(self):
26636  * 
26637  *         return "\t".join( map(str, (             # <<<<<<<<<<<<<<
26638  *                     self.tid,
26639  *                     self.pos,
26640  */
26641   __Pyx_XDECREF(__pyx_r);
26642   __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;}
26643   __Pyx_GOTREF(__pyx_t_1);
26644
26645   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2863
26646  * 
26647  *         return "\t".join( map(str, (
26648  *                     self.tid,             # <<<<<<<<<<<<<<
26649  *                     self.pos,
26650  *                     self.reference_base,
26651  */
26652   __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;}
26653   __Pyx_GOTREF(__pyx_t_2);
26654
26655   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2864
26656  *         return "\t".join( map(str, (
26657  *                     self.tid,
26658  *                     self.pos,             # <<<<<<<<<<<<<<
26659  *                     self.reference_base,
26660  *                     self.genotype,
26661  */
26662   __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;}
26663   __Pyx_GOTREF(__pyx_t_3);
26664
26665   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2865
26666  *                     self.tid,
26667  *                     self.pos,
26668  *                     self.reference_base,             # <<<<<<<<<<<<<<
26669  *                     self.genotype,
26670  *                     self.consensus_quality,
26671  */
26672   __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;}
26673   __Pyx_GOTREF(__pyx_t_4);
26674
26675   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2866
26676  *                     self.pos,
26677  *                     self.reference_base,
26678  *                     self.genotype,             # <<<<<<<<<<<<<<
26679  *                     self.consensus_quality,
26680  *                     self.snp_quality,
26681  */
26682   __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;}
26683   __Pyx_GOTREF(__pyx_t_5);
26684
26685   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2867
26686  *                     self.reference_base,
26687  *                     self.genotype,
26688  *                     self.consensus_quality,             # <<<<<<<<<<<<<<
26689  *                     self.snp_quality,
26690  *                     self.mapping_quality,
26691  */
26692   __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;}
26693   __Pyx_GOTREF(__pyx_t_6);
26694
26695   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2868
26696  *                     self.genotype,
26697  *                     self.consensus_quality,
26698  *                     self.snp_quality,             # <<<<<<<<<<<<<<
26699  *                     self.mapping_quality,
26700  *                     self.coverage ) ) )
26701  */
26702   __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;}
26703   __Pyx_GOTREF(__pyx_t_7);
26704
26705   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2869
26706  *                     self.consensus_quality,
26707  *                     self.snp_quality,
26708  *                     self.mapping_quality,             # <<<<<<<<<<<<<<
26709  *                     self.coverage ) ) )
26710  * 
26711  */
26712   __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;}
26713   __Pyx_GOTREF(__pyx_t_8);
26714
26715   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2870
26716  *                     self.snp_quality,
26717  *                     self.mapping_quality,
26718  *                     self.coverage ) ) )             # <<<<<<<<<<<<<<
26719  * 
26720  * 
26721  */
26722   __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;}
26723   __Pyx_GOTREF(__pyx_t_9);
26724   __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;}
26725   __Pyx_GOTREF(__pyx_t_10);
26726   PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_2);
26727   __Pyx_GIVEREF(__pyx_t_2);
26728   PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_3);
26729   __Pyx_GIVEREF(__pyx_t_3);
26730   PyTuple_SET_ITEM(__pyx_t_10, 2, __pyx_t_4);
26731   __Pyx_GIVEREF(__pyx_t_4);
26732   PyTuple_SET_ITEM(__pyx_t_10, 3, __pyx_t_5);
26733   __Pyx_GIVEREF(__pyx_t_5);
26734   PyTuple_SET_ITEM(__pyx_t_10, 4, __pyx_t_6);
26735   __Pyx_GIVEREF(__pyx_t_6);
26736   PyTuple_SET_ITEM(__pyx_t_10, 5, __pyx_t_7);
26737   __Pyx_GIVEREF(__pyx_t_7);
26738   PyTuple_SET_ITEM(__pyx_t_10, 6, __pyx_t_8);
26739   __Pyx_GIVEREF(__pyx_t_8);
26740   PyTuple_SET_ITEM(__pyx_t_10, 7, __pyx_t_9);
26741   __Pyx_GIVEREF(__pyx_t_9);
26742   __pyx_t_2 = 0;
26743   __pyx_t_3 = 0;
26744   __pyx_t_4 = 0;
26745   __pyx_t_5 = 0;
26746   __pyx_t_6 = 0;
26747   __pyx_t_7 = 0;
26748   __pyx_t_8 = 0;
26749   __pyx_t_9 = 0;
26750   __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;}
26751   __Pyx_GOTREF(__pyx_t_9);
26752   __Pyx_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
26753   PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)((PyObject*)&PyString_Type)));
26754   __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
26755   PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_10);
26756   __Pyx_GIVEREF(__pyx_t_10);
26757   __pyx_t_10 = 0;
26758   __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;}
26759   __Pyx_GOTREF(__pyx_t_10);
26760   __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
26761   __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;}
26762   __Pyx_GOTREF(__pyx_t_9);
26763   PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_10);
26764   __Pyx_GIVEREF(__pyx_t_10);
26765   __pyx_t_10 = 0;
26766   __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;}
26767   __Pyx_GOTREF(__pyx_t_10);
26768   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
26769   __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
26770   __pyx_r = __pyx_t_10;
26771   __pyx_t_10 = 0;
26772   goto __pyx_L0;
26773
26774   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
26775   goto __pyx_L0;
26776   __pyx_L1_error:;
26777   __Pyx_XDECREF(__pyx_t_1);
26778   __Pyx_XDECREF(__pyx_t_2);
26779   __Pyx_XDECREF(__pyx_t_3);
26780   __Pyx_XDECREF(__pyx_t_4);
26781   __Pyx_XDECREF(__pyx_t_5);
26782   __Pyx_XDECREF(__pyx_t_6);
26783   __Pyx_XDECREF(__pyx_t_7);
26784   __Pyx_XDECREF(__pyx_t_8);
26785   __Pyx_XDECREF(__pyx_t_9);
26786   __Pyx_XDECREF(__pyx_t_10);
26787   __Pyx_AddTraceback("csamtools.SNPCall.__str__");
26788   __pyx_r = NULL;
26789   __pyx_L0:;
26790   __Pyx_XGIVEREF(__pyx_r);
26791   __Pyx_TraceReturn(__pyx_r);
26792   __Pyx_RefNannyFinishContext();
26793   return __pyx_r;
26794 }
26795
26796 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2891
26797  *     cdef IteratorColumn iter
26798  * 
26799  *     def __cinit__(self,             # <<<<<<<<<<<<<<
26800  *                   IteratorColumn iterator_column,
26801  *                   **kwargs ):
26802  */
26803
26804 static int __pyx_pf_9csamtools_13SNPCallerBase___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
26805 static int __pyx_pf_9csamtools_13SNPCallerBase___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
26806   struct __pyx_obj_9csamtools_IteratorColumn *__pyx_v_iterator_column = 0;
26807   PyObject *__pyx_v_kwargs = 0;
26808   int __pyx_r;
26809   PyObject *__pyx_t_1 = NULL;
26810   PyObject *__pyx_t_2 = NULL;
26811   int __pyx_t_3;
26812   float __pyx_t_4;
26813   int __pyx_t_5;
26814   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__iterator_column,0};
26815   __Pyx_TraceDeclarations
26816   __Pyx_RefNannySetupContext("__cinit__");
26817   __Pyx_TraceCall("__cinit__", __pyx_f[0], 2891);
26818   __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
26819   __Pyx_GOTREF(__pyx_v_kwargs);
26820   if (unlikely(__pyx_kwds)) {
26821     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
26822     PyObject* values[1] = {0};
26823     switch (PyTuple_GET_SIZE(__pyx_args)) {
26824       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
26825       case  0: break;
26826       default: goto __pyx_L5_argtuple_error;
26827     }
26828     switch (PyTuple_GET_SIZE(__pyx_args)) {
26829       case  0:
26830       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__iterator_column);
26831       if (likely(values[0])) kw_args--;
26832       else goto __pyx_L5_argtuple_error;
26833     }
26834     if (unlikely(kw_args > 0)) {
26835       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;}
26836     }
26837     __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)values[0]);
26838   } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
26839     goto __pyx_L5_argtuple_error;
26840   } else {
26841     __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)PyTuple_GET_ITEM(__pyx_args, 0));
26842   }
26843   goto __pyx_L4_argument_unpacking_done;
26844   __pyx_L5_argtuple_error:;
26845   __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;}
26846   __pyx_L3_error:;
26847   __Pyx_DECREF(__pyx_v_kwargs);
26848   __Pyx_AddTraceback("csamtools.SNPCallerBase.__cinit__");
26849   __Pyx_RefNannyFinishContext();
26850   return -1;
26851   __pyx_L4_argument_unpacking_done:;
26852   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;}
26853
26854   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2895
26855  *                   **kwargs ):
26856  * 
26857  *         self.iter = iterator_column             # <<<<<<<<<<<<<<
26858  *         self.c =  bam_maqcns_init()
26859  * 
26860  */
26861   __Pyx_INCREF(((PyObject *)__pyx_v_iterator_column));
26862   __Pyx_GIVEREF(((PyObject *)__pyx_v_iterator_column));
26863   __Pyx_GOTREF(((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->iter);
26864   __Pyx_DECREF(((PyObject *)((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->iter));
26865   ((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->iter = __pyx_v_iterator_column;
26866
26867   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2896
26868  * 
26869  *         self.iter = iterator_column
26870  *         self.c =  bam_maqcns_init()             # <<<<<<<<<<<<<<
26871  * 
26872  *         # set the default parameterization according to
26873  */
26874   ((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->c = bam_maqcns_init();
26875
26876   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2902
26877  * 
26878  *         # new default mode for samtools >0.1.10
26879  *         self.c.errmod = kwargs.get( "errmod", BAM_ERRMOD_MAQ2 )             # <<<<<<<<<<<<<<
26880  * 
26881  *         self.c.min_baseQ = kwargs.get( "min_baseQ", 13 )
26882  */
26883   if (unlikely(__pyx_v_kwargs == Py_None)) {
26884     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;} 
26885   }
26886   __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;}
26887   __Pyx_GOTREF(__pyx_t_1);
26888   __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;}
26889   __Pyx_GOTREF(__pyx_t_2);
26890   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
26891   __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;}
26892   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
26893   ((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->c->errmod = __pyx_t_3;
26894
26895   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2904
26896  *         self.c.errmod = kwargs.get( "errmod", BAM_ERRMOD_MAQ2 )
26897  * 
26898  *         self.c.min_baseQ = kwargs.get( "min_baseQ", 13 )             # <<<<<<<<<<<<<<
26899  *         # self.c.capQ_thres = kwargs.get( "capQ_threshold", 60 )
26900  *         self.c.n_hap = kwargs.get( "n_haplotypes", 2 )
26901  */
26902   if (unlikely(__pyx_v_kwargs == Py_None)) {
26903     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;} 
26904   }
26905   __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;}
26906   __Pyx_GOTREF(__pyx_t_2);
26907   __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;}
26908   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
26909   ((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->c->min_baseQ = __pyx_t_3;
26910
26911   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2906
26912  *         self.c.min_baseQ = kwargs.get( "min_baseQ", 13 )
26913  *         # self.c.capQ_thres = kwargs.get( "capQ_threshold", 60 )
26914  *         self.c.n_hap = kwargs.get( "n_haplotypes", 2 )             # <<<<<<<<<<<<<<
26915  *         self.c.het_rate = kwargs.get( "het_rate", 0.001 )
26916  *         self.c.theta = kwargs.get( "theta", 0.83 )
26917  */
26918   if (unlikely(__pyx_v_kwargs == Py_None)) {
26919     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;} 
26920   }
26921   __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;}
26922   __Pyx_GOTREF(__pyx_t_2);
26923   __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;}
26924   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
26925   ((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->c->n_hap = __pyx_t_3;
26926
26927   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2907
26928  *         # self.c.capQ_thres = kwargs.get( "capQ_threshold", 60 )
26929  *         self.c.n_hap = kwargs.get( "n_haplotypes", 2 )
26930  *         self.c.het_rate = kwargs.get( "het_rate", 0.001 )             # <<<<<<<<<<<<<<
26931  *         self.c.theta = kwargs.get( "theta", 0.83 )
26932  * 
26933  */
26934   if (unlikely(__pyx_v_kwargs == Py_None)) {
26935     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;} 
26936   }
26937   __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;}
26938   __Pyx_GOTREF(__pyx_t_2);
26939   __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;}
26940   __Pyx_GOTREF(__pyx_t_1);
26941   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
26942   __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;}
26943   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
26944   ((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->c->het_rate = __pyx_t_4;
26945
26946   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2908
26947  *         self.c.n_hap = kwargs.get( "n_haplotypes", 2 )
26948  *         self.c.het_rate = kwargs.get( "het_rate", 0.001 )
26949  *         self.c.theta = kwargs.get( "theta", 0.83 )             # <<<<<<<<<<<<<<
26950  * 
26951  *         if self.c.errmod != BAM_ERRMOD_MAQ2:
26952  */
26953   if (unlikely(__pyx_v_kwargs == Py_None)) {
26954     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;} 
26955   }
26956   __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;}
26957   __Pyx_GOTREF(__pyx_t_1);
26958   __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;}
26959   __Pyx_GOTREF(__pyx_t_2);
26960   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
26961   __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;}
26962   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
26963   ((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->c->theta = __pyx_t_4;
26964
26965   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2910
26966  *         self.c.theta = kwargs.get( "theta", 0.83 )
26967  * 
26968  *         if self.c.errmod != BAM_ERRMOD_MAQ2:             # <<<<<<<<<<<<<<
26969  *             self.c.theta += 0.02
26970  * 
26971  */
26972   __pyx_t_5 = (((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->c->errmod != BAM_ERRMOD_MAQ2);
26973   if (__pyx_t_5) {
26974
26975     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2911
26976  * 
26977  *         if self.c.errmod != BAM_ERRMOD_MAQ2:
26978  *             self.c.theta += 0.02             # <<<<<<<<<<<<<<
26979  * 
26980  *         # call prepare AFTER setting parameters
26981  */
26982     ((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->c->theta += 0.02;
26983     goto __pyx_L6;
26984   }
26985   __pyx_L6:;
26986
26987   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2914
26988  * 
26989  *         # call prepare AFTER setting parameters
26990  *         bam_maqcns_prepare( self.c )             # <<<<<<<<<<<<<<
26991  * 
26992  *     def __dealloc__(self):
26993  */
26994   bam_maqcns_prepare(((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->c);
26995
26996   __pyx_r = 0;
26997   goto __pyx_L0;
26998   __pyx_L1_error:;
26999   __Pyx_XDECREF(__pyx_t_1);
27000   __Pyx_XDECREF(__pyx_t_2);
27001   __Pyx_AddTraceback("csamtools.SNPCallerBase.__cinit__");
27002   __pyx_r = -1;
27003   __pyx_L0:;
27004   __Pyx_DECREF(__pyx_v_kwargs);
27005   __Pyx_TraceReturn(Py_None);
27006   __Pyx_RefNannyFinishContext();
27007   return __pyx_r;
27008 }
27009
27010 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2916
27011  *         bam_maqcns_prepare( self.c )
27012  * 
27013  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
27014  *         bam_maqcns_destroy( self.c )
27015  * 
27016  */
27017
27018 static void __pyx_pf_9csamtools_13SNPCallerBase___dealloc__(PyObject *__pyx_v_self); /*proto*/
27019 static void __pyx_pf_9csamtools_13SNPCallerBase___dealloc__(PyObject *__pyx_v_self) {
27020   __Pyx_TraceDeclarations
27021   __Pyx_RefNannySetupContext("__dealloc__");
27022   __Pyx_TraceCall("__dealloc__", __pyx_f[0], 2916);
27023
27024   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2917
27025  * 
27026  *     def __dealloc__(self):
27027  *         bam_maqcns_destroy( self.c )             # <<<<<<<<<<<<<<
27028  * 
27029  *     cdef __dump( self, glf1_t * g, uint32_t cns, int rb ):
27030  */
27031   bam_maqcns_destroy(((struct __pyx_obj_9csamtools_SNPCallerBase *)__pyx_v_self)->c);
27032
27033   __Pyx_TraceReturn(Py_None);
27034   __Pyx_RefNannyFinishContext();
27035 }
27036
27037 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2919
27038  *         bam_maqcns_destroy( self.c )
27039  * 
27040  *     cdef __dump( self, glf1_t * g, uint32_t cns, int rb ):             # <<<<<<<<<<<<<<
27041  *         '''debugging output.'''
27042  * 
27043  */
27044
27045 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) {
27046   int __pyx_v_x;
27047   PyObject *__pyx_r = NULL;
27048   int __pyx_t_1;
27049   int __pyx_t_2;
27050   PyObject *__pyx_t_3 = NULL;
27051   PyObject *__pyx_t_4 = NULL;
27052   PyObject *__pyx_t_5 = NULL;
27053   PyObject *__pyx_t_6 = NULL;
27054   PyObject *__pyx_t_7 = NULL;
27055   PyObject *__pyx_t_8 = NULL;
27056   PyObject *__pyx_t_9 = NULL;
27057   PyObject *__pyx_t_10 = NULL;
27058   PyObject *__pyx_t_11 = NULL;
27059   PyObject *__pyx_t_12 = NULL;
27060   PyObject *__pyx_t_13 = NULL;
27061   __Pyx_TraceDeclarations
27062   __Pyx_RefNannySetupContext("__dump");
27063   __Pyx_TraceCall("__dump", __pyx_f[0], 2919);
27064
27065   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2922
27066  *         '''debugging output.'''
27067  * 
27068  *         pysam_dump_glf( g, self.c );             # <<<<<<<<<<<<<<
27069  *         print ""
27070  *         for x in range(self.iter.n_plp):
27071  */
27072   pysam_dump_glf(__pyx_v_g, __pyx_v_self->c);
27073
27074   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2923
27075  * 
27076  *         pysam_dump_glf( g, self.c );
27077  *         print ""             # <<<<<<<<<<<<<<
27078  *         for x in range(self.iter.n_plp):
27079  *             print "--> read %i %s %i" % (x,
27080  */
27081   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;}
27082
27083   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2924
27084  *         pysam_dump_glf( g, self.c );
27085  *         print ""
27086  *         for x in range(self.iter.n_plp):             # <<<<<<<<<<<<<<
27087  *             print "--> read %i %s %i" % (x,
27088  *                                          bam1_qname(self.iter.plp[x].b),
27089  */
27090   __pyx_t_1 = __pyx_v_self->iter->n_plp;
27091   for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
27092     __pyx_v_x = __pyx_t_2;
27093
27094     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2925
27095  *         print ""
27096  *         for x in range(self.iter.n_plp):
27097  *             print "--> read %i %s %i" % (x,             # <<<<<<<<<<<<<<
27098  *                                          bam1_qname(self.iter.plp[x].b),
27099  *                                          self.iter.plp[x].qpos,
27100  */
27101     __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;}
27102     __Pyx_GOTREF(__pyx_t_3);
27103
27104     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2926
27105  *         for x in range(self.iter.n_plp):
27106  *             print "--> read %i %s %i" % (x,
27107  *                                          bam1_qname(self.iter.plp[x].b),             # <<<<<<<<<<<<<<
27108  *                                          self.iter.plp[x].qpos,
27109  *                                          )
27110  */
27111     __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;}
27112     __Pyx_GOTREF(((PyObject *)__pyx_t_4));
27113
27114     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2927
27115  *             print "--> read %i %s %i" % (x,
27116  *                                          bam1_qname(self.iter.plp[x].b),
27117  *                                          self.iter.plp[x].qpos,             # <<<<<<<<<<<<<<
27118  *                                          )
27119  * 
27120  */
27121     __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;}
27122     __Pyx_GOTREF(__pyx_t_5);
27123     __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;}
27124     __Pyx_GOTREF(__pyx_t_6);
27125     PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3);
27126     __Pyx_GIVEREF(__pyx_t_3);
27127     PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_t_4));
27128     __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
27129     PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_5);
27130     __Pyx_GIVEREF(__pyx_t_5);
27131     __pyx_t_3 = 0;
27132     __pyx_t_4 = 0;
27133     __pyx_t_5 = 0;
27134     __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;}
27135     __Pyx_GOTREF(((PyObject *)__pyx_t_5));
27136     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
27137     if (__Pyx_PrintOne(0, ((PyObject *)__pyx_t_5)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
27138     __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
27139   }
27140
27141   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2931
27142  * 
27143  *         print "pos=%i, cns=%i, q_r = %f, depth=%i, n=%i, rb=%i, cns-cq=%i %i %i %i" \
27144  *             % (self.iter.pos,             # <<<<<<<<<<<<<<
27145  *                cns,
27146  *                self.c.q_r,
27147  */
27148   __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;}
27149   __Pyx_GOTREF(__pyx_t_5);
27150
27151   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2932
27152  *         print "pos=%i, cns=%i, q_r = %f, depth=%i, n=%i, rb=%i, cns-cq=%i %i %i %i" \
27153  *             % (self.iter.pos,
27154  *                cns,             # <<<<<<<<<<<<<<
27155  *                self.c.q_r,
27156  *                self.iter.n_plp,
27157  */
27158   __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;}
27159   __Pyx_GOTREF(__pyx_t_6);
27160
27161   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2933
27162  *             % (self.iter.pos,
27163  *                cns,
27164  *                self.c.q_r,             # <<<<<<<<<<<<<<
27165  *                self.iter.n_plp,
27166  *                self.iter.n_plp,
27167  */
27168   __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;}
27169   __Pyx_GOTREF(__pyx_t_4);
27170
27171   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2934
27172  *                cns,
27173  *                self.c.q_r,
27174  *                self.iter.n_plp,             # <<<<<<<<<<<<<<
27175  *                self.iter.n_plp,
27176  *                rb,
27177  */
27178   __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;}
27179   __Pyx_GOTREF(__pyx_t_3);
27180
27181   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2935
27182  *                self.c.q_r,
27183  *                self.iter.n_plp,
27184  *                self.iter.n_plp,             # <<<<<<<<<<<<<<
27185  *                rb,
27186  *                cns >> 8 & 0xff,
27187  */
27188   __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;}
27189   __Pyx_GOTREF(__pyx_t_7);
27190
27191   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2936
27192  *                self.iter.n_plp,
27193  *                self.iter.n_plp,
27194  *                rb,             # <<<<<<<<<<<<<<
27195  *                cns >> 8 & 0xff,
27196  *                cns >> 16 & 0xff,
27197  */
27198   __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;}
27199   __Pyx_GOTREF(__pyx_t_8);
27200
27201   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2937
27202  *                self.iter.n_plp,
27203  *                rb,
27204  *                cns >> 8 & 0xff,             # <<<<<<<<<<<<<<
27205  *                cns >> 16 & 0xff,
27206  *                cns & 0xff,
27207  */
27208   __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;}
27209   __Pyx_GOTREF(__pyx_t_9);
27210
27211   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2938
27212  *                rb,
27213  *                cns >> 8 & 0xff,
27214  *                cns >> 16 & 0xff,             # <<<<<<<<<<<<<<
27215  *                cns & 0xff,
27216  *                cns >> 28,
27217  */
27218   __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;}
27219   __Pyx_GOTREF(__pyx_t_10);
27220
27221   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2939
27222  *                cns >> 8 & 0xff,
27223  *                cns >> 16 & 0xff,
27224  *                cns & 0xff,             # <<<<<<<<<<<<<<
27225  *                cns >> 28,
27226  *                )
27227  */
27228   __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;}
27229   __Pyx_GOTREF(__pyx_t_11);
27230
27231   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2940
27232  *                cns >> 16 & 0xff,
27233  *                cns & 0xff,
27234  *                cns >> 28,             # <<<<<<<<<<<<<<
27235  *                )
27236  * 
27237  */
27238   __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;}
27239   __Pyx_GOTREF(__pyx_t_12);
27240   __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;}
27241   __Pyx_GOTREF(__pyx_t_13);
27242   PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_5);
27243   __Pyx_GIVEREF(__pyx_t_5);
27244   PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_6);
27245   __Pyx_GIVEREF(__pyx_t_6);
27246   PyTuple_SET_ITEM(__pyx_t_13, 2, __pyx_t_4);
27247   __Pyx_GIVEREF(__pyx_t_4);
27248   PyTuple_SET_ITEM(__pyx_t_13, 3, __pyx_t_3);
27249   __Pyx_GIVEREF(__pyx_t_3);
27250   PyTuple_SET_ITEM(__pyx_t_13, 4, __pyx_t_7);
27251   __Pyx_GIVEREF(__pyx_t_7);
27252   PyTuple_SET_ITEM(__pyx_t_13, 5, __pyx_t_8);
27253   __Pyx_GIVEREF(__pyx_t_8);
27254   PyTuple_SET_ITEM(__pyx_t_13, 6, __pyx_t_9);
27255   __Pyx_GIVEREF(__pyx_t_9);
27256   PyTuple_SET_ITEM(__pyx_t_13, 7, __pyx_t_10);
27257   __Pyx_GIVEREF(__pyx_t_10);
27258   PyTuple_SET_ITEM(__pyx_t_13, 8, __pyx_t_11);
27259   __Pyx_GIVEREF(__pyx_t_11);
27260   PyTuple_SET_ITEM(__pyx_t_13, 9, __pyx_t_12);
27261   __Pyx_GIVEREF(__pyx_t_12);
27262   __pyx_t_5 = 0;
27263   __pyx_t_6 = 0;
27264   __pyx_t_4 = 0;
27265   __pyx_t_3 = 0;
27266   __pyx_t_7 = 0;
27267   __pyx_t_8 = 0;
27268   __pyx_t_9 = 0;
27269   __pyx_t_10 = 0;
27270   __pyx_t_11 = 0;
27271   __pyx_t_12 = 0;
27272   __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;}
27273   __Pyx_GOTREF(((PyObject *)__pyx_t_12));
27274   __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
27275   if (__Pyx_PrintOne(0, ((PyObject *)__pyx_t_12)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2930; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
27276   __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0;
27277
27278   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2943
27279  *                )
27280  * 
27281  *         printf("-------------------------------------\n");             # <<<<<<<<<<<<<<
27282  *         sys.stdout.flush()
27283  * 
27284  */
27285   printf(__pyx_k_106);
27286
27287   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2944
27288  * 
27289  *         printf("-------------------------------------\n");
27290  *         sys.stdout.flush()             # <<<<<<<<<<<<<<
27291  * 
27292  * cdef class IteratorSNPCalls( SNPCallerBase ):
27293  */
27294   __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;}
27295   __Pyx_GOTREF(__pyx_t_12);
27296   __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;}
27297   __Pyx_GOTREF(__pyx_t_13);
27298   __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
27299   __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;}
27300   __Pyx_GOTREF(__pyx_t_12);
27301   __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
27302   __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;}
27303   __Pyx_GOTREF(__pyx_t_13);
27304   __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
27305   __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
27306
27307   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
27308   goto __pyx_L0;
27309   __pyx_L1_error:;
27310   __Pyx_XDECREF(__pyx_t_3);
27311   __Pyx_XDECREF(__pyx_t_4);
27312   __Pyx_XDECREF(__pyx_t_5);
27313   __Pyx_XDECREF(__pyx_t_6);
27314   __Pyx_XDECREF(__pyx_t_7);
27315   __Pyx_XDECREF(__pyx_t_8);
27316   __Pyx_XDECREF(__pyx_t_9);
27317   __Pyx_XDECREF(__pyx_t_10);
27318   __Pyx_XDECREF(__pyx_t_11);
27319   __Pyx_XDECREF(__pyx_t_12);
27320   __Pyx_XDECREF(__pyx_t_13);
27321   __Pyx_AddTraceback("csamtools.SNPCallerBase.__dump");
27322   __pyx_r = 0;
27323   __pyx_L0:;
27324   __Pyx_XGIVEREF(__pyx_r);
27325   __Pyx_TraceReturn(__pyx_r);
27326   __Pyx_RefNannyFinishContext();
27327   return __pyx_r;
27328 }
27329
27330 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2960
27331  *     """
27332  * 
27333  *     def __cinit__(self,             # <<<<<<<<<<<<<<
27334  *                   IteratorColumn iterator_column,
27335  *                   **kwargs ):
27336  */
27337
27338 static int __pyx_pf_9csamtools_16IteratorSNPCalls___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
27339 static int __pyx_pf_9csamtools_16IteratorSNPCalls___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
27340   struct __pyx_obj_9csamtools_IteratorColumn *__pyx_v_iterator_column = 0;
27341   PyObject *__pyx_v_kwargs = 0;
27342   int __pyx_r;
27343   PyObject *__pyx_t_1 = NULL;
27344   PyObject *__pyx_t_2 = NULL;
27345   int __pyx_t_3;
27346   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__iterator_column,0};
27347   __Pyx_TraceDeclarations
27348   __Pyx_RefNannySetupContext("__cinit__");
27349   __Pyx_TraceCall("__cinit__", __pyx_f[0], 2960);
27350   __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
27351   __Pyx_GOTREF(__pyx_v_kwargs);
27352   if (unlikely(__pyx_kwds)) {
27353     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
27354     PyObject* values[1] = {0};
27355     switch (PyTuple_GET_SIZE(__pyx_args)) {
27356       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
27357       case  0: break;
27358       default: goto __pyx_L5_argtuple_error;
27359     }
27360     switch (PyTuple_GET_SIZE(__pyx_args)) {
27361       case  0:
27362       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__iterator_column);
27363       if (likely(values[0])) kw_args--;
27364       else goto __pyx_L5_argtuple_error;
27365     }
27366     if (unlikely(kw_args > 0)) {
27367       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;}
27368     }
27369     __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)values[0]);
27370   } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
27371     goto __pyx_L5_argtuple_error;
27372   } else {
27373     __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)PyTuple_GET_ITEM(__pyx_args, 0));
27374   }
27375   goto __pyx_L4_argument_unpacking_done;
27376   __pyx_L5_argtuple_error:;
27377   __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;}
27378   __pyx_L3_error:;
27379   __Pyx_DECREF(__pyx_v_kwargs);
27380   __Pyx_AddTraceback("csamtools.IteratorSNPCalls.__cinit__");
27381   __Pyx_RefNannyFinishContext();
27382   return -1;
27383   __pyx_L4_argument_unpacking_done:;
27384   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;}
27385
27386   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2964
27387  *                   **kwargs ):
27388  * 
27389  *         assert self.iter.hasReference(), "IteratorSNPCalls requires an pileup iterator with reference sequence"             # <<<<<<<<<<<<<<
27390  * 
27391  *     def __iter__(self):
27392  */
27393   #ifndef PYREX_WITHOUT_ASSERTIONS
27394   __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;}
27395   __Pyx_GOTREF(__pyx_t_1);
27396   __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;}
27397   __Pyx_GOTREF(__pyx_t_2);
27398   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
27399   __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;}
27400   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
27401   if (unlikely(!__pyx_t_3)) {
27402     PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_107));
27403     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
27404   }
27405   #endif
27406
27407   __pyx_r = 0;
27408   goto __pyx_L0;
27409   __pyx_L1_error:;
27410   __Pyx_XDECREF(__pyx_t_1);
27411   __Pyx_XDECREF(__pyx_t_2);
27412   __Pyx_AddTraceback("csamtools.IteratorSNPCalls.__cinit__");
27413   __pyx_r = -1;
27414   __pyx_L0:;
27415   __Pyx_DECREF(__pyx_v_kwargs);
27416   __Pyx_TraceReturn(Py_None);
27417   __Pyx_RefNannyFinishContext();
27418   return __pyx_r;
27419 }
27420
27421 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2966
27422  *         assert self.iter.hasReference(), "IteratorSNPCalls requires an pileup iterator with reference sequence"
27423  * 
27424  *     def __iter__(self):             # <<<<<<<<<<<<<<
27425  *         return self
27426  * 
27427  */
27428
27429 static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___iter__(PyObject *__pyx_v_self); /*proto*/
27430 static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___iter__(PyObject *__pyx_v_self) {
27431   PyObject *__pyx_r = NULL;
27432   __Pyx_TraceDeclarations
27433   __Pyx_RefNannySetupContext("__iter__");
27434   __Pyx_TraceCall("__iter__", __pyx_f[0], 2966);
27435
27436   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2967
27437  * 
27438  *     def __iter__(self):
27439  *         return self             # <<<<<<<<<<<<<<
27440  * 
27441  *     def __next__(self):
27442  */
27443   __Pyx_XDECREF(__pyx_r);
27444   __Pyx_INCREF(__pyx_v_self);
27445   __pyx_r = __pyx_v_self;
27446   goto __pyx_L0;
27447
27448   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
27449   __pyx_L0:;
27450   __Pyx_XGIVEREF(__pyx_r);
27451   __Pyx_TraceReturn(__pyx_r);
27452   __Pyx_RefNannyFinishContext();
27453   return __pyx_r;
27454 }
27455
27456 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2969
27457  *         return self
27458  * 
27459  *     def __next__(self):             # <<<<<<<<<<<<<<
27460  *         """python version of next().
27461  *         """
27462  */
27463
27464 static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___next__(PyObject *__pyx_v_self); /*proto*/
27465 static char __pyx_doc_9csamtools_16IteratorSNPCalls___next__[] = "python version of next().\n        ";
27466 struct wrapperbase __pyx_wrapperbase_9csamtools_16IteratorSNPCalls___next__;
27467 static PyObject *__pyx_pf_9csamtools_16IteratorSNPCalls___next__(PyObject *__pyx_v_self) {
27468   char *__pyx_v_seq;
27469   int __pyx_v_seq_len;
27470   int __pyx_v_rb;
27471   uint32_t __pyx_v_cns;
27472   glf1_t *__pyx_v_g;
27473   struct __pyx_obj_9csamtools_SNPCall *__pyx_v_call;
27474   PyObject *__pyx_r = NULL;
27475   int __pyx_t_1;
27476   PyObject *__pyx_t_2 = NULL;
27477   PyObject *__pyx_t_3 = NULL;
27478   int __pyx_t_4;
27479   PyObject *__pyx_t_5 = NULL;
27480   __Pyx_TraceDeclarations
27481   __Pyx_RefNannySetupContext("__next__");
27482   __Pyx_TraceCall("__next__", __pyx_f[0], 2969);
27483   __pyx_v_call = ((struct __pyx_obj_9csamtools_SNPCall *)Py_None); __Pyx_INCREF(Py_None);
27484
27485   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2974
27486  * 
27487  *         # the following code was adapted from bam_plcmd.c:pileup_func()
27488  *         self.iter.cnext()             # <<<<<<<<<<<<<<
27489  * 
27490  *         if self.iter.n_plp < 0:
27491  */
27492   ((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);
27493
27494   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2976
27495  *         self.iter.cnext()
27496  * 
27497  *         if self.iter.n_plp < 0:             # <<<<<<<<<<<<<<
27498  *             raise ValueError("error during iteration" )
27499  * 
27500  */
27501   __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->n_plp < 0);
27502   if (__pyx_t_1) {
27503
27504     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2977
27505  * 
27506  *         if self.iter.n_plp < 0:
27507  *             raise ValueError("error during iteration" )             # <<<<<<<<<<<<<<
27508  * 
27509  *         if self.iter.plp == NULL:
27510  */
27511     __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;}
27512     __Pyx_GOTREF(__pyx_t_2);
27513     __Pyx_INCREF(((PyObject *)__pyx_kp_s_59));
27514     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_59));
27515     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_59));
27516     __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;}
27517     __Pyx_GOTREF(__pyx_t_3);
27518     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
27519     __Pyx_Raise(__pyx_t_3, 0, 0);
27520     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
27521     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2977; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
27522     goto __pyx_L5;
27523   }
27524   __pyx_L5:;
27525
27526   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2979
27527  *             raise ValueError("error during iteration" )
27528  * 
27529  *         if self.iter.plp == NULL:             # <<<<<<<<<<<<<<
27530  *            raise StopIteration
27531  * 
27532  */
27533   __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->plp == NULL);
27534   if (__pyx_t_1) {
27535
27536     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2980
27537  * 
27538  *         if self.iter.plp == NULL:
27539  *            raise StopIteration             # <<<<<<<<<<<<<<
27540  * 
27541  *         cdef char * seq = self.iter.getSequence()
27542  */
27543     __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
27544     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
27545     goto __pyx_L6;
27546   }
27547   __pyx_L6:;
27548
27549   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2982
27550  *            raise StopIteration
27551  * 
27552  *         cdef char * seq = self.iter.getSequence()             # <<<<<<<<<<<<<<
27553  *         cdef int seq_len = self.iter.seq_len
27554  * 
27555  */
27556   __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);
27557
27558   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2983
27559  * 
27560  *         cdef char * seq = self.iter.getSequence()
27561  *         cdef int seq_len = self.iter.seq_len             # <<<<<<<<<<<<<<
27562  * 
27563  *         assert seq != NULL
27564  */
27565   __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;}
27566   __Pyx_GOTREF(__pyx_t_3);
27567   __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;}
27568   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
27569   __pyx_v_seq_len = __pyx_t_4;
27570
27571   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2985
27572  *         cdef int seq_len = self.iter.seq_len
27573  * 
27574  *         assert seq != NULL             # <<<<<<<<<<<<<<
27575  * 
27576  *         # reference base
27577  */
27578   #ifndef PYREX_WITHOUT_ASSERTIONS
27579   if (unlikely(!(__pyx_v_seq != NULL))) {
27580     PyErr_SetNone(PyExc_AssertionError);
27581     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
27582   }
27583   #endif
27584
27585   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2988
27586  * 
27587  *         # reference base
27588  *         if self.iter.pos >= seq_len:             # <<<<<<<<<<<<<<
27589  *             raise ValueError( "position %i out of bounds on reference sequence (len=%i)" % (self.iter.pos, seq_len) )
27590  * 
27591  */
27592   __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->pos >= __pyx_v_seq_len);
27593   if (__pyx_t_1) {
27594
27595     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2989
27596  *         # reference base
27597  *         if self.iter.pos >= seq_len:
27598  *             raise ValueError( "position %i out of bounds on reference sequence (len=%i)" % (self.iter.pos, seq_len) )             # <<<<<<<<<<<<<<
27599  * 
27600  *         cdef int rb = seq[self.iter.pos]
27601  */
27602     __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;}
27603     __Pyx_GOTREF(__pyx_t_3);
27604     __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;}
27605     __Pyx_GOTREF(__pyx_t_2);
27606     __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;}
27607     __Pyx_GOTREF(__pyx_t_5);
27608     PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_3);
27609     __Pyx_GIVEREF(__pyx_t_3);
27610     PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
27611     __Pyx_GIVEREF(__pyx_t_2);
27612     __pyx_t_3 = 0;
27613     __pyx_t_2 = 0;
27614     __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;}
27615     __Pyx_GOTREF(((PyObject *)__pyx_t_2));
27616     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
27617     __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;}
27618     __Pyx_GOTREF(__pyx_t_5);
27619     PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_2));
27620     __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
27621     __pyx_t_2 = 0;
27622     __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;}
27623     __Pyx_GOTREF(__pyx_t_2);
27624     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
27625     __Pyx_Raise(__pyx_t_2, 0, 0);
27626     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
27627     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
27628     goto __pyx_L7;
27629   }
27630   __pyx_L7:;
27631
27632   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2991
27633  *             raise ValueError( "position %i out of bounds on reference sequence (len=%i)" % (self.iter.pos, seq_len) )
27634  * 
27635  *         cdef int rb = seq[self.iter.pos]             # <<<<<<<<<<<<<<
27636  *         cdef uint32_t cns
27637  *         cdef glf1_t * g
27638  */
27639   __pyx_v_rb = (__pyx_v_seq[((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->pos]);
27640
27641   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2998
27642  *                                self.iter.plp,
27643  *                                bam_nt16_table[rb],
27644  *                                self.c )             # <<<<<<<<<<<<<<
27645  * 
27646  *         if pysam_glf_depth( g ) == 0:
27647  */
27648   __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);
27649
27650   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3000
27651  *                                self.c )
27652  * 
27653  *         if pysam_glf_depth( g ) == 0:             # <<<<<<<<<<<<<<
27654  *             cns = 0xfu << 28 | 0xf << 24
27655  *         else:
27656  */
27657   __pyx_t_1 = (pysam_glf_depth(__pyx_v_g) == 0);
27658   if (__pyx_t_1) {
27659
27660     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3001
27661  * 
27662  *         if pysam_glf_depth( g ) == 0:
27663  *             cns = 0xfu << 28 | 0xf << 24             # <<<<<<<<<<<<<<
27664  *         else:
27665  *             cns = glf2cns(g, <int>(self.c.q_r + .499))
27666  */
27667     __pyx_v_cns = 4278190080U;
27668     goto __pyx_L8;
27669   }
27670   /*else*/ {
27671
27672     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3003
27673  *             cns = 0xfu << 28 | 0xf << 24
27674  *         else:
27675  *             cns = glf2cns(g, <int>(self.c.q_r + .499))             # <<<<<<<<<<<<<<
27676  * 
27677  *         free(g)
27678  */
27679     __pyx_v_cns = glf2cns(__pyx_v_g, ((int)(((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.c->q_r + .499)));
27680   }
27681   __pyx_L8:;
27682
27683   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3005
27684  *             cns = glf2cns(g, <int>(self.c.q_r + .499))
27685  * 
27686  *         free(g)             # <<<<<<<<<<<<<<
27687  * 
27688  *         cdef SNPCall call
27689  */
27690   free(__pyx_v_g);
27691
27692   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3009
27693  *         cdef SNPCall call
27694  * 
27695  *         call = SNPCall()             # <<<<<<<<<<<<<<
27696  *         call._tid = self.iter.tid
27697  *         call._pos = self.iter.pos
27698  */
27699   __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;}
27700   __Pyx_GOTREF(__pyx_t_2);
27701   __Pyx_DECREF(((PyObject *)__pyx_v_call));
27702   __pyx_v_call = ((struct __pyx_obj_9csamtools_SNPCall *)__pyx_t_2);
27703   __pyx_t_2 = 0;
27704
27705   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3010
27706  * 
27707  *         call = SNPCall()
27708  *         call._tid = self.iter.tid             # <<<<<<<<<<<<<<
27709  *         call._pos = self.iter.pos
27710  *         call._reference_base = rb
27711  */
27712   __pyx_v_call->_tid = ((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->tid;
27713
27714   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3011
27715  *         call = SNPCall()
27716  *         call._tid = self.iter.tid
27717  *         call._pos = self.iter.pos             # <<<<<<<<<<<<<<
27718  *         call._reference_base = rb
27719  *         call._genotype = bam_nt16_rev_table[cns>>28]
27720  */
27721   __pyx_v_call->_pos = ((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->pos;
27722
27723   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3012
27724  *         call._tid = self.iter.tid
27725  *         call._pos = self.iter.pos
27726  *         call._reference_base = rb             # <<<<<<<<<<<<<<
27727  *         call._genotype = bam_nt16_rev_table[cns>>28]
27728  *         call._consensus_quality = cns >> 8 & 0xff
27729  */
27730   __pyx_v_call->_reference_base = __pyx_v_rb;
27731
27732   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3013
27733  *         call._pos = self.iter.pos
27734  *         call._reference_base = rb
27735  *         call._genotype = bam_nt16_rev_table[cns>>28]             # <<<<<<<<<<<<<<
27736  *         call._consensus_quality = cns >> 8 & 0xff
27737  *         call._snp_quality = cns & 0xff
27738  */
27739   __pyx_v_call->_genotype = (__pyx_v_9csamtools_bam_nt16_rev_table[(__pyx_v_cns >> 28)]);
27740
27741   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3014
27742  *         call._reference_base = rb
27743  *         call._genotype = bam_nt16_rev_table[cns>>28]
27744  *         call._consensus_quality = cns >> 8 & 0xff             # <<<<<<<<<<<<<<
27745  *         call._snp_quality = cns & 0xff
27746  *         call._rms_mapping_quality = cns >> 16&0xff
27747  */
27748   __pyx_v_call->_consensus_quality = ((__pyx_v_cns >> 8) & 0xff);
27749
27750   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3015
27751  *         call._genotype = bam_nt16_rev_table[cns>>28]
27752  *         call._consensus_quality = cns >> 8 & 0xff
27753  *         call._snp_quality = cns & 0xff             # <<<<<<<<<<<<<<
27754  *         call._rms_mapping_quality = cns >> 16&0xff
27755  *         call._coverage = self.iter.n_plp
27756  */
27757   __pyx_v_call->_snp_quality = (__pyx_v_cns & 0xff);
27758
27759   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3016
27760  *         call._consensus_quality = cns >> 8 & 0xff
27761  *         call._snp_quality = cns & 0xff
27762  *         call._rms_mapping_quality = cns >> 16&0xff             # <<<<<<<<<<<<<<
27763  *         call._coverage = self.iter.n_plp
27764  * 
27765  */
27766   __pyx_v_call->_rms_mapping_quality = ((__pyx_v_cns >> 16) & 0xff);
27767
27768   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3017
27769  *         call._snp_quality = cns & 0xff
27770  *         call._rms_mapping_quality = cns >> 16&0xff
27771  *         call._coverage = self.iter.n_plp             # <<<<<<<<<<<<<<
27772  * 
27773  *         return call
27774  */
27775   __pyx_v_call->_coverage = ((struct __pyx_obj_9csamtools_IteratorSNPCalls *)__pyx_v_self)->__pyx_base.iter->n_plp;
27776
27777   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3019
27778  *         call._coverage = self.iter.n_plp
27779  * 
27780  *         return call             # <<<<<<<<<<<<<<
27781  * 
27782  * cdef class SNPCaller( SNPCallerBase ):
27783  */
27784   __Pyx_XDECREF(__pyx_r);
27785   __Pyx_INCREF(((PyObject *)__pyx_v_call));
27786   __pyx_r = ((PyObject *)__pyx_v_call);
27787   goto __pyx_L0;
27788
27789   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
27790   goto __pyx_L0;
27791   __pyx_L1_error:;
27792   __Pyx_XDECREF(__pyx_t_2);
27793   __Pyx_XDECREF(__pyx_t_3);
27794   __Pyx_XDECREF(__pyx_t_5);
27795   __Pyx_AddTraceback("csamtools.IteratorSNPCalls.__next__");
27796   __pyx_r = NULL;
27797   __pyx_L0:;
27798   __Pyx_DECREF((PyObject *)__pyx_v_call);
27799   __Pyx_XGIVEREF(__pyx_r);
27800   __Pyx_TraceReturn(__pyx_r);
27801   __Pyx_RefNannyFinishContext();
27802   return __pyx_r;
27803 }
27804
27805 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3035
27806  * 
27807  * 
27808  *     def __cinit__(self,             # <<<<<<<<<<<<<<
27809  *                   IteratorColumn iterator_column,
27810  *                   **kwargs ):
27811  */
27812
27813 static int __pyx_pf_9csamtools_9SNPCaller___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
27814 static int __pyx_pf_9csamtools_9SNPCaller___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
27815   struct __pyx_obj_9csamtools_IteratorColumn *__pyx_v_iterator_column = 0;
27816   PyObject *__pyx_v_kwargs = 0;
27817   int __pyx_r;
27818   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__iterator_column,0};
27819   __Pyx_TraceDeclarations
27820   __Pyx_RefNannySetupContext("__cinit__");
27821   __Pyx_TraceCall("__cinit__", __pyx_f[0], 3035);
27822   __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
27823   __Pyx_GOTREF(__pyx_v_kwargs);
27824   if (unlikely(__pyx_kwds)) {
27825     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
27826     PyObject* values[1] = {0};
27827     switch (PyTuple_GET_SIZE(__pyx_args)) {
27828       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
27829       case  0: break;
27830       default: goto __pyx_L5_argtuple_error;
27831     }
27832     switch (PyTuple_GET_SIZE(__pyx_args)) {
27833       case  0:
27834       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__iterator_column);
27835       if (likely(values[0])) kw_args--;
27836       else goto __pyx_L5_argtuple_error;
27837     }
27838     if (unlikely(kw_args > 0)) {
27839       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;}
27840     }
27841     __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)values[0]);
27842   } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
27843     goto __pyx_L5_argtuple_error;
27844   } else {
27845     __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)PyTuple_GET_ITEM(__pyx_args, 0));
27846   }
27847   goto __pyx_L4_argument_unpacking_done;
27848   __pyx_L5_argtuple_error:;
27849   __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;}
27850   __pyx_L3_error:;
27851   __Pyx_DECREF(__pyx_v_kwargs);
27852   __Pyx_AddTraceback("csamtools.SNPCaller.__cinit__");
27853   __Pyx_RefNannyFinishContext();
27854   return -1;
27855   __pyx_L4_argument_unpacking_done:;
27856   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;}
27857
27858   __pyx_r = 0;
27859   goto __pyx_L0;
27860   __pyx_L1_error:;
27861   __Pyx_AddTraceback("csamtools.SNPCaller.__cinit__");
27862   __pyx_r = -1;
27863   __pyx_L0:;
27864   __Pyx_DECREF(__pyx_v_kwargs);
27865   __Pyx_TraceReturn(Py_None);
27866   __Pyx_RefNannyFinishContext();
27867   return __pyx_r;
27868 }
27869
27870 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3041
27871  *         pass
27872  * 
27873  *     def call(self, reference, int pos ):             # <<<<<<<<<<<<<<
27874  *         """call a snp on chromosome *reference*
27875  *         and position *pos*.
27876  */
27877
27878 static PyObject *__pyx_pf_9csamtools_9SNPCaller_call(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
27879 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        ";
27880 static PyObject *__pyx_pf_9csamtools_9SNPCaller_call(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
27881   PyObject *__pyx_v_reference = 0;
27882   int __pyx_v_pos;
27883   int __pyx_v_tid;
27884   char *__pyx_v_seq;
27885   int __pyx_v_seq_len;
27886   int __pyx_v_rb;
27887   uint32_t __pyx_v_cns;
27888   glf1_t *__pyx_v_g;
27889   struct __pyx_obj_9csamtools_SNPCall *__pyx_v_call;
27890   PyObject *__pyx_r = NULL;
27891   PyObject *__pyx_t_1 = NULL;
27892   PyObject *__pyx_t_2 = NULL;
27893   PyObject *__pyx_t_3 = NULL;
27894   int __pyx_t_4;
27895   PyObject *__pyx_t_5 = NULL;
27896   int __pyx_t_6;
27897   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__reference,&__pyx_n_s__pos,0};
27898   __Pyx_TraceDeclarations
27899   __Pyx_RefNannySetupContext("call");
27900   __Pyx_TraceCall("call", __pyx_f[0], 3041);
27901   if (unlikely(__pyx_kwds)) {
27902     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
27903     PyObject* values[2] = {0,0};
27904     switch (PyTuple_GET_SIZE(__pyx_args)) {
27905       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
27906       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
27907       case  0: break;
27908       default: goto __pyx_L5_argtuple_error;
27909     }
27910     switch (PyTuple_GET_SIZE(__pyx_args)) {
27911       case  0:
27912       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reference);
27913       if (likely(values[0])) kw_args--;
27914       else goto __pyx_L5_argtuple_error;
27915       case  1:
27916       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pos);
27917       if (likely(values[1])) kw_args--;
27918       else {
27919         __Pyx_RaiseArgtupleInvalid("call", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3041; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
27920       }
27921     }
27922     if (unlikely(kw_args > 0)) {
27923       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;}
27924     }
27925     __pyx_v_reference = values[0];
27926     __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;}
27927   } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
27928     goto __pyx_L5_argtuple_error;
27929   } else {
27930     __pyx_v_reference = PyTuple_GET_ITEM(__pyx_args, 0);
27931     __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;}
27932   }
27933   goto __pyx_L4_argument_unpacking_done;
27934   __pyx_L5_argtuple_error:;
27935   __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;}
27936   __pyx_L3_error:;
27937   __Pyx_AddTraceback("csamtools.SNPCaller.call");
27938   __Pyx_RefNannyFinishContext();
27939   return NULL;
27940   __pyx_L4_argument_unpacking_done:;
27941   __pyx_v_call = ((struct __pyx_obj_9csamtools_SNPCall *)Py_None); __Pyx_INCREF(Py_None);
27942
27943   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3048
27944  *         """
27945  * 
27946  *         cdef int tid = self.iter.samfile.gettid( reference )             # <<<<<<<<<<<<<<
27947  * 
27948  *         self.iter.reset( tid, pos, pos + 1 )
27949  */
27950   __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;}
27951   __Pyx_GOTREF(__pyx_t_1);
27952   __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;}
27953   __Pyx_GOTREF(__pyx_t_2);
27954   __Pyx_INCREF(__pyx_v_reference);
27955   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_reference);
27956   __Pyx_GIVEREF(__pyx_v_reference);
27957   __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;}
27958   __Pyx_GOTREF(__pyx_t_3);
27959   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
27960   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
27961   __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;}
27962   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
27963   __pyx_v_tid = __pyx_t_4;
27964
27965   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3050
27966  *         cdef int tid = self.iter.samfile.gettid( reference )
27967  * 
27968  *         self.iter.reset( tid, pos, pos + 1 )             # <<<<<<<<<<<<<<
27969  * 
27970  *         while 1:
27971  */
27972   __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;}
27973   __Pyx_GOTREF(__pyx_t_3);
27974   __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;}
27975   __Pyx_GOTREF(__pyx_t_2);
27976   __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;}
27977   __Pyx_GOTREF(__pyx_t_1);
27978   __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;}
27979   __Pyx_GOTREF(__pyx_t_5);
27980   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
27981   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
27982   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
27983   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
27984
27985   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3052
27986  *         self.iter.reset( tid, pos, pos + 1 )
27987  * 
27988  *         while 1:             # <<<<<<<<<<<<<<
27989  *             self.iter.cnext()
27990  * 
27991  */
27992   while (1) {
27993     if (!1) break;
27994
27995     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3053
27996  * 
27997  *         while 1:
27998  *             self.iter.cnext()             # <<<<<<<<<<<<<<
27999  * 
28000  *             if self.iter.n_plp < 0:
28001  */
28002     ((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);
28003
28004     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3055
28005  *             self.iter.cnext()
28006  * 
28007  *             if self.iter.n_plp < 0:             # <<<<<<<<<<<<<<
28008  *                 raise ValueError("error during iteration" )
28009  * 
28010  */
28011     __pyx_t_6 = (((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->n_plp < 0);
28012     if (__pyx_t_6) {
28013
28014       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3056
28015  * 
28016  *             if self.iter.n_plp < 0:
28017  *                 raise ValueError("error during iteration" )             # <<<<<<<<<<<<<<
28018  * 
28019  *             if self.iter.plp == NULL:
28020  */
28021       __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;}
28022       __Pyx_GOTREF(__pyx_t_5);
28023       __Pyx_INCREF(((PyObject *)__pyx_kp_s_59));
28024       PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_59));
28025       __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_59));
28026       __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;}
28027       __Pyx_GOTREF(__pyx_t_1);
28028       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
28029       __Pyx_Raise(__pyx_t_1, 0, 0);
28030       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
28031       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
28032       goto __pyx_L8;
28033     }
28034     __pyx_L8:;
28035
28036     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3058
28037  *                 raise ValueError("error during iteration" )
28038  * 
28039  *             if self.iter.plp == NULL:             # <<<<<<<<<<<<<<
28040  *                 raise ValueError( "no reads in region - no call" )
28041  * 
28042  */
28043     __pyx_t_6 = (((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->plp == NULL);
28044     if (__pyx_t_6) {
28045
28046       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3059
28047  * 
28048  *             if self.iter.plp == NULL:
28049  *                 raise ValueError( "no reads in region - no call" )             # <<<<<<<<<<<<<<
28050  * 
28051  *             if self.iter.pos == pos: break
28052  */
28053       __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;}
28054       __Pyx_GOTREF(__pyx_t_1);
28055       __Pyx_INCREF(((PyObject *)__pyx_kp_s_109));
28056       PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_109));
28057       __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_109));
28058       __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;}
28059       __Pyx_GOTREF(__pyx_t_5);
28060       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
28061       __Pyx_Raise(__pyx_t_5, 0, 0);
28062       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
28063       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
28064       goto __pyx_L9;
28065     }
28066     __pyx_L9:;
28067
28068     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3061
28069  *                 raise ValueError( "no reads in region - no call" )
28070  * 
28071  *             if self.iter.pos == pos: break             # <<<<<<<<<<<<<<
28072  * 
28073  *         cdef char * seq = self.iter.getSequence()
28074  */
28075     __pyx_t_6 = (((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->pos == __pyx_v_pos);
28076     if (__pyx_t_6) {
28077       goto __pyx_L7_break;
28078       goto __pyx_L10;
28079     }
28080     __pyx_L10:;
28081   }
28082   __pyx_L7_break:;
28083
28084   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3063
28085  *             if self.iter.pos == pos: break
28086  * 
28087  *         cdef char * seq = self.iter.getSequence()             # <<<<<<<<<<<<<<
28088  *         cdef int seq_len = self.iter.seq_len
28089  * 
28090  */
28091   __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);
28092
28093   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3064
28094  * 
28095  *         cdef char * seq = self.iter.getSequence()
28096  *         cdef int seq_len = self.iter.seq_len             # <<<<<<<<<<<<<<
28097  * 
28098  *         assert seq != NULL
28099  */
28100   __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;}
28101   __Pyx_GOTREF(__pyx_t_5);
28102   __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;}
28103   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
28104   __pyx_v_seq_len = __pyx_t_4;
28105
28106   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3066
28107  *         cdef int seq_len = self.iter.seq_len
28108  * 
28109  *         assert seq != NULL             # <<<<<<<<<<<<<<
28110  * 
28111  *         # reference base
28112  */
28113   #ifndef PYREX_WITHOUT_ASSERTIONS
28114   if (unlikely(!(__pyx_v_seq != NULL))) {
28115     PyErr_SetNone(PyExc_AssertionError);
28116     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
28117   }
28118   #endif
28119
28120   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3069
28121  * 
28122  *         # reference base
28123  *         if self.iter.pos >= seq_len:             # <<<<<<<<<<<<<<
28124  *             raise ValueError( "position %i out of bounds on reference sequence (len=%i)" % (self.iter.pos, seq_len) )
28125  * 
28126  */
28127   __pyx_t_6 = (((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->pos >= __pyx_v_seq_len);
28128   if (__pyx_t_6) {
28129
28130     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3070
28131  *         # reference base
28132  *         if self.iter.pos >= seq_len:
28133  *             raise ValueError( "position %i out of bounds on reference sequence (len=%i)" % (self.iter.pos, seq_len) )             # <<<<<<<<<<<<<<
28134  * 
28135  *         cdef int rb = seq[self.iter.pos]
28136  */
28137     __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;}
28138     __Pyx_GOTREF(__pyx_t_5);
28139     __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;}
28140     __Pyx_GOTREF(__pyx_t_1);
28141     __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;}
28142     __Pyx_GOTREF(__pyx_t_2);
28143     PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_5);
28144     __Pyx_GIVEREF(__pyx_t_5);
28145     PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_1);
28146     __Pyx_GIVEREF(__pyx_t_1);
28147     __pyx_t_5 = 0;
28148     __pyx_t_1 = 0;
28149     __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;}
28150     __Pyx_GOTREF(((PyObject *)__pyx_t_1));
28151     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
28152     __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;}
28153     __Pyx_GOTREF(__pyx_t_2);
28154     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
28155     __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
28156     __pyx_t_1 = 0;
28157     __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;}
28158     __Pyx_GOTREF(__pyx_t_1);
28159     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
28160     __Pyx_Raise(__pyx_t_1, 0, 0);
28161     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
28162     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
28163     goto __pyx_L11;
28164   }
28165   __pyx_L11:;
28166
28167   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3072
28168  *             raise ValueError( "position %i out of bounds on reference sequence (len=%i)" % (self.iter.pos, seq_len) )
28169  * 
28170  *         cdef int rb = seq[self.iter.pos]             # <<<<<<<<<<<<<<
28171  *         cdef uint32_t cns
28172  *         cdef glf1_t * g
28173  */
28174   __pyx_v_rb = (__pyx_v_seq[((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->pos]);
28175
28176   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3079
28177  *                                self.iter.plp,
28178  *                                bam_nt16_table[rb],
28179  *                                self.c )             # <<<<<<<<<<<<<<
28180  * 
28181  * 
28182  */
28183   __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);
28184
28185   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3082
28186  * 
28187  * 
28188  *         if pysam_glf_depth( g ) == 0:             # <<<<<<<<<<<<<<
28189  *             cns = 0xfu << 28 | 0xf << 24
28190  *         else:
28191  */
28192   __pyx_t_6 = (pysam_glf_depth(__pyx_v_g) == 0);
28193   if (__pyx_t_6) {
28194
28195     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3083
28196  * 
28197  *         if pysam_glf_depth( g ) == 0:
28198  *             cns = 0xfu << 28 | 0xf << 24             # <<<<<<<<<<<<<<
28199  *         else:
28200  *             cns = glf2cns(g, <int>(self.c.q_r + .499))
28201  */
28202     __pyx_v_cns = 4278190080U;
28203     goto __pyx_L12;
28204   }
28205   /*else*/ {
28206
28207     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3085
28208  *             cns = 0xfu << 28 | 0xf << 24
28209  *         else:
28210  *             cns = glf2cns(g, <int>(self.c.q_r + .499))             # <<<<<<<<<<<<<<
28211  * 
28212  *         free(g)
28213  */
28214     __pyx_v_cns = glf2cns(__pyx_v_g, ((int)(((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.c->q_r + .499)));
28215   }
28216   __pyx_L12:;
28217
28218   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3087
28219  *             cns = glf2cns(g, <int>(self.c.q_r + .499))
28220  * 
28221  *         free(g)             # <<<<<<<<<<<<<<
28222  * 
28223  *         cdef SNPCall call
28224  */
28225   free(__pyx_v_g);
28226
28227   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3091
28228  *         cdef SNPCall call
28229  * 
28230  *         call = SNPCall()             # <<<<<<<<<<<<<<
28231  *         call._tid = self.iter.tid
28232  *         call._pos = self.iter.pos
28233  */
28234   __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;}
28235   __Pyx_GOTREF(__pyx_t_1);
28236   __Pyx_DECREF(((PyObject *)__pyx_v_call));
28237   __pyx_v_call = ((struct __pyx_obj_9csamtools_SNPCall *)__pyx_t_1);
28238   __pyx_t_1 = 0;
28239
28240   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3092
28241  * 
28242  *         call = SNPCall()
28243  *         call._tid = self.iter.tid             # <<<<<<<<<<<<<<
28244  *         call._pos = self.iter.pos
28245  *         call._reference_base = rb
28246  */
28247   __pyx_v_call->_tid = ((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->tid;
28248
28249   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3093
28250  *         call = SNPCall()
28251  *         call._tid = self.iter.tid
28252  *         call._pos = self.iter.pos             # <<<<<<<<<<<<<<
28253  *         call._reference_base = rb
28254  *         call._genotype = bam_nt16_rev_table[cns>>28]
28255  */
28256   __pyx_v_call->_pos = ((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->pos;
28257
28258   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3094
28259  *         call._tid = self.iter.tid
28260  *         call._pos = self.iter.pos
28261  *         call._reference_base = rb             # <<<<<<<<<<<<<<
28262  *         call._genotype = bam_nt16_rev_table[cns>>28]
28263  *         call._consensus_quality = cns >> 8 & 0xff
28264  */
28265   __pyx_v_call->_reference_base = __pyx_v_rb;
28266
28267   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3095
28268  *         call._pos = self.iter.pos
28269  *         call._reference_base = rb
28270  *         call._genotype = bam_nt16_rev_table[cns>>28]             # <<<<<<<<<<<<<<
28271  *         call._consensus_quality = cns >> 8 & 0xff
28272  *         call._snp_quality = cns & 0xff
28273  */
28274   __pyx_v_call->_genotype = (__pyx_v_9csamtools_bam_nt16_rev_table[(__pyx_v_cns >> 28)]);
28275
28276   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3096
28277  *         call._reference_base = rb
28278  *         call._genotype = bam_nt16_rev_table[cns>>28]
28279  *         call._consensus_quality = cns >> 8 & 0xff             # <<<<<<<<<<<<<<
28280  *         call._snp_quality = cns & 0xff
28281  *         call._rms_mapping_quality = cns >> 16&0xff
28282  */
28283   __pyx_v_call->_consensus_quality = ((__pyx_v_cns >> 8) & 0xff);
28284
28285   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3097
28286  *         call._genotype = bam_nt16_rev_table[cns>>28]
28287  *         call._consensus_quality = cns >> 8 & 0xff
28288  *         call._snp_quality = cns & 0xff             # <<<<<<<<<<<<<<
28289  *         call._rms_mapping_quality = cns >> 16&0xff
28290  *         call._coverage = self.iter.n_plp
28291  */
28292   __pyx_v_call->_snp_quality = (__pyx_v_cns & 0xff);
28293
28294   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3098
28295  *         call._consensus_quality = cns >> 8 & 0xff
28296  *         call._snp_quality = cns & 0xff
28297  *         call._rms_mapping_quality = cns >> 16&0xff             # <<<<<<<<<<<<<<
28298  *         call._coverage = self.iter.n_plp
28299  * 
28300  */
28301   __pyx_v_call->_rms_mapping_quality = ((__pyx_v_cns >> 16) & 0xff);
28302
28303   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3099
28304  *         call._snp_quality = cns & 0xff
28305  *         call._rms_mapping_quality = cns >> 16&0xff
28306  *         call._coverage = self.iter.n_plp             # <<<<<<<<<<<<<<
28307  * 
28308  *         return call
28309  */
28310   __pyx_v_call->_coverage = ((struct __pyx_obj_9csamtools_SNPCaller *)__pyx_v_self)->__pyx_base.iter->n_plp;
28311
28312   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3101
28313  *         call._coverage = self.iter.n_plp
28314  * 
28315  *         return call             # <<<<<<<<<<<<<<
28316  * 
28317  * cdef class IndelCall:
28318  */
28319   __Pyx_XDECREF(__pyx_r);
28320   __Pyx_INCREF(((PyObject *)__pyx_v_call));
28321   __pyx_r = ((PyObject *)__pyx_v_call);
28322   goto __pyx_L0;
28323
28324   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
28325   goto __pyx_L0;
28326   __pyx_L1_error:;
28327   __Pyx_XDECREF(__pyx_t_1);
28328   __Pyx_XDECREF(__pyx_t_2);
28329   __Pyx_XDECREF(__pyx_t_3);
28330   __Pyx_XDECREF(__pyx_t_5);
28331   __Pyx_AddTraceback("csamtools.SNPCaller.call");
28332   __pyx_r = NULL;
28333   __pyx_L0:;
28334   __Pyx_DECREF((PyObject *)__pyx_v_call);
28335   __Pyx_XGIVEREF(__pyx_r);
28336   __Pyx_TraceReturn(__pyx_r);
28337   __Pyx_RefNannyFinishContext();
28338   return __pyx_r;
28339 }
28340
28341 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3111
28342  *     cdef bam_maqindel_ret_t * _r
28343  * 
28344  *     def __cinit__(self):             # <<<<<<<<<<<<<<
28345  *         #assert r != NULL
28346  *         #self._r = r
28347  */
28348
28349 static int __pyx_pf_9csamtools_9IndelCall___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
28350 static int __pyx_pf_9csamtools_9IndelCall___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
28351   int __pyx_r;
28352   __Pyx_TraceDeclarations
28353   __Pyx_RefNannySetupContext("__cinit__");
28354   __Pyx_TraceCall("__cinit__", __pyx_f[0], 3111);
28355   if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
28356     __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
28357   if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;
28358
28359   __pyx_r = 0;
28360   __Pyx_TraceReturn(Py_None);
28361   __Pyx_RefNannyFinishContext();
28362   return __pyx_r;
28363 }
28364
28365 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3118
28366  *     property tid:
28367  *         '''the chromosome ID as is defined in the header'''
28368  *         def __get__(self):             # <<<<<<<<<<<<<<
28369  *             return self._tid
28370  * 
28371  */
28372
28373 static PyObject *__pyx_pf_9csamtools_9IndelCall_3tid___get__(PyObject *__pyx_v_self); /*proto*/
28374 static PyObject *__pyx_pf_9csamtools_9IndelCall_3tid___get__(PyObject *__pyx_v_self) {
28375   PyObject *__pyx_r = NULL;
28376   PyObject *__pyx_t_1 = NULL;
28377   __Pyx_TraceDeclarations
28378   __Pyx_RefNannySetupContext("__get__");
28379   __Pyx_TraceCall("__get__", __pyx_f[0], 3118);
28380
28381   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3119
28382  *         '''the chromosome ID as is defined in the header'''
28383  *         def __get__(self):
28384  *             return self._tid             # <<<<<<<<<<<<<<
28385  * 
28386  *     property pos:
28387  */
28388   __Pyx_XDECREF(__pyx_r);
28389   __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;}
28390   __Pyx_GOTREF(__pyx_t_1);
28391   __pyx_r = __pyx_t_1;
28392   __pyx_t_1 = 0;
28393   goto __pyx_L0;
28394
28395   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
28396   goto __pyx_L0;
28397   __pyx_L1_error:;
28398   __Pyx_XDECREF(__pyx_t_1);
28399   __Pyx_AddTraceback("csamtools.IndelCall.tid.__get__");
28400   __pyx_r = NULL;
28401   __pyx_L0:;
28402   __Pyx_XGIVEREF(__pyx_r);
28403   __Pyx_TraceReturn(__pyx_r);
28404   __Pyx_RefNannyFinishContext();
28405   return __pyx_r;
28406 }
28407
28408 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3123
28409  *     property pos:
28410  *        '''nucleotide position of SNP.'''
28411  *        def __get__(self): return self._pos             # <<<<<<<<<<<<<<
28412  * 
28413  *     property genotype:
28414  */
28415
28416 static PyObject *__pyx_pf_9csamtools_9IndelCall_3pos___get__(PyObject *__pyx_v_self); /*proto*/
28417 static PyObject *__pyx_pf_9csamtools_9IndelCall_3pos___get__(PyObject *__pyx_v_self) {
28418   PyObject *__pyx_r = NULL;
28419   PyObject *__pyx_t_1 = NULL;
28420   __Pyx_TraceDeclarations
28421   __Pyx_RefNannySetupContext("__get__");
28422   __Pyx_TraceCall("__get__", __pyx_f[0], 3123);
28423   __Pyx_XDECREF(__pyx_r);
28424   __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;}
28425   __Pyx_GOTREF(__pyx_t_1);
28426   __pyx_r = __pyx_t_1;
28427   __pyx_t_1 = 0;
28428   goto __pyx_L0;
28429
28430   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
28431   goto __pyx_L0;
28432   __pyx_L1_error:;
28433   __Pyx_XDECREF(__pyx_t_1);
28434   __Pyx_AddTraceback("csamtools.IndelCall.pos.__get__");
28435   __pyx_r = NULL;
28436   __pyx_L0:;
28437   __Pyx_XGIVEREF(__pyx_r);
28438   __Pyx_TraceReturn(__pyx_r);
28439   __Pyx_RefNannyFinishContext();
28440   return __pyx_r;
28441 }
28442
28443 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3127
28444  *     property genotype:
28445  *        '''the genotype called.'''
28446  *        def __get__(self):             # <<<<<<<<<<<<<<
28447  *            if self._r.gt == 0:
28448  *                s = PyString_FromStringAndSize( self._r.s[0], self._r.indel1 + 1)
28449  */
28450
28451 static PyObject *__pyx_pf_9csamtools_9IndelCall_8genotype___get__(PyObject *__pyx_v_self); /*proto*/
28452 static PyObject *__pyx_pf_9csamtools_9IndelCall_8genotype___get__(PyObject *__pyx_v_self) {
28453   PyObject *__pyx_v_s;
28454   PyObject *__pyx_r = NULL;
28455   PyObject *__pyx_t_1 = NULL;
28456   PyObject *__pyx_t_2 = NULL;
28457   PyObject *__pyx_t_3 = NULL;
28458   __Pyx_TraceDeclarations
28459   __Pyx_RefNannySetupContext("__get__");
28460   __Pyx_TraceCall("__get__", __pyx_f[0], 3127);
28461   __pyx_v_s = Py_None; __Pyx_INCREF(Py_None);
28462
28463   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3128
28464  *        '''the genotype called.'''
28465  *        def __get__(self):
28466  *            if self._r.gt == 0:             # <<<<<<<<<<<<<<
28467  *                s = PyString_FromStringAndSize( self._r.s[0], self._r.indel1 + 1)
28468  *                return "%s/%s" % (s,s)
28469  */
28470   switch (((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r->gt) {
28471     case 0:
28472
28473     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3129
28474  *        def __get__(self):
28475  *            if self._r.gt == 0:
28476  *                s = PyString_FromStringAndSize( self._r.s[0], self._r.indel1 + 1)             # <<<<<<<<<<<<<<
28477  *                return "%s/%s" % (s,s)
28478  *            elif self._r.gt == 1:
28479  */
28480     __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;}
28481     __Pyx_GOTREF(__pyx_t_1);
28482     __Pyx_DECREF(__pyx_v_s);
28483     __pyx_v_s = __pyx_t_1;
28484     __pyx_t_1 = 0;
28485
28486     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3130
28487  *            if self._r.gt == 0:
28488  *                s = PyString_FromStringAndSize( self._r.s[0], self._r.indel1 + 1)
28489  *                return "%s/%s" % (s,s)             # <<<<<<<<<<<<<<
28490  *            elif self._r.gt == 1:
28491  *                s = PyString_FromStringAndSize( self._r.s[1], self._r.indel2 + 1)
28492  */
28493     __Pyx_XDECREF(__pyx_r);
28494     __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;}
28495     __Pyx_GOTREF(__pyx_t_1);
28496     __Pyx_INCREF(__pyx_v_s);
28497     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_s);
28498     __Pyx_GIVEREF(__pyx_v_s);
28499     __Pyx_INCREF(__pyx_v_s);
28500     PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_s);
28501     __Pyx_GIVEREF(__pyx_v_s);
28502     __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;}
28503     __Pyx_GOTREF(((PyObject *)__pyx_t_2));
28504     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
28505     __pyx_r = ((PyObject *)__pyx_t_2);
28506     __pyx_t_2 = 0;
28507     goto __pyx_L0;
28508     break;
28509
28510     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3131
28511  *                s = PyString_FromStringAndSize( self._r.s[0], self._r.indel1 + 1)
28512  *                return "%s/%s" % (s,s)
28513  *            elif self._r.gt == 1:             # <<<<<<<<<<<<<<
28514  *                s = PyString_FromStringAndSize( self._r.s[1], self._r.indel2 + 1)
28515  *                return "%s/%s" % (s,s)
28516  */
28517     case 1:
28518
28519     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3132
28520  *                return "%s/%s" % (s,s)
28521  *            elif self._r.gt == 1:
28522  *                s = PyString_FromStringAndSize( self._r.s[1], self._r.indel2 + 1)             # <<<<<<<<<<<<<<
28523  *                return "%s/%s" % (s,s)
28524  *            else:
28525  */
28526     __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;}
28527     __Pyx_GOTREF(__pyx_t_2);
28528     __Pyx_DECREF(__pyx_v_s);
28529     __pyx_v_s = __pyx_t_2;
28530     __pyx_t_2 = 0;
28531
28532     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3133
28533  *            elif self._r.gt == 1:
28534  *                s = PyString_FromStringAndSize( self._r.s[1], self._r.indel2 + 1)
28535  *                return "%s/%s" % (s,s)             # <<<<<<<<<<<<<<
28536  *            else:
28537  *                return "%s/%s" % (self.first_allele, self.second_allele )
28538  */
28539     __Pyx_XDECREF(__pyx_r);
28540     __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;}
28541     __Pyx_GOTREF(__pyx_t_2);
28542     __Pyx_INCREF(__pyx_v_s);
28543     PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_s);
28544     __Pyx_GIVEREF(__pyx_v_s);
28545     __Pyx_INCREF(__pyx_v_s);
28546     PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_s);
28547     __Pyx_GIVEREF(__pyx_v_s);
28548     __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;}
28549     __Pyx_GOTREF(((PyObject *)__pyx_t_1));
28550     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
28551     __pyx_r = ((PyObject *)__pyx_t_1);
28552     __pyx_t_1 = 0;
28553     goto __pyx_L0;
28554     break;
28555     default:
28556
28557     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3135
28558  *                return "%s/%s" % (s,s)
28559  *            else:
28560  *                return "%s/%s" % (self.first_allele, self.second_allele )             # <<<<<<<<<<<<<<
28561  * 
28562  *     property consensus_quality:
28563  */
28564     __Pyx_XDECREF(__pyx_r);
28565     __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;}
28566     __Pyx_GOTREF(__pyx_t_1);
28567     __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;}
28568     __Pyx_GOTREF(__pyx_t_2);
28569     __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;}
28570     __Pyx_GOTREF(__pyx_t_3);
28571     PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
28572     __Pyx_GIVEREF(__pyx_t_1);
28573     PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
28574     __Pyx_GIVEREF(__pyx_t_2);
28575     __pyx_t_1 = 0;
28576     __pyx_t_2 = 0;
28577     __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;}
28578     __Pyx_GOTREF(((PyObject *)__pyx_t_2));
28579     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
28580     __pyx_r = ((PyObject *)__pyx_t_2);
28581     __pyx_t_2 = 0;
28582     goto __pyx_L0;
28583     break;
28584   }
28585
28586   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
28587   goto __pyx_L0;
28588   __pyx_L1_error:;
28589   __Pyx_XDECREF(__pyx_t_1);
28590   __Pyx_XDECREF(__pyx_t_2);
28591   __Pyx_XDECREF(__pyx_t_3);
28592   __Pyx_AddTraceback("csamtools.IndelCall.genotype.__get__");
28593   __pyx_r = NULL;
28594   __pyx_L0:;
28595   __Pyx_DECREF(__pyx_v_s);
28596   __Pyx_XGIVEREF(__pyx_r);
28597   __Pyx_TraceReturn(__pyx_r);
28598   __Pyx_RefNannyFinishContext();
28599   return __pyx_r;
28600 }
28601
28602 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3139
28603  *     property consensus_quality:
28604  *        '''the genotype quality (Phred-scaled).'''
28605  *        def __get__(self): return self._r.q_cns             # <<<<<<<<<<<<<<
28606  * 
28607  *     property snp_quality:
28608  */
28609
28610 static PyObject *__pyx_pf_9csamtools_9IndelCall_17consensus_quality___get__(PyObject *__pyx_v_self); /*proto*/
28611 static PyObject *__pyx_pf_9csamtools_9IndelCall_17consensus_quality___get__(PyObject *__pyx_v_self) {
28612   PyObject *__pyx_r = NULL;
28613   PyObject *__pyx_t_1 = NULL;
28614   __Pyx_TraceDeclarations
28615   __Pyx_RefNannySetupContext("__get__");
28616   __Pyx_TraceCall("__get__", __pyx_f[0], 3139);
28617   __Pyx_XDECREF(__pyx_r);
28618   __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;}
28619   __Pyx_GOTREF(__pyx_t_1);
28620   __pyx_r = __pyx_t_1;
28621   __pyx_t_1 = 0;
28622   goto __pyx_L0;
28623
28624   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
28625   goto __pyx_L0;
28626   __pyx_L1_error:;
28627   __Pyx_XDECREF(__pyx_t_1);
28628   __Pyx_AddTraceback("csamtools.IndelCall.consensus_quality.__get__");
28629   __pyx_r = NULL;
28630   __pyx_L0:;
28631   __Pyx_XGIVEREF(__pyx_r);
28632   __Pyx_TraceReturn(__pyx_r);
28633   __Pyx_RefNannyFinishContext();
28634   return __pyx_r;
28635 }
28636
28637 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3143
28638  *     property snp_quality:
28639  *        '''the snp quality (Phred scaled) - probability of consensus being identical to reference sequence.'''
28640  *        def __get__(self): return self._r.q_ref             # <<<<<<<<<<<<<<
28641  * 
28642  *     property mapping_quality:
28643  */
28644
28645 static PyObject *__pyx_pf_9csamtools_9IndelCall_11snp_quality___get__(PyObject *__pyx_v_self); /*proto*/
28646 static PyObject *__pyx_pf_9csamtools_9IndelCall_11snp_quality___get__(PyObject *__pyx_v_self) {
28647   PyObject *__pyx_r = NULL;
28648   PyObject *__pyx_t_1 = NULL;
28649   __Pyx_TraceDeclarations
28650   __Pyx_RefNannySetupContext("__get__");
28651   __Pyx_TraceCall("__get__", __pyx_f[0], 3143);
28652   __Pyx_XDECREF(__pyx_r);
28653   __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;}
28654   __Pyx_GOTREF(__pyx_t_1);
28655   __pyx_r = __pyx_t_1;
28656   __pyx_t_1 = 0;
28657   goto __pyx_L0;
28658
28659   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
28660   goto __pyx_L0;
28661   __pyx_L1_error:;
28662   __Pyx_XDECREF(__pyx_t_1);
28663   __Pyx_AddTraceback("csamtools.IndelCall.snp_quality.__get__");
28664   __pyx_r = NULL;
28665   __pyx_L0:;
28666   __Pyx_XGIVEREF(__pyx_r);
28667   __Pyx_TraceReturn(__pyx_r);
28668   __Pyx_RefNannyFinishContext();
28669   return __pyx_r;
28670 }
28671
28672 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3147
28673  *     property mapping_quality:
28674  *        '''the root mean square (rms) of the mapping quality of all reads involved in the call.'''
28675  *        def __get__(self): return self._rms_mapping_quality             # <<<<<<<<<<<<<<
28676  * 
28677  *     property coverage:
28678  */
28679
28680 static PyObject *__pyx_pf_9csamtools_9IndelCall_15mapping_quality___get__(PyObject *__pyx_v_self); /*proto*/
28681 static PyObject *__pyx_pf_9csamtools_9IndelCall_15mapping_quality___get__(PyObject *__pyx_v_self) {
28682   PyObject *__pyx_r = NULL;
28683   PyObject *__pyx_t_1 = NULL;
28684   __Pyx_TraceDeclarations
28685   __Pyx_RefNannySetupContext("__get__");
28686   __Pyx_TraceCall("__get__", __pyx_f[0], 3147);
28687   __Pyx_XDECREF(__pyx_r);
28688   __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;}
28689   __Pyx_GOTREF(__pyx_t_1);
28690   __pyx_r = __pyx_t_1;
28691   __pyx_t_1 = 0;
28692   goto __pyx_L0;
28693
28694   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
28695   goto __pyx_L0;
28696   __pyx_L1_error:;
28697   __Pyx_XDECREF(__pyx_t_1);
28698   __Pyx_AddTraceback("csamtools.IndelCall.mapping_quality.__get__");
28699   __pyx_r = NULL;
28700   __pyx_L0:;
28701   __Pyx_XGIVEREF(__pyx_r);
28702   __Pyx_TraceReturn(__pyx_r);
28703   __Pyx_RefNannyFinishContext();
28704   return __pyx_r;
28705 }
28706
28707 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3151
28708  *     property coverage:
28709  *        '''coverage or read depth - the number of reads involved in the call.'''
28710  *        def __get__(self): return self._coverage             # <<<<<<<<<<<<<<
28711  * 
28712  *     property first_allele:
28713  */
28714
28715 static PyObject *__pyx_pf_9csamtools_9IndelCall_8coverage___get__(PyObject *__pyx_v_self); /*proto*/
28716 static PyObject *__pyx_pf_9csamtools_9IndelCall_8coverage___get__(PyObject *__pyx_v_self) {
28717   PyObject *__pyx_r = NULL;
28718   PyObject *__pyx_t_1 = NULL;
28719   __Pyx_TraceDeclarations
28720   __Pyx_RefNannySetupContext("__get__");
28721   __Pyx_TraceCall("__get__", __pyx_f[0], 3151);
28722   __Pyx_XDECREF(__pyx_r);
28723   __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;}
28724   __Pyx_GOTREF(__pyx_t_1);
28725   __pyx_r = __pyx_t_1;
28726   __pyx_t_1 = 0;
28727   goto __pyx_L0;
28728
28729   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
28730   goto __pyx_L0;
28731   __pyx_L1_error:;
28732   __Pyx_XDECREF(__pyx_t_1);
28733   __Pyx_AddTraceback("csamtools.IndelCall.coverage.__get__");
28734   __pyx_r = NULL;
28735   __pyx_L0:;
28736   __Pyx_XGIVEREF(__pyx_r);
28737   __Pyx_TraceReturn(__pyx_r);
28738   __Pyx_RefNannyFinishContext();
28739   return __pyx_r;
28740 }
28741
28742 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3155
28743  *     property first_allele:
28744  *        '''sequence of first allele.'''
28745  *        def __get__(self): return PyString_FromStringAndSize( self._r.s[0], self._r.indel1 + 1)             # <<<<<<<<<<<<<<
28746  * 
28747  *     property second_allele:
28748  */
28749
28750 static PyObject *__pyx_pf_9csamtools_9IndelCall_12first_allele___get__(PyObject *__pyx_v_self); /*proto*/
28751 static PyObject *__pyx_pf_9csamtools_9IndelCall_12first_allele___get__(PyObject *__pyx_v_self) {
28752   PyObject *__pyx_r = NULL;
28753   PyObject *__pyx_t_1 = NULL;
28754   __Pyx_TraceDeclarations
28755   __Pyx_RefNannySetupContext("__get__");
28756   __Pyx_TraceCall("__get__", __pyx_f[0], 3155);
28757   __Pyx_XDECREF(__pyx_r);
28758   __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;}
28759   __Pyx_GOTREF(__pyx_t_1);
28760   __pyx_r = __pyx_t_1;
28761   __pyx_t_1 = 0;
28762   goto __pyx_L0;
28763
28764   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
28765   goto __pyx_L0;
28766   __pyx_L1_error:;
28767   __Pyx_XDECREF(__pyx_t_1);
28768   __Pyx_AddTraceback("csamtools.IndelCall.first_allele.__get__");
28769   __pyx_r = NULL;
28770   __pyx_L0:;
28771   __Pyx_XGIVEREF(__pyx_r);
28772   __Pyx_TraceReturn(__pyx_r);
28773   __Pyx_RefNannyFinishContext();
28774   return __pyx_r;
28775 }
28776
28777 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3159
28778  *     property second_allele:
28779  *        '''sequence of second allele.'''
28780  *        def __get__(self): return PyString_FromStringAndSize( self._r.s[1], self._r.indel2 + 1)             # <<<<<<<<<<<<<<
28781  * 
28782  *     property reads_first:
28783  */
28784
28785 static PyObject *__pyx_pf_9csamtools_9IndelCall_13second_allele___get__(PyObject *__pyx_v_self); /*proto*/
28786 static PyObject *__pyx_pf_9csamtools_9IndelCall_13second_allele___get__(PyObject *__pyx_v_self) {
28787   PyObject *__pyx_r = NULL;
28788   PyObject *__pyx_t_1 = NULL;
28789   __Pyx_TraceDeclarations
28790   __Pyx_RefNannySetupContext("__get__");
28791   __Pyx_TraceCall("__get__", __pyx_f[0], 3159);
28792   __Pyx_XDECREF(__pyx_r);
28793   __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;}
28794   __Pyx_GOTREF(__pyx_t_1);
28795   __pyx_r = __pyx_t_1;
28796   __pyx_t_1 = 0;
28797   goto __pyx_L0;
28798
28799   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
28800   goto __pyx_L0;
28801   __pyx_L1_error:;
28802   __Pyx_XDECREF(__pyx_t_1);
28803   __Pyx_AddTraceback("csamtools.IndelCall.second_allele.__get__");
28804   __pyx_r = NULL;
28805   __pyx_L0:;
28806   __Pyx_XGIVEREF(__pyx_r);
28807   __Pyx_TraceReturn(__pyx_r);
28808   __Pyx_RefNannyFinishContext();
28809   return __pyx_r;
28810 }
28811
28812 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3163
28813  *     property reads_first:
28814  *        '''reads supporting first allele.'''
28815  *        def __get__(self): return self._r.cnt1             # <<<<<<<<<<<<<<
28816  * 
28817  *     property reads_second:
28818  */
28819
28820 static PyObject *__pyx_pf_9csamtools_9IndelCall_11reads_first___get__(PyObject *__pyx_v_self); /*proto*/
28821 static PyObject *__pyx_pf_9csamtools_9IndelCall_11reads_first___get__(PyObject *__pyx_v_self) {
28822   PyObject *__pyx_r = NULL;
28823   PyObject *__pyx_t_1 = NULL;
28824   __Pyx_TraceDeclarations
28825   __Pyx_RefNannySetupContext("__get__");
28826   __Pyx_TraceCall("__get__", __pyx_f[0], 3163);
28827   __Pyx_XDECREF(__pyx_r);
28828   __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;}
28829   __Pyx_GOTREF(__pyx_t_1);
28830   __pyx_r = __pyx_t_1;
28831   __pyx_t_1 = 0;
28832   goto __pyx_L0;
28833
28834   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
28835   goto __pyx_L0;
28836   __pyx_L1_error:;
28837   __Pyx_XDECREF(__pyx_t_1);
28838   __Pyx_AddTraceback("csamtools.IndelCall.reads_first.__get__");
28839   __pyx_r = NULL;
28840   __pyx_L0:;
28841   __Pyx_XGIVEREF(__pyx_r);
28842   __Pyx_TraceReturn(__pyx_r);
28843   __Pyx_RefNannyFinishContext();
28844   return __pyx_r;
28845 }
28846
28847 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3167
28848  *     property reads_second:
28849  *        '''reads supporting first allele.'''
28850  *        def __get__(self): return self._r.cnt2             # <<<<<<<<<<<<<<
28851  * 
28852  *     property reads_diff:
28853  */
28854
28855 static PyObject *__pyx_pf_9csamtools_9IndelCall_12reads_second___get__(PyObject *__pyx_v_self); /*proto*/
28856 static PyObject *__pyx_pf_9csamtools_9IndelCall_12reads_second___get__(PyObject *__pyx_v_self) {
28857   PyObject *__pyx_r = NULL;
28858   PyObject *__pyx_t_1 = NULL;
28859   __Pyx_TraceDeclarations
28860   __Pyx_RefNannySetupContext("__get__");
28861   __Pyx_TraceCall("__get__", __pyx_f[0], 3167);
28862   __Pyx_XDECREF(__pyx_r);
28863   __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;}
28864   __Pyx_GOTREF(__pyx_t_1);
28865   __pyx_r = __pyx_t_1;
28866   __pyx_t_1 = 0;
28867   goto __pyx_L0;
28868
28869   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
28870   goto __pyx_L0;
28871   __pyx_L1_error:;
28872   __Pyx_XDECREF(__pyx_t_1);
28873   __Pyx_AddTraceback("csamtools.IndelCall.reads_second.__get__");
28874   __pyx_r = NULL;
28875   __pyx_L0:;
28876   __Pyx_XGIVEREF(__pyx_r);
28877   __Pyx_TraceReturn(__pyx_r);
28878   __Pyx_RefNannyFinishContext();
28879   return __pyx_r;
28880 }
28881
28882 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3171
28883  *     property reads_diff:
28884  *        '''reads supporting first allele.'''
28885  *        def __get__(self): return self._r.cnt_anti             # <<<<<<<<<<<<<<
28886  * 
28887  *     def __str__(self):
28888  */
28889
28890 static PyObject *__pyx_pf_9csamtools_9IndelCall_10reads_diff___get__(PyObject *__pyx_v_self); /*proto*/
28891 static PyObject *__pyx_pf_9csamtools_9IndelCall_10reads_diff___get__(PyObject *__pyx_v_self) {
28892   PyObject *__pyx_r = NULL;
28893   PyObject *__pyx_t_1 = NULL;
28894   __Pyx_TraceDeclarations
28895   __Pyx_RefNannySetupContext("__get__");
28896   __Pyx_TraceCall("__get__", __pyx_f[0], 3171);
28897   __Pyx_XDECREF(__pyx_r);
28898   __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;}
28899   __Pyx_GOTREF(__pyx_t_1);
28900   __pyx_r = __pyx_t_1;
28901   __pyx_t_1 = 0;
28902   goto __pyx_L0;
28903
28904   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
28905   goto __pyx_L0;
28906   __pyx_L1_error:;
28907   __Pyx_XDECREF(__pyx_t_1);
28908   __Pyx_AddTraceback("csamtools.IndelCall.reads_diff.__get__");
28909   __pyx_r = NULL;
28910   __pyx_L0:;
28911   __Pyx_XGIVEREF(__pyx_r);
28912   __Pyx_TraceReturn(__pyx_r);
28913   __Pyx_RefNannyFinishContext();
28914   return __pyx_r;
28915 }
28916
28917 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3173
28918  *        def __get__(self): return self._r.cnt_anti
28919  * 
28920  *     def __str__(self):             # <<<<<<<<<<<<<<
28921  * 
28922  *         return "\t".join( map(str, (
28923  */
28924
28925 static PyObject *__pyx_pf_9csamtools_9IndelCall___str__(PyObject *__pyx_v_self); /*proto*/
28926 static PyObject *__pyx_pf_9csamtools_9IndelCall___str__(PyObject *__pyx_v_self) {
28927   PyObject *__pyx_r = NULL;
28928   PyObject *__pyx_t_1 = NULL;
28929   PyObject *__pyx_t_2 = NULL;
28930   PyObject *__pyx_t_3 = NULL;
28931   PyObject *__pyx_t_4 = NULL;
28932   PyObject *__pyx_t_5 = NULL;
28933   PyObject *__pyx_t_6 = NULL;
28934   PyObject *__pyx_t_7 = NULL;
28935   PyObject *__pyx_t_8 = NULL;
28936   PyObject *__pyx_t_9 = NULL;
28937   PyObject *__pyx_t_10 = NULL;
28938   PyObject *__pyx_t_11 = NULL;
28939   PyObject *__pyx_t_12 = NULL;
28940   PyObject *__pyx_t_13 = NULL;
28941   PyObject *__pyx_t_14 = NULL;
28942   __Pyx_TraceDeclarations
28943   __Pyx_RefNannySetupContext("__str__");
28944   __Pyx_TraceCall("__str__", __pyx_f[0], 3173);
28945
28946   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3175
28947  *     def __str__(self):
28948  * 
28949  *         return "\t".join( map(str, (             # <<<<<<<<<<<<<<
28950  *                     self.tid,
28951  *                     self.pos,
28952  */
28953   __Pyx_XDECREF(__pyx_r);
28954   __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;}
28955   __Pyx_GOTREF(__pyx_t_1);
28956
28957   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3176
28958  * 
28959  *         return "\t".join( map(str, (
28960  *                     self.tid,             # <<<<<<<<<<<<<<
28961  *                     self.pos,
28962  *                     self.genotype,
28963  */
28964   __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;}
28965   __Pyx_GOTREF(__pyx_t_2);
28966
28967   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3177
28968  *         return "\t".join( map(str, (
28969  *                     self.tid,
28970  *                     self.pos,             # <<<<<<<<<<<<<<
28971  *                     self.genotype,
28972  *                     self.consensus_quality,
28973  */
28974   __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;}
28975   __Pyx_GOTREF(__pyx_t_3);
28976
28977   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3178
28978  *                     self.tid,
28979  *                     self.pos,
28980  *                     self.genotype,             # <<<<<<<<<<<<<<
28981  *                     self.consensus_quality,
28982  *                     self.snp_quality,
28983  */
28984   __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;}
28985   __Pyx_GOTREF(__pyx_t_4);
28986
28987   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3179
28988  *                     self.pos,
28989  *                     self.genotype,
28990  *                     self.consensus_quality,             # <<<<<<<<<<<<<<
28991  *                     self.snp_quality,
28992  *                     self.mapping_quality,
28993  */
28994   __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;}
28995   __Pyx_GOTREF(__pyx_t_5);
28996
28997   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3180
28998  *                     self.genotype,
28999  *                     self.consensus_quality,
29000  *                     self.snp_quality,             # <<<<<<<<<<<<<<
29001  *                     self.mapping_quality,
29002  *                     self.coverage,
29003  */
29004   __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;}
29005   __Pyx_GOTREF(__pyx_t_6);
29006
29007   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3181
29008  *                     self.consensus_quality,
29009  *                     self.snp_quality,
29010  *                     self.mapping_quality,             # <<<<<<<<<<<<<<
29011  *                     self.coverage,
29012  *                     self.first_allele,
29013  */
29014   __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;}
29015   __Pyx_GOTREF(__pyx_t_7);
29016
29017   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3182
29018  *                     self.snp_quality,
29019  *                     self.mapping_quality,
29020  *                     self.coverage,             # <<<<<<<<<<<<<<
29021  *                     self.first_allele,
29022  *                     self.second_allele,
29023  */
29024   __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;}
29025   __Pyx_GOTREF(__pyx_t_8);
29026
29027   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3183
29028  *                     self.mapping_quality,
29029  *                     self.coverage,
29030  *                     self.first_allele,             # <<<<<<<<<<<<<<
29031  *                     self.second_allele,
29032  *                     self.reads_first,
29033  */
29034   __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;}
29035   __Pyx_GOTREF(__pyx_t_9);
29036
29037   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3184
29038  *                     self.coverage,
29039  *                     self.first_allele,
29040  *                     self.second_allele,             # <<<<<<<<<<<<<<
29041  *                     self.reads_first,
29042  *                     self.reads_second,
29043  */
29044   __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;}
29045   __Pyx_GOTREF(__pyx_t_10);
29046
29047   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3185
29048  *                     self.first_allele,
29049  *                     self.second_allele,
29050  *                     self.reads_first,             # <<<<<<<<<<<<<<
29051  *                     self.reads_second,
29052  *                     self.reads_diff ) ) )
29053  */
29054   __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;}
29055   __Pyx_GOTREF(__pyx_t_11);
29056
29057   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3186
29058  *                     self.second_allele,
29059  *                     self.reads_first,
29060  *                     self.reads_second,             # <<<<<<<<<<<<<<
29061  *                     self.reads_diff ) ) )
29062  * 
29063  */
29064   __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;}
29065   __Pyx_GOTREF(__pyx_t_12);
29066
29067   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3187
29068  *                     self.reads_first,
29069  *                     self.reads_second,
29070  *                     self.reads_diff ) ) )             # <<<<<<<<<<<<<<
29071  * 
29072  *     def __dealloc__(self ):
29073  */
29074   __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;}
29075   __Pyx_GOTREF(__pyx_t_13);
29076   __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;}
29077   __Pyx_GOTREF(__pyx_t_14);
29078   PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_2);
29079   __Pyx_GIVEREF(__pyx_t_2);
29080   PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_3);
29081   __Pyx_GIVEREF(__pyx_t_3);
29082   PyTuple_SET_ITEM(__pyx_t_14, 2, __pyx_t_4);
29083   __Pyx_GIVEREF(__pyx_t_4);
29084   PyTuple_SET_ITEM(__pyx_t_14, 3, __pyx_t_5);
29085   __Pyx_GIVEREF(__pyx_t_5);
29086   PyTuple_SET_ITEM(__pyx_t_14, 4, __pyx_t_6);
29087   __Pyx_GIVEREF(__pyx_t_6);
29088   PyTuple_SET_ITEM(__pyx_t_14, 5, __pyx_t_7);
29089   __Pyx_GIVEREF(__pyx_t_7);
29090   PyTuple_SET_ITEM(__pyx_t_14, 6, __pyx_t_8);
29091   __Pyx_GIVEREF(__pyx_t_8);
29092   PyTuple_SET_ITEM(__pyx_t_14, 7, __pyx_t_9);
29093   __Pyx_GIVEREF(__pyx_t_9);
29094   PyTuple_SET_ITEM(__pyx_t_14, 8, __pyx_t_10);
29095   __Pyx_GIVEREF(__pyx_t_10);
29096   PyTuple_SET_ITEM(__pyx_t_14, 9, __pyx_t_11);
29097   __Pyx_GIVEREF(__pyx_t_11);
29098   PyTuple_SET_ITEM(__pyx_t_14, 10, __pyx_t_12);
29099   __Pyx_GIVEREF(__pyx_t_12);
29100   PyTuple_SET_ITEM(__pyx_t_14, 11, __pyx_t_13);
29101   __Pyx_GIVEREF(__pyx_t_13);
29102   __pyx_t_2 = 0;
29103   __pyx_t_3 = 0;
29104   __pyx_t_4 = 0;
29105   __pyx_t_5 = 0;
29106   __pyx_t_6 = 0;
29107   __pyx_t_7 = 0;
29108   __pyx_t_8 = 0;
29109   __pyx_t_9 = 0;
29110   __pyx_t_10 = 0;
29111   __pyx_t_11 = 0;
29112   __pyx_t_12 = 0;
29113   __pyx_t_13 = 0;
29114   __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;}
29115   __Pyx_GOTREF(__pyx_t_13);
29116   __Pyx_INCREF(((PyObject *)((PyObject*)&PyString_Type)));
29117   PyTuple_SET_ITEM(__pyx_t_13, 0, ((PyObject *)((PyObject*)&PyString_Type)));
29118   __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyString_Type)));
29119   PyTuple_SET_ITEM(__pyx_t_13, 1, __pyx_t_14);
29120   __Pyx_GIVEREF(__pyx_t_14);
29121   __pyx_t_14 = 0;
29122   __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;}
29123   __Pyx_GOTREF(__pyx_t_14);
29124   __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
29125   __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;}
29126   __Pyx_GOTREF(__pyx_t_13);
29127   PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_14);
29128   __Pyx_GIVEREF(__pyx_t_14);
29129   __pyx_t_14 = 0;
29130   __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;}
29131   __Pyx_GOTREF(__pyx_t_14);
29132   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
29133   __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
29134   __pyx_r = __pyx_t_14;
29135   __pyx_t_14 = 0;
29136   goto __pyx_L0;
29137
29138   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
29139   goto __pyx_L0;
29140   __pyx_L1_error:;
29141   __Pyx_XDECREF(__pyx_t_1);
29142   __Pyx_XDECREF(__pyx_t_2);
29143   __Pyx_XDECREF(__pyx_t_3);
29144   __Pyx_XDECREF(__pyx_t_4);
29145   __Pyx_XDECREF(__pyx_t_5);
29146   __Pyx_XDECREF(__pyx_t_6);
29147   __Pyx_XDECREF(__pyx_t_7);
29148   __Pyx_XDECREF(__pyx_t_8);
29149   __Pyx_XDECREF(__pyx_t_9);
29150   __Pyx_XDECREF(__pyx_t_10);
29151   __Pyx_XDECREF(__pyx_t_11);
29152   __Pyx_XDECREF(__pyx_t_12);
29153   __Pyx_XDECREF(__pyx_t_13);
29154   __Pyx_XDECREF(__pyx_t_14);
29155   __Pyx_AddTraceback("csamtools.IndelCall.__str__");
29156   __pyx_r = NULL;
29157   __pyx_L0:;
29158   __Pyx_XGIVEREF(__pyx_r);
29159   __Pyx_TraceReturn(__pyx_r);
29160   __Pyx_RefNannyFinishContext();
29161   return __pyx_r;
29162 }
29163
29164 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3189
29165  *                     self.reads_diff ) ) )
29166  * 
29167  *     def __dealloc__(self ):             # <<<<<<<<<<<<<<
29168  *         bam_maqindel_ret_destroy(self._r)
29169  * 
29170  */
29171
29172 static void __pyx_pf_9csamtools_9IndelCall___dealloc__(PyObject *__pyx_v_self); /*proto*/
29173 static void __pyx_pf_9csamtools_9IndelCall___dealloc__(PyObject *__pyx_v_self) {
29174   __Pyx_TraceDeclarations
29175   __Pyx_RefNannySetupContext("__dealloc__");
29176   __Pyx_TraceCall("__dealloc__", __pyx_f[0], 3189);
29177
29178   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3190
29179  * 
29180  *     def __dealloc__(self ):
29181  *         bam_maqindel_ret_destroy(self._r)             # <<<<<<<<<<<<<<
29182  * 
29183  * cdef class IndelCallerBase:
29184  */
29185   bam_maqindel_ret_destroy(((struct __pyx_obj_9csamtools_IndelCall *)__pyx_v_self)->_r);
29186
29187   __Pyx_TraceReturn(Py_None);
29188   __Pyx_RefNannyFinishContext();
29189 }
29190
29191 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3212
29192  *     cdef int max_depth
29193  * 
29194  *     def __cinit__(self,             # <<<<<<<<<<<<<<
29195  *                   IteratorColumn iterator_column,
29196  *                   **kwargs ):
29197  */
29198
29199 static int __pyx_pf_9csamtools_15IndelCallerBase___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
29200 static int __pyx_pf_9csamtools_15IndelCallerBase___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
29201   struct __pyx_obj_9csamtools_IteratorColumn *__pyx_v_iterator_column = 0;
29202   PyObject *__pyx_v_kwargs = 0;
29203   int __pyx_r;
29204   PyObject *__pyx_t_1 = NULL;
29205   PyObject *__pyx_t_2 = NULL;
29206   int __pyx_t_3;
29207   float __pyx_t_4;
29208   int __pyx_t_5;
29209   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__iterator_column,0};
29210   __Pyx_TraceDeclarations
29211   __Pyx_RefNannySetupContext("__cinit__");
29212   __Pyx_TraceCall("__cinit__", __pyx_f[0], 3212);
29213   __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
29214   __Pyx_GOTREF(__pyx_v_kwargs);
29215   if (unlikely(__pyx_kwds)) {
29216     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
29217     PyObject* values[1] = {0};
29218     switch (PyTuple_GET_SIZE(__pyx_args)) {
29219       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
29220       case  0: break;
29221       default: goto __pyx_L5_argtuple_error;
29222     }
29223     switch (PyTuple_GET_SIZE(__pyx_args)) {
29224       case  0:
29225       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__iterator_column);
29226       if (likely(values[0])) kw_args--;
29227       else goto __pyx_L5_argtuple_error;
29228     }
29229     if (unlikely(kw_args > 0)) {
29230       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;}
29231     }
29232     __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)values[0]);
29233   } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
29234     goto __pyx_L5_argtuple_error;
29235   } else {
29236     __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)PyTuple_GET_ITEM(__pyx_args, 0));
29237   }
29238   goto __pyx_L4_argument_unpacking_done;
29239   __pyx_L5_argtuple_error:;
29240   __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;}
29241   __pyx_L3_error:;
29242   __Pyx_DECREF(__pyx_v_kwargs);
29243   __Pyx_AddTraceback("csamtools.IndelCallerBase.__cinit__");
29244   __Pyx_RefNannyFinishContext();
29245   return -1;
29246   __pyx_L4_argument_unpacking_done:;
29247   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;}
29248
29249   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3217
29250  * 
29251  * 
29252  *         self.iter = iterator_column             # <<<<<<<<<<<<<<
29253  * 
29254  *         assert iterator_column.hasReference(), "IndelCallerBase requires an pileup iterator with reference sequence"
29255  */
29256   __Pyx_INCREF(((PyObject *)__pyx_v_iterator_column));
29257   __Pyx_GIVEREF(((PyObject *)__pyx_v_iterator_column));
29258   __Pyx_GOTREF(((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter);
29259   __Pyx_DECREF(((PyObject *)((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter));
29260   ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter = __pyx_v_iterator_column;
29261
29262   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3219
29263  *         self.iter = iterator_column
29264  * 
29265  *         assert iterator_column.hasReference(), "IndelCallerBase requires an pileup iterator with reference sequence"             # <<<<<<<<<<<<<<
29266  * 
29267  *         self.options = bam_maqindel_opt_init()
29268  */
29269   #ifndef PYREX_WITHOUT_ASSERTIONS
29270   __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;}
29271   __Pyx_GOTREF(__pyx_t_1);
29272   __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;}
29273   __Pyx_GOTREF(__pyx_t_2);
29274   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
29275   __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;}
29276   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
29277   if (unlikely(!__pyx_t_3)) {
29278     PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_111));
29279     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
29280   }
29281   #endif
29282
29283   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3221
29284  *         assert iterator_column.hasReference(), "IndelCallerBase requires an pileup iterator with reference sequence"
29285  * 
29286  *         self.options = bam_maqindel_opt_init()             # <<<<<<<<<<<<<<
29287  * 
29288  *         # set the default parameterization according to
29289  */
29290   ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->options = bam_maqindel_opt_init();
29291
29292   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3226
29293  *         # samtools
29294  * 
29295  *         self.options.r_indel = kwargs.get( "r_indel", 0.00015 )             # <<<<<<<<<<<<<<
29296  *         self.options.q_indel = kwargs.get( "q_indel", 40 )
29297  *         self.cap_mapQ = kwargs.get( "cap_mapQ", 60 )
29298  */
29299   if (unlikely(__pyx_v_kwargs == Py_None)) {
29300     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;} 
29301   }
29302   __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;}
29303   __Pyx_GOTREF(__pyx_t_2);
29304   __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;}
29305   __Pyx_GOTREF(__pyx_t_1);
29306   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
29307   __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;}
29308   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
29309   ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->options->r_indel = __pyx_t_4;
29310
29311   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3227
29312  * 
29313  *         self.options.r_indel = kwargs.get( "r_indel", 0.00015 )
29314  *         self.options.q_indel = kwargs.get( "q_indel", 40 )             # <<<<<<<<<<<<<<
29315  *         self.cap_mapQ = kwargs.get( "cap_mapQ", 60 )
29316  *         self.max_depth = kwargs.get( "max_depth", 1024 )
29317  */
29318   if (unlikely(__pyx_v_kwargs == Py_None)) {
29319     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;} 
29320   }
29321   __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;}
29322   __Pyx_GOTREF(__pyx_t_1);
29323   __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;}
29324   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
29325   ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->options->q_indel = __pyx_t_5;
29326
29327   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3228
29328  *         self.options.r_indel = kwargs.get( "r_indel", 0.00015 )
29329  *         self.options.q_indel = kwargs.get( "q_indel", 40 )
29330  *         self.cap_mapQ = kwargs.get( "cap_mapQ", 60 )             # <<<<<<<<<<<<<<
29331  *         self.max_depth = kwargs.get( "max_depth", 1024 )
29332  * 
29333  */
29334   if (unlikely(__pyx_v_kwargs == Py_None)) {
29335     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;} 
29336   }
29337   __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;}
29338   __Pyx_GOTREF(__pyx_t_1);
29339   __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;}
29340   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
29341   ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->cap_mapQ = __pyx_t_5;
29342
29343   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3229
29344  *         self.options.q_indel = kwargs.get( "q_indel", 40 )
29345  *         self.cap_mapQ = kwargs.get( "cap_mapQ", 60 )
29346  *         self.max_depth = kwargs.get( "max_depth", 1024 )             # <<<<<<<<<<<<<<
29347  * 
29348  *     def __dealloc__(self):
29349  */
29350   if (unlikely(__pyx_v_kwargs == Py_None)) {
29351     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;} 
29352   }
29353   __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;}
29354   __Pyx_GOTREF(__pyx_t_1);
29355   __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;}
29356   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
29357   ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->max_depth = __pyx_t_5;
29358
29359   __pyx_r = 0;
29360   goto __pyx_L0;
29361   __pyx_L1_error:;
29362   __Pyx_XDECREF(__pyx_t_1);
29363   __Pyx_XDECREF(__pyx_t_2);
29364   __Pyx_AddTraceback("csamtools.IndelCallerBase.__cinit__");
29365   __pyx_r = -1;
29366   __pyx_L0:;
29367   __Pyx_DECREF(__pyx_v_kwargs);
29368   __Pyx_TraceReturn(Py_None);
29369   __Pyx_RefNannyFinishContext();
29370   return __pyx_r;
29371 }
29372
29373 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3231
29374  *         self.max_depth = kwargs.get( "max_depth", 1024 )
29375  * 
29376  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
29377  *         free( self.options )
29378  * 
29379  */
29380
29381 static void __pyx_pf_9csamtools_15IndelCallerBase___dealloc__(PyObject *__pyx_v_self); /*proto*/
29382 static void __pyx_pf_9csamtools_15IndelCallerBase___dealloc__(PyObject *__pyx_v_self) {
29383   __Pyx_TraceDeclarations
29384   __Pyx_RefNannySetupContext("__dealloc__");
29385   __Pyx_TraceCall("__dealloc__", __pyx_f[0], 3231);
29386
29387   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3232
29388  * 
29389  *     def __dealloc__(self):
29390  *         free( self.options )             # <<<<<<<<<<<<<<
29391  * 
29392  *     def _call( self ):
29393  */
29394   free(((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->options);
29395
29396   __Pyx_TraceReturn(Py_None);
29397   __Pyx_RefNannyFinishContext();
29398 }
29399
29400 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3234
29401  *         free( self.options )
29402  * 
29403  *     def _call( self ):             # <<<<<<<<<<<<<<
29404  * 
29405  *         cdef char * seq = self.iter.getSequence()
29406  */
29407
29408 static PyObject *__pyx_pf_9csamtools_15IndelCallerBase__call(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
29409 static char __pyx_doc_9csamtools_15IndelCallerBase__call[] = "IndelCallerBase._call(self)";
29410 static PyObject *__pyx_pf_9csamtools_15IndelCallerBase__call(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
29411   char *__pyx_v_seq;
29412   int __pyx_v_seq_len;
29413   bam_maqindel_ret_t *__pyx_v_r;
29414   int __pyx_v_m;
29415   struct __pyx_obj_9csamtools_IndelCall *__pyx_v_call;
29416   uint64_t __pyx_v_rms_aux;
29417   int __pyx_v_i;
29418   bam_pileup1_t *__pyx_v_p;
29419   int __pyx_v_tmp;
29420   PyObject *__pyx_r = NULL;
29421   PyObject *__pyx_t_1 = NULL;
29422   int __pyx_t_2;
29423   int __pyx_t_3;
29424   PyObject *__pyx_t_4 = NULL;
29425   PyObject *__pyx_t_5 = NULL;
29426   int __pyx_t_6;
29427   int __pyx_t_7;
29428   double __pyx_t_8;
29429   __Pyx_TraceDeclarations
29430   __Pyx_RefNannySetupContext("_call");
29431   __Pyx_TraceCall("_call", __pyx_f[0], 3234);
29432   __pyx_v_call = ((struct __pyx_obj_9csamtools_IndelCall *)Py_None); __Pyx_INCREF(Py_None);
29433
29434   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3236
29435  *     def _call( self ):
29436  * 
29437  *         cdef char * seq = self.iter.getSequence()             # <<<<<<<<<<<<<<
29438  *         cdef int seq_len = self.iter.seq_len
29439  * 
29440  */
29441   __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);
29442
29443   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3237
29444  * 
29445  *         cdef char * seq = self.iter.getSequence()
29446  *         cdef int seq_len = self.iter.seq_len             # <<<<<<<<<<<<<<
29447  * 
29448  *         assert seq != NULL
29449  */
29450   __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;}
29451   __Pyx_GOTREF(__pyx_t_1);
29452   __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;}
29453   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
29454   __pyx_v_seq_len = __pyx_t_2;
29455
29456   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3239
29457  *         cdef int seq_len = self.iter.seq_len
29458  * 
29459  *         assert seq != NULL             # <<<<<<<<<<<<<<
29460  * 
29461  *         # reference base
29462  */
29463   #ifndef PYREX_WITHOUT_ASSERTIONS
29464   if (unlikely(!(__pyx_v_seq != NULL))) {
29465     PyErr_SetNone(PyExc_AssertionError);
29466     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
29467   }
29468   #endif
29469
29470   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3242
29471  * 
29472  *         # reference base
29473  *         if self.iter.pos >= seq_len:             # <<<<<<<<<<<<<<
29474  *             raise ValueError( "position %i out of bounds on reference sequence (len=%i)" % (self.iter.pos, seq_len) )
29475  * 
29476  */
29477   __pyx_t_3 = (((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->pos >= __pyx_v_seq_len);
29478   if (__pyx_t_3) {
29479
29480     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3243
29481  *         # reference base
29482  *         if self.iter.pos >= seq_len:
29483  *             raise ValueError( "position %i out of bounds on reference sequence (len=%i)" % (self.iter.pos, seq_len) )             # <<<<<<<<<<<<<<
29484  * 
29485  *         cdef bam_maqindel_ret_t * r
29486  */
29487     __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;}
29488     __Pyx_GOTREF(__pyx_t_1);
29489     __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;}
29490     __Pyx_GOTREF(__pyx_t_4);
29491     __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;}
29492     __Pyx_GOTREF(__pyx_t_5);
29493     PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_1);
29494     __Pyx_GIVEREF(__pyx_t_1);
29495     PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_4);
29496     __Pyx_GIVEREF(__pyx_t_4);
29497     __pyx_t_1 = 0;
29498     __pyx_t_4 = 0;
29499     __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;}
29500     __Pyx_GOTREF(((PyObject *)__pyx_t_4));
29501     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
29502     __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;}
29503     __Pyx_GOTREF(__pyx_t_5);
29504     PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_4));
29505     __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
29506     __pyx_t_4 = 0;
29507     __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;}
29508     __Pyx_GOTREF(__pyx_t_4);
29509     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
29510     __Pyx_Raise(__pyx_t_4, 0, 0);
29511     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
29512     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
29513     goto __pyx_L5;
29514   }
29515   __pyx_L5:;
29516
29517   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3247
29518  *         cdef bam_maqindel_ret_t * r
29519  * 
29520  *         cdef int m = min( self.max_depth, self.iter.n_plp )             # <<<<<<<<<<<<<<
29521  * 
29522  *         # printf("pysam: m=%i, q_indel=%i, r_indel=%f, r_snp=%i, mm_penalty=%i, indel_err=%i, ambi_thres=%i\n",
29523  */
29524   __pyx_t_2 = ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->n_plp;
29525   __pyx_t_6 = ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->max_depth;
29526   if ((__pyx_t_2 < __pyx_t_6)) {
29527     __pyx_t_7 = __pyx_t_2;
29528   } else {
29529     __pyx_t_7 = __pyx_t_6;
29530   }
29531   __pyx_v_m = __pyx_t_7;
29532
29533   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3259
29534  *                          seq,
29535  *                          0,
29536  *                          NULL)             # <<<<<<<<<<<<<<
29537  * 
29538  *         if r == NULL: return None
29539  */
29540   __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);
29541
29542   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3261
29543  *                          NULL)
29544  * 
29545  *         if r == NULL: return None             # <<<<<<<<<<<<<<
29546  * 
29547  *         cdef IndelCall call
29548  */
29549   __pyx_t_3 = (__pyx_v_r == NULL);
29550   if (__pyx_t_3) {
29551     __Pyx_XDECREF(__pyx_r);
29552     __Pyx_INCREF(Py_None);
29553     __pyx_r = Py_None;
29554     goto __pyx_L0;
29555     goto __pyx_L6;
29556   }
29557   __pyx_L6:;
29558
29559   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3264
29560  * 
29561  *         cdef IndelCall call
29562  *         call = IndelCall()             # <<<<<<<<<<<<<<
29563  *         call._r = r
29564  *         call._tid = self.iter.tid
29565  */
29566   __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;}
29567   __Pyx_GOTREF(__pyx_t_4);
29568   __Pyx_DECREF(((PyObject *)__pyx_v_call));
29569   __pyx_v_call = ((struct __pyx_obj_9csamtools_IndelCall *)__pyx_t_4);
29570   __pyx_t_4 = 0;
29571
29572   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3265
29573  *         cdef IndelCall call
29574  *         call = IndelCall()
29575  *         call._r = r             # <<<<<<<<<<<<<<
29576  *         call._tid = self.iter.tid
29577  *         call._pos = self.iter.pos
29578  */
29579   __pyx_v_call->_r = __pyx_v_r;
29580
29581   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3266
29582  *         call = IndelCall()
29583  *         call._r = r
29584  *         call._tid = self.iter.tid             # <<<<<<<<<<<<<<
29585  *         call._pos = self.iter.pos
29586  *         call._coverage = self.iter.n_plp
29587  */
29588   __pyx_v_call->_tid = ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->tid;
29589
29590   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3267
29591  *         call._r = r
29592  *         call._tid = self.iter.tid
29593  *         call._pos = self.iter.pos             # <<<<<<<<<<<<<<
29594  *         call._coverage = self.iter.n_plp
29595  * 
29596  */
29597   __pyx_v_call->_pos = ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->pos;
29598
29599   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3268
29600  *         call._tid = self.iter.tid
29601  *         call._pos = self.iter.pos
29602  *         call._coverage = self.iter.n_plp             # <<<<<<<<<<<<<<
29603  * 
29604  *         cdef uint64_t rms_aux = 0
29605  */
29606   __pyx_v_call->_coverage = ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->n_plp;
29607
29608   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3270
29609  *         call._coverage = self.iter.n_plp
29610  * 
29611  *         cdef uint64_t rms_aux = 0             # <<<<<<<<<<<<<<
29612  *         cdef int i = 0
29613  *         cdef bam_pileup1_t * p
29614  */
29615   __pyx_v_rms_aux = 0;
29616
29617   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3271
29618  * 
29619  *         cdef uint64_t rms_aux = 0
29620  *         cdef int i = 0             # <<<<<<<<<<<<<<
29621  *         cdef bam_pileup1_t * p
29622  *         cdef int tmp
29623  */
29624   __pyx_v_i = 0;
29625
29626   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3275
29627  *         cdef int tmp
29628  * 
29629  *         for i from 0 <= i < self.iter.n_plp:             # <<<<<<<<<<<<<<
29630  *             p = self.iter.plp + i
29631  *             if p.b.core.qual < self.cap_mapQ:
29632  */
29633   __pyx_t_7 = ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->n_plp;
29634   for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {
29635
29636     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3276
29637  * 
29638  *         for i from 0 <= i < self.iter.n_plp:
29639  *             p = self.iter.plp + i             # <<<<<<<<<<<<<<
29640  *             if p.b.core.qual < self.cap_mapQ:
29641  *                 tmp = p.b.core.qual
29642  */
29643     __pyx_v_p = (((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->plp + __pyx_v_i);
29644
29645     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3277
29646  *         for i from 0 <= i < self.iter.n_plp:
29647  *             p = self.iter.plp + i
29648  *             if p.b.core.qual < self.cap_mapQ:             # <<<<<<<<<<<<<<
29649  *                 tmp = p.b.core.qual
29650  *             else:
29651  */
29652     __pyx_t_3 = (__pyx_v_p->b->core.qual < ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->cap_mapQ);
29653     if (__pyx_t_3) {
29654
29655       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3278
29656  *             p = self.iter.plp + i
29657  *             if p.b.core.qual < self.cap_mapQ:
29658  *                 tmp = p.b.core.qual             # <<<<<<<<<<<<<<
29659  *             else:
29660  *                 tmp = self.cap_mapQ
29661  */
29662       __pyx_v_tmp = __pyx_v_p->b->core.qual;
29663       goto __pyx_L9;
29664     }
29665     /*else*/ {
29666
29667       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3280
29668  *                 tmp = p.b.core.qual
29669  *             else:
29670  *                 tmp = self.cap_mapQ             # <<<<<<<<<<<<<<
29671  *             rms_aux += tmp * tmp
29672  * 
29673  */
29674       __pyx_v_tmp = ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->cap_mapQ;
29675     }
29676     __pyx_L9:;
29677
29678     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3281
29679  *             else:
29680  *                 tmp = self.cap_mapQ
29681  *             rms_aux += tmp * tmp             # <<<<<<<<<<<<<<
29682  * 
29683  *         call._rms_mapping_quality = <uint64_t>(sqrt(<double>rms_aux / self.iter.n_plp) + .499)
29684  */
29685     __pyx_v_rms_aux += (__pyx_v_tmp * __pyx_v_tmp);
29686   }
29687
29688   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3283
29689  *             rms_aux += tmp * tmp
29690  * 
29691  *         call._rms_mapping_quality = <uint64_t>(sqrt(<double>rms_aux / self.iter.n_plp) + .499)             # <<<<<<<<<<<<<<
29692  * 
29693  *         return call
29694  */
29695   __pyx_t_8 = ((double)__pyx_v_rms_aux);
29696   if (unlikely(((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->n_plp == 0)) {
29697     PyErr_Format(PyExc_ZeroDivisionError, "float division");
29698     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
29699   }
29700   __pyx_v_call->_rms_mapping_quality = ((uint64_t)(sqrt((__pyx_t_8 / ((struct __pyx_obj_9csamtools_IndelCallerBase *)__pyx_v_self)->iter->n_plp)) + .499));
29701
29702   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3285
29703  *         call._rms_mapping_quality = <uint64_t>(sqrt(<double>rms_aux / self.iter.n_plp) + .499)
29704  * 
29705  *         return call             # <<<<<<<<<<<<<<
29706  * 
29707  * cdef class IndelCaller( IndelCallerBase ):
29708  */
29709   __Pyx_XDECREF(__pyx_r);
29710   __Pyx_INCREF(((PyObject *)__pyx_v_call));
29711   __pyx_r = ((PyObject *)__pyx_v_call);
29712   goto __pyx_L0;
29713
29714   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
29715   goto __pyx_L0;
29716   __pyx_L1_error:;
29717   __Pyx_XDECREF(__pyx_t_1);
29718   __Pyx_XDECREF(__pyx_t_4);
29719   __Pyx_XDECREF(__pyx_t_5);
29720   __Pyx_AddTraceback("csamtools.IndelCallerBase._call");
29721   __pyx_r = NULL;
29722   __pyx_L0:;
29723   __Pyx_DECREF((PyObject *)__pyx_v_call);
29724   __Pyx_XGIVEREF(__pyx_r);
29725   __Pyx_TraceReturn(__pyx_r);
29726   __Pyx_RefNannyFinishContext();
29727   return __pyx_r;
29728 }
29729
29730 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3300
29731  *     '''
29732  * 
29733  *     def __cinit__(self,             # <<<<<<<<<<<<<<
29734  *                   IteratorColumn iterator_column,
29735  *                   **kwargs ):
29736  */
29737
29738 static int __pyx_pf_9csamtools_11IndelCaller___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
29739 static int __pyx_pf_9csamtools_11IndelCaller___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
29740   struct __pyx_obj_9csamtools_IteratorColumn *__pyx_v_iterator_column = 0;
29741   PyObject *__pyx_v_kwargs = 0;
29742   int __pyx_r;
29743   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__iterator_column,0};
29744   __Pyx_TraceDeclarations
29745   __Pyx_RefNannySetupContext("__cinit__");
29746   __Pyx_TraceCall("__cinit__", __pyx_f[0], 3300);
29747   __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
29748   __Pyx_GOTREF(__pyx_v_kwargs);
29749   if (unlikely(__pyx_kwds)) {
29750     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
29751     PyObject* values[1] = {0};
29752     switch (PyTuple_GET_SIZE(__pyx_args)) {
29753       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
29754       case  0: break;
29755       default: goto __pyx_L5_argtuple_error;
29756     }
29757     switch (PyTuple_GET_SIZE(__pyx_args)) {
29758       case  0:
29759       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__iterator_column);
29760       if (likely(values[0])) kw_args--;
29761       else goto __pyx_L5_argtuple_error;
29762     }
29763     if (unlikely(kw_args > 0)) {
29764       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;}
29765     }
29766     __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)values[0]);
29767   } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
29768     goto __pyx_L5_argtuple_error;
29769   } else {
29770     __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)PyTuple_GET_ITEM(__pyx_args, 0));
29771   }
29772   goto __pyx_L4_argument_unpacking_done;
29773   __pyx_L5_argtuple_error:;
29774   __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;}
29775   __pyx_L3_error:;
29776   __Pyx_DECREF(__pyx_v_kwargs);
29777   __Pyx_AddTraceback("csamtools.IndelCaller.__cinit__");
29778   __Pyx_RefNannyFinishContext();
29779   return -1;
29780   __pyx_L4_argument_unpacking_done:;
29781   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;}
29782
29783   __pyx_r = 0;
29784   goto __pyx_L0;
29785   __pyx_L1_error:;
29786   __Pyx_AddTraceback("csamtools.IndelCaller.__cinit__");
29787   __pyx_r = -1;
29788   __pyx_L0:;
29789   __Pyx_DECREF(__pyx_v_kwargs);
29790   __Pyx_TraceReturn(Py_None);
29791   __Pyx_RefNannyFinishContext();
29792   return __pyx_r;
29793 }
29794
29795 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3306
29796  *         pass
29797  * 
29798  *     def call(self, reference, int pos ):             # <<<<<<<<<<<<<<
29799  *         """call a snp on chromosome *reference*
29800  *         and position *pos*.
29801  */
29802
29803 static PyObject *__pyx_pf_9csamtools_11IndelCaller_call(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
29804 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        ";
29805 static PyObject *__pyx_pf_9csamtools_11IndelCaller_call(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
29806   PyObject *__pyx_v_reference = 0;
29807   int __pyx_v_pos;
29808   int __pyx_v_tid;
29809   PyObject *__pyx_r = NULL;
29810   PyObject *__pyx_t_1 = NULL;
29811   PyObject *__pyx_t_2 = NULL;
29812   PyObject *__pyx_t_3 = NULL;
29813   int __pyx_t_4;
29814   PyObject *__pyx_t_5 = NULL;
29815   int __pyx_t_6;
29816   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__reference,&__pyx_n_s__pos,0};
29817   __Pyx_TraceDeclarations
29818   __Pyx_RefNannySetupContext("call");
29819   __Pyx_TraceCall("call", __pyx_f[0], 3306);
29820   if (unlikely(__pyx_kwds)) {
29821     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
29822     PyObject* values[2] = {0,0};
29823     switch (PyTuple_GET_SIZE(__pyx_args)) {
29824       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
29825       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
29826       case  0: break;
29827       default: goto __pyx_L5_argtuple_error;
29828     }
29829     switch (PyTuple_GET_SIZE(__pyx_args)) {
29830       case  0:
29831       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reference);
29832       if (likely(values[0])) kw_args--;
29833       else goto __pyx_L5_argtuple_error;
29834       case  1:
29835       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__pos);
29836       if (likely(values[1])) kw_args--;
29837       else {
29838         __Pyx_RaiseArgtupleInvalid("call", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3306; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
29839       }
29840     }
29841     if (unlikely(kw_args > 0)) {
29842       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;}
29843     }
29844     __pyx_v_reference = values[0];
29845     __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;}
29846   } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
29847     goto __pyx_L5_argtuple_error;
29848   } else {
29849     __pyx_v_reference = PyTuple_GET_ITEM(__pyx_args, 0);
29850     __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;}
29851   }
29852   goto __pyx_L4_argument_unpacking_done;
29853   __pyx_L5_argtuple_error:;
29854   __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;}
29855   __pyx_L3_error:;
29856   __Pyx_AddTraceback("csamtools.IndelCaller.call");
29857   __Pyx_RefNannyFinishContext();
29858   return NULL;
29859   __pyx_L4_argument_unpacking_done:;
29860
29861   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3313
29862  *         """
29863  * 
29864  *         cdef int tid = self.iter.samfile.gettid( reference )             # <<<<<<<<<<<<<<
29865  * 
29866  *         self.iter.reset( tid, pos, pos + 1 )
29867  */
29868   __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;}
29869   __Pyx_GOTREF(__pyx_t_1);
29870   __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;}
29871   __Pyx_GOTREF(__pyx_t_2);
29872   __Pyx_INCREF(__pyx_v_reference);
29873   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_reference);
29874   __Pyx_GIVEREF(__pyx_v_reference);
29875   __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;}
29876   __Pyx_GOTREF(__pyx_t_3);
29877   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
29878   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
29879   __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;}
29880   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
29881   __pyx_v_tid = __pyx_t_4;
29882
29883   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3315
29884  *         cdef int tid = self.iter.samfile.gettid( reference )
29885  * 
29886  *         self.iter.reset( tid, pos, pos + 1 )             # <<<<<<<<<<<<<<
29887  * 
29888  *         while 1:
29889  */
29890   __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;}
29891   __Pyx_GOTREF(__pyx_t_3);
29892   __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;}
29893   __Pyx_GOTREF(__pyx_t_2);
29894   __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;}
29895   __Pyx_GOTREF(__pyx_t_1);
29896   __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;}
29897   __Pyx_GOTREF(__pyx_t_5);
29898   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
29899   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
29900   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
29901   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
29902
29903   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3317
29904  *         self.iter.reset( tid, pos, pos + 1 )
29905  * 
29906  *         while 1:             # <<<<<<<<<<<<<<
29907  *             self.iter.cnext()
29908  * 
29909  */
29910   while (1) {
29911     if (!1) break;
29912
29913     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3318
29914  * 
29915  *         while 1:
29916  *             self.iter.cnext()             # <<<<<<<<<<<<<<
29917  * 
29918  *             if self.iter.n_plp < 0:
29919  */
29920     ((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);
29921
29922     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3320
29923  *             self.iter.cnext()
29924  * 
29925  *             if self.iter.n_plp < 0:             # <<<<<<<<<<<<<<
29926  *                 raise ValueError("error during iteration" )
29927  * 
29928  */
29929     __pyx_t_6 = (((struct __pyx_obj_9csamtools_IndelCaller *)__pyx_v_self)->__pyx_base.iter->n_plp < 0);
29930     if (__pyx_t_6) {
29931
29932       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3321
29933  * 
29934  *             if self.iter.n_plp < 0:
29935  *                 raise ValueError("error during iteration" )             # <<<<<<<<<<<<<<
29936  * 
29937  *             if self.iter.plp == NULL:
29938  */
29939       __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;}
29940       __Pyx_GOTREF(__pyx_t_5);
29941       __Pyx_INCREF(((PyObject *)__pyx_kp_s_59));
29942       PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_59));
29943       __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_59));
29944       __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;}
29945       __Pyx_GOTREF(__pyx_t_1);
29946       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
29947       __Pyx_Raise(__pyx_t_1, 0, 0);
29948       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
29949       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
29950       goto __pyx_L8;
29951     }
29952     __pyx_L8:;
29953
29954     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3323
29955  *                 raise ValueError("error during iteration" )
29956  * 
29957  *             if self.iter.plp == NULL:             # <<<<<<<<<<<<<<
29958  *                 raise ValueError( "no reads in region - no call" )
29959  * 
29960  */
29961     __pyx_t_6 = (((struct __pyx_obj_9csamtools_IndelCaller *)__pyx_v_self)->__pyx_base.iter->plp == NULL);
29962     if (__pyx_t_6) {
29963
29964       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3324
29965  * 
29966  *             if self.iter.plp == NULL:
29967  *                 raise ValueError( "no reads in region - no call" )             # <<<<<<<<<<<<<<
29968  * 
29969  *             if self.iter.pos == pos: break
29970  */
29971       __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;}
29972       __Pyx_GOTREF(__pyx_t_1);
29973       __Pyx_INCREF(((PyObject *)__pyx_kp_s_109));
29974       PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_109));
29975       __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_109));
29976       __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;}
29977       __Pyx_GOTREF(__pyx_t_5);
29978       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
29979       __Pyx_Raise(__pyx_t_5, 0, 0);
29980       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
29981       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
29982       goto __pyx_L9;
29983     }
29984     __pyx_L9:;
29985
29986     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3326
29987  *                 raise ValueError( "no reads in region - no call" )
29988  * 
29989  *             if self.iter.pos == pos: break             # <<<<<<<<<<<<<<
29990  * 
29991  *         return self._call()
29992  */
29993     __pyx_t_6 = (((struct __pyx_obj_9csamtools_IndelCaller *)__pyx_v_self)->__pyx_base.iter->pos == __pyx_v_pos);
29994     if (__pyx_t_6) {
29995       goto __pyx_L7_break;
29996       goto __pyx_L10;
29997     }
29998     __pyx_L10:;
29999   }
30000   __pyx_L7_break:;
30001
30002   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3328
30003  *             if self.iter.pos == pos: break
30004  * 
30005  *         return self._call()             # <<<<<<<<<<<<<<
30006  * 
30007  * cdef class IteratorIndelCalls( IndelCallerBase ):
30008  */
30009   __Pyx_XDECREF(__pyx_r);
30010   __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;}
30011   __Pyx_GOTREF(__pyx_t_5);
30012   __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;}
30013   __Pyx_GOTREF(__pyx_t_1);
30014   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
30015   __pyx_r = __pyx_t_1;
30016   __pyx_t_1 = 0;
30017   goto __pyx_L0;
30018
30019   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
30020   goto __pyx_L0;
30021   __pyx_L1_error:;
30022   __Pyx_XDECREF(__pyx_t_1);
30023   __Pyx_XDECREF(__pyx_t_2);
30024   __Pyx_XDECREF(__pyx_t_3);
30025   __Pyx_XDECREF(__pyx_t_5);
30026   __Pyx_AddTraceback("csamtools.IndelCaller.call");
30027   __pyx_r = NULL;
30028   __pyx_L0:;
30029   __Pyx_XGIVEREF(__pyx_r);
30030   __Pyx_TraceReturn(__pyx_r);
30031   __Pyx_RefNannyFinishContext();
30032   return __pyx_r;
30033 }
30034
30035 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3344
30036  *     """
30037  * 
30038  *     def __cinit__(self,             # <<<<<<<<<<<<<<
30039  *                   IteratorColumn iterator_column,
30040  *                   **kwargs ):
30041  */
30042
30043 static int __pyx_pf_9csamtools_18IteratorIndelCalls___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
30044 static int __pyx_pf_9csamtools_18IteratorIndelCalls___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
30045   struct __pyx_obj_9csamtools_IteratorColumn *__pyx_v_iterator_column = 0;
30046   PyObject *__pyx_v_kwargs = 0;
30047   int __pyx_r;
30048   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__iterator_column,0};
30049   __Pyx_TraceDeclarations
30050   __Pyx_RefNannySetupContext("__cinit__");
30051   __Pyx_TraceCall("__cinit__", __pyx_f[0], 3344);
30052   __pyx_v_kwargs = PyDict_New(); if (unlikely(!__pyx_v_kwargs)) return -1;
30053   __Pyx_GOTREF(__pyx_v_kwargs);
30054   if (unlikely(__pyx_kwds)) {
30055     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
30056     PyObject* values[1] = {0};
30057     switch (PyTuple_GET_SIZE(__pyx_args)) {
30058       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
30059       case  0: break;
30060       default: goto __pyx_L5_argtuple_error;
30061     }
30062     switch (PyTuple_GET_SIZE(__pyx_args)) {
30063       case  0:
30064       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__iterator_column);
30065       if (likely(values[0])) kw_args--;
30066       else goto __pyx_L5_argtuple_error;
30067     }
30068     if (unlikely(kw_args > 0)) {
30069       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;}
30070     }
30071     __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)values[0]);
30072   } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
30073     goto __pyx_L5_argtuple_error;
30074   } else {
30075     __pyx_v_iterator_column = ((struct __pyx_obj_9csamtools_IteratorColumn *)PyTuple_GET_ITEM(__pyx_args, 0));
30076   }
30077   goto __pyx_L4_argument_unpacking_done;
30078   __pyx_L5_argtuple_error:;
30079   __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;}
30080   __pyx_L3_error:;
30081   __Pyx_DECREF(__pyx_v_kwargs);
30082   __Pyx_AddTraceback("csamtools.IteratorIndelCalls.__cinit__");
30083   __Pyx_RefNannyFinishContext();
30084   return -1;
30085   __pyx_L4_argument_unpacking_done:;
30086   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;}
30087
30088   __pyx_r = 0;
30089   goto __pyx_L0;
30090   __pyx_L1_error:;
30091   __Pyx_AddTraceback("csamtools.IteratorIndelCalls.__cinit__");
30092   __pyx_r = -1;
30093   __pyx_L0:;
30094   __Pyx_DECREF(__pyx_v_kwargs);
30095   __Pyx_TraceReturn(Py_None);
30096   __Pyx_RefNannyFinishContext();
30097   return __pyx_r;
30098 }
30099
30100 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3350
30101  * 
30102  * 
30103  *     def __iter__(self):             # <<<<<<<<<<<<<<
30104  *         return self
30105  * 
30106  */
30107
30108 static PyObject *__pyx_pf_9csamtools_18IteratorIndelCalls___iter__(PyObject *__pyx_v_self); /*proto*/
30109 static PyObject *__pyx_pf_9csamtools_18IteratorIndelCalls___iter__(PyObject *__pyx_v_self) {
30110   PyObject *__pyx_r = NULL;
30111   __Pyx_TraceDeclarations
30112   __Pyx_RefNannySetupContext("__iter__");
30113   __Pyx_TraceCall("__iter__", __pyx_f[0], 3350);
30114
30115   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3351
30116  * 
30117  *     def __iter__(self):
30118  *         return self             # <<<<<<<<<<<<<<
30119  * 
30120  *     def __next__(self):
30121  */
30122   __Pyx_XDECREF(__pyx_r);
30123   __Pyx_INCREF(__pyx_v_self);
30124   __pyx_r = __pyx_v_self;
30125   goto __pyx_L0;
30126
30127   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
30128   __pyx_L0:;
30129   __Pyx_XGIVEREF(__pyx_r);
30130   __Pyx_TraceReturn(__pyx_r);
30131   __Pyx_RefNannyFinishContext();
30132   return __pyx_r;
30133 }
30134
30135 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3353
30136  *         return self
30137  * 
30138  *     def __next__(self):             # <<<<<<<<<<<<<<
30139  *         """python version of next().
30140  *         """
30141  */
30142
30143 static PyObject *__pyx_pf_9csamtools_18IteratorIndelCalls___next__(PyObject *__pyx_v_self); /*proto*/
30144 static char __pyx_doc_9csamtools_18IteratorIndelCalls___next__[] = "python version of next().\n        ";
30145 struct wrapperbase __pyx_wrapperbase_9csamtools_18IteratorIndelCalls___next__;
30146 static PyObject *__pyx_pf_9csamtools_18IteratorIndelCalls___next__(PyObject *__pyx_v_self) {
30147   PyObject *__pyx_r = NULL;
30148   int __pyx_t_1;
30149   PyObject *__pyx_t_2 = NULL;
30150   PyObject *__pyx_t_3 = NULL;
30151   __Pyx_TraceDeclarations
30152   __Pyx_RefNannySetupContext("__next__");
30153   __Pyx_TraceCall("__next__", __pyx_f[0], 3353);
30154
30155   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3358
30156  * 
30157  *         # the following code was adapted from bam_plcmd.c:pileup_func()
30158  *         self.iter.cnext()             # <<<<<<<<<<<<<<
30159  * 
30160  *         if self.iter.n_plp < 0:
30161  */
30162   ((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);
30163
30164   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3360
30165  *         self.iter.cnext()
30166  * 
30167  *         if self.iter.n_plp < 0:             # <<<<<<<<<<<<<<
30168  *             raise ValueError("error during iteration" )
30169  * 
30170  */
30171   __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorIndelCalls *)__pyx_v_self)->__pyx_base.iter->n_plp < 0);
30172   if (__pyx_t_1) {
30173
30174     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3361
30175  * 
30176  *         if self.iter.n_plp < 0:
30177  *             raise ValueError("error during iteration" )             # <<<<<<<<<<<<<<
30178  * 
30179  *         if self.iter.plp == NULL:
30180  */
30181     __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;}
30182     __Pyx_GOTREF(__pyx_t_2);
30183     __Pyx_INCREF(((PyObject *)__pyx_kp_s_59));
30184     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_59));
30185     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_59));
30186     __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;}
30187     __Pyx_GOTREF(__pyx_t_3);
30188     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
30189     __Pyx_Raise(__pyx_t_3, 0, 0);
30190     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
30191     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
30192     goto __pyx_L5;
30193   }
30194   __pyx_L5:;
30195
30196   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3363
30197  *             raise ValueError("error during iteration" )
30198  * 
30199  *         if self.iter.plp == NULL:             # <<<<<<<<<<<<<<
30200  *            raise StopIteration
30201  * 
30202  */
30203   __pyx_t_1 = (((struct __pyx_obj_9csamtools_IteratorIndelCalls *)__pyx_v_self)->__pyx_base.iter->plp == NULL);
30204   if (__pyx_t_1) {
30205
30206     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3364
30207  * 
30208  *         if self.iter.plp == NULL:
30209  *            raise StopIteration             # <<<<<<<<<<<<<<
30210  * 
30211  *         return self._call()
30212  */
30213     __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
30214     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
30215     goto __pyx_L6;
30216   }
30217   __pyx_L6:;
30218
30219   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3366
30220  *            raise StopIteration
30221  * 
30222  *         return self._call()             # <<<<<<<<<<<<<<
30223  * 
30224  * 
30225  */
30226   __Pyx_XDECREF(__pyx_r);
30227   __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;}
30228   __Pyx_GOTREF(__pyx_t_3);
30229   __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;}
30230   __Pyx_GOTREF(__pyx_t_2);
30231   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
30232   __pyx_r = __pyx_t_2;
30233   __pyx_t_2 = 0;
30234   goto __pyx_L0;
30235
30236   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
30237   goto __pyx_L0;
30238   __pyx_L1_error:;
30239   __Pyx_XDECREF(__pyx_t_2);
30240   __Pyx_XDECREF(__pyx_t_3);
30241   __Pyx_AddTraceback("csamtools.IteratorIndelCalls.__next__");
30242   __pyx_r = NULL;
30243   __pyx_L0:;
30244   __Pyx_XGIVEREF(__pyx_r);
30245   __Pyx_TraceReturn(__pyx_r);
30246   __Pyx_RefNannyFinishContext();
30247   return __pyx_r;
30248 }
30249
30250 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3386
30251  *     cdef int owns_samfile
30252  * 
30253  *     def __init__(self, Samfile samfile, int reopen = True ):             # <<<<<<<<<<<<<<
30254  *         self.samfile = samfile
30255  * 
30256  */
30257
30258 static int __pyx_pf_9csamtools_12IndexedReads___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
30259 static int __pyx_pf_9csamtools_12IndexedReads___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
30260   struct __pyx_obj_9csamtools_Samfile *__pyx_v_samfile = 0;
30261   int __pyx_v_reopen;
30262   PyObject *__pyx_v_mode;
30263   PyObject *__pyx_v_store;
30264   int __pyx_r;
30265   PyObject *__pyx_t_1 = NULL;
30266   PyObject *__pyx_t_2 = NULL;
30267   char *__pyx_t_3;
30268   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__samfile,&__pyx_n_s__reopen,0};
30269   __Pyx_TraceDeclarations
30270   __Pyx_RefNannySetupContext("__init__");
30271   __Pyx_TraceCall("__init__", __pyx_f[0], 3386);
30272   if (unlikely(__pyx_kwds)) {
30273     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
30274     PyObject* values[2] = {0,0};
30275     switch (PyTuple_GET_SIZE(__pyx_args)) {
30276       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
30277       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
30278       case  0: break;
30279       default: goto __pyx_L5_argtuple_error;
30280     }
30281     switch (PyTuple_GET_SIZE(__pyx_args)) {
30282       case  0:
30283       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__samfile);
30284       if (likely(values[0])) kw_args--;
30285       else goto __pyx_L5_argtuple_error;
30286       case  1:
30287       if (kw_args > 0) {
30288         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reopen);
30289         if (value) { values[1] = value; kw_args--; }
30290       }
30291     }
30292     if (unlikely(kw_args > 0)) {
30293       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;}
30294     }
30295     __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)values[0]);
30296     if (values[1]) {
30297       __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;}
30298     } else {
30299       __pyx_v_reopen = ((int)1);
30300     }
30301   } else {
30302     __pyx_v_reopen = ((int)1);
30303     switch (PyTuple_GET_SIZE(__pyx_args)) {
30304       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;}
30305       case  1: __pyx_v_samfile = ((struct __pyx_obj_9csamtools_Samfile *)PyTuple_GET_ITEM(__pyx_args, 0));
30306       break;
30307       default: goto __pyx_L5_argtuple_error;
30308     }
30309   }
30310   goto __pyx_L4_argument_unpacking_done;
30311   __pyx_L5_argtuple_error:;
30312   __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;}
30313   __pyx_L3_error:;
30314   __Pyx_AddTraceback("csamtools.IndexedReads.__init__");
30315   __Pyx_RefNannyFinishContext();
30316   return -1;
30317   __pyx_L4_argument_unpacking_done:;
30318   __pyx_v_mode = Py_None; __Pyx_INCREF(Py_None);
30319   __pyx_v_store = Py_None; __Pyx_INCREF(Py_None);
30320   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;}
30321
30322   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3387
30323  * 
30324  *     def __init__(self, Samfile samfile, int reopen = True ):
30325  *         self.samfile = samfile             # <<<<<<<<<<<<<<
30326  * 
30327  *         if samfile.isbam: mode = "rb"
30328  */
30329   __Pyx_INCREF(((PyObject *)__pyx_v_samfile));
30330   __Pyx_GIVEREF(((PyObject *)__pyx_v_samfile));
30331   __Pyx_GOTREF(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->samfile);
30332   __Pyx_DECREF(((PyObject *)((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->samfile));
30333   ((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->samfile = __pyx_v_samfile;
30334
30335   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3389
30336  *         self.samfile = samfile
30337  * 
30338  *         if samfile.isbam: mode = "rb"             # <<<<<<<<<<<<<<
30339  *         else: mode = "r"
30340  * 
30341  */
30342   if (__pyx_v_samfile->isbam) {
30343     __Pyx_INCREF(((PyObject *)__pyx_n_s__rb));
30344     __Pyx_DECREF(__pyx_v_mode);
30345     __pyx_v_mode = ((PyObject *)__pyx_n_s__rb);
30346     goto __pyx_L6;
30347   }
30348   /*else*/ {
30349
30350     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3390
30351  * 
30352  *         if samfile.isbam: mode = "rb"
30353  *         else: mode = "r"             # <<<<<<<<<<<<<<
30354  * 
30355  *         # reopen the file - note that this makes the iterator
30356  */
30357     __Pyx_INCREF(((PyObject *)__pyx_n_s__r));
30358     __Pyx_DECREF(__pyx_v_mode);
30359     __pyx_v_mode = ((PyObject *)__pyx_n_s__r);
30360   }
30361   __pyx_L6:;
30362
30363   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3394
30364  *         # reopen the file - note that this makes the iterator
30365  *         # slow and causes pileup to slow down significantly.
30366  *         if reopen:             # <<<<<<<<<<<<<<
30367  *             store = StderrStore()
30368  *             self.fp = samopen( samfile._filename, mode, NULL )
30369  */
30370   if (__pyx_v_reopen) {
30371
30372     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3395
30373  *         # slow and causes pileup to slow down significantly.
30374  *         if reopen:
30375  *             store = StderrStore()             # <<<<<<<<<<<<<<
30376  *             self.fp = samopen( samfile._filename, mode, NULL )
30377  *             store.release()
30378  */
30379     __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;}
30380     __Pyx_GOTREF(__pyx_t_1);
30381     __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;}
30382     __Pyx_GOTREF(__pyx_t_2);
30383     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
30384     __Pyx_DECREF(__pyx_v_store);
30385     __pyx_v_store = __pyx_t_2;
30386     __pyx_t_2 = 0;
30387
30388     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3396
30389  *         if reopen:
30390  *             store = StderrStore()
30391  *             self.fp = samopen( samfile._filename, mode, NULL )             # <<<<<<<<<<<<<<
30392  *             store.release()
30393  *             assert self.fp != NULL
30394  */
30395     __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;}
30396     ((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->fp = samopen(__pyx_v_samfile->_filename, __pyx_t_3, NULL);
30397
30398     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3397
30399  *             store = StderrStore()
30400  *             self.fp = samopen( samfile._filename, mode, NULL )
30401  *             store.release()             # <<<<<<<<<<<<<<
30402  *             assert self.fp != NULL
30403  *             self.owns_samfile = True
30404  */
30405     __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;}
30406     __Pyx_GOTREF(__pyx_t_2);
30407     __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;}
30408     __Pyx_GOTREF(__pyx_t_1);
30409     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
30410     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
30411
30412     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3398
30413  *             self.fp = samopen( samfile._filename, mode, NULL )
30414  *             store.release()
30415  *             assert self.fp != NULL             # <<<<<<<<<<<<<<
30416  *             self.owns_samfile = True
30417  *         else:
30418  */
30419     #ifndef PYREX_WITHOUT_ASSERTIONS
30420     if (unlikely(!(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->fp != NULL))) {
30421       PyErr_SetNone(PyExc_AssertionError);
30422       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
30423     }
30424     #endif
30425
30426     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3399
30427  *             store.release()
30428  *             assert self.fp != NULL
30429  *             self.owns_samfile = True             # <<<<<<<<<<<<<<
30430  *         else:
30431  *             self.fp = samfile.samfile
30432  */
30433     ((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->owns_samfile = 1;
30434     goto __pyx_L7;
30435   }
30436   /*else*/ {
30437
30438     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3401
30439  *             self.owns_samfile = True
30440  *         else:
30441  *             self.fp = samfile.samfile             # <<<<<<<<<<<<<<
30442  *             self.owns_samfile = False
30443  * 
30444  */
30445     ((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->fp = __pyx_v_samfile->samfile;
30446
30447     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3402
30448  *         else:
30449  *             self.fp = samfile.samfile
30450  *             self.owns_samfile = False             # <<<<<<<<<<<<<<
30451  * 
30452  *         assert samfile.isbam, "can only IndexReads on bam files"
30453  */
30454     ((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->owns_samfile = 0;
30455   }
30456   __pyx_L7:;
30457
30458   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3404
30459  *             self.owns_samfile = False
30460  * 
30461  *         assert samfile.isbam, "can only IndexReads on bam files"             # <<<<<<<<<<<<<<
30462  * 
30463  *     def build( self ):
30464  */
30465   #ifndef PYREX_WITHOUT_ASSERTIONS
30466   if (unlikely(!__pyx_v_samfile->isbam)) {
30467     PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_112));
30468     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
30469   }
30470   #endif
30471
30472   __pyx_r = 0;
30473   goto __pyx_L0;
30474   __pyx_L1_error:;
30475   __Pyx_XDECREF(__pyx_t_1);
30476   __Pyx_XDECREF(__pyx_t_2);
30477   __Pyx_AddTraceback("csamtools.IndexedReads.__init__");
30478   __pyx_r = -1;
30479   __pyx_L0:;
30480   __Pyx_DECREF(__pyx_v_mode);
30481   __Pyx_DECREF(__pyx_v_store);
30482   __Pyx_TraceReturn(Py_None);
30483   __Pyx_RefNannyFinishContext();
30484   return __pyx_r;
30485 }
30486
30487 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3406
30488  *         assert samfile.isbam, "can only IndexReads on bam files"
30489  * 
30490  *     def build( self ):             # <<<<<<<<<<<<<<
30491  *         '''build index.'''
30492  * 
30493  */
30494
30495 static PyObject *__pyx_pf_9csamtools_12IndexedReads_build(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
30496 static char __pyx_doc_9csamtools_12IndexedReads_build[] = "IndexedReads.build(self)\nbuild index.";
30497 static PyObject *__pyx_pf_9csamtools_12IndexedReads_build(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
30498   int __pyx_v_ret;
30499   bam1_t *__pyx_v_b;
30500   uint64_t __pyx_v_pos;
30501   char *__pyx_v_qname;
30502   PyObject *__pyx_r = NULL;
30503   PyObject *__pyx_t_1 = NULL;
30504   PyObject *__pyx_t_2 = NULL;
30505   PyObject *__pyx_t_3 = NULL;
30506   int __pyx_t_4;
30507   __Pyx_TraceDeclarations
30508   __Pyx_RefNannySetupContext("build");
30509   __Pyx_TraceCall("build", __pyx_f[0], 3406);
30510
30511   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3409
30512  *         '''build index.'''
30513  * 
30514  *         self.index = collections.defaultdict( list )             # <<<<<<<<<<<<<<
30515  * 
30516  *         # this method will start indexing from the current file position
30517  */
30518   __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;}
30519   __Pyx_GOTREF(__pyx_t_1);
30520   __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;}
30521   __Pyx_GOTREF(__pyx_t_2);
30522   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
30523   __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;}
30524   __Pyx_GOTREF(__pyx_t_1);
30525   __Pyx_INCREF(((PyObject *)((PyObject*)&PyList_Type)));
30526   PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)&PyList_Type)));
30527   __Pyx_GIVEREF(((PyObject *)((PyObject*)&PyList_Type)));
30528   __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;}
30529   __Pyx_GOTREF(__pyx_t_3);
30530   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
30531   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
30532   __Pyx_GIVEREF(__pyx_t_3);
30533   __Pyx_GOTREF(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->index);
30534   __Pyx_DECREF(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->index);
30535   ((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->index = __pyx_t_3;
30536   __pyx_t_3 = 0;
30537
30538   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3413
30539  *         # this method will start indexing from the current file position
30540  *         # if you decide
30541  *         cdef int ret = 1             # <<<<<<<<<<<<<<
30542  *         cdef bam1_t * b = <bam1_t*> calloc(1, sizeof( bam1_t) )
30543  * 
30544  */
30545   __pyx_v_ret = 1;
30546
30547   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3414
30548  *         # if you decide
30549  *         cdef int ret = 1
30550  *         cdef bam1_t * b = <bam1_t*> calloc(1, sizeof( bam1_t) )             # <<<<<<<<<<<<<<
30551  * 
30552  *         cdef uint64_t pos
30553  */
30554   __pyx_v_b = ((bam1_t *)calloc(1, (sizeof(bam1_t))));
30555
30556   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3418
30557  *         cdef uint64_t pos
30558  * 
30559  *         while ret > 0:             # <<<<<<<<<<<<<<
30560  *             pos = bam_tell( self.fp.x.bam )
30561  *             ret = samread( self.fp, b)
30562  */
30563   while (1) {
30564     __pyx_t_4 = (__pyx_v_ret > 0);
30565     if (!__pyx_t_4) break;
30566
30567     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3419
30568  * 
30569  *         while ret > 0:
30570  *             pos = bam_tell( self.fp.x.bam )             # <<<<<<<<<<<<<<
30571  *             ret = samread( self.fp, b)
30572  *             if ret > 0:
30573  */
30574     __pyx_v_pos = bam_tell(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->fp->x.bam);
30575
30576     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3420
30577  *         while ret > 0:
30578  *             pos = bam_tell( self.fp.x.bam )
30579  *             ret = samread( self.fp, b)             # <<<<<<<<<<<<<<
30580  *             if ret > 0:
30581  *                 qname = bam1_qname( b )
30582  */
30583     __pyx_v_ret = samread(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->fp, __pyx_v_b);
30584
30585     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3421
30586  *             pos = bam_tell( self.fp.x.bam )
30587  *             ret = samread( self.fp, b)
30588  *             if ret > 0:             # <<<<<<<<<<<<<<
30589  *                 qname = bam1_qname( b )
30590  *                 self.index[qname].append( pos )
30591  */
30592     __pyx_t_4 = (__pyx_v_ret > 0);
30593     if (__pyx_t_4) {
30594
30595       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3422
30596  *             ret = samread( self.fp, b)
30597  *             if ret > 0:
30598  *                 qname = bam1_qname( b )             # <<<<<<<<<<<<<<
30599  *                 self.index[qname].append( pos )
30600  * 
30601  */
30602       __pyx_v_qname = bam1_qname(__pyx_v_b);
30603
30604       /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3423
30605  *             if ret > 0:
30606  *                 qname = bam1_qname( b )
30607  *                 self.index[qname].append( pos )             # <<<<<<<<<<<<<<
30608  * 
30609  *         bam_destroy1( b )
30610  */
30611       __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;}
30612       __Pyx_GOTREF(((PyObject *)__pyx_t_3));
30613       __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;}
30614       __Pyx_GOTREF(__pyx_t_1);
30615       __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
30616       __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;}
30617       __Pyx_GOTREF(__pyx_t_3);
30618       __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;}
30619       __Pyx_GOTREF(__pyx_t_2);
30620       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
30621       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
30622       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
30623       goto __pyx_L7;
30624     }
30625     __pyx_L7:;
30626   }
30627
30628   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3425
30629  *                 self.index[qname].append( pos )
30630  * 
30631  *         bam_destroy1( b )             # <<<<<<<<<<<<<<
30632  * 
30633  *     def find( self, qname ):
30634  */
30635   bam_destroy1(__pyx_v_b);
30636
30637   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
30638   goto __pyx_L0;
30639   __pyx_L1_error:;
30640   __Pyx_XDECREF(__pyx_t_1);
30641   __Pyx_XDECREF(__pyx_t_2);
30642   __Pyx_XDECREF(__pyx_t_3);
30643   __Pyx_AddTraceback("csamtools.IndexedReads.build");
30644   __pyx_r = NULL;
30645   __pyx_L0:;
30646   __Pyx_XGIVEREF(__pyx_r);
30647   __Pyx_TraceReturn(__pyx_r);
30648   __Pyx_RefNannyFinishContext();
30649   return __pyx_r;
30650 }
30651
30652 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3427
30653  *         bam_destroy1( b )
30654  * 
30655  *     def find( self, qname ):             # <<<<<<<<<<<<<<
30656  *         if qname in self.index:
30657  *             return IteratorRowSelection( self.samfile, self.index[qname], reopen = False )
30658  */
30659
30660 static PyObject *__pyx_pf_9csamtools_12IndexedReads_find(PyObject *__pyx_v_self, PyObject *__pyx_v_qname); /*proto*/
30661 static char __pyx_doc_9csamtools_12IndexedReads_find[] = "IndexedReads.find(self, qname)";
30662 static PyObject *__pyx_pf_9csamtools_12IndexedReads_find(PyObject *__pyx_v_self, PyObject *__pyx_v_qname) {
30663   PyObject *__pyx_r = NULL;
30664   int __pyx_t_1;
30665   PyObject *__pyx_t_2 = NULL;
30666   PyObject *__pyx_t_3 = NULL;
30667   PyObject *__pyx_t_4 = NULL;
30668   __Pyx_TraceDeclarations
30669   __Pyx_RefNannySetupContext("find");
30670   __Pyx_TraceCall("find", __pyx_f[0], 3427);
30671
30672   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3428
30673  * 
30674  *     def find( self, qname ):
30675  *         if qname in self.index:             # <<<<<<<<<<<<<<
30676  *             return IteratorRowSelection( self.samfile, self.index[qname], reopen = False )
30677  *         else:
30678  */
30679   __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;}
30680   if (__pyx_t_1) {
30681
30682     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3429
30683  *     def find( self, qname ):
30684  *         if qname in self.index:
30685  *             return IteratorRowSelection( self.samfile, self.index[qname], reopen = False )             # <<<<<<<<<<<<<<
30686  *         else:
30687  *             raise KeyError( "read %s not found" % qname )
30688  */
30689     __Pyx_XDECREF(__pyx_r);
30690     __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;}
30691     __Pyx_GOTREF(__pyx_t_2);
30692     __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;}
30693     __Pyx_GOTREF(__pyx_t_3);
30694     __Pyx_INCREF(((PyObject *)((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->samfile));
30695     PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->samfile));
30696     __Pyx_GIVEREF(((PyObject *)((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->samfile));
30697     PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
30698     __Pyx_GIVEREF(__pyx_t_2);
30699     __pyx_t_2 = 0;
30700     __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;}
30701     __Pyx_GOTREF(((PyObject *)__pyx_t_2));
30702     __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;}
30703     __Pyx_GOTREF(__pyx_t_4);
30704     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;}
30705     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
30706     __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;}
30707     __Pyx_GOTREF(__pyx_t_4);
30708     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
30709     __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
30710     __pyx_r = __pyx_t_4;
30711     __pyx_t_4 = 0;
30712     goto __pyx_L0;
30713     goto __pyx_L5;
30714   }
30715   /*else*/ {
30716
30717     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3431
30718  *             return IteratorRowSelection( self.samfile, self.index[qname], reopen = False )
30719  *         else:
30720  *             raise KeyError( "read %s not found" % qname )             # <<<<<<<<<<<<<<
30721  * 
30722  *     def __dealloc__(self):
30723  */
30724     __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;}
30725     __Pyx_GOTREF(((PyObject *)__pyx_t_4));
30726     __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;}
30727     __Pyx_GOTREF(__pyx_t_2);
30728     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_4));
30729     __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
30730     __pyx_t_4 = 0;
30731     __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;}
30732     __Pyx_GOTREF(__pyx_t_4);
30733     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
30734     __Pyx_Raise(__pyx_t_4, 0, 0);
30735     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
30736     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
30737   }
30738   __pyx_L5:;
30739
30740   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
30741   goto __pyx_L0;
30742   __pyx_L1_error:;
30743   __Pyx_XDECREF(__pyx_t_2);
30744   __Pyx_XDECREF(__pyx_t_3);
30745   __Pyx_XDECREF(__pyx_t_4);
30746   __Pyx_AddTraceback("csamtools.IndexedReads.find");
30747   __pyx_r = NULL;
30748   __pyx_L0:;
30749   __Pyx_XGIVEREF(__pyx_r);
30750   __Pyx_TraceReturn(__pyx_r);
30751   __Pyx_RefNannyFinishContext();
30752   return __pyx_r;
30753 }
30754
30755 /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3433
30756  *             raise KeyError( "read %s not found" % qname )
30757  * 
30758  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
30759  *         if self.owns_samfile: samclose( self.fp )
30760  * 
30761  */
30762
30763 static void __pyx_pf_9csamtools_12IndexedReads___dealloc__(PyObject *__pyx_v_self); /*proto*/
30764 static void __pyx_pf_9csamtools_12IndexedReads___dealloc__(PyObject *__pyx_v_self) {
30765   __Pyx_TraceDeclarations
30766   __Pyx_RefNannySetupContext("__dealloc__");
30767   __Pyx_TraceCall("__dealloc__", __pyx_f[0], 3433);
30768
30769   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3434
30770  * 
30771  *     def __dealloc__(self):
30772  *         if self.owns_samfile: samclose( self.fp )             # <<<<<<<<<<<<<<
30773  * 
30774  * __all__ = ["Samfile",
30775  */
30776   if (((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->owns_samfile) {
30777     samclose(((struct __pyx_obj_9csamtools_IndexedReads *)__pyx_v_self)->fp);
30778     goto __pyx_L5;
30779   }
30780   __pyx_L5:;
30781
30782   __Pyx_TraceReturn(Py_None);
30783   __Pyx_RefNannyFinishContext();
30784 }
30785
30786 static PyObject *__pyx_tp_new_9csamtools_AlignedRead(PyTypeObject *t, PyObject *a, PyObject *k) {
30787   PyObject *o = (*t->tp_alloc)(t, 0);
30788   if (!o) return 0;
30789   return o;
30790 }
30791
30792 static void __pyx_tp_dealloc_9csamtools_AlignedRead(PyObject *o) {
30793   {
30794     PyObject *etype, *eval, *etb;
30795     PyErr_Fetch(&etype, &eval, &etb);
30796     ++Py_REFCNT(o);
30797     __pyx_pf_9csamtools_11AlignedRead___dealloc__(o);
30798     if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
30799     --Py_REFCNT(o);
30800     PyErr_Restore(etype, eval, etb);
30801   }
30802   (*Py_TYPE(o)->tp_free)(o);
30803 }
30804
30805 static PyObject *__pyx_getprop_9csamtools_11AlignedRead_qname(PyObject *o, void *x) {
30806   return __pyx_pf_9csamtools_11AlignedRead_5qname___get__(o);
30807 }
30808
30809 static int __pyx_setprop_9csamtools_11AlignedRead_qname(PyObject *o, PyObject *v, void *x) {
30810   if (v) {
30811     return __pyx_pf_9csamtools_11AlignedRead_5qname___set__(o, v);
30812   }
30813   else {
30814     PyErr_SetString(PyExc_NotImplementedError, "__del__");
30815     return -1;
30816   }
30817 }
30818
30819 static PyObject *__pyx_getprop_9csamtools_11AlignedRead_cigar(PyObject *o, void *x) {
30820   return __pyx_pf_9csamtools_11AlignedRead_5cigar___get__(o);
30821 }
30822
30823 static int __pyx_setprop_9csamtools_11AlignedRead_cigar(PyObject *o, PyObject *v, void *x) {
30824   if (v) {
30825     return __pyx_pf_9csamtools_11AlignedRead_5cigar___set__(o, v);
30826   }
30827   else {
30828     PyErr_SetString(PyExc_NotImplementedError, "__del__");
30829     return -1;
30830   }
30831 }
30832
30833 static PyObject *__pyx_getprop_9csamtools_11AlignedRead_seq(PyObject *o, void *x) {
30834   return __pyx_pf_9csamtools_11AlignedRead_3seq___get__(o);
30835 }
30836
30837 static int __pyx_setprop_9csamtools_11AlignedRead_seq(PyObject *o, PyObject *v, void *x) {
30838   if (v) {
30839     return __pyx_pf_9csamtools_11AlignedRead_3seq___set__(o, v);
30840   }
30841   else {
30842     PyErr_SetString(PyExc_NotImplementedError, "__del__");
30843     return -1;
30844   }
30845 }
30846
30847 static PyObject *__pyx_getprop_9csamtools_11AlignedRead_qual(PyObject *o, void *x) {
30848   return __pyx_pf_9csamtools_11AlignedRead_4qual___get__(o);
30849 }
30850
30851 static int __pyx_setprop_9csamtools_11AlignedRead_qual(PyObject *o, PyObject *v, void *x) {
30852   if (v) {
30853     return __pyx_pf_9csamtools_11AlignedRead_4qual___set__(o, v);
30854   }
30855   else {
30856     PyErr_SetString(PyExc_NotImplementedError, "__del__");
30857     return -1;
30858   }
30859 }
30860
30861 static PyObject *__pyx_getprop_9csamtools_11AlignedRead_query(PyObject *o, void *x) {
30862   return __pyx_pf_9csamtools_11AlignedRead_5query___get__(o);
30863 }
30864
30865 static PyObject *__pyx_getprop_9csamtools_11AlignedRead_qqual(PyObject *o, void *x) {
30866   return __pyx_pf_9csamtools_11AlignedRead_5qqual___get__(o);
30867 }
30868
30869 static PyObject *__pyx_getprop_9csamtools_11AlignedRead_qstart(PyObject *o, void *x) {
30870   return __pyx_pf_9csamtools_11AlignedRead_6qstart___get__(o);
30871 }
30872
30873 static PyObject *__pyx_getprop_9csamtools_11AlignedRead_qend(PyObject *o, void *x) {
30874   return __pyx_pf_9csamtools_11AlignedRead_4qend___get__(o);
30875 }
30876
30877 static PyObject *__pyx_getprop_9csamtools_11AlignedRead_qlen(PyObject *o, void *x) {
30878   return __pyx_pf_9csamtools_11AlignedRead_4qlen___get__(o);
30879 }
30880
30881 static PyObject *__pyx_getprop_9csamtools_11AlignedRead_tags(PyObject *o, void *x) {
30882   return __pyx_pf_9csamtools_11AlignedRead_4tags___get__(o);
30883 }
30884
30885 static int __pyx_setprop_9csamtools_11AlignedRead_tags(PyObject *o, PyObject *v, void *x) {
30886   if (v) {
30887     return __pyx_pf_9csamtools_11AlignedRead_4tags___set__(o, v);
30888   }
30889   else {
30890     PyErr_SetString(PyExc_NotImplementedError, "__del__");
30891     return -1;
30892   }
30893 }
30894
30895 static PyObject *__pyx_getprop_9csamtools_11AlignedRead_flag(PyObject *o, void *x) {
30896   return __pyx_pf_9csamtools_11AlignedRead_4flag___get__(o);
30897 }
30898
30899 static int __pyx_setprop_9csamtools_11AlignedRead_flag(PyObject *o, PyObject *v, void *x) {
30900   if (v) {
30901     return __pyx_pf_9csamtools_11AlignedRead_4flag___set__(o, v);
30902   }
30903   else {
30904     PyErr_SetString(PyExc_NotImplementedError, "__del__");
30905     return -1;
30906   }
30907 }
30908
30909 static PyObject *__pyx_getprop_9csamtools_11AlignedRead_rname(PyObject *o, void *x) {
30910   return __pyx_pf_9csamtools_11AlignedRead_5rname___get__(o);
30911 }
30912
30913 static int __pyx_setprop_9csamtools_11AlignedRead_rname(PyObject *o, PyObject *v, void *x) {
30914   if (v) {
30915     return __pyx_pf_9csamtools_11AlignedRead_5rname___set__(o, v);
30916   }
30917   else {
30918     PyErr_SetString(PyExc_NotImplementedError, "__del__");
30919     return -1;
30920   }
30921 }
30922
30923 static PyObject *__pyx_getprop_9csamtools_11AlignedRead_tid(PyObject *o, void *x) {
30924   return __pyx_pf_9csamtools_11AlignedRead_3tid___get__(o);
30925 }
30926
30927 static int __pyx_setprop_9csamtools_11AlignedRead_tid(PyObject *o, PyObject *v, void *x) {
30928   if (v) {
30929     return __pyx_pf_9csamtools_11AlignedRead_3tid___set__(o, v);
30930   }
30931   else {
30932     PyErr_SetString(PyExc_NotImplementedError, "__del__");
30933     return -1;
30934   }
30935 }
30936
30937 static PyObject *__pyx_getprop_9csamtools_11AlignedRead_pos(PyObject *o, void *x) {
30938   return __pyx_pf_9csamtools_11AlignedRead_3pos___get__(o);
30939 }
30940
30941 static int __pyx_setprop_9csamtools_11AlignedRead_pos(PyObject *o, PyObject *v, void *x) {
30942   if (v) {
30943     return __pyx_pf_9csamtools_11AlignedRead_3pos___set__(o, v);
30944   }
30945   else {
30946     PyErr_SetString(PyExc_NotImplementedError, "__del__");
30947     return -1;
30948   }
30949 }
30950
30951 static PyObject *__pyx_getprop_9csamtools_11AlignedRead_bin(PyObject *o, void *x) {
30952   return __pyx_pf_9csamtools_11AlignedRead_3bin___get__(o);
30953 }
30954
30955 static int __pyx_setprop_9csamtools_11AlignedRead_bin(PyObject *o, PyObject *v, void *x) {
30956   if (v) {
30957     return __pyx_pf_9csamtools_11AlignedRead_3bin___set__(o, v);
30958   }
30959   else {
30960     PyErr_SetString(PyExc_NotImplementedError, "__del__");
30961     return -1;
30962   }
30963 }
30964
30965 static PyObject *__pyx_getprop_9csamtools_11AlignedRead_rlen(PyObject *o, void *x) {
30966   return __pyx_pf_9csamtools_11AlignedRead_4rlen___get__(o);
30967 }
30968
30969 static PyObject *__pyx_getprop_9csamtools_11AlignedRead_aend(PyObject *o, void *x) {
30970   return __pyx_pf_9csamtools_11AlignedRead_4aend___get__(o);
30971 }
30972
30973 static PyObject *__pyx_getprop_9csamtools_11AlignedRead_alen(PyObject *o, void *x) {
30974   return __pyx_pf_9csamtools_11AlignedRead_4alen___get__(o);
30975 }
30976
30977 static PyObject *__pyx_getprop_9csamtools_11AlignedRead_mapq(PyObject *o, void *x) {
30978   return __pyx_pf_9csamtools_11AlignedRead_4mapq___get__(o);
30979 }
30980
30981 static int __pyx_setprop_9csamtools_11AlignedRead_mapq(PyObject *o, PyObject *v, void *x) {
30982   if (v) {
30983     return __pyx_pf_9csamtools_11AlignedRead_4mapq___set__(o, v);
30984   }
30985   else {
30986     PyErr_SetString(PyExc_NotImplementedError, "__del__");
30987     return -1;
30988   }
30989 }
30990
30991 static PyObject *__pyx_getprop_9csamtools_11AlignedRead_mrnm(PyObject *o, void *x) {
30992   return __pyx_pf_9csamtools_11AlignedRead_4mrnm___get__(o);
30993 }
30994
30995 static int __pyx_setprop_9csamtools_11AlignedRead_mrnm(PyObject *o, PyObject *v, void *x) {
30996   if (v) {
30997     return __pyx_pf_9csamtools_11AlignedRead_4mrnm___set__(o, v);
30998   }
30999   else {
31000     PyErr_SetString(PyExc_NotImplementedError, "__del__");
31001     return -1;
31002   }
31003 }
31004
31005 static PyObject *__pyx_getprop_9csamtools_11AlignedRead_mpos(PyObject *o, void *x) {
31006   return __pyx_pf_9csamtools_11AlignedRead_4mpos___get__(o);
31007 }
31008
31009 static int __pyx_setprop_9csamtools_11AlignedRead_mpos(PyObject *o, PyObject *v, void *x) {
31010   if (v) {
31011     return __pyx_pf_9csamtools_11AlignedRead_4mpos___set__(o, v);
31012   }
31013   else {
31014     PyErr_SetString(PyExc_NotImplementedError, "__del__");
31015     return -1;
31016   }
31017 }
31018
31019 static PyObject *__pyx_getprop_9csamtools_11AlignedRead_isize(PyObject *o, void *x) {
31020   return __pyx_pf_9csamtools_11AlignedRead_5isize___get__(o);
31021 }
31022
31023 static int __pyx_setprop_9csamtools_11AlignedRead_isize(PyObject *o, PyObject *v, void *x) {
31024   if (v) {
31025     return __pyx_pf_9csamtools_11AlignedRead_5isize___set__(o, v);
31026   }
31027   else {
31028     PyErr_SetString(PyExc_NotImplementedError, "__del__");
31029     return -1;
31030   }
31031 }
31032
31033 static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_paired(PyObject *o, void *x) {
31034   return __pyx_pf_9csamtools_11AlignedRead_9is_paired___get__(o);
31035 }
31036
31037 static int __pyx_setprop_9csamtools_11AlignedRead_is_paired(PyObject *o, PyObject *v, void *x) {
31038   if (v) {
31039     return __pyx_pf_9csamtools_11AlignedRead_9is_paired___set__(o, v);
31040   }
31041   else {
31042     PyErr_SetString(PyExc_NotImplementedError, "__del__");
31043     return -1;
31044   }
31045 }
31046
31047 static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_proper_pair(PyObject *o, void *x) {
31048   return __pyx_pf_9csamtools_11AlignedRead_14is_proper_pair___get__(o);
31049 }
31050
31051 static int __pyx_setprop_9csamtools_11AlignedRead_is_proper_pair(PyObject *o, PyObject *v, void *x) {
31052   if (v) {
31053     return __pyx_pf_9csamtools_11AlignedRead_14is_proper_pair___set__(o, v);
31054   }
31055   else {
31056     PyErr_SetString(PyExc_NotImplementedError, "__del__");
31057     return -1;
31058   }
31059 }
31060
31061 static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_unmapped(PyObject *o, void *x) {
31062   return __pyx_pf_9csamtools_11AlignedRead_11is_unmapped___get__(o);
31063 }
31064
31065 static int __pyx_setprop_9csamtools_11AlignedRead_is_unmapped(PyObject *o, PyObject *v, void *x) {
31066   if (v) {
31067     return __pyx_pf_9csamtools_11AlignedRead_11is_unmapped___set__(o, v);
31068   }
31069   else {
31070     PyErr_SetString(PyExc_NotImplementedError, "__del__");
31071     return -1;
31072   }
31073 }
31074
31075 static PyObject *__pyx_getprop_9csamtools_11AlignedRead_mate_is_unmapped(PyObject *o, void *x) {
31076   return __pyx_pf_9csamtools_11AlignedRead_16mate_is_unmapped___get__(o);
31077 }
31078
31079 static int __pyx_setprop_9csamtools_11AlignedRead_mate_is_unmapped(PyObject *o, PyObject *v, void *x) {
31080   if (v) {
31081     return __pyx_pf_9csamtools_11AlignedRead_16mate_is_unmapped___set__(o, v);
31082   }
31083   else {
31084     PyErr_SetString(PyExc_NotImplementedError, "__del__");
31085     return -1;
31086   }
31087 }
31088
31089 static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_reverse(PyObject *o, void *x) {
31090   return __pyx_pf_9csamtools_11AlignedRead_10is_reverse___get__(o);
31091 }
31092
31093 static int __pyx_setprop_9csamtools_11AlignedRead_is_reverse(PyObject *o, PyObject *v, void *x) {
31094   if (v) {
31095     return __pyx_pf_9csamtools_11AlignedRead_10is_reverse___set__(o, v);
31096   }
31097   else {
31098     PyErr_SetString(PyExc_NotImplementedError, "__del__");
31099     return -1;
31100   }
31101 }
31102
31103 static PyObject *__pyx_getprop_9csamtools_11AlignedRead_mate_is_reverse(PyObject *o, void *x) {
31104   return __pyx_pf_9csamtools_11AlignedRead_15mate_is_reverse___get__(o);
31105 }
31106
31107 static int __pyx_setprop_9csamtools_11AlignedRead_mate_is_reverse(PyObject *o, PyObject *v, void *x) {
31108   if (v) {
31109     return __pyx_pf_9csamtools_11AlignedRead_15mate_is_reverse___set__(o, v);
31110   }
31111   else {
31112     PyErr_SetString(PyExc_NotImplementedError, "__del__");
31113     return -1;
31114   }
31115 }
31116
31117 static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_read1(PyObject *o, void *x) {
31118   return __pyx_pf_9csamtools_11AlignedRead_8is_read1___get__(o);
31119 }
31120
31121 static int __pyx_setprop_9csamtools_11AlignedRead_is_read1(PyObject *o, PyObject *v, void *x) {
31122   if (v) {
31123     return __pyx_pf_9csamtools_11AlignedRead_8is_read1___set__(o, v);
31124   }
31125   else {
31126     PyErr_SetString(PyExc_NotImplementedError, "__del__");
31127     return -1;
31128   }
31129 }
31130
31131 static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_read2(PyObject *o, void *x) {
31132   return __pyx_pf_9csamtools_11AlignedRead_8is_read2___get__(o);
31133 }
31134
31135 static int __pyx_setprop_9csamtools_11AlignedRead_is_read2(PyObject *o, PyObject *v, void *x) {
31136   if (v) {
31137     return __pyx_pf_9csamtools_11AlignedRead_8is_read2___set__(o, v);
31138   }
31139   else {
31140     PyErr_SetString(PyExc_NotImplementedError, "__del__");
31141     return -1;
31142   }
31143 }
31144
31145 static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_secondary(PyObject *o, void *x) {
31146   return __pyx_pf_9csamtools_11AlignedRead_12is_secondary___get__(o);
31147 }
31148
31149 static int __pyx_setprop_9csamtools_11AlignedRead_is_secondary(PyObject *o, PyObject *v, void *x) {
31150   if (v) {
31151     return __pyx_pf_9csamtools_11AlignedRead_12is_secondary___set__(o, v);
31152   }
31153   else {
31154     PyErr_SetString(PyExc_NotImplementedError, "__del__");
31155     return -1;
31156   }
31157 }
31158
31159 static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_qcfail(PyObject *o, void *x) {
31160   return __pyx_pf_9csamtools_11AlignedRead_9is_qcfail___get__(o);
31161 }
31162
31163 static int __pyx_setprop_9csamtools_11AlignedRead_is_qcfail(PyObject *o, PyObject *v, void *x) {
31164   if (v) {
31165     return __pyx_pf_9csamtools_11AlignedRead_9is_qcfail___set__(o, v);
31166   }
31167   else {
31168     PyErr_SetString(PyExc_NotImplementedError, "__del__");
31169     return -1;
31170   }
31171 }
31172
31173 static PyObject *__pyx_getprop_9csamtools_11AlignedRead_is_duplicate(PyObject *o, void *x) {
31174   return __pyx_pf_9csamtools_11AlignedRead_12is_duplicate___get__(o);
31175 }
31176
31177 static int __pyx_setprop_9csamtools_11AlignedRead_is_duplicate(PyObject *o, PyObject *v, void *x) {
31178   if (v) {
31179     return __pyx_pf_9csamtools_11AlignedRead_12is_duplicate___set__(o, v);
31180   }
31181   else {
31182     PyErr_SetString(PyExc_NotImplementedError, "__del__");
31183     return -1;
31184   }
31185 }
31186
31187 static PyObject *__pyx_getprop_9csamtools_11AlignedRead_positions(PyObject *o, void *x) {
31188   return __pyx_pf_9csamtools_11AlignedRead_9positions___get__(o);
31189 }
31190
31191 static PyMethodDef __pyx_methods_9csamtools_AlignedRead[] = {
31192   {__Pyx_NAMESTR("compare"), (PyCFunction)__pyx_pf_9csamtools_11AlignedRead_compare, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_11AlignedRead_compare)},
31193   {__Pyx_NAMESTR("overlap"), (PyCFunction)__pyx_pf_9csamtools_11AlignedRead_overlap, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_11AlignedRead_overlap)},
31194   {__Pyx_NAMESTR("opt"), (PyCFunction)__pyx_pf_9csamtools_11AlignedRead_opt, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_11AlignedRead_opt)},
31195   {__Pyx_NAMESTR("fancy_str"), (PyCFunction)__pyx_pf_9csamtools_11AlignedRead_fancy_str, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_11AlignedRead_fancy_str)},
31196   {0, 0, 0, 0}
31197 };
31198
31199 static struct PyGetSetDef __pyx_getsets_9csamtools_AlignedRead[] = {
31200   {(char *)"qname", __pyx_getprop_9csamtools_11AlignedRead_qname, __pyx_setprop_9csamtools_11AlignedRead_qname, __Pyx_DOCSTR(__pyx_k_114), 0},
31201   {(char *)"cigar", __pyx_getprop_9csamtools_11AlignedRead_cigar, __pyx_setprop_9csamtools_11AlignedRead_cigar, __Pyx_DOCSTR(__pyx_k_115), 0},
31202   {(char *)"seq", __pyx_getprop_9csamtools_11AlignedRead_seq, __pyx_setprop_9csamtools_11AlignedRead_seq, __Pyx_DOCSTR(__pyx_k_116), 0},
31203   {(char *)"qual", __pyx_getprop_9csamtools_11AlignedRead_qual, __pyx_setprop_9csamtools_11AlignedRead_qual, __Pyx_DOCSTR(__pyx_k_117), 0},
31204   {(char *)"query", __pyx_getprop_9csamtools_11AlignedRead_query, 0, __Pyx_DOCSTR(__pyx_k_118), 0},
31205   {(char *)"qqual", __pyx_getprop_9csamtools_11AlignedRead_qqual, 0, __Pyx_DOCSTR(__pyx_k_119), 0},
31206   {(char *)"qstart", __pyx_getprop_9csamtools_11AlignedRead_qstart, 0, __Pyx_DOCSTR(__pyx_k_120), 0},
31207   {(char *)"qend", __pyx_getprop_9csamtools_11AlignedRead_qend, 0, __Pyx_DOCSTR(__pyx_k_121), 0},
31208   {(char *)"qlen", __pyx_getprop_9csamtools_11AlignedRead_qlen, 0, __Pyx_DOCSTR(__pyx_k_122), 0},
31209   {(char *)"tags", __pyx_getprop_9csamtools_11AlignedRead_tags, __pyx_setprop_9csamtools_11AlignedRead_tags, __Pyx_DOCSTR(__pyx_k_123), 0},
31210   {(char *)"flag", __pyx_getprop_9csamtools_11AlignedRead_flag, __pyx_setprop_9csamtools_11AlignedRead_flag, __Pyx_DOCSTR(__pyx_k_124), 0},
31211   {(char *)"rname", __pyx_getprop_9csamtools_11AlignedRead_rname, __pyx_setprop_9csamtools_11AlignedRead_rname, __Pyx_DOCSTR(__pyx_k_125), 0},
31212   {(char *)"tid", __pyx_getprop_9csamtools_11AlignedRead_tid, __pyx_setprop_9csamtools_11AlignedRead_tid, __Pyx_DOCSTR(__pyx_k_126), 0},
31213   {(char *)"pos", __pyx_getprop_9csamtools_11AlignedRead_pos, __pyx_setprop_9csamtools_11AlignedRead_pos, __Pyx_DOCSTR(__pyx_k_127), 0},
31214   {(char *)"bin", __pyx_getprop_9csamtools_11AlignedRead_bin, __pyx_setprop_9csamtools_11AlignedRead_bin, __Pyx_DOCSTR(__pyx_k_128), 0},
31215   {(char *)"rlen", __pyx_getprop_9csamtools_11AlignedRead_rlen, 0, __Pyx_DOCSTR(__pyx_k_129), 0},
31216   {(char *)"aend", __pyx_getprop_9csamtools_11AlignedRead_aend, 0, __Pyx_DOCSTR(__pyx_k_130), 0},
31217   {(char *)"alen", __pyx_getprop_9csamtools_11AlignedRead_alen, 0, __Pyx_DOCSTR(__pyx_k_131), 0},
31218   {(char *)"mapq", __pyx_getprop_9csamtools_11AlignedRead_mapq, __pyx_setprop_9csamtools_11AlignedRead_mapq, __Pyx_DOCSTR(__pyx_k_132), 0},
31219   {(char *)"mrnm", __pyx_getprop_9csamtools_11AlignedRead_mrnm, __pyx_setprop_9csamtools_11AlignedRead_mrnm, __Pyx_DOCSTR(__pyx_k_133), 0},
31220   {(char *)"mpos", __pyx_getprop_9csamtools_11AlignedRead_mpos, __pyx_setprop_9csamtools_11AlignedRead_mpos, __Pyx_DOCSTR(__pyx_k_134), 0},
31221   {(char *)"isize", __pyx_getprop_9csamtools_11AlignedRead_isize, __pyx_setprop_9csamtools_11AlignedRead_isize, __Pyx_DOCSTR(__pyx_k_135), 0},
31222   {(char *)"is_paired", __pyx_getprop_9csamtools_11AlignedRead_is_paired, __pyx_setprop_9csamtools_11AlignedRead_is_paired, __Pyx_DOCSTR(__pyx_k_136), 0},
31223   {(char *)"is_proper_pair", __pyx_getprop_9csamtools_11AlignedRead_is_proper_pair, __pyx_setprop_9csamtools_11AlignedRead_is_proper_pair, __Pyx_DOCSTR(__pyx_k_137), 0},
31224   {(char *)"is_unmapped", __pyx_getprop_9csamtools_11AlignedRead_is_unmapped, __pyx_setprop_9csamtools_11AlignedRead_is_unmapped, __Pyx_DOCSTR(__pyx_k_138), 0},
31225   {(char *)"mate_is_unmapped", __pyx_getprop_9csamtools_11AlignedRead_mate_is_unmapped, __pyx_setprop_9csamtools_11AlignedRead_mate_is_unmapped, __Pyx_DOCSTR(__pyx_k_139), 0},
31226   {(char *)"is_reverse", __pyx_getprop_9csamtools_11AlignedRead_is_reverse, __pyx_setprop_9csamtools_11AlignedRead_is_reverse, __Pyx_DOCSTR(__pyx_k_140), 0},
31227   {(char *)"mate_is_reverse", __pyx_getprop_9csamtools_11AlignedRead_mate_is_reverse, __pyx_setprop_9csamtools_11AlignedRead_mate_is_reverse, __Pyx_DOCSTR(__pyx_k_141), 0},
31228   {(char *)"is_read1", __pyx_getprop_9csamtools_11AlignedRead_is_read1, __pyx_setprop_9csamtools_11AlignedRead_is_read1, __Pyx_DOCSTR(__pyx_k_142), 0},
31229   {(char *)"is_read2", __pyx_getprop_9csamtools_11AlignedRead_is_read2, __pyx_setprop_9csamtools_11AlignedRead_is_read2, __Pyx_DOCSTR(__pyx_k_143), 0},
31230   {(char *)"is_secondary", __pyx_getprop_9csamtools_11AlignedRead_is_secondary, __pyx_setprop_9csamtools_11AlignedRead_is_secondary, __Pyx_DOCSTR(__pyx_k_144), 0},
31231   {(char *)"is_qcfail", __pyx_getprop_9csamtools_11AlignedRead_is_qcfail, __pyx_setprop_9csamtools_11AlignedRead_is_qcfail, __Pyx_DOCSTR(__pyx_k_145), 0},
31232   {(char *)"is_duplicate", __pyx_getprop_9csamtools_11AlignedRead_is_duplicate, __pyx_setprop_9csamtools_11AlignedRead_is_duplicate, __Pyx_DOCSTR(__pyx_k_146), 0},
31233   {(char *)"positions", __pyx_getprop_9csamtools_11AlignedRead_positions, 0, __Pyx_DOCSTR(__pyx_k_147), 0},
31234   {0, 0, 0, 0, 0}
31235 };
31236
31237 static PyNumberMethods __pyx_tp_as_number_AlignedRead = {
31238   0, /*nb_add*/
31239   0, /*nb_subtract*/
31240   0, /*nb_multiply*/
31241   #if PY_MAJOR_VERSION < 3
31242   0, /*nb_divide*/
31243   #endif
31244   0, /*nb_remainder*/
31245   0, /*nb_divmod*/
31246   0, /*nb_power*/
31247   0, /*nb_negative*/
31248   0, /*nb_positive*/
31249   0, /*nb_absolute*/
31250   0, /*nb_nonzero*/
31251   0, /*nb_invert*/
31252   0, /*nb_lshift*/
31253   0, /*nb_rshift*/
31254   0, /*nb_and*/
31255   0, /*nb_xor*/
31256   0, /*nb_or*/
31257   #if PY_MAJOR_VERSION < 3
31258   0, /*nb_coerce*/
31259   #endif
31260   0, /*nb_int*/
31261   #if PY_MAJOR_VERSION < 3
31262   0, /*nb_long*/
31263   #else
31264   0, /*reserved*/
31265   #endif
31266   0, /*nb_float*/
31267   #if PY_MAJOR_VERSION < 3
31268   0, /*nb_oct*/
31269   #endif
31270   #if PY_MAJOR_VERSION < 3
31271   0, /*nb_hex*/
31272   #endif
31273   0, /*nb_inplace_add*/
31274   0, /*nb_inplace_subtract*/
31275   0, /*nb_inplace_multiply*/
31276   #if PY_MAJOR_VERSION < 3
31277   0, /*nb_inplace_divide*/
31278   #endif
31279   0, /*nb_inplace_remainder*/
31280   0, /*nb_inplace_power*/
31281   0, /*nb_inplace_lshift*/
31282   0, /*nb_inplace_rshift*/
31283   0, /*nb_inplace_and*/
31284   0, /*nb_inplace_xor*/
31285   0, /*nb_inplace_or*/
31286   0, /*nb_floor_divide*/
31287   0, /*nb_true_divide*/
31288   0, /*nb_inplace_floor_divide*/
31289   0, /*nb_inplace_true_divide*/
31290   #if PY_VERSION_HEX >= 0x02050000
31291   0, /*nb_index*/
31292   #endif
31293 };
31294
31295 static PySequenceMethods __pyx_tp_as_sequence_AlignedRead = {
31296   0, /*sq_length*/
31297   0, /*sq_concat*/
31298   0, /*sq_repeat*/
31299   0, /*sq_item*/
31300   0, /*sq_slice*/
31301   0, /*sq_ass_item*/
31302   0, /*sq_ass_slice*/
31303   0, /*sq_contains*/
31304   0, /*sq_inplace_concat*/
31305   0, /*sq_inplace_repeat*/
31306 };
31307
31308 static PyMappingMethods __pyx_tp_as_mapping_AlignedRead = {
31309   0, /*mp_length*/
31310   0, /*mp_subscript*/
31311   0, /*mp_ass_subscript*/
31312 };
31313
31314 static PyBufferProcs __pyx_tp_as_buffer_AlignedRead = {
31315   #if PY_MAJOR_VERSION < 3
31316   0, /*bf_getreadbuffer*/
31317   #endif
31318   #if PY_MAJOR_VERSION < 3
31319   0, /*bf_getwritebuffer*/
31320   #endif
31321   #if PY_MAJOR_VERSION < 3
31322   0, /*bf_getsegcount*/
31323   #endif
31324   #if PY_MAJOR_VERSION < 3
31325   0, /*bf_getcharbuffer*/
31326   #endif
31327   #if PY_VERSION_HEX >= 0x02060000
31328   0, /*bf_getbuffer*/
31329   #endif
31330   #if PY_VERSION_HEX >= 0x02060000
31331   0, /*bf_releasebuffer*/
31332   #endif
31333 };
31334
31335 PyTypeObject __pyx_type_9csamtools_AlignedRead = {
31336   PyVarObject_HEAD_INIT(0, 0)
31337   __Pyx_NAMESTR("csamtools.AlignedRead"), /*tp_name*/
31338   sizeof(struct __pyx_obj_9csamtools_AlignedRead), /*tp_basicsize*/
31339   0, /*tp_itemsize*/
31340   __pyx_tp_dealloc_9csamtools_AlignedRead, /*tp_dealloc*/
31341   0, /*tp_print*/
31342   0, /*tp_getattr*/
31343   0, /*tp_setattr*/
31344   #if PY_MAJOR_VERSION < 3
31345   0, /*tp_compare*/
31346   #else
31347   0, /*reserved*/
31348   #endif
31349   0, /*tp_repr*/
31350   &__pyx_tp_as_number_AlignedRead, /*tp_as_number*/
31351   &__pyx_tp_as_sequence_AlignedRead, /*tp_as_sequence*/
31352   &__pyx_tp_as_mapping_AlignedRead, /*tp_as_mapping*/
31353   __pyx_pf_9csamtools_11AlignedRead___hash__, /*tp_hash*/
31354   0, /*tp_call*/
31355   __pyx_pf_9csamtools_11AlignedRead___str__, /*tp_str*/
31356   0, /*tp_getattro*/
31357   0, /*tp_setattro*/
31358   &__pyx_tp_as_buffer_AlignedRead, /*tp_as_buffer*/
31359   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
31360   __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*/
31361   0, /*tp_traverse*/
31362   0, /*tp_clear*/
31363   0, /*tp_richcompare*/
31364   0, /*tp_weaklistoffset*/
31365   0, /*tp_iter*/
31366   0, /*tp_iternext*/
31367   __pyx_methods_9csamtools_AlignedRead, /*tp_methods*/
31368   0, /*tp_members*/
31369   __pyx_getsets_9csamtools_AlignedRead, /*tp_getset*/
31370   0, /*tp_base*/
31371   0, /*tp_dict*/
31372   0, /*tp_descr_get*/
31373   0, /*tp_descr_set*/
31374   0, /*tp_dictoffset*/
31375   __pyx_pf_9csamtools_11AlignedRead___init__, /*tp_init*/
31376   0, /*tp_alloc*/
31377   __pyx_tp_new_9csamtools_AlignedRead, /*tp_new*/
31378   0, /*tp_free*/
31379   0, /*tp_is_gc*/
31380   0, /*tp_bases*/
31381   0, /*tp_mro*/
31382   0, /*tp_cache*/
31383   0, /*tp_subclasses*/
31384   0, /*tp_weaklist*/
31385   0, /*tp_del*/
31386   #if PY_VERSION_HEX >= 0x02060000
31387   0, /*tp_version_tag*/
31388   #endif
31389 };
31390 static struct __pyx_vtabstruct_9csamtools_Samfile __pyx_vtable_9csamtools_Samfile;
31391
31392 static PyObject *__pyx_tp_new_9csamtools_Samfile(PyTypeObject *t, PyObject *a, PyObject *k) {
31393   struct __pyx_obj_9csamtools_Samfile *p;
31394   PyObject *o = (*t->tp_alloc)(t, 0);
31395   if (!o) return 0;
31396   p = ((struct __pyx_obj_9csamtools_Samfile *)o);
31397   p->__pyx_vtab = __pyx_vtabptr_9csamtools_Samfile;
31398   if (__pyx_pf_9csamtools_7Samfile___cinit__(o, a, k) < 0) {
31399     Py_DECREF(o); o = 0;
31400   }
31401   return o;
31402 }
31403
31404 static void __pyx_tp_dealloc_9csamtools_Samfile(PyObject *o) {
31405   {
31406     PyObject *etype, *eval, *etb;
31407     PyErr_Fetch(&etype, &eval, &etb);
31408     ++Py_REFCNT(o);
31409     __pyx_pf_9csamtools_7Samfile___dealloc__(o);
31410     if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
31411     --Py_REFCNT(o);
31412     PyErr_Restore(etype, eval, etb);
31413   }
31414   (*Py_TYPE(o)->tp_free)(o);
31415 }
31416
31417 static PyObject *__pyx_getprop_9csamtools_7Samfile_filename(PyObject *o, void *x) {
31418   return __pyx_pf_9csamtools_7Samfile_8filename___get__(o);
31419 }
31420
31421 static PyObject *__pyx_getprop_9csamtools_7Samfile_nreferences(PyObject *o, void *x) {
31422   return __pyx_pf_9csamtools_7Samfile_11nreferences___get__(o);
31423 }
31424
31425 static PyObject *__pyx_getprop_9csamtools_7Samfile_references(PyObject *o, void *x) {
31426   return __pyx_pf_9csamtools_7Samfile_10references___get__(o);
31427 }
31428
31429 static PyObject *__pyx_getprop_9csamtools_7Samfile_lengths(PyObject *o, void *x) {
31430   return __pyx_pf_9csamtools_7Samfile_7lengths___get__(o);
31431 }
31432
31433 static PyObject *__pyx_getprop_9csamtools_7Samfile_text(PyObject *o, void *x) {
31434   return __pyx_pf_9csamtools_7Samfile_4text___get__(o);
31435 }
31436
31437 static PyObject *__pyx_getprop_9csamtools_7Samfile_header(PyObject *o, void *x) {
31438   return __pyx_pf_9csamtools_7Samfile_6header___get__(o);
31439 }
31440
31441 static PyMethodDef __pyx_methods_9csamtools_Samfile[] = {
31442   {__Pyx_NAMESTR("_isOpen"), (PyCFunction)__pyx_pf_9csamtools_7Samfile__isOpen, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile__isOpen)},
31443   {__Pyx_NAMESTR("_hasIndex"), (PyCFunction)__pyx_pf_9csamtools_7Samfile__hasIndex, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile__hasIndex)},
31444   {__Pyx_NAMESTR("_open"), (PyCFunction)__pyx_pf_9csamtools_7Samfile__open, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile__open)},
31445   {__Pyx_NAMESTR("gettid"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_gettid, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_gettid)},
31446   {__Pyx_NAMESTR("getrname"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_getrname, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_getrname)},
31447   {__Pyx_NAMESTR("_parseRegion"), (PyCFunction)__pyx_pf_9csamtools_7Samfile__parseRegion, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile__parseRegion)},
31448   {__Pyx_NAMESTR("seek"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_seek, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_seek)},
31449   {__Pyx_NAMESTR("tell"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_tell, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_tell)},
31450   {__Pyx_NAMESTR("fetch"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_fetch, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_fetch)},
31451   {__Pyx_NAMESTR("mate"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_mate, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_mate)},
31452   {__Pyx_NAMESTR("count"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_count, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_count)},
31453   {__Pyx_NAMESTR("pileup"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_pileup, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_pileup)},
31454   {__Pyx_NAMESTR("close"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_close, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_close)},
31455   {__Pyx_NAMESTR("write"), (PyCFunction)__pyx_pf_9csamtools_7Samfile_write, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile_write)},
31456   {__Pyx_NAMESTR("__enter__"), (PyCFunction)__pyx_pf_9csamtools_7Samfile___enter__, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile___enter__)},
31457   {__Pyx_NAMESTR("__exit__"), (PyCFunction)__pyx_pf_9csamtools_7Samfile___exit__, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile___exit__)},
31458   {__Pyx_NAMESTR("_buildLine"), (PyCFunction)__pyx_pf_9csamtools_7Samfile__buildLine, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile__buildLine)},
31459   {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_7Samfile___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_7Samfile___next__)},
31460   {0, 0, 0, 0}
31461 };
31462
31463 static struct PyGetSetDef __pyx_getsets_9csamtools_Samfile[] = {
31464   {(char *)"filename", __pyx_getprop_9csamtools_7Samfile_filename, 0, __Pyx_DOCSTR(__pyx_k_148), 0},
31465   {(char *)"nreferences", __pyx_getprop_9csamtools_7Samfile_nreferences, 0, __Pyx_DOCSTR(__pyx_k_149), 0},
31466   {(char *)"references", __pyx_getprop_9csamtools_7Samfile_references, 0, __Pyx_DOCSTR(__pyx_k_150), 0},
31467   {(char *)"lengths", __pyx_getprop_9csamtools_7Samfile_lengths, 0, __Pyx_DOCSTR(__pyx_k_151), 0},
31468   {(char *)"text", __pyx_getprop_9csamtools_7Samfile_text, 0, __Pyx_DOCSTR(__pyx_k_152), 0},
31469   {(char *)"header", __pyx_getprop_9csamtools_7Samfile_header, 0, __Pyx_DOCSTR(__pyx_k_153), 0},
31470   {0, 0, 0, 0, 0}
31471 };
31472
31473 static PyNumberMethods __pyx_tp_as_number_Samfile = {
31474   0, /*nb_add*/
31475   0, /*nb_subtract*/
31476   0, /*nb_multiply*/
31477   #if PY_MAJOR_VERSION < 3
31478   0, /*nb_divide*/
31479   #endif
31480   0, /*nb_remainder*/
31481   0, /*nb_divmod*/
31482   0, /*nb_power*/
31483   0, /*nb_negative*/
31484   0, /*nb_positive*/
31485   0, /*nb_absolute*/
31486   0, /*nb_nonzero*/
31487   0, /*nb_invert*/
31488   0, /*nb_lshift*/
31489   0, /*nb_rshift*/
31490   0, /*nb_and*/
31491   0, /*nb_xor*/
31492   0, /*nb_or*/
31493   #if PY_MAJOR_VERSION < 3
31494   0, /*nb_coerce*/
31495   #endif
31496   0, /*nb_int*/
31497   #if PY_MAJOR_VERSION < 3
31498   0, /*nb_long*/
31499   #else
31500   0, /*reserved*/
31501   #endif
31502   0, /*nb_float*/
31503   #if PY_MAJOR_VERSION < 3
31504   0, /*nb_oct*/
31505   #endif
31506   #if PY_MAJOR_VERSION < 3
31507   0, /*nb_hex*/
31508   #endif
31509   0, /*nb_inplace_add*/
31510   0, /*nb_inplace_subtract*/
31511   0, /*nb_inplace_multiply*/
31512   #if PY_MAJOR_VERSION < 3
31513   0, /*nb_inplace_divide*/
31514   #endif
31515   0, /*nb_inplace_remainder*/
31516   0, /*nb_inplace_power*/
31517   0, /*nb_inplace_lshift*/
31518   0, /*nb_inplace_rshift*/
31519   0, /*nb_inplace_and*/
31520   0, /*nb_inplace_xor*/
31521   0, /*nb_inplace_or*/
31522   0, /*nb_floor_divide*/
31523   0, /*nb_true_divide*/
31524   0, /*nb_inplace_floor_divide*/
31525   0, /*nb_inplace_true_divide*/
31526   #if PY_VERSION_HEX >= 0x02050000
31527   0, /*nb_index*/
31528   #endif
31529 };
31530
31531 static PySequenceMethods __pyx_tp_as_sequence_Samfile = {
31532   0, /*sq_length*/
31533   0, /*sq_concat*/
31534   0, /*sq_repeat*/
31535   0, /*sq_item*/
31536   0, /*sq_slice*/
31537   0, /*sq_ass_item*/
31538   0, /*sq_ass_slice*/
31539   0, /*sq_contains*/
31540   0, /*sq_inplace_concat*/
31541   0, /*sq_inplace_repeat*/
31542 };
31543
31544 static PyMappingMethods __pyx_tp_as_mapping_Samfile = {
31545   0, /*mp_length*/
31546   0, /*mp_subscript*/
31547   0, /*mp_ass_subscript*/
31548 };
31549
31550 static PyBufferProcs __pyx_tp_as_buffer_Samfile = {
31551   #if PY_MAJOR_VERSION < 3
31552   0, /*bf_getreadbuffer*/
31553   #endif
31554   #if PY_MAJOR_VERSION < 3
31555   0, /*bf_getwritebuffer*/
31556   #endif
31557   #if PY_MAJOR_VERSION < 3
31558   0, /*bf_getsegcount*/
31559   #endif
31560   #if PY_MAJOR_VERSION < 3
31561   0, /*bf_getcharbuffer*/
31562   #endif
31563   #if PY_VERSION_HEX >= 0x02060000
31564   0, /*bf_getbuffer*/
31565   #endif
31566   #if PY_VERSION_HEX >= 0x02060000
31567   0, /*bf_releasebuffer*/
31568   #endif
31569 };
31570
31571 PyTypeObject __pyx_type_9csamtools_Samfile = {
31572   PyVarObject_HEAD_INIT(0, 0)
31573   __Pyx_NAMESTR("csamtools.Samfile"), /*tp_name*/
31574   sizeof(struct __pyx_obj_9csamtools_Samfile), /*tp_basicsize*/
31575   0, /*tp_itemsize*/
31576   __pyx_tp_dealloc_9csamtools_Samfile, /*tp_dealloc*/
31577   0, /*tp_print*/
31578   0, /*tp_getattr*/
31579   0, /*tp_setattr*/
31580   #if PY_MAJOR_VERSION < 3
31581   0, /*tp_compare*/
31582   #else
31583   0, /*reserved*/
31584   #endif
31585   0, /*tp_repr*/
31586   &__pyx_tp_as_number_Samfile, /*tp_as_number*/
31587   &__pyx_tp_as_sequence_Samfile, /*tp_as_sequence*/
31588   &__pyx_tp_as_mapping_Samfile, /*tp_as_mapping*/
31589   0, /*tp_hash*/
31590   0, /*tp_call*/
31591   0, /*tp_str*/
31592   0, /*tp_getattro*/
31593   0, /*tp_setattro*/
31594   &__pyx_tp_as_buffer_Samfile, /*tp_as_buffer*/
31595   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
31596   __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*/
31597   0, /*tp_traverse*/
31598   0, /*tp_clear*/
31599   0, /*tp_richcompare*/
31600   0, /*tp_weaklistoffset*/
31601   __pyx_pf_9csamtools_7Samfile___iter__, /*tp_iter*/
31602   __pyx_pf_9csamtools_7Samfile___next__, /*tp_iternext*/
31603   __pyx_methods_9csamtools_Samfile, /*tp_methods*/
31604   0, /*tp_members*/
31605   __pyx_getsets_9csamtools_Samfile, /*tp_getset*/
31606   0, /*tp_base*/
31607   0, /*tp_dict*/
31608   0, /*tp_descr_get*/
31609   0, /*tp_descr_set*/
31610   0, /*tp_dictoffset*/
31611   0, /*tp_init*/
31612   0, /*tp_alloc*/
31613   __pyx_tp_new_9csamtools_Samfile, /*tp_new*/
31614   0, /*tp_free*/
31615   0, /*tp_is_gc*/
31616   0, /*tp_bases*/
31617   0, /*tp_mro*/
31618   0, /*tp_cache*/
31619   0, /*tp_subclasses*/
31620   0, /*tp_weaklist*/
31621   0, /*tp_del*/
31622   #if PY_VERSION_HEX >= 0x02060000
31623   0, /*tp_version_tag*/
31624   #endif
31625 };
31626
31627 static PyObject *__pyx_tp_new_9csamtools_PileupProxy(PyTypeObject *t, PyObject *a, PyObject *k) {
31628   PyObject *o = (*t->tp_alloc)(t, 0);
31629   if (!o) return 0;
31630   return o;
31631 }
31632
31633 static void __pyx_tp_dealloc_9csamtools_PileupProxy(PyObject *o) {
31634   (*Py_TYPE(o)->tp_free)(o);
31635 }
31636
31637 static PyObject *__pyx_getprop_9csamtools_11PileupProxy_tid(PyObject *o, void *x) {
31638   return __pyx_pf_9csamtools_11PileupProxy_3tid___get__(o);
31639 }
31640
31641 static PyObject *__pyx_getprop_9csamtools_11PileupProxy_n(PyObject *o, void *x) {
31642   return __pyx_pf_9csamtools_11PileupProxy_1n___get__(o);
31643 }
31644
31645 static int __pyx_setprop_9csamtools_11PileupProxy_n(PyObject *o, PyObject *v, void *x) {
31646   if (v) {
31647     return __pyx_pf_9csamtools_11PileupProxy_1n___set__(o, v);
31648   }
31649   else {
31650     PyErr_SetString(PyExc_NotImplementedError, "__del__");
31651     return -1;
31652   }
31653 }
31654
31655 static PyObject *__pyx_getprop_9csamtools_11PileupProxy_pos(PyObject *o, void *x) {
31656   return __pyx_pf_9csamtools_11PileupProxy_3pos___get__(o);
31657 }
31658
31659 static PyObject *__pyx_getprop_9csamtools_11PileupProxy_pileups(PyObject *o, void *x) {
31660   return __pyx_pf_9csamtools_11PileupProxy_7pileups___get__(o);
31661 }
31662
31663 static PyMethodDef __pyx_methods_9csamtools_PileupProxy[] = {
31664   {0, 0, 0, 0}
31665 };
31666
31667 static struct PyGetSetDef __pyx_getsets_9csamtools_PileupProxy[] = {
31668   {(char *)"tid", __pyx_getprop_9csamtools_11PileupProxy_tid, 0, __Pyx_DOCSTR(__pyx_k_154), 0},
31669   {(char *)"n", __pyx_getprop_9csamtools_11PileupProxy_n, __pyx_setprop_9csamtools_11PileupProxy_n, __Pyx_DOCSTR(__pyx_k_155), 0},
31670   {(char *)"pos", __pyx_getprop_9csamtools_11PileupProxy_pos, 0, 0, 0},
31671   {(char *)"pileups", __pyx_getprop_9csamtools_11PileupProxy_pileups, 0, __Pyx_DOCSTR(__pyx_k_156), 0},
31672   {0, 0, 0, 0, 0}
31673 };
31674
31675 static PyNumberMethods __pyx_tp_as_number_PileupProxy = {
31676   0, /*nb_add*/
31677   0, /*nb_subtract*/
31678   0, /*nb_multiply*/
31679   #if PY_MAJOR_VERSION < 3
31680   0, /*nb_divide*/
31681   #endif
31682   0, /*nb_remainder*/
31683   0, /*nb_divmod*/
31684   0, /*nb_power*/
31685   0, /*nb_negative*/
31686   0, /*nb_positive*/
31687   0, /*nb_absolute*/
31688   0, /*nb_nonzero*/
31689   0, /*nb_invert*/
31690   0, /*nb_lshift*/
31691   0, /*nb_rshift*/
31692   0, /*nb_and*/
31693   0, /*nb_xor*/
31694   0, /*nb_or*/
31695   #if PY_MAJOR_VERSION < 3
31696   0, /*nb_coerce*/
31697   #endif
31698   0, /*nb_int*/
31699   #if PY_MAJOR_VERSION < 3
31700   0, /*nb_long*/
31701   #else
31702   0, /*reserved*/
31703   #endif
31704   0, /*nb_float*/
31705   #if PY_MAJOR_VERSION < 3
31706   0, /*nb_oct*/
31707   #endif
31708   #if PY_MAJOR_VERSION < 3
31709   0, /*nb_hex*/
31710   #endif
31711   0, /*nb_inplace_add*/
31712   0, /*nb_inplace_subtract*/
31713   0, /*nb_inplace_multiply*/
31714   #if PY_MAJOR_VERSION < 3
31715   0, /*nb_inplace_divide*/
31716   #endif
31717   0, /*nb_inplace_remainder*/
31718   0, /*nb_inplace_power*/
31719   0, /*nb_inplace_lshift*/
31720   0, /*nb_inplace_rshift*/
31721   0, /*nb_inplace_and*/
31722   0, /*nb_inplace_xor*/
31723   0, /*nb_inplace_or*/
31724   0, /*nb_floor_divide*/
31725   0, /*nb_true_divide*/
31726   0, /*nb_inplace_floor_divide*/
31727   0, /*nb_inplace_true_divide*/
31728   #if PY_VERSION_HEX >= 0x02050000
31729   0, /*nb_index*/
31730   #endif
31731 };
31732
31733 static PySequenceMethods __pyx_tp_as_sequence_PileupProxy = {
31734   0, /*sq_length*/
31735   0, /*sq_concat*/
31736   0, /*sq_repeat*/
31737   0, /*sq_item*/
31738   0, /*sq_slice*/
31739   0, /*sq_ass_item*/
31740   0, /*sq_ass_slice*/
31741   0, /*sq_contains*/
31742   0, /*sq_inplace_concat*/
31743   0, /*sq_inplace_repeat*/
31744 };
31745
31746 static PyMappingMethods __pyx_tp_as_mapping_PileupProxy = {
31747   0, /*mp_length*/
31748   0, /*mp_subscript*/
31749   0, /*mp_ass_subscript*/
31750 };
31751
31752 static PyBufferProcs __pyx_tp_as_buffer_PileupProxy = {
31753   #if PY_MAJOR_VERSION < 3
31754   0, /*bf_getreadbuffer*/
31755   #endif
31756   #if PY_MAJOR_VERSION < 3
31757   0, /*bf_getwritebuffer*/
31758   #endif
31759   #if PY_MAJOR_VERSION < 3
31760   0, /*bf_getsegcount*/
31761   #endif
31762   #if PY_MAJOR_VERSION < 3
31763   0, /*bf_getcharbuffer*/
31764   #endif
31765   #if PY_VERSION_HEX >= 0x02060000
31766   0, /*bf_getbuffer*/
31767   #endif
31768   #if PY_VERSION_HEX >= 0x02060000
31769   0, /*bf_releasebuffer*/
31770   #endif
31771 };
31772
31773 PyTypeObject __pyx_type_9csamtools_PileupProxy = {
31774   PyVarObject_HEAD_INIT(0, 0)
31775   __Pyx_NAMESTR("csamtools.PileupProxy"), /*tp_name*/
31776   sizeof(struct __pyx_obj_9csamtools_PileupProxy), /*tp_basicsize*/
31777   0, /*tp_itemsize*/
31778   __pyx_tp_dealloc_9csamtools_PileupProxy, /*tp_dealloc*/
31779   0, /*tp_print*/
31780   0, /*tp_getattr*/
31781   0, /*tp_setattr*/
31782   #if PY_MAJOR_VERSION < 3
31783   0, /*tp_compare*/
31784   #else
31785   0, /*reserved*/
31786   #endif
31787   0, /*tp_repr*/
31788   &__pyx_tp_as_number_PileupProxy, /*tp_as_number*/
31789   &__pyx_tp_as_sequence_PileupProxy, /*tp_as_sequence*/
31790   &__pyx_tp_as_mapping_PileupProxy, /*tp_as_mapping*/
31791   0, /*tp_hash*/
31792   0, /*tp_call*/
31793   __pyx_pf_9csamtools_11PileupProxy___str__, /*tp_str*/
31794   0, /*tp_getattro*/
31795   0, /*tp_setattro*/
31796   &__pyx_tp_as_buffer_PileupProxy, /*tp_as_buffer*/
31797   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
31798   __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*/
31799   0, /*tp_traverse*/
31800   0, /*tp_clear*/
31801   0, /*tp_richcompare*/
31802   0, /*tp_weaklistoffset*/
31803   0, /*tp_iter*/
31804   0, /*tp_iternext*/
31805   __pyx_methods_9csamtools_PileupProxy, /*tp_methods*/
31806   0, /*tp_members*/
31807   __pyx_getsets_9csamtools_PileupProxy, /*tp_getset*/
31808   0, /*tp_base*/
31809   0, /*tp_dict*/
31810   0, /*tp_descr_get*/
31811   0, /*tp_descr_set*/
31812   0, /*tp_dictoffset*/
31813   __pyx_pf_9csamtools_11PileupProxy___init__, /*tp_init*/
31814   0, /*tp_alloc*/
31815   __pyx_tp_new_9csamtools_PileupProxy, /*tp_new*/
31816   0, /*tp_free*/
31817   0, /*tp_is_gc*/
31818   0, /*tp_bases*/
31819   0, /*tp_mro*/
31820   0, /*tp_cache*/
31821   0, /*tp_subclasses*/
31822   0, /*tp_weaklist*/
31823   0, /*tp_del*/
31824   #if PY_VERSION_HEX >= 0x02060000
31825   0, /*tp_version_tag*/
31826   #endif
31827 };
31828
31829 static PyObject *__pyx_tp_new_9csamtools_PileupRead(PyTypeObject *t, PyObject *a, PyObject *k) {
31830   struct __pyx_obj_9csamtools_PileupRead *p;
31831   PyObject *o = (*t->tp_alloc)(t, 0);
31832   if (!o) return 0;
31833   p = ((struct __pyx_obj_9csamtools_PileupRead *)o);
31834   p->_alignment = ((struct __pyx_obj_9csamtools_AlignedRead *)Py_None); Py_INCREF(Py_None);
31835   return o;
31836 }
31837
31838 static void __pyx_tp_dealloc_9csamtools_PileupRead(PyObject *o) {
31839   struct __pyx_obj_9csamtools_PileupRead *p = (struct __pyx_obj_9csamtools_PileupRead *)o;
31840   Py_XDECREF(((PyObject *)p->_alignment));
31841   (*Py_TYPE(o)->tp_free)(o);
31842 }
31843
31844 static int __pyx_tp_traverse_9csamtools_PileupRead(PyObject *o, visitproc v, void *a) {
31845   int e;
31846   struct __pyx_obj_9csamtools_PileupRead *p = (struct __pyx_obj_9csamtools_PileupRead *)o;
31847   if (p->_alignment) {
31848     e = (*v)(((PyObject*)p->_alignment), a); if (e) return e;
31849   }
31850   return 0;
31851 }
31852
31853 static int __pyx_tp_clear_9csamtools_PileupRead(PyObject *o) {
31854   struct __pyx_obj_9csamtools_PileupRead *p = (struct __pyx_obj_9csamtools_PileupRead *)o;
31855   PyObject* tmp;
31856   tmp = ((PyObject*)p->_alignment);
31857   p->_alignment = ((struct __pyx_obj_9csamtools_AlignedRead *)Py_None); Py_INCREF(Py_None);
31858   Py_XDECREF(tmp);
31859   return 0;
31860 }
31861
31862 static PyObject *__pyx_getprop_9csamtools_10PileupRead_alignment(PyObject *o, void *x) {
31863   return __pyx_pf_9csamtools_10PileupRead_9alignment___get__(o);
31864 }
31865
31866 static PyObject *__pyx_getprop_9csamtools_10PileupRead_qpos(PyObject *o, void *x) {
31867   return __pyx_pf_9csamtools_10PileupRead_4qpos___get__(o);
31868 }
31869
31870 static PyObject *__pyx_getprop_9csamtools_10PileupRead_indel(PyObject *o, void *x) {
31871   return __pyx_pf_9csamtools_10PileupRead_5indel___get__(o);
31872 }
31873
31874 static PyObject *__pyx_getprop_9csamtools_10PileupRead_is_del(PyObject *o, void *x) {
31875   return __pyx_pf_9csamtools_10PileupRead_6is_del___get__(o);
31876 }
31877
31878 static PyObject *__pyx_getprop_9csamtools_10PileupRead_is_head(PyObject *o, void *x) {
31879   return __pyx_pf_9csamtools_10PileupRead_7is_head___get__(o);
31880 }
31881
31882 static PyObject *__pyx_getprop_9csamtools_10PileupRead_is_tail(PyObject *o, void *x) {
31883   return __pyx_pf_9csamtools_10PileupRead_7is_tail___get__(o);
31884 }
31885
31886 static PyObject *__pyx_getprop_9csamtools_10PileupRead_level(PyObject *o, void *x) {
31887   return __pyx_pf_9csamtools_10PileupRead_5level___get__(o);
31888 }
31889
31890 static PyMethodDef __pyx_methods_9csamtools_PileupRead[] = {
31891   {0, 0, 0, 0}
31892 };
31893
31894 static struct PyGetSetDef __pyx_getsets_9csamtools_PileupRead[] = {
31895   {(char *)"alignment", __pyx_getprop_9csamtools_10PileupRead_alignment, 0, __Pyx_DOCSTR(__pyx_k_157), 0},
31896   {(char *)"qpos", __pyx_getprop_9csamtools_10PileupRead_qpos, 0, __Pyx_DOCSTR(__pyx_k_158), 0},
31897   {(char *)"indel", __pyx_getprop_9csamtools_10PileupRead_indel, 0, __Pyx_DOCSTR(__pyx_k_159), 0},
31898   {(char *)"is_del", __pyx_getprop_9csamtools_10PileupRead_is_del, 0, __Pyx_DOCSTR(__pyx_k_160), 0},
31899   {(char *)"is_head", __pyx_getprop_9csamtools_10PileupRead_is_head, 0, 0, 0},
31900   {(char *)"is_tail", __pyx_getprop_9csamtools_10PileupRead_is_tail, 0, 0, 0},
31901   {(char *)"level", __pyx_getprop_9csamtools_10PileupRead_level, 0, 0, 0},
31902   {0, 0, 0, 0, 0}
31903 };
31904
31905 static PyNumberMethods __pyx_tp_as_number_PileupRead = {
31906   0, /*nb_add*/
31907   0, /*nb_subtract*/
31908   0, /*nb_multiply*/
31909   #if PY_MAJOR_VERSION < 3
31910   0, /*nb_divide*/
31911   #endif
31912   0, /*nb_remainder*/
31913   0, /*nb_divmod*/
31914   0, /*nb_power*/
31915   0, /*nb_negative*/
31916   0, /*nb_positive*/
31917   0, /*nb_absolute*/
31918   0, /*nb_nonzero*/
31919   0, /*nb_invert*/
31920   0, /*nb_lshift*/
31921   0, /*nb_rshift*/
31922   0, /*nb_and*/
31923   0, /*nb_xor*/
31924   0, /*nb_or*/
31925   #if PY_MAJOR_VERSION < 3
31926   0, /*nb_coerce*/
31927   #endif
31928   0, /*nb_int*/
31929   #if PY_MAJOR_VERSION < 3
31930   0, /*nb_long*/
31931   #else
31932   0, /*reserved*/
31933   #endif
31934   0, /*nb_float*/
31935   #if PY_MAJOR_VERSION < 3
31936   0, /*nb_oct*/
31937   #endif
31938   #if PY_MAJOR_VERSION < 3
31939   0, /*nb_hex*/
31940   #endif
31941   0, /*nb_inplace_add*/
31942   0, /*nb_inplace_subtract*/
31943   0, /*nb_inplace_multiply*/
31944   #if PY_MAJOR_VERSION < 3
31945   0, /*nb_inplace_divide*/
31946   #endif
31947   0, /*nb_inplace_remainder*/
31948   0, /*nb_inplace_power*/
31949   0, /*nb_inplace_lshift*/
31950   0, /*nb_inplace_rshift*/
31951   0, /*nb_inplace_and*/
31952   0, /*nb_inplace_xor*/
31953   0, /*nb_inplace_or*/
31954   0, /*nb_floor_divide*/
31955   0, /*nb_true_divide*/
31956   0, /*nb_inplace_floor_divide*/
31957   0, /*nb_inplace_true_divide*/
31958   #if PY_VERSION_HEX >= 0x02050000
31959   0, /*nb_index*/
31960   #endif
31961 };
31962
31963 static PySequenceMethods __pyx_tp_as_sequence_PileupRead = {
31964   0, /*sq_length*/
31965   0, /*sq_concat*/
31966   0, /*sq_repeat*/
31967   0, /*sq_item*/
31968   0, /*sq_slice*/
31969   0, /*sq_ass_item*/
31970   0, /*sq_ass_slice*/
31971   0, /*sq_contains*/
31972   0, /*sq_inplace_concat*/
31973   0, /*sq_inplace_repeat*/
31974 };
31975
31976 static PyMappingMethods __pyx_tp_as_mapping_PileupRead = {
31977   0, /*mp_length*/
31978   0, /*mp_subscript*/
31979   0, /*mp_ass_subscript*/
31980 };
31981
31982 static PyBufferProcs __pyx_tp_as_buffer_PileupRead = {
31983   #if PY_MAJOR_VERSION < 3
31984   0, /*bf_getreadbuffer*/
31985   #endif
31986   #if PY_MAJOR_VERSION < 3
31987   0, /*bf_getwritebuffer*/
31988   #endif
31989   #if PY_MAJOR_VERSION < 3
31990   0, /*bf_getsegcount*/
31991   #endif
31992   #if PY_MAJOR_VERSION < 3
31993   0, /*bf_getcharbuffer*/
31994   #endif
31995   #if PY_VERSION_HEX >= 0x02060000
31996   0, /*bf_getbuffer*/
31997   #endif
31998   #if PY_VERSION_HEX >= 0x02060000
31999   0, /*bf_releasebuffer*/
32000   #endif
32001 };
32002
32003 PyTypeObject __pyx_type_9csamtools_PileupRead = {
32004   PyVarObject_HEAD_INIT(0, 0)
32005   __Pyx_NAMESTR("csamtools.PileupRead"), /*tp_name*/
32006   sizeof(struct __pyx_obj_9csamtools_PileupRead), /*tp_basicsize*/
32007   0, /*tp_itemsize*/
32008   __pyx_tp_dealloc_9csamtools_PileupRead, /*tp_dealloc*/
32009   0, /*tp_print*/
32010   0, /*tp_getattr*/
32011   0, /*tp_setattr*/
32012   #if PY_MAJOR_VERSION < 3
32013   0, /*tp_compare*/
32014   #else
32015   0, /*reserved*/
32016   #endif
32017   0, /*tp_repr*/
32018   &__pyx_tp_as_number_PileupRead, /*tp_as_number*/
32019   &__pyx_tp_as_sequence_PileupRead, /*tp_as_sequence*/
32020   &__pyx_tp_as_mapping_PileupRead, /*tp_as_mapping*/
32021   0, /*tp_hash*/
32022   0, /*tp_call*/
32023   __pyx_pf_9csamtools_10PileupRead___str__, /*tp_str*/
32024   0, /*tp_getattro*/
32025   0, /*tp_setattro*/
32026   &__pyx_tp_as_buffer_PileupRead, /*tp_as_buffer*/
32027   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
32028   __Pyx_DOCSTR("PileupRead()\nA read aligned to a column.\n    "), /*tp_doc*/
32029   __pyx_tp_traverse_9csamtools_PileupRead, /*tp_traverse*/
32030   __pyx_tp_clear_9csamtools_PileupRead, /*tp_clear*/
32031   0, /*tp_richcompare*/
32032   0, /*tp_weaklistoffset*/
32033   0, /*tp_iter*/
32034   0, /*tp_iternext*/
32035   __pyx_methods_9csamtools_PileupRead, /*tp_methods*/
32036   0, /*tp_members*/
32037   __pyx_getsets_9csamtools_PileupRead, /*tp_getset*/
32038   0, /*tp_base*/
32039   0, /*tp_dict*/
32040   0, /*tp_descr_get*/
32041   0, /*tp_descr_set*/
32042   0, /*tp_dictoffset*/
32043   __pyx_pf_9csamtools_10PileupRead___init__, /*tp_init*/
32044   0, /*tp_alloc*/
32045   __pyx_tp_new_9csamtools_PileupRead, /*tp_new*/
32046   0, /*tp_free*/
32047   0, /*tp_is_gc*/
32048   0, /*tp_bases*/
32049   0, /*tp_mro*/
32050   0, /*tp_cache*/
32051   0, /*tp_subclasses*/
32052   0, /*tp_weaklist*/
32053   0, /*tp_del*/
32054   #if PY_VERSION_HEX >= 0x02060000
32055   0, /*tp_version_tag*/
32056   #endif
32057 };
32058 static struct __pyx_vtabstruct_9csamtools_Fastafile __pyx_vtable_9csamtools_Fastafile;
32059
32060 static PyObject *__pyx_tp_new_9csamtools_Fastafile(PyTypeObject *t, PyObject *a, PyObject *k) {
32061   struct __pyx_obj_9csamtools_Fastafile *p;
32062   PyObject *o = (*t->tp_alloc)(t, 0);
32063   if (!o) return 0;
32064   p = ((struct __pyx_obj_9csamtools_Fastafile *)o);
32065   p->__pyx_vtab = __pyx_vtabptr_9csamtools_Fastafile;
32066   if (__pyx_pf_9csamtools_9Fastafile___cinit__(o, a, k) < 0) {
32067     Py_DECREF(o); o = 0;
32068   }
32069   return o;
32070 }
32071
32072 static void __pyx_tp_dealloc_9csamtools_Fastafile(PyObject *o) {
32073   {
32074     PyObject *etype, *eval, *etb;
32075     PyErr_Fetch(&etype, &eval, &etb);
32076     ++Py_REFCNT(o);
32077     __pyx_pf_9csamtools_9Fastafile___dealloc__(o);
32078     if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
32079     --Py_REFCNT(o);
32080     PyErr_Restore(etype, eval, etb);
32081   }
32082   (*Py_TYPE(o)->tp_free)(o);
32083 }
32084
32085 static PyObject *__pyx_getprop_9csamtools_9Fastafile_filename(PyObject *o, void *x) {
32086   return __pyx_pf_9csamtools_9Fastafile_8filename___get__(o);
32087 }
32088
32089 static PyMethodDef __pyx_methods_9csamtools_Fastafile[] = {
32090   {__Pyx_NAMESTR("_isOpen"), (PyCFunction)__pyx_pf_9csamtools_9Fastafile__isOpen, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_9Fastafile__isOpen)},
32091   {__Pyx_NAMESTR("_open"), (PyCFunction)__pyx_pf_9csamtools_9Fastafile__open, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_9Fastafile__open)},
32092   {__Pyx_NAMESTR("close"), (PyCFunction)__pyx_pf_9csamtools_9Fastafile_close, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_9Fastafile_close)},
32093   {__Pyx_NAMESTR("fetch"), (PyCFunction)__pyx_pf_9csamtools_9Fastafile_fetch, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_9Fastafile_fetch)},
32094   {0, 0, 0, 0}
32095 };
32096
32097 static struct PyGetSetDef __pyx_getsets_9csamtools_Fastafile[] = {
32098   {(char *)"filename", __pyx_getprop_9csamtools_9Fastafile_filename, 0, __Pyx_DOCSTR(__pyx_k_148), 0},
32099   {0, 0, 0, 0, 0}
32100 };
32101
32102 static PyNumberMethods __pyx_tp_as_number_Fastafile = {
32103   0, /*nb_add*/
32104   0, /*nb_subtract*/
32105   0, /*nb_multiply*/
32106   #if PY_MAJOR_VERSION < 3
32107   0, /*nb_divide*/
32108   #endif
32109   0, /*nb_remainder*/
32110   0, /*nb_divmod*/
32111   0, /*nb_power*/
32112   0, /*nb_negative*/
32113   0, /*nb_positive*/
32114   0, /*nb_absolute*/
32115   0, /*nb_nonzero*/
32116   0, /*nb_invert*/
32117   0, /*nb_lshift*/
32118   0, /*nb_rshift*/
32119   0, /*nb_and*/
32120   0, /*nb_xor*/
32121   0, /*nb_or*/
32122   #if PY_MAJOR_VERSION < 3
32123   0, /*nb_coerce*/
32124   #endif
32125   0, /*nb_int*/
32126   #if PY_MAJOR_VERSION < 3
32127   0, /*nb_long*/
32128   #else
32129   0, /*reserved*/
32130   #endif
32131   0, /*nb_float*/
32132   #if PY_MAJOR_VERSION < 3
32133   0, /*nb_oct*/
32134   #endif
32135   #if PY_MAJOR_VERSION < 3
32136   0, /*nb_hex*/
32137   #endif
32138   0, /*nb_inplace_add*/
32139   0, /*nb_inplace_subtract*/
32140   0, /*nb_inplace_multiply*/
32141   #if PY_MAJOR_VERSION < 3
32142   0, /*nb_inplace_divide*/
32143   #endif
32144   0, /*nb_inplace_remainder*/
32145   0, /*nb_inplace_power*/
32146   0, /*nb_inplace_lshift*/
32147   0, /*nb_inplace_rshift*/
32148   0, /*nb_inplace_and*/
32149   0, /*nb_inplace_xor*/
32150   0, /*nb_inplace_or*/
32151   0, /*nb_floor_divide*/
32152   0, /*nb_true_divide*/
32153   0, /*nb_inplace_floor_divide*/
32154   0, /*nb_inplace_true_divide*/
32155   #if PY_VERSION_HEX >= 0x02050000
32156   0, /*nb_index*/
32157   #endif
32158 };
32159
32160 static PySequenceMethods __pyx_tp_as_sequence_Fastafile = {
32161   __pyx_pf_9csamtools_9Fastafile___len__, /*sq_length*/
32162   0, /*sq_concat*/
32163   0, /*sq_repeat*/
32164   0, /*sq_item*/
32165   0, /*sq_slice*/
32166   0, /*sq_ass_item*/
32167   0, /*sq_ass_slice*/
32168   0, /*sq_contains*/
32169   0, /*sq_inplace_concat*/
32170   0, /*sq_inplace_repeat*/
32171 };
32172
32173 static PyMappingMethods __pyx_tp_as_mapping_Fastafile = {
32174   __pyx_pf_9csamtools_9Fastafile___len__, /*mp_length*/
32175   0, /*mp_subscript*/
32176   0, /*mp_ass_subscript*/
32177 };
32178
32179 static PyBufferProcs __pyx_tp_as_buffer_Fastafile = {
32180   #if PY_MAJOR_VERSION < 3
32181   0, /*bf_getreadbuffer*/
32182   #endif
32183   #if PY_MAJOR_VERSION < 3
32184   0, /*bf_getwritebuffer*/
32185   #endif
32186   #if PY_MAJOR_VERSION < 3
32187   0, /*bf_getsegcount*/
32188   #endif
32189   #if PY_MAJOR_VERSION < 3
32190   0, /*bf_getcharbuffer*/
32191   #endif
32192   #if PY_VERSION_HEX >= 0x02060000
32193   0, /*bf_getbuffer*/
32194   #endif
32195   #if PY_VERSION_HEX >= 0x02060000
32196   0, /*bf_releasebuffer*/
32197   #endif
32198 };
32199
32200 PyTypeObject __pyx_type_9csamtools_Fastafile = {
32201   PyVarObject_HEAD_INIT(0, 0)
32202   __Pyx_NAMESTR("csamtools.Fastafile"), /*tp_name*/
32203   sizeof(struct __pyx_obj_9csamtools_Fastafile), /*tp_basicsize*/
32204   0, /*tp_itemsize*/
32205   __pyx_tp_dealloc_9csamtools_Fastafile, /*tp_dealloc*/
32206   0, /*tp_print*/
32207   0, /*tp_getattr*/
32208   0, /*tp_setattr*/
32209   #if PY_MAJOR_VERSION < 3
32210   0, /*tp_compare*/
32211   #else
32212   0, /*reserved*/
32213   #endif
32214   0, /*tp_repr*/
32215   &__pyx_tp_as_number_Fastafile, /*tp_as_number*/
32216   &__pyx_tp_as_sequence_Fastafile, /*tp_as_sequence*/
32217   &__pyx_tp_as_mapping_Fastafile, /*tp_as_mapping*/
32218   0, /*tp_hash*/
32219   0, /*tp_call*/
32220   0, /*tp_str*/
32221   0, /*tp_getattro*/
32222   0, /*tp_setattro*/
32223   &__pyx_tp_as_buffer_Fastafile, /*tp_as_buffer*/
32224   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
32225   __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*/
32226   0, /*tp_traverse*/
32227   0, /*tp_clear*/
32228   0, /*tp_richcompare*/
32229   0, /*tp_weaklistoffset*/
32230   0, /*tp_iter*/
32231   0, /*tp_iternext*/
32232   __pyx_methods_9csamtools_Fastafile, /*tp_methods*/
32233   0, /*tp_members*/
32234   __pyx_getsets_9csamtools_Fastafile, /*tp_getset*/
32235   0, /*tp_base*/
32236   0, /*tp_dict*/
32237   0, /*tp_descr_get*/
32238   0, /*tp_descr_set*/
32239   0, /*tp_dictoffset*/
32240   0, /*tp_init*/
32241   0, /*tp_alloc*/
32242   __pyx_tp_new_9csamtools_Fastafile, /*tp_new*/
32243   0, /*tp_free*/
32244   0, /*tp_is_gc*/
32245   0, /*tp_bases*/
32246   0, /*tp_mro*/
32247   0, /*tp_cache*/
32248   0, /*tp_subclasses*/
32249   0, /*tp_weaklist*/
32250   0, /*tp_del*/
32251   #if PY_VERSION_HEX >= 0x02060000
32252   0, /*tp_version_tag*/
32253   #endif
32254 };
32255
32256 static PyObject *__pyx_tp_new_9csamtools_IteratorRow(PyTypeObject *t, PyObject *a, PyObject *k) {
32257   PyObject *o = (*t->tp_alloc)(t, 0);
32258   if (!o) return 0;
32259   return o;
32260 }
32261
32262 static void __pyx_tp_dealloc_9csamtools_IteratorRow(PyObject *o) {
32263   (*Py_TYPE(o)->tp_free)(o);
32264 }
32265
32266 static PyMethodDef __pyx_methods_9csamtools_IteratorRow[] = {
32267   {0, 0, 0, 0}
32268 };
32269
32270 static PyNumberMethods __pyx_tp_as_number_IteratorRow = {
32271   0, /*nb_add*/
32272   0, /*nb_subtract*/
32273   0, /*nb_multiply*/
32274   #if PY_MAJOR_VERSION < 3
32275   0, /*nb_divide*/
32276   #endif
32277   0, /*nb_remainder*/
32278   0, /*nb_divmod*/
32279   0, /*nb_power*/
32280   0, /*nb_negative*/
32281   0, /*nb_positive*/
32282   0, /*nb_absolute*/
32283   0, /*nb_nonzero*/
32284   0, /*nb_invert*/
32285   0, /*nb_lshift*/
32286   0, /*nb_rshift*/
32287   0, /*nb_and*/
32288   0, /*nb_xor*/
32289   0, /*nb_or*/
32290   #if PY_MAJOR_VERSION < 3
32291   0, /*nb_coerce*/
32292   #endif
32293   0, /*nb_int*/
32294   #if PY_MAJOR_VERSION < 3
32295   0, /*nb_long*/
32296   #else
32297   0, /*reserved*/
32298   #endif
32299   0, /*nb_float*/
32300   #if PY_MAJOR_VERSION < 3
32301   0, /*nb_oct*/
32302   #endif
32303   #if PY_MAJOR_VERSION < 3
32304   0, /*nb_hex*/
32305   #endif
32306   0, /*nb_inplace_add*/
32307   0, /*nb_inplace_subtract*/
32308   0, /*nb_inplace_multiply*/
32309   #if PY_MAJOR_VERSION < 3
32310   0, /*nb_inplace_divide*/
32311   #endif
32312   0, /*nb_inplace_remainder*/
32313   0, /*nb_inplace_power*/
32314   0, /*nb_inplace_lshift*/
32315   0, /*nb_inplace_rshift*/
32316   0, /*nb_inplace_and*/
32317   0, /*nb_inplace_xor*/
32318   0, /*nb_inplace_or*/
32319   0, /*nb_floor_divide*/
32320   0, /*nb_true_divide*/
32321   0, /*nb_inplace_floor_divide*/
32322   0, /*nb_inplace_true_divide*/
32323   #if PY_VERSION_HEX >= 0x02050000
32324   0, /*nb_index*/
32325   #endif
32326 };
32327
32328 static PySequenceMethods __pyx_tp_as_sequence_IteratorRow = {
32329   0, /*sq_length*/
32330   0, /*sq_concat*/
32331   0, /*sq_repeat*/
32332   0, /*sq_item*/
32333   0, /*sq_slice*/
32334   0, /*sq_ass_item*/
32335   0, /*sq_ass_slice*/
32336   0, /*sq_contains*/
32337   0, /*sq_inplace_concat*/
32338   0, /*sq_inplace_repeat*/
32339 };
32340
32341 static PyMappingMethods __pyx_tp_as_mapping_IteratorRow = {
32342   0, /*mp_length*/
32343   0, /*mp_subscript*/
32344   0, /*mp_ass_subscript*/
32345 };
32346
32347 static PyBufferProcs __pyx_tp_as_buffer_IteratorRow = {
32348   #if PY_MAJOR_VERSION < 3
32349   0, /*bf_getreadbuffer*/
32350   #endif
32351   #if PY_MAJOR_VERSION < 3
32352   0, /*bf_getwritebuffer*/
32353   #endif
32354   #if PY_MAJOR_VERSION < 3
32355   0, /*bf_getsegcount*/
32356   #endif
32357   #if PY_MAJOR_VERSION < 3
32358   0, /*bf_getcharbuffer*/
32359   #endif
32360   #if PY_VERSION_HEX >= 0x02060000
32361   0, /*bf_getbuffer*/
32362   #endif
32363   #if PY_VERSION_HEX >= 0x02060000
32364   0, /*bf_releasebuffer*/
32365   #endif
32366 };
32367
32368 PyTypeObject __pyx_type_9csamtools_IteratorRow = {
32369   PyVarObject_HEAD_INIT(0, 0)
32370   __Pyx_NAMESTR("csamtools.IteratorRow"), /*tp_name*/
32371   sizeof(struct __pyx_obj_9csamtools_IteratorRow), /*tp_basicsize*/
32372   0, /*tp_itemsize*/
32373   __pyx_tp_dealloc_9csamtools_IteratorRow, /*tp_dealloc*/
32374   0, /*tp_print*/
32375   0, /*tp_getattr*/
32376   0, /*tp_setattr*/
32377   #if PY_MAJOR_VERSION < 3
32378   0, /*tp_compare*/
32379   #else
32380   0, /*reserved*/
32381   #endif
32382   0, /*tp_repr*/
32383   &__pyx_tp_as_number_IteratorRow, /*tp_as_number*/
32384   &__pyx_tp_as_sequence_IteratorRow, /*tp_as_sequence*/
32385   &__pyx_tp_as_mapping_IteratorRow, /*tp_as_mapping*/
32386   0, /*tp_hash*/
32387   0, /*tp_call*/
32388   0, /*tp_str*/
32389   0, /*tp_getattro*/
32390   0, /*tp_setattro*/
32391   &__pyx_tp_as_buffer_IteratorRow, /*tp_as_buffer*/
32392   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
32393   __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*/
32394   0, /*tp_traverse*/
32395   0, /*tp_clear*/
32396   0, /*tp_richcompare*/
32397   0, /*tp_weaklistoffset*/
32398   0, /*tp_iter*/
32399   0, /*tp_iternext*/
32400   __pyx_methods_9csamtools_IteratorRow, /*tp_methods*/
32401   0, /*tp_members*/
32402   0, /*tp_getset*/
32403   0, /*tp_base*/
32404   0, /*tp_dict*/
32405   0, /*tp_descr_get*/
32406   0, /*tp_descr_set*/
32407   0, /*tp_dictoffset*/
32408   0, /*tp_init*/
32409   0, /*tp_alloc*/
32410   __pyx_tp_new_9csamtools_IteratorRow, /*tp_new*/
32411   0, /*tp_free*/
32412   0, /*tp_is_gc*/
32413   0, /*tp_bases*/
32414   0, /*tp_mro*/
32415   0, /*tp_cache*/
32416   0, /*tp_subclasses*/
32417   0, /*tp_weaklist*/
32418   0, /*tp_del*/
32419   #if PY_VERSION_HEX >= 0x02060000
32420   0, /*tp_version_tag*/
32421   #endif
32422 };
32423 static struct __pyx_vtabstruct_9csamtools_IteratorRowRegion __pyx_vtable_9csamtools_IteratorRowRegion;
32424
32425 static PyObject *__pyx_tp_new_9csamtools_IteratorRowRegion(PyTypeObject *t, PyObject *a, PyObject *k) {
32426   struct __pyx_obj_9csamtools_IteratorRowRegion *p;
32427   PyObject *o = __pyx_tp_new_9csamtools_IteratorRow(t, a, k);
32428   if (!o) return 0;
32429   p = ((struct __pyx_obj_9csamtools_IteratorRowRegion *)o);
32430   p->__pyx_vtab = __pyx_vtabptr_9csamtools_IteratorRowRegion;
32431   p->samfile = ((struct __pyx_obj_9csamtools_Samfile *)Py_None); Py_INCREF(Py_None);
32432   if (__pyx_pf_9csamtools_17IteratorRowRegion___cinit__(o, a, k) < 0) {
32433     Py_DECREF(o); o = 0;
32434   }
32435   return o;
32436 }
32437
32438 static void __pyx_tp_dealloc_9csamtools_IteratorRowRegion(PyObject *o) {
32439   struct __pyx_obj_9csamtools_IteratorRowRegion *p = (struct __pyx_obj_9csamtools_IteratorRowRegion *)o;
32440   {
32441     PyObject *etype, *eval, *etb;
32442     PyErr_Fetch(&etype, &eval, &etb);
32443     ++Py_REFCNT(o);
32444     __pyx_pf_9csamtools_17IteratorRowRegion___dealloc__(o);
32445     if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
32446     --Py_REFCNT(o);
32447     PyErr_Restore(etype, eval, etb);
32448   }
32449   Py_XDECREF(((PyObject *)p->samfile));
32450   __pyx_tp_dealloc_9csamtools_IteratorRow(o);
32451 }
32452
32453 static int __pyx_tp_traverse_9csamtools_IteratorRowRegion(PyObject *o, visitproc v, void *a) {
32454   int e;
32455   struct __pyx_obj_9csamtools_IteratorRowRegion *p = (struct __pyx_obj_9csamtools_IteratorRowRegion *)o;
32456   if (__pyx_ptype_9csamtools_IteratorRow->tp_traverse) {
32457     e = __pyx_ptype_9csamtools_IteratorRow->tp_traverse(o, v, a); if (e) return e;
32458   }
32459   if (p->samfile) {
32460     e = (*v)(((PyObject*)p->samfile), a); if (e) return e;
32461   }
32462   return 0;
32463 }
32464
32465 static int __pyx_tp_clear_9csamtools_IteratorRowRegion(PyObject *o) {
32466   struct __pyx_obj_9csamtools_IteratorRowRegion *p = (struct __pyx_obj_9csamtools_IteratorRowRegion *)o;
32467   PyObject* tmp;
32468   if (__pyx_ptype_9csamtools_IteratorRow->tp_clear) {
32469     __pyx_ptype_9csamtools_IteratorRow->tp_clear(o);
32470   }
32471   tmp = ((PyObject*)p->samfile);
32472   p->samfile = ((struct __pyx_obj_9csamtools_Samfile *)Py_None); Py_INCREF(Py_None);
32473   Py_XDECREF(tmp);
32474   return 0;
32475 }
32476
32477 static PyMethodDef __pyx_methods_9csamtools_IteratorRowRegion[] = {
32478   {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_17IteratorRowRegion___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_17IteratorRowRegion___next__)},
32479   {0, 0, 0, 0}
32480 };
32481
32482 static PyNumberMethods __pyx_tp_as_number_IteratorRowRegion = {
32483   0, /*nb_add*/
32484   0, /*nb_subtract*/
32485   0, /*nb_multiply*/
32486   #if PY_MAJOR_VERSION < 3
32487   0, /*nb_divide*/
32488   #endif
32489   0, /*nb_remainder*/
32490   0, /*nb_divmod*/
32491   0, /*nb_power*/
32492   0, /*nb_negative*/
32493   0, /*nb_positive*/
32494   0, /*nb_absolute*/
32495   0, /*nb_nonzero*/
32496   0, /*nb_invert*/
32497   0, /*nb_lshift*/
32498   0, /*nb_rshift*/
32499   0, /*nb_and*/
32500   0, /*nb_xor*/
32501   0, /*nb_or*/
32502   #if PY_MAJOR_VERSION < 3
32503   0, /*nb_coerce*/
32504   #endif
32505   0, /*nb_int*/
32506   #if PY_MAJOR_VERSION < 3
32507   0, /*nb_long*/
32508   #else
32509   0, /*reserved*/
32510   #endif
32511   0, /*nb_float*/
32512   #if PY_MAJOR_VERSION < 3
32513   0, /*nb_oct*/
32514   #endif
32515   #if PY_MAJOR_VERSION < 3
32516   0, /*nb_hex*/
32517   #endif
32518   0, /*nb_inplace_add*/
32519   0, /*nb_inplace_subtract*/
32520   0, /*nb_inplace_multiply*/
32521   #if PY_MAJOR_VERSION < 3
32522   0, /*nb_inplace_divide*/
32523   #endif
32524   0, /*nb_inplace_remainder*/
32525   0, /*nb_inplace_power*/
32526   0, /*nb_inplace_lshift*/
32527   0, /*nb_inplace_rshift*/
32528   0, /*nb_inplace_and*/
32529   0, /*nb_inplace_xor*/
32530   0, /*nb_inplace_or*/
32531   0, /*nb_floor_divide*/
32532   0, /*nb_true_divide*/
32533   0, /*nb_inplace_floor_divide*/
32534   0, /*nb_inplace_true_divide*/
32535   #if PY_VERSION_HEX >= 0x02050000
32536   0, /*nb_index*/
32537   #endif
32538 };
32539
32540 static PySequenceMethods __pyx_tp_as_sequence_IteratorRowRegion = {
32541   0, /*sq_length*/
32542   0, /*sq_concat*/
32543   0, /*sq_repeat*/
32544   0, /*sq_item*/
32545   0, /*sq_slice*/
32546   0, /*sq_ass_item*/
32547   0, /*sq_ass_slice*/
32548   0, /*sq_contains*/
32549   0, /*sq_inplace_concat*/
32550   0, /*sq_inplace_repeat*/
32551 };
32552
32553 static PyMappingMethods __pyx_tp_as_mapping_IteratorRowRegion = {
32554   0, /*mp_length*/
32555   0, /*mp_subscript*/
32556   0, /*mp_ass_subscript*/
32557 };
32558
32559 static PyBufferProcs __pyx_tp_as_buffer_IteratorRowRegion = {
32560   #if PY_MAJOR_VERSION < 3
32561   0, /*bf_getreadbuffer*/
32562   #endif
32563   #if PY_MAJOR_VERSION < 3
32564   0, /*bf_getwritebuffer*/
32565   #endif
32566   #if PY_MAJOR_VERSION < 3
32567   0, /*bf_getsegcount*/
32568   #endif
32569   #if PY_MAJOR_VERSION < 3
32570   0, /*bf_getcharbuffer*/
32571   #endif
32572   #if PY_VERSION_HEX >= 0x02060000
32573   0, /*bf_getbuffer*/
32574   #endif
32575   #if PY_VERSION_HEX >= 0x02060000
32576   0, /*bf_releasebuffer*/
32577   #endif
32578 };
32579
32580 PyTypeObject __pyx_type_9csamtools_IteratorRowRegion = {
32581   PyVarObject_HEAD_INIT(0, 0)
32582   __Pyx_NAMESTR("csamtools.IteratorRowRegion"), /*tp_name*/
32583   sizeof(struct __pyx_obj_9csamtools_IteratorRowRegion), /*tp_basicsize*/
32584   0, /*tp_itemsize*/
32585   __pyx_tp_dealloc_9csamtools_IteratorRowRegion, /*tp_dealloc*/
32586   0, /*tp_print*/
32587   0, /*tp_getattr*/
32588   0, /*tp_setattr*/
32589   #if PY_MAJOR_VERSION < 3
32590   0, /*tp_compare*/
32591   #else
32592   0, /*reserved*/
32593   #endif
32594   0, /*tp_repr*/
32595   &__pyx_tp_as_number_IteratorRowRegion, /*tp_as_number*/
32596   &__pyx_tp_as_sequence_IteratorRowRegion, /*tp_as_sequence*/
32597   &__pyx_tp_as_mapping_IteratorRowRegion, /*tp_as_mapping*/
32598   0, /*tp_hash*/
32599   0, /*tp_call*/
32600   0, /*tp_str*/
32601   0, /*tp_getattro*/
32602   0, /*tp_setattro*/
32603   &__pyx_tp_as_buffer_IteratorRowRegion, /*tp_as_buffer*/
32604   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
32605   __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*/
32606   __pyx_tp_traverse_9csamtools_IteratorRowRegion, /*tp_traverse*/
32607   __pyx_tp_clear_9csamtools_IteratorRowRegion, /*tp_clear*/
32608   0, /*tp_richcompare*/
32609   0, /*tp_weaklistoffset*/
32610   __pyx_pf_9csamtools_17IteratorRowRegion___iter__, /*tp_iter*/
32611   __pyx_pf_9csamtools_17IteratorRowRegion___next__, /*tp_iternext*/
32612   __pyx_methods_9csamtools_IteratorRowRegion, /*tp_methods*/
32613   0, /*tp_members*/
32614   0, /*tp_getset*/
32615   0, /*tp_base*/
32616   0, /*tp_dict*/
32617   0, /*tp_descr_get*/
32618   0, /*tp_descr_set*/
32619   0, /*tp_dictoffset*/
32620   0, /*tp_init*/
32621   0, /*tp_alloc*/
32622   __pyx_tp_new_9csamtools_IteratorRowRegion, /*tp_new*/
32623   0, /*tp_free*/
32624   0, /*tp_is_gc*/
32625   0, /*tp_bases*/
32626   0, /*tp_mro*/
32627   0, /*tp_cache*/
32628   0, /*tp_subclasses*/
32629   0, /*tp_weaklist*/
32630   0, /*tp_del*/
32631   #if PY_VERSION_HEX >= 0x02060000
32632   0, /*tp_version_tag*/
32633   #endif
32634 };
32635 static struct __pyx_vtabstruct_9csamtools_IteratorRowAll __pyx_vtable_9csamtools_IteratorRowAll;
32636
32637 static PyObject *__pyx_tp_new_9csamtools_IteratorRowAll(PyTypeObject *t, PyObject *a, PyObject *k) {
32638   struct __pyx_obj_9csamtools_IteratorRowAll *p;
32639   PyObject *o = __pyx_tp_new_9csamtools_IteratorRow(t, a, k);
32640   if (!o) return 0;
32641   p = ((struct __pyx_obj_9csamtools_IteratorRowAll *)o);
32642   p->__pyx_vtab = __pyx_vtabptr_9csamtools_IteratorRowAll;
32643   if (__pyx_pf_9csamtools_14IteratorRowAll___cinit__(o, a, k) < 0) {
32644     Py_DECREF(o); o = 0;
32645   }
32646   return o;
32647 }
32648
32649 static void __pyx_tp_dealloc_9csamtools_IteratorRowAll(PyObject *o) {
32650   {
32651     PyObject *etype, *eval, *etb;
32652     PyErr_Fetch(&etype, &eval, &etb);
32653     ++Py_REFCNT(o);
32654     __pyx_pf_9csamtools_14IteratorRowAll___dealloc__(o);
32655     if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
32656     --Py_REFCNT(o);
32657     PyErr_Restore(etype, eval, etb);
32658   }
32659   __pyx_tp_dealloc_9csamtools_IteratorRow(o);
32660 }
32661
32662 static PyMethodDef __pyx_methods_9csamtools_IteratorRowAll[] = {
32663   {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_14IteratorRowAll___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_14IteratorRowAll___next__)},
32664   {0, 0, 0, 0}
32665 };
32666
32667 static PyNumberMethods __pyx_tp_as_number_IteratorRowAll = {
32668   0, /*nb_add*/
32669   0, /*nb_subtract*/
32670   0, /*nb_multiply*/
32671   #if PY_MAJOR_VERSION < 3
32672   0, /*nb_divide*/
32673   #endif
32674   0, /*nb_remainder*/
32675   0, /*nb_divmod*/
32676   0, /*nb_power*/
32677   0, /*nb_negative*/
32678   0, /*nb_positive*/
32679   0, /*nb_absolute*/
32680   0, /*nb_nonzero*/
32681   0, /*nb_invert*/
32682   0, /*nb_lshift*/
32683   0, /*nb_rshift*/
32684   0, /*nb_and*/
32685   0, /*nb_xor*/
32686   0, /*nb_or*/
32687   #if PY_MAJOR_VERSION < 3
32688   0, /*nb_coerce*/
32689   #endif
32690   0, /*nb_int*/
32691   #if PY_MAJOR_VERSION < 3
32692   0, /*nb_long*/
32693   #else
32694   0, /*reserved*/
32695   #endif
32696   0, /*nb_float*/
32697   #if PY_MAJOR_VERSION < 3
32698   0, /*nb_oct*/
32699   #endif
32700   #if PY_MAJOR_VERSION < 3
32701   0, /*nb_hex*/
32702   #endif
32703   0, /*nb_inplace_add*/
32704   0, /*nb_inplace_subtract*/
32705   0, /*nb_inplace_multiply*/
32706   #if PY_MAJOR_VERSION < 3
32707   0, /*nb_inplace_divide*/
32708   #endif
32709   0, /*nb_inplace_remainder*/
32710   0, /*nb_inplace_power*/
32711   0, /*nb_inplace_lshift*/
32712   0, /*nb_inplace_rshift*/
32713   0, /*nb_inplace_and*/
32714   0, /*nb_inplace_xor*/
32715   0, /*nb_inplace_or*/
32716   0, /*nb_floor_divide*/
32717   0, /*nb_true_divide*/
32718   0, /*nb_inplace_floor_divide*/
32719   0, /*nb_inplace_true_divide*/
32720   #if PY_VERSION_HEX >= 0x02050000
32721   0, /*nb_index*/
32722   #endif
32723 };
32724
32725 static PySequenceMethods __pyx_tp_as_sequence_IteratorRowAll = {
32726   0, /*sq_length*/
32727   0, /*sq_concat*/
32728   0, /*sq_repeat*/
32729   0, /*sq_item*/
32730   0, /*sq_slice*/
32731   0, /*sq_ass_item*/
32732   0, /*sq_ass_slice*/
32733   0, /*sq_contains*/
32734   0, /*sq_inplace_concat*/
32735   0, /*sq_inplace_repeat*/
32736 };
32737
32738 static PyMappingMethods __pyx_tp_as_mapping_IteratorRowAll = {
32739   0, /*mp_length*/
32740   0, /*mp_subscript*/
32741   0, /*mp_ass_subscript*/
32742 };
32743
32744 static PyBufferProcs __pyx_tp_as_buffer_IteratorRowAll = {
32745   #if PY_MAJOR_VERSION < 3
32746   0, /*bf_getreadbuffer*/
32747   #endif
32748   #if PY_MAJOR_VERSION < 3
32749   0, /*bf_getwritebuffer*/
32750   #endif
32751   #if PY_MAJOR_VERSION < 3
32752   0, /*bf_getsegcount*/
32753   #endif
32754   #if PY_MAJOR_VERSION < 3
32755   0, /*bf_getcharbuffer*/
32756   #endif
32757   #if PY_VERSION_HEX >= 0x02060000
32758   0, /*bf_getbuffer*/
32759   #endif
32760   #if PY_VERSION_HEX >= 0x02060000
32761   0, /*bf_releasebuffer*/
32762   #endif
32763 };
32764
32765 PyTypeObject __pyx_type_9csamtools_IteratorRowAll = {
32766   PyVarObject_HEAD_INIT(0, 0)
32767   __Pyx_NAMESTR("csamtools.IteratorRowAll"), /*tp_name*/
32768   sizeof(struct __pyx_obj_9csamtools_IteratorRowAll), /*tp_basicsize*/
32769   0, /*tp_itemsize*/
32770   __pyx_tp_dealloc_9csamtools_IteratorRowAll, /*tp_dealloc*/
32771   0, /*tp_print*/
32772   0, /*tp_getattr*/
32773   0, /*tp_setattr*/
32774   #if PY_MAJOR_VERSION < 3
32775   0, /*tp_compare*/
32776   #else
32777   0, /*reserved*/
32778   #endif
32779   0, /*tp_repr*/
32780   &__pyx_tp_as_number_IteratorRowAll, /*tp_as_number*/
32781   &__pyx_tp_as_sequence_IteratorRowAll, /*tp_as_sequence*/
32782   &__pyx_tp_as_mapping_IteratorRowAll, /*tp_as_mapping*/
32783   0, /*tp_hash*/
32784   0, /*tp_call*/
32785   0, /*tp_str*/
32786   0, /*tp_getattro*/
32787   0, /*tp_setattro*/
32788   &__pyx_tp_as_buffer_IteratorRowAll, /*tp_as_buffer*/
32789   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
32790   __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*/
32791   0, /*tp_traverse*/
32792   0, /*tp_clear*/
32793   0, /*tp_richcompare*/
32794   0, /*tp_weaklistoffset*/
32795   __pyx_pf_9csamtools_14IteratorRowAll___iter__, /*tp_iter*/
32796   __pyx_pf_9csamtools_14IteratorRowAll___next__, /*tp_iternext*/
32797   __pyx_methods_9csamtools_IteratorRowAll, /*tp_methods*/
32798   0, /*tp_members*/
32799   0, /*tp_getset*/
32800   0, /*tp_base*/
32801   0, /*tp_dict*/
32802   0, /*tp_descr_get*/
32803   0, /*tp_descr_set*/
32804   0, /*tp_dictoffset*/
32805   0, /*tp_init*/
32806   0, /*tp_alloc*/
32807   __pyx_tp_new_9csamtools_IteratorRowAll, /*tp_new*/
32808   0, /*tp_free*/
32809   0, /*tp_is_gc*/
32810   0, /*tp_bases*/
32811   0, /*tp_mro*/
32812   0, /*tp_cache*/
32813   0, /*tp_subclasses*/
32814   0, /*tp_weaklist*/
32815   0, /*tp_del*/
32816   #if PY_VERSION_HEX >= 0x02060000
32817   0, /*tp_version_tag*/
32818   #endif
32819 };
32820
32821 static PyObject *__pyx_tp_new_9csamtools_IteratorRowAllRefs(PyTypeObject *t, PyObject *a, PyObject *k) {
32822   struct __pyx_obj_9csamtools_IteratorRowAllRefs *p;
32823   PyObject *o = __pyx_tp_new_9csamtools_IteratorRow(t, a, k);
32824   if (!o) return 0;
32825   p = ((struct __pyx_obj_9csamtools_IteratorRowAllRefs *)o);
32826   p->samfile = ((struct __pyx_obj_9csamtools_Samfile *)Py_None); Py_INCREF(Py_None);
32827   p->rowiter = ((struct __pyx_obj_9csamtools_IteratorRowRegion *)Py_None); Py_INCREF(Py_None);
32828   if (__pyx_pf_9csamtools_18IteratorRowAllRefs___cinit__(o, a, k) < 0) {
32829     Py_DECREF(o); o = 0;
32830   }
32831   return o;
32832 }
32833
32834 static void __pyx_tp_dealloc_9csamtools_IteratorRowAllRefs(PyObject *o) {
32835   struct __pyx_obj_9csamtools_IteratorRowAllRefs *p = (struct __pyx_obj_9csamtools_IteratorRowAllRefs *)o;
32836   Py_XDECREF(((PyObject *)p->samfile));
32837   Py_XDECREF(((PyObject *)p->rowiter));
32838   __pyx_tp_dealloc_9csamtools_IteratorRow(o);
32839 }
32840
32841 static int __pyx_tp_traverse_9csamtools_IteratorRowAllRefs(PyObject *o, visitproc v, void *a) {
32842   int e;
32843   struct __pyx_obj_9csamtools_IteratorRowAllRefs *p = (struct __pyx_obj_9csamtools_IteratorRowAllRefs *)o;
32844   if (__pyx_ptype_9csamtools_IteratorRow->tp_traverse) {
32845     e = __pyx_ptype_9csamtools_IteratorRow->tp_traverse(o, v, a); if (e) return e;
32846   }
32847   if (p->samfile) {
32848     e = (*v)(((PyObject*)p->samfile), a); if (e) return e;
32849   }
32850   if (p->rowiter) {
32851     e = (*v)(((PyObject*)p->rowiter), a); if (e) return e;
32852   }
32853   return 0;
32854 }
32855
32856 static int __pyx_tp_clear_9csamtools_IteratorRowAllRefs(PyObject *o) {
32857   struct __pyx_obj_9csamtools_IteratorRowAllRefs *p = (struct __pyx_obj_9csamtools_IteratorRowAllRefs *)o;
32858   PyObject* tmp;
32859   if (__pyx_ptype_9csamtools_IteratorRow->tp_clear) {
32860     __pyx_ptype_9csamtools_IteratorRow->tp_clear(o);
32861   }
32862   tmp = ((PyObject*)p->samfile);
32863   p->samfile = ((struct __pyx_obj_9csamtools_Samfile *)Py_None); Py_INCREF(Py_None);
32864   Py_XDECREF(tmp);
32865   tmp = ((PyObject*)p->rowiter);
32866   p->rowiter = ((struct __pyx_obj_9csamtools_IteratorRowRegion *)Py_None); Py_INCREF(Py_None);
32867   Py_XDECREF(tmp);
32868   return 0;
32869 }
32870
32871 static PyMethodDef __pyx_methods_9csamtools_IteratorRowAllRefs[] = {
32872   {__Pyx_NAMESTR("nextiter"), (PyCFunction)__pyx_pf_9csamtools_18IteratorRowAllRefs_nextiter, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_18IteratorRowAllRefs_nextiter)},
32873   {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_18IteratorRowAllRefs___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_18IteratorRowAllRefs___next__)},
32874   {0, 0, 0, 0}
32875 };
32876
32877 static PyNumberMethods __pyx_tp_as_number_IteratorRowAllRefs = {
32878   0, /*nb_add*/
32879   0, /*nb_subtract*/
32880   0, /*nb_multiply*/
32881   #if PY_MAJOR_VERSION < 3
32882   0, /*nb_divide*/
32883   #endif
32884   0, /*nb_remainder*/
32885   0, /*nb_divmod*/
32886   0, /*nb_power*/
32887   0, /*nb_negative*/
32888   0, /*nb_positive*/
32889   0, /*nb_absolute*/
32890   0, /*nb_nonzero*/
32891   0, /*nb_invert*/
32892   0, /*nb_lshift*/
32893   0, /*nb_rshift*/
32894   0, /*nb_and*/
32895   0, /*nb_xor*/
32896   0, /*nb_or*/
32897   #if PY_MAJOR_VERSION < 3
32898   0, /*nb_coerce*/
32899   #endif
32900   0, /*nb_int*/
32901   #if PY_MAJOR_VERSION < 3
32902   0, /*nb_long*/
32903   #else
32904   0, /*reserved*/
32905   #endif
32906   0, /*nb_float*/
32907   #if PY_MAJOR_VERSION < 3
32908   0, /*nb_oct*/
32909   #endif
32910   #if PY_MAJOR_VERSION < 3
32911   0, /*nb_hex*/
32912   #endif
32913   0, /*nb_inplace_add*/
32914   0, /*nb_inplace_subtract*/
32915   0, /*nb_inplace_multiply*/
32916   #if PY_MAJOR_VERSION < 3
32917   0, /*nb_inplace_divide*/
32918   #endif
32919   0, /*nb_inplace_remainder*/
32920   0, /*nb_inplace_power*/
32921   0, /*nb_inplace_lshift*/
32922   0, /*nb_inplace_rshift*/
32923   0, /*nb_inplace_and*/
32924   0, /*nb_inplace_xor*/
32925   0, /*nb_inplace_or*/
32926   0, /*nb_floor_divide*/
32927   0, /*nb_true_divide*/
32928   0, /*nb_inplace_floor_divide*/
32929   0, /*nb_inplace_true_divide*/
32930   #if PY_VERSION_HEX >= 0x02050000
32931   0, /*nb_index*/
32932   #endif
32933 };
32934
32935 static PySequenceMethods __pyx_tp_as_sequence_IteratorRowAllRefs = {
32936   0, /*sq_length*/
32937   0, /*sq_concat*/
32938   0, /*sq_repeat*/
32939   0, /*sq_item*/
32940   0, /*sq_slice*/
32941   0, /*sq_ass_item*/
32942   0, /*sq_ass_slice*/
32943   0, /*sq_contains*/
32944   0, /*sq_inplace_concat*/
32945   0, /*sq_inplace_repeat*/
32946 };
32947
32948 static PyMappingMethods __pyx_tp_as_mapping_IteratorRowAllRefs = {
32949   0, /*mp_length*/
32950   0, /*mp_subscript*/
32951   0, /*mp_ass_subscript*/
32952 };
32953
32954 static PyBufferProcs __pyx_tp_as_buffer_IteratorRowAllRefs = {
32955   #if PY_MAJOR_VERSION < 3
32956   0, /*bf_getreadbuffer*/
32957   #endif
32958   #if PY_MAJOR_VERSION < 3
32959   0, /*bf_getwritebuffer*/
32960   #endif
32961   #if PY_MAJOR_VERSION < 3
32962   0, /*bf_getsegcount*/
32963   #endif
32964   #if PY_MAJOR_VERSION < 3
32965   0, /*bf_getcharbuffer*/
32966   #endif
32967   #if PY_VERSION_HEX >= 0x02060000
32968   0, /*bf_getbuffer*/
32969   #endif
32970   #if PY_VERSION_HEX >= 0x02060000
32971   0, /*bf_releasebuffer*/
32972   #endif
32973 };
32974
32975 PyTypeObject __pyx_type_9csamtools_IteratorRowAllRefs = {
32976   PyVarObject_HEAD_INIT(0, 0)
32977   __Pyx_NAMESTR("csamtools.IteratorRowAllRefs"), /*tp_name*/
32978   sizeof(struct __pyx_obj_9csamtools_IteratorRowAllRefs), /*tp_basicsize*/
32979   0, /*tp_itemsize*/
32980   __pyx_tp_dealloc_9csamtools_IteratorRowAllRefs, /*tp_dealloc*/
32981   0, /*tp_print*/
32982   0, /*tp_getattr*/
32983   0, /*tp_setattr*/
32984   #if PY_MAJOR_VERSION < 3
32985   0, /*tp_compare*/
32986   #else
32987   0, /*reserved*/
32988   #endif
32989   0, /*tp_repr*/
32990   &__pyx_tp_as_number_IteratorRowAllRefs, /*tp_as_number*/
32991   &__pyx_tp_as_sequence_IteratorRowAllRefs, /*tp_as_sequence*/
32992   &__pyx_tp_as_mapping_IteratorRowAllRefs, /*tp_as_mapping*/
32993   0, /*tp_hash*/
32994   0, /*tp_call*/
32995   0, /*tp_str*/
32996   0, /*tp_getattro*/
32997   0, /*tp_setattro*/
32998   &__pyx_tp_as_buffer_IteratorRowAllRefs, /*tp_as_buffer*/
32999   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
33000   __Pyx_DOCSTR("iterates over all mapped reads by chaining iterators over each reference\n    "), /*tp_doc*/
33001   __pyx_tp_traverse_9csamtools_IteratorRowAllRefs, /*tp_traverse*/
33002   __pyx_tp_clear_9csamtools_IteratorRowAllRefs, /*tp_clear*/
33003   0, /*tp_richcompare*/
33004   0, /*tp_weaklistoffset*/
33005   __pyx_pf_9csamtools_18IteratorRowAllRefs___iter__, /*tp_iter*/
33006   __pyx_pf_9csamtools_18IteratorRowAllRefs___next__, /*tp_iternext*/
33007   __pyx_methods_9csamtools_IteratorRowAllRefs, /*tp_methods*/
33008   0, /*tp_members*/
33009   0, /*tp_getset*/
33010   0, /*tp_base*/
33011   0, /*tp_dict*/
33012   0, /*tp_descr_get*/
33013   0, /*tp_descr_set*/
33014   0, /*tp_dictoffset*/
33015   0, /*tp_init*/
33016   0, /*tp_alloc*/
33017   __pyx_tp_new_9csamtools_IteratorRowAllRefs, /*tp_new*/
33018   0, /*tp_free*/
33019   0, /*tp_is_gc*/
33020   0, /*tp_bases*/
33021   0, /*tp_mro*/
33022   0, /*tp_cache*/
33023   0, /*tp_subclasses*/
33024   0, /*tp_weaklist*/
33025   0, /*tp_del*/
33026   #if PY_VERSION_HEX >= 0x02060000
33027   0, /*tp_version_tag*/
33028   #endif
33029 };
33030 static struct __pyx_vtabstruct_9csamtools_IteratorRowSelection __pyx_vtable_9csamtools_IteratorRowSelection;
33031
33032 static PyObject *__pyx_tp_new_9csamtools_IteratorRowSelection(PyTypeObject *t, PyObject *a, PyObject *k) {
33033   struct __pyx_obj_9csamtools_IteratorRowSelection *p;
33034   PyObject *o = __pyx_tp_new_9csamtools_IteratorRow(t, a, k);
33035   if (!o) return 0;
33036   p = ((struct __pyx_obj_9csamtools_IteratorRowSelection *)o);
33037   p->__pyx_vtab = __pyx_vtabptr_9csamtools_IteratorRowSelection;
33038   p->positions = Py_None; Py_INCREF(Py_None);
33039   if (__pyx_pf_9csamtools_20IteratorRowSelection___cinit__(o, a, k) < 0) {
33040     Py_DECREF(o); o = 0;
33041   }
33042   return o;
33043 }
33044
33045 static void __pyx_tp_dealloc_9csamtools_IteratorRowSelection(PyObject *o) {
33046   struct __pyx_obj_9csamtools_IteratorRowSelection *p = (struct __pyx_obj_9csamtools_IteratorRowSelection *)o;
33047   {
33048     PyObject *etype, *eval, *etb;
33049     PyErr_Fetch(&etype, &eval, &etb);
33050     ++Py_REFCNT(o);
33051     __pyx_pf_9csamtools_20IteratorRowSelection___dealloc__(o);
33052     if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
33053     --Py_REFCNT(o);
33054     PyErr_Restore(etype, eval, etb);
33055   }
33056   Py_XDECREF(p->positions);
33057   __pyx_tp_dealloc_9csamtools_IteratorRow(o);
33058 }
33059
33060 static int __pyx_tp_traverse_9csamtools_IteratorRowSelection(PyObject *o, visitproc v, void *a) {
33061   int e;
33062   struct __pyx_obj_9csamtools_IteratorRowSelection *p = (struct __pyx_obj_9csamtools_IteratorRowSelection *)o;
33063   if (__pyx_ptype_9csamtools_IteratorRow->tp_traverse) {
33064     e = __pyx_ptype_9csamtools_IteratorRow->tp_traverse(o, v, a); if (e) return e;
33065   }
33066   if (p->positions) {
33067     e = (*v)(p->positions, a); if (e) return e;
33068   }
33069   return 0;
33070 }
33071
33072 static int __pyx_tp_clear_9csamtools_IteratorRowSelection(PyObject *o) {
33073   struct __pyx_obj_9csamtools_IteratorRowSelection *p = (struct __pyx_obj_9csamtools_IteratorRowSelection *)o;
33074   PyObject* tmp;
33075   if (__pyx_ptype_9csamtools_IteratorRow->tp_clear) {
33076     __pyx_ptype_9csamtools_IteratorRow->tp_clear(o);
33077   }
33078   tmp = ((PyObject*)p->positions);
33079   p->positions = Py_None; Py_INCREF(Py_None);
33080   Py_XDECREF(tmp);
33081   return 0;
33082 }
33083
33084 static PyMethodDef __pyx_methods_9csamtools_IteratorRowSelection[] = {
33085   {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_20IteratorRowSelection___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_20IteratorRowSelection___next__)},
33086   {0, 0, 0, 0}
33087 };
33088
33089 static PyNumberMethods __pyx_tp_as_number_IteratorRowSelection = {
33090   0, /*nb_add*/
33091   0, /*nb_subtract*/
33092   0, /*nb_multiply*/
33093   #if PY_MAJOR_VERSION < 3
33094   0, /*nb_divide*/
33095   #endif
33096   0, /*nb_remainder*/
33097   0, /*nb_divmod*/
33098   0, /*nb_power*/
33099   0, /*nb_negative*/
33100   0, /*nb_positive*/
33101   0, /*nb_absolute*/
33102   0, /*nb_nonzero*/
33103   0, /*nb_invert*/
33104   0, /*nb_lshift*/
33105   0, /*nb_rshift*/
33106   0, /*nb_and*/
33107   0, /*nb_xor*/
33108   0, /*nb_or*/
33109   #if PY_MAJOR_VERSION < 3
33110   0, /*nb_coerce*/
33111   #endif
33112   0, /*nb_int*/
33113   #if PY_MAJOR_VERSION < 3
33114   0, /*nb_long*/
33115   #else
33116   0, /*reserved*/
33117   #endif
33118   0, /*nb_float*/
33119   #if PY_MAJOR_VERSION < 3
33120   0, /*nb_oct*/
33121   #endif
33122   #if PY_MAJOR_VERSION < 3
33123   0, /*nb_hex*/
33124   #endif
33125   0, /*nb_inplace_add*/
33126   0, /*nb_inplace_subtract*/
33127   0, /*nb_inplace_multiply*/
33128   #if PY_MAJOR_VERSION < 3
33129   0, /*nb_inplace_divide*/
33130   #endif
33131   0, /*nb_inplace_remainder*/
33132   0, /*nb_inplace_power*/
33133   0, /*nb_inplace_lshift*/
33134   0, /*nb_inplace_rshift*/
33135   0, /*nb_inplace_and*/
33136   0, /*nb_inplace_xor*/
33137   0, /*nb_inplace_or*/
33138   0, /*nb_floor_divide*/
33139   0, /*nb_true_divide*/
33140   0, /*nb_inplace_floor_divide*/
33141   0, /*nb_inplace_true_divide*/
33142   #if PY_VERSION_HEX >= 0x02050000
33143   0, /*nb_index*/
33144   #endif
33145 };
33146
33147 static PySequenceMethods __pyx_tp_as_sequence_IteratorRowSelection = {
33148   0, /*sq_length*/
33149   0, /*sq_concat*/
33150   0, /*sq_repeat*/
33151   0, /*sq_item*/
33152   0, /*sq_slice*/
33153   0, /*sq_ass_item*/
33154   0, /*sq_ass_slice*/
33155   0, /*sq_contains*/
33156   0, /*sq_inplace_concat*/
33157   0, /*sq_inplace_repeat*/
33158 };
33159
33160 static PyMappingMethods __pyx_tp_as_mapping_IteratorRowSelection = {
33161   0, /*mp_length*/
33162   0, /*mp_subscript*/
33163   0, /*mp_ass_subscript*/
33164 };
33165
33166 static PyBufferProcs __pyx_tp_as_buffer_IteratorRowSelection = {
33167   #if PY_MAJOR_VERSION < 3
33168   0, /*bf_getreadbuffer*/
33169   #endif
33170   #if PY_MAJOR_VERSION < 3
33171   0, /*bf_getwritebuffer*/
33172   #endif
33173   #if PY_MAJOR_VERSION < 3
33174   0, /*bf_getsegcount*/
33175   #endif
33176   #if PY_MAJOR_VERSION < 3
33177   0, /*bf_getcharbuffer*/
33178   #endif
33179   #if PY_VERSION_HEX >= 0x02060000
33180   0, /*bf_getbuffer*/
33181   #endif
33182   #if PY_VERSION_HEX >= 0x02060000
33183   0, /*bf_releasebuffer*/
33184   #endif
33185 };
33186
33187 PyTypeObject __pyx_type_9csamtools_IteratorRowSelection = {
33188   PyVarObject_HEAD_INIT(0, 0)
33189   __Pyx_NAMESTR("csamtools.IteratorRowSelection"), /*tp_name*/
33190   sizeof(struct __pyx_obj_9csamtools_IteratorRowSelection), /*tp_basicsize*/
33191   0, /*tp_itemsize*/
33192   __pyx_tp_dealloc_9csamtools_IteratorRowSelection, /*tp_dealloc*/
33193   0, /*tp_print*/
33194   0, /*tp_getattr*/
33195   0, /*tp_setattr*/
33196   #if PY_MAJOR_VERSION < 3
33197   0, /*tp_compare*/
33198   #else
33199   0, /*reserved*/
33200   #endif
33201   0, /*tp_repr*/
33202   &__pyx_tp_as_number_IteratorRowSelection, /*tp_as_number*/
33203   &__pyx_tp_as_sequence_IteratorRowSelection, /*tp_as_sequence*/
33204   &__pyx_tp_as_mapping_IteratorRowSelection, /*tp_as_mapping*/
33205   0, /*tp_hash*/
33206   0, /*tp_call*/
33207   0, /*tp_str*/
33208   0, /*tp_getattro*/
33209   0, /*tp_setattro*/
33210   &__pyx_tp_as_buffer_IteratorRowSelection, /*tp_as_buffer*/
33211   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
33212   __Pyx_DOCSTR("*(Samfile samfile)*\n\n    iterate over reads in *samfile* at a given list of file positions.\n    "), /*tp_doc*/
33213   __pyx_tp_traverse_9csamtools_IteratorRowSelection, /*tp_traverse*/
33214   __pyx_tp_clear_9csamtools_IteratorRowSelection, /*tp_clear*/
33215   0, /*tp_richcompare*/
33216   0, /*tp_weaklistoffset*/
33217   __pyx_pf_9csamtools_20IteratorRowSelection___iter__, /*tp_iter*/
33218   __pyx_pf_9csamtools_20IteratorRowSelection___next__, /*tp_iternext*/
33219   __pyx_methods_9csamtools_IteratorRowSelection, /*tp_methods*/
33220   0, /*tp_members*/
33221   0, /*tp_getset*/
33222   0, /*tp_base*/
33223   0, /*tp_dict*/
33224   0, /*tp_descr_get*/
33225   0, /*tp_descr_set*/
33226   0, /*tp_dictoffset*/
33227   0, /*tp_init*/
33228   0, /*tp_alloc*/
33229   __pyx_tp_new_9csamtools_IteratorRowSelection, /*tp_new*/
33230   0, /*tp_free*/
33231   0, /*tp_is_gc*/
33232   0, /*tp_bases*/
33233   0, /*tp_mro*/
33234   0, /*tp_cache*/
33235   0, /*tp_subclasses*/
33236   0, /*tp_weaklist*/
33237   0, /*tp_del*/
33238   #if PY_VERSION_HEX >= 0x02060000
33239   0, /*tp_version_tag*/
33240   #endif
33241 };
33242 static struct __pyx_vtabstruct_9csamtools_IteratorColumn __pyx_vtable_9csamtools_IteratorColumn;
33243
33244 static PyObject *__pyx_tp_new_9csamtools_IteratorColumn(PyTypeObject *t, PyObject *a, PyObject *k) {
33245   struct __pyx_obj_9csamtools_IteratorColumn *p;
33246   PyObject *o = (*t->tp_alloc)(t, 0);
33247   if (!o) return 0;
33248   p = ((struct __pyx_obj_9csamtools_IteratorColumn *)o);
33249   p->__pyx_vtab = __pyx_vtabptr_9csamtools_IteratorColumn;
33250   p->iter = ((struct __pyx_obj_9csamtools_IteratorRowRegion *)Py_None); Py_INCREF(Py_None);
33251   p->samfile = ((struct __pyx_obj_9csamtools_Samfile *)Py_None); Py_INCREF(Py_None);
33252   p->fastafile = ((struct __pyx_obj_9csamtools_Fastafile *)Py_None); Py_INCREF(Py_None);
33253   p->stepper = Py_None; Py_INCREF(Py_None);
33254   if (__pyx_pf_9csamtools_14IteratorColumn___cinit__(o, a, k) < 0) {
33255     Py_DECREF(o); o = 0;
33256   }
33257   return o;
33258 }
33259
33260 static void __pyx_tp_dealloc_9csamtools_IteratorColumn(PyObject *o) {
33261   struct __pyx_obj_9csamtools_IteratorColumn *p = (struct __pyx_obj_9csamtools_IteratorColumn *)o;
33262   {
33263     PyObject *etype, *eval, *etb;
33264     PyErr_Fetch(&etype, &eval, &etb);
33265     ++Py_REFCNT(o);
33266     __pyx_pf_9csamtools_14IteratorColumn___dealloc__(o);
33267     if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
33268     --Py_REFCNT(o);
33269     PyErr_Restore(etype, eval, etb);
33270   }
33271   Py_XDECREF(((PyObject *)p->iter));
33272   Py_XDECREF(((PyObject *)p->samfile));
33273   Py_XDECREF(((PyObject *)p->fastafile));
33274   Py_XDECREF(p->stepper);
33275   (*Py_TYPE(o)->tp_free)(o);
33276 }
33277
33278 static int __pyx_tp_traverse_9csamtools_IteratorColumn(PyObject *o, visitproc v, void *a) {
33279   int e;
33280   struct __pyx_obj_9csamtools_IteratorColumn *p = (struct __pyx_obj_9csamtools_IteratorColumn *)o;
33281   if (p->iter) {
33282     e = (*v)(((PyObject*)p->iter), a); if (e) return e;
33283   }
33284   if (p->samfile) {
33285     e = (*v)(((PyObject*)p->samfile), a); if (e) return e;
33286   }
33287   if (p->fastafile) {
33288     e = (*v)(((PyObject*)p->fastafile), a); if (e) return e;
33289   }
33290   if (p->stepper) {
33291     e = (*v)(p->stepper, a); if (e) return e;
33292   }
33293   return 0;
33294 }
33295
33296 static int __pyx_tp_clear_9csamtools_IteratorColumn(PyObject *o) {
33297   struct __pyx_obj_9csamtools_IteratorColumn *p = (struct __pyx_obj_9csamtools_IteratorColumn *)o;
33298   PyObject* tmp;
33299   tmp = ((PyObject*)p->iter);
33300   p->iter = ((struct __pyx_obj_9csamtools_IteratorRowRegion *)Py_None); Py_INCREF(Py_None);
33301   Py_XDECREF(tmp);
33302   tmp = ((PyObject*)p->samfile);
33303   p->samfile = ((struct __pyx_obj_9csamtools_Samfile *)Py_None); Py_INCREF(Py_None);
33304   Py_XDECREF(tmp);
33305   tmp = ((PyObject*)p->fastafile);
33306   p->fastafile = ((struct __pyx_obj_9csamtools_Fastafile *)Py_None); Py_INCREF(Py_None);
33307   Py_XDECREF(tmp);
33308   tmp = ((PyObject*)p->stepper);
33309   p->stepper = Py_None; Py_INCREF(Py_None);
33310   Py_XDECREF(tmp);
33311   return 0;
33312 }
33313
33314 static PyObject *__pyx_getprop_9csamtools_14IteratorColumn_seq_len(PyObject *o, void *x) {
33315   return __pyx_pf_9csamtools_14IteratorColumn_7seq_len___get__(o);
33316 }
33317
33318 static PyMethodDef __pyx_methods_9csamtools_IteratorColumn[] = {
33319   {__Pyx_NAMESTR("addReference"), (PyCFunction)__pyx_pf_9csamtools_14IteratorColumn_addReference, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_14IteratorColumn_addReference)},
33320   {__Pyx_NAMESTR("hasReference"), (PyCFunction)__pyx_pf_9csamtools_14IteratorColumn_hasReference, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_14IteratorColumn_hasReference)},
33321   {0, 0, 0, 0}
33322 };
33323
33324 static struct PyGetSetDef __pyx_getsets_9csamtools_IteratorColumn[] = {
33325   {(char *)"seq_len", __pyx_getprop_9csamtools_14IteratorColumn_seq_len, 0, __Pyx_DOCSTR(__pyx_k_161), 0},
33326   {0, 0, 0, 0, 0}
33327 };
33328
33329 static PyNumberMethods __pyx_tp_as_number_IteratorColumn = {
33330   0, /*nb_add*/
33331   0, /*nb_subtract*/
33332   0, /*nb_multiply*/
33333   #if PY_MAJOR_VERSION < 3
33334   0, /*nb_divide*/
33335   #endif
33336   0, /*nb_remainder*/
33337   0, /*nb_divmod*/
33338   0, /*nb_power*/
33339   0, /*nb_negative*/
33340   0, /*nb_positive*/
33341   0, /*nb_absolute*/
33342   0, /*nb_nonzero*/
33343   0, /*nb_invert*/
33344   0, /*nb_lshift*/
33345   0, /*nb_rshift*/
33346   0, /*nb_and*/
33347   0, /*nb_xor*/
33348   0, /*nb_or*/
33349   #if PY_MAJOR_VERSION < 3
33350   0, /*nb_coerce*/
33351   #endif
33352   0, /*nb_int*/
33353   #if PY_MAJOR_VERSION < 3
33354   0, /*nb_long*/
33355   #else
33356   0, /*reserved*/
33357   #endif
33358   0, /*nb_float*/
33359   #if PY_MAJOR_VERSION < 3
33360   0, /*nb_oct*/
33361   #endif
33362   #if PY_MAJOR_VERSION < 3
33363   0, /*nb_hex*/
33364   #endif
33365   0, /*nb_inplace_add*/
33366   0, /*nb_inplace_subtract*/
33367   0, /*nb_inplace_multiply*/
33368   #if PY_MAJOR_VERSION < 3
33369   0, /*nb_inplace_divide*/
33370   #endif
33371   0, /*nb_inplace_remainder*/
33372   0, /*nb_inplace_power*/
33373   0, /*nb_inplace_lshift*/
33374   0, /*nb_inplace_rshift*/
33375   0, /*nb_inplace_and*/
33376   0, /*nb_inplace_xor*/
33377   0, /*nb_inplace_or*/
33378   0, /*nb_floor_divide*/
33379   0, /*nb_true_divide*/
33380   0, /*nb_inplace_floor_divide*/
33381   0, /*nb_inplace_true_divide*/
33382   #if PY_VERSION_HEX >= 0x02050000
33383   0, /*nb_index*/
33384   #endif
33385 };
33386
33387 static PySequenceMethods __pyx_tp_as_sequence_IteratorColumn = {
33388   0, /*sq_length*/
33389   0, /*sq_concat*/
33390   0, /*sq_repeat*/
33391   0, /*sq_item*/
33392   0, /*sq_slice*/
33393   0, /*sq_ass_item*/
33394   0, /*sq_ass_slice*/
33395   0, /*sq_contains*/
33396   0, /*sq_inplace_concat*/
33397   0, /*sq_inplace_repeat*/
33398 };
33399
33400 static PyMappingMethods __pyx_tp_as_mapping_IteratorColumn = {
33401   0, /*mp_length*/
33402   0, /*mp_subscript*/
33403   0, /*mp_ass_subscript*/
33404 };
33405
33406 static PyBufferProcs __pyx_tp_as_buffer_IteratorColumn = {
33407   #if PY_MAJOR_VERSION < 3
33408   0, /*bf_getreadbuffer*/
33409   #endif
33410   #if PY_MAJOR_VERSION < 3
33411   0, /*bf_getwritebuffer*/
33412   #endif
33413   #if PY_MAJOR_VERSION < 3
33414   0, /*bf_getsegcount*/
33415   #endif
33416   #if PY_MAJOR_VERSION < 3
33417   0, /*bf_getcharbuffer*/
33418   #endif
33419   #if PY_VERSION_HEX >= 0x02060000
33420   0, /*bf_getbuffer*/
33421   #endif
33422   #if PY_VERSION_HEX >= 0x02060000
33423   0, /*bf_releasebuffer*/
33424   #endif
33425 };
33426
33427 PyTypeObject __pyx_type_9csamtools_IteratorColumn = {
33428   PyVarObject_HEAD_INIT(0, 0)
33429   __Pyx_NAMESTR("csamtools.IteratorColumn"), /*tp_name*/
33430   sizeof(struct __pyx_obj_9csamtools_IteratorColumn), /*tp_basicsize*/
33431   0, /*tp_itemsize*/
33432   __pyx_tp_dealloc_9csamtools_IteratorColumn, /*tp_dealloc*/
33433   0, /*tp_print*/
33434   0, /*tp_getattr*/
33435   0, /*tp_setattr*/
33436   #if PY_MAJOR_VERSION < 3
33437   0, /*tp_compare*/
33438   #else
33439   0, /*reserved*/
33440   #endif
33441   0, /*tp_repr*/
33442   &__pyx_tp_as_number_IteratorColumn, /*tp_as_number*/
33443   &__pyx_tp_as_sequence_IteratorColumn, /*tp_as_sequence*/
33444   &__pyx_tp_as_mapping_IteratorColumn, /*tp_as_mapping*/
33445   0, /*tp_hash*/
33446   0, /*tp_call*/
33447   0, /*tp_str*/
33448   0, /*tp_getattro*/
33449   0, /*tp_setattro*/
33450   &__pyx_tp_as_buffer_IteratorColumn, /*tp_as_buffer*/
33451   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
33452   __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*/
33453   __pyx_tp_traverse_9csamtools_IteratorColumn, /*tp_traverse*/
33454   __pyx_tp_clear_9csamtools_IteratorColumn, /*tp_clear*/
33455   0, /*tp_richcompare*/
33456   0, /*tp_weaklistoffset*/
33457   __pyx_pf_9csamtools_14IteratorColumn___iter__, /*tp_iter*/
33458   0, /*tp_iternext*/
33459   __pyx_methods_9csamtools_IteratorColumn, /*tp_methods*/
33460   0, /*tp_members*/
33461   __pyx_getsets_9csamtools_IteratorColumn, /*tp_getset*/
33462   0, /*tp_base*/
33463   0, /*tp_dict*/
33464   0, /*tp_descr_get*/
33465   0, /*tp_descr_set*/
33466   0, /*tp_dictoffset*/
33467   0, /*tp_init*/
33468   0, /*tp_alloc*/
33469   __pyx_tp_new_9csamtools_IteratorColumn, /*tp_new*/
33470   0, /*tp_free*/
33471   0, /*tp_is_gc*/
33472   0, /*tp_bases*/
33473   0, /*tp_mro*/
33474   0, /*tp_cache*/
33475   0, /*tp_subclasses*/
33476   0, /*tp_weaklist*/
33477   0, /*tp_del*/
33478   #if PY_VERSION_HEX >= 0x02060000
33479   0, /*tp_version_tag*/
33480   #endif
33481 };
33482 static struct __pyx_vtabstruct_9csamtools_IteratorColumnRegion __pyx_vtable_9csamtools_IteratorColumnRegion;
33483
33484 static PyObject *__pyx_tp_new_9csamtools_IteratorColumnRegion(PyTypeObject *t, PyObject *a, PyObject *k) {
33485   struct __pyx_obj_9csamtools_IteratorColumnRegion *p;
33486   PyObject *o = __pyx_tp_new_9csamtools_IteratorColumn(t, a, k);
33487   if (!o) return 0;
33488   p = ((struct __pyx_obj_9csamtools_IteratorColumnRegion *)o);
33489   p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_9csamtools_IteratorColumn*)__pyx_vtabptr_9csamtools_IteratorColumnRegion;
33490   if (__pyx_pf_9csamtools_20IteratorColumnRegion___cinit__(o, a, k) < 0) {
33491     Py_DECREF(o); o = 0;
33492   }
33493   return o;
33494 }
33495
33496 static PyMethodDef __pyx_methods_9csamtools_IteratorColumnRegion[] = {
33497   {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_20IteratorColumnRegion___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_20IteratorColumnRegion___next__)},
33498   {0, 0, 0, 0}
33499 };
33500
33501 static PyNumberMethods __pyx_tp_as_number_IteratorColumnRegion = {
33502   0, /*nb_add*/
33503   0, /*nb_subtract*/
33504   0, /*nb_multiply*/
33505   #if PY_MAJOR_VERSION < 3
33506   0, /*nb_divide*/
33507   #endif
33508   0, /*nb_remainder*/
33509   0, /*nb_divmod*/
33510   0, /*nb_power*/
33511   0, /*nb_negative*/
33512   0, /*nb_positive*/
33513   0, /*nb_absolute*/
33514   0, /*nb_nonzero*/
33515   0, /*nb_invert*/
33516   0, /*nb_lshift*/
33517   0, /*nb_rshift*/
33518   0, /*nb_and*/
33519   0, /*nb_xor*/
33520   0, /*nb_or*/
33521   #if PY_MAJOR_VERSION < 3
33522   0, /*nb_coerce*/
33523   #endif
33524   0, /*nb_int*/
33525   #if PY_MAJOR_VERSION < 3
33526   0, /*nb_long*/
33527   #else
33528   0, /*reserved*/
33529   #endif
33530   0, /*nb_float*/
33531   #if PY_MAJOR_VERSION < 3
33532   0, /*nb_oct*/
33533   #endif
33534   #if PY_MAJOR_VERSION < 3
33535   0, /*nb_hex*/
33536   #endif
33537   0, /*nb_inplace_add*/
33538   0, /*nb_inplace_subtract*/
33539   0, /*nb_inplace_multiply*/
33540   #if PY_MAJOR_VERSION < 3
33541   0, /*nb_inplace_divide*/
33542   #endif
33543   0, /*nb_inplace_remainder*/
33544   0, /*nb_inplace_power*/
33545   0, /*nb_inplace_lshift*/
33546   0, /*nb_inplace_rshift*/
33547   0, /*nb_inplace_and*/
33548   0, /*nb_inplace_xor*/
33549   0, /*nb_inplace_or*/
33550   0, /*nb_floor_divide*/
33551   0, /*nb_true_divide*/
33552   0, /*nb_inplace_floor_divide*/
33553   0, /*nb_inplace_true_divide*/
33554   #if PY_VERSION_HEX >= 0x02050000
33555   0, /*nb_index*/
33556   #endif
33557 };
33558
33559 static PySequenceMethods __pyx_tp_as_sequence_IteratorColumnRegion = {
33560   0, /*sq_length*/
33561   0, /*sq_concat*/
33562   0, /*sq_repeat*/
33563   0, /*sq_item*/
33564   0, /*sq_slice*/
33565   0, /*sq_ass_item*/
33566   0, /*sq_ass_slice*/
33567   0, /*sq_contains*/
33568   0, /*sq_inplace_concat*/
33569   0, /*sq_inplace_repeat*/
33570 };
33571
33572 static PyMappingMethods __pyx_tp_as_mapping_IteratorColumnRegion = {
33573   0, /*mp_length*/
33574   0, /*mp_subscript*/
33575   0, /*mp_ass_subscript*/
33576 };
33577
33578 static PyBufferProcs __pyx_tp_as_buffer_IteratorColumnRegion = {
33579   #if PY_MAJOR_VERSION < 3
33580   0, /*bf_getreadbuffer*/
33581   #endif
33582   #if PY_MAJOR_VERSION < 3
33583   0, /*bf_getwritebuffer*/
33584   #endif
33585   #if PY_MAJOR_VERSION < 3
33586   0, /*bf_getsegcount*/
33587   #endif
33588   #if PY_MAJOR_VERSION < 3
33589   0, /*bf_getcharbuffer*/
33590   #endif
33591   #if PY_VERSION_HEX >= 0x02060000
33592   0, /*bf_getbuffer*/
33593   #endif
33594   #if PY_VERSION_HEX >= 0x02060000
33595   0, /*bf_releasebuffer*/
33596   #endif
33597 };
33598
33599 PyTypeObject __pyx_type_9csamtools_IteratorColumnRegion = {
33600   PyVarObject_HEAD_INIT(0, 0)
33601   __Pyx_NAMESTR("csamtools.IteratorColumnRegion"), /*tp_name*/
33602   sizeof(struct __pyx_obj_9csamtools_IteratorColumnRegion), /*tp_basicsize*/
33603   0, /*tp_itemsize*/
33604   __pyx_tp_dealloc_9csamtools_IteratorColumn, /*tp_dealloc*/
33605   0, /*tp_print*/
33606   0, /*tp_getattr*/
33607   0, /*tp_setattr*/
33608   #if PY_MAJOR_VERSION < 3
33609   0, /*tp_compare*/
33610   #else
33611   0, /*reserved*/
33612   #endif
33613   0, /*tp_repr*/
33614   &__pyx_tp_as_number_IteratorColumnRegion, /*tp_as_number*/
33615   &__pyx_tp_as_sequence_IteratorColumnRegion, /*tp_as_sequence*/
33616   &__pyx_tp_as_mapping_IteratorColumnRegion, /*tp_as_mapping*/
33617   0, /*tp_hash*/
33618   0, /*tp_call*/
33619   0, /*tp_str*/
33620   0, /*tp_getattro*/
33621   0, /*tp_setattro*/
33622   &__pyx_tp_as_buffer_IteratorColumnRegion, /*tp_as_buffer*/
33623   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
33624   __Pyx_DOCSTR("iterates over a region only.\n    "), /*tp_doc*/
33625   __pyx_tp_traverse_9csamtools_IteratorColumn, /*tp_traverse*/
33626   __pyx_tp_clear_9csamtools_IteratorColumn, /*tp_clear*/
33627   0, /*tp_richcompare*/
33628   0, /*tp_weaklistoffset*/
33629   0, /*tp_iter*/
33630   __pyx_pf_9csamtools_20IteratorColumnRegion___next__, /*tp_iternext*/
33631   __pyx_methods_9csamtools_IteratorColumnRegion, /*tp_methods*/
33632   0, /*tp_members*/
33633   0, /*tp_getset*/
33634   0, /*tp_base*/
33635   0, /*tp_dict*/
33636   0, /*tp_descr_get*/
33637   0, /*tp_descr_set*/
33638   0, /*tp_dictoffset*/
33639   0, /*tp_init*/
33640   0, /*tp_alloc*/
33641   __pyx_tp_new_9csamtools_IteratorColumnRegion, /*tp_new*/
33642   0, /*tp_free*/
33643   0, /*tp_is_gc*/
33644   0, /*tp_bases*/
33645   0, /*tp_mro*/
33646   0, /*tp_cache*/
33647   0, /*tp_subclasses*/
33648   0, /*tp_weaklist*/
33649   0, /*tp_del*/
33650   #if PY_VERSION_HEX >= 0x02060000
33651   0, /*tp_version_tag*/
33652   #endif
33653 };
33654 static struct __pyx_vtabstruct_9csamtools_IteratorColumnAllRefs __pyx_vtable_9csamtools_IteratorColumnAllRefs;
33655
33656 static PyObject *__pyx_tp_new_9csamtools_IteratorColumnAllRefs(PyTypeObject *t, PyObject *a, PyObject *k) {
33657   struct __pyx_obj_9csamtools_IteratorColumnAllRefs *p;
33658   PyObject *o = __pyx_tp_new_9csamtools_IteratorColumn(t, a, k);
33659   if (!o) return 0;
33660   p = ((struct __pyx_obj_9csamtools_IteratorColumnAllRefs *)o);
33661   p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_9csamtools_IteratorColumn*)__pyx_vtabptr_9csamtools_IteratorColumnAllRefs;
33662   if (__pyx_pf_9csamtools_21IteratorColumnAllRefs___cinit__(o, a, k) < 0) {
33663     Py_DECREF(o); o = 0;
33664   }
33665   return o;
33666 }
33667
33668 static PyMethodDef __pyx_methods_9csamtools_IteratorColumnAllRefs[] = {
33669   {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_21IteratorColumnAllRefs___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_21IteratorColumnAllRefs___next__)},
33670   {0, 0, 0, 0}
33671 };
33672
33673 static PyNumberMethods __pyx_tp_as_number_IteratorColumnAllRefs = {
33674   0, /*nb_add*/
33675   0, /*nb_subtract*/
33676   0, /*nb_multiply*/
33677   #if PY_MAJOR_VERSION < 3
33678   0, /*nb_divide*/
33679   #endif
33680   0, /*nb_remainder*/
33681   0, /*nb_divmod*/
33682   0, /*nb_power*/
33683   0, /*nb_negative*/
33684   0, /*nb_positive*/
33685   0, /*nb_absolute*/
33686   0, /*nb_nonzero*/
33687   0, /*nb_invert*/
33688   0, /*nb_lshift*/
33689   0, /*nb_rshift*/
33690   0, /*nb_and*/
33691   0, /*nb_xor*/
33692   0, /*nb_or*/
33693   #if PY_MAJOR_VERSION < 3
33694   0, /*nb_coerce*/
33695   #endif
33696   0, /*nb_int*/
33697   #if PY_MAJOR_VERSION < 3
33698   0, /*nb_long*/
33699   #else
33700   0, /*reserved*/
33701   #endif
33702   0, /*nb_float*/
33703   #if PY_MAJOR_VERSION < 3
33704   0, /*nb_oct*/
33705   #endif
33706   #if PY_MAJOR_VERSION < 3
33707   0, /*nb_hex*/
33708   #endif
33709   0, /*nb_inplace_add*/
33710   0, /*nb_inplace_subtract*/
33711   0, /*nb_inplace_multiply*/
33712   #if PY_MAJOR_VERSION < 3
33713   0, /*nb_inplace_divide*/
33714   #endif
33715   0, /*nb_inplace_remainder*/
33716   0, /*nb_inplace_power*/
33717   0, /*nb_inplace_lshift*/
33718   0, /*nb_inplace_rshift*/
33719   0, /*nb_inplace_and*/
33720   0, /*nb_inplace_xor*/
33721   0, /*nb_inplace_or*/
33722   0, /*nb_floor_divide*/
33723   0, /*nb_true_divide*/
33724   0, /*nb_inplace_floor_divide*/
33725   0, /*nb_inplace_true_divide*/
33726   #if PY_VERSION_HEX >= 0x02050000
33727   0, /*nb_index*/
33728   #endif
33729 };
33730
33731 static PySequenceMethods __pyx_tp_as_sequence_IteratorColumnAllRefs = {
33732   0, /*sq_length*/
33733   0, /*sq_concat*/
33734   0, /*sq_repeat*/
33735   0, /*sq_item*/
33736   0, /*sq_slice*/
33737   0, /*sq_ass_item*/
33738   0, /*sq_ass_slice*/
33739   0, /*sq_contains*/
33740   0, /*sq_inplace_concat*/
33741   0, /*sq_inplace_repeat*/
33742 };
33743
33744 static PyMappingMethods __pyx_tp_as_mapping_IteratorColumnAllRefs = {
33745   0, /*mp_length*/
33746   0, /*mp_subscript*/
33747   0, /*mp_ass_subscript*/
33748 };
33749
33750 static PyBufferProcs __pyx_tp_as_buffer_IteratorColumnAllRefs = {
33751   #if PY_MAJOR_VERSION < 3
33752   0, /*bf_getreadbuffer*/
33753   #endif
33754   #if PY_MAJOR_VERSION < 3
33755   0, /*bf_getwritebuffer*/
33756   #endif
33757   #if PY_MAJOR_VERSION < 3
33758   0, /*bf_getsegcount*/
33759   #endif
33760   #if PY_MAJOR_VERSION < 3
33761   0, /*bf_getcharbuffer*/
33762   #endif
33763   #if PY_VERSION_HEX >= 0x02060000
33764   0, /*bf_getbuffer*/
33765   #endif
33766   #if PY_VERSION_HEX >= 0x02060000
33767   0, /*bf_releasebuffer*/
33768   #endif
33769 };
33770
33771 PyTypeObject __pyx_type_9csamtools_IteratorColumnAllRefs = {
33772   PyVarObject_HEAD_INIT(0, 0)
33773   __Pyx_NAMESTR("csamtools.IteratorColumnAllRefs"), /*tp_name*/
33774   sizeof(struct __pyx_obj_9csamtools_IteratorColumnAllRefs), /*tp_basicsize*/
33775   0, /*tp_itemsize*/
33776   __pyx_tp_dealloc_9csamtools_IteratorColumn, /*tp_dealloc*/
33777   0, /*tp_print*/
33778   0, /*tp_getattr*/
33779   0, /*tp_setattr*/
33780   #if PY_MAJOR_VERSION < 3
33781   0, /*tp_compare*/
33782   #else
33783   0, /*reserved*/
33784   #endif
33785   0, /*tp_repr*/
33786   &__pyx_tp_as_number_IteratorColumnAllRefs, /*tp_as_number*/
33787   &__pyx_tp_as_sequence_IteratorColumnAllRefs, /*tp_as_sequence*/
33788   &__pyx_tp_as_mapping_IteratorColumnAllRefs, /*tp_as_mapping*/
33789   0, /*tp_hash*/
33790   0, /*tp_call*/
33791   0, /*tp_str*/
33792   0, /*tp_getattro*/
33793   0, /*tp_setattro*/
33794   &__pyx_tp_as_buffer_IteratorColumnAllRefs, /*tp_as_buffer*/
33795   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
33796   __Pyx_DOCSTR("iterates over all columns by chaining iterators over each reference\n    "), /*tp_doc*/
33797   __pyx_tp_traverse_9csamtools_IteratorColumn, /*tp_traverse*/
33798   __pyx_tp_clear_9csamtools_IteratorColumn, /*tp_clear*/
33799   0, /*tp_richcompare*/
33800   0, /*tp_weaklistoffset*/
33801   0, /*tp_iter*/
33802   __pyx_pf_9csamtools_21IteratorColumnAllRefs___next__, /*tp_iternext*/
33803   __pyx_methods_9csamtools_IteratorColumnAllRefs, /*tp_methods*/
33804   0, /*tp_members*/
33805   0, /*tp_getset*/
33806   0, /*tp_base*/
33807   0, /*tp_dict*/
33808   0, /*tp_descr_get*/
33809   0, /*tp_descr_set*/
33810   0, /*tp_dictoffset*/
33811   0, /*tp_init*/
33812   0, /*tp_alloc*/
33813   __pyx_tp_new_9csamtools_IteratorColumnAllRefs, /*tp_new*/
33814   0, /*tp_free*/
33815   0, /*tp_is_gc*/
33816   0, /*tp_bases*/
33817   0, /*tp_mro*/
33818   0, /*tp_cache*/
33819   0, /*tp_subclasses*/
33820   0, /*tp_weaklist*/
33821   0, /*tp_del*/
33822   #if PY_VERSION_HEX >= 0x02060000
33823   0, /*tp_version_tag*/
33824   #endif
33825 };
33826
33827 static PyObject *__pyx_tp_new_9csamtools_SNPCall(PyTypeObject *t, PyObject *a, PyObject *k) {
33828   PyObject *o = (*t->tp_alloc)(t, 0);
33829   if (!o) return 0;
33830   return o;
33831 }
33832
33833 static void __pyx_tp_dealloc_9csamtools_SNPCall(PyObject *o) {
33834   (*Py_TYPE(o)->tp_free)(o);
33835 }
33836
33837 static PyObject *__pyx_getprop_9csamtools_7SNPCall_tid(PyObject *o, void *x) {
33838   return __pyx_pf_9csamtools_7SNPCall_3tid___get__(o);
33839 }
33840
33841 static PyObject *__pyx_getprop_9csamtools_7SNPCall_pos(PyObject *o, void *x) {
33842   return __pyx_pf_9csamtools_7SNPCall_3pos___get__(o);
33843 }
33844
33845 static PyObject *__pyx_getprop_9csamtools_7SNPCall_reference_base(PyObject *o, void *x) {
33846   return __pyx_pf_9csamtools_7SNPCall_14reference_base___get__(o);
33847 }
33848
33849 static PyObject *__pyx_getprop_9csamtools_7SNPCall_genotype(PyObject *o, void *x) {
33850   return __pyx_pf_9csamtools_7SNPCall_8genotype___get__(o);
33851 }
33852
33853 static PyObject *__pyx_getprop_9csamtools_7SNPCall_consensus_quality(PyObject *o, void *x) {
33854   return __pyx_pf_9csamtools_7SNPCall_17consensus_quality___get__(o);
33855 }
33856
33857 static PyObject *__pyx_getprop_9csamtools_7SNPCall_snp_quality(PyObject *o, void *x) {
33858   return __pyx_pf_9csamtools_7SNPCall_11snp_quality___get__(o);
33859 }
33860
33861 static PyObject *__pyx_getprop_9csamtools_7SNPCall_mapping_quality(PyObject *o, void *x) {
33862   return __pyx_pf_9csamtools_7SNPCall_15mapping_quality___get__(o);
33863 }
33864
33865 static PyObject *__pyx_getprop_9csamtools_7SNPCall_coverage(PyObject *o, void *x) {
33866   return __pyx_pf_9csamtools_7SNPCall_8coverage___get__(o);
33867 }
33868
33869 static PyMethodDef __pyx_methods_9csamtools_SNPCall[] = {
33870   {0, 0, 0, 0}
33871 };
33872
33873 static struct PyGetSetDef __pyx_getsets_9csamtools_SNPCall[] = {
33874   {(char *)"tid", __pyx_getprop_9csamtools_7SNPCall_tid, 0, __Pyx_DOCSTR(__pyx_k_154), 0},
33875   {(char *)"pos", __pyx_getprop_9csamtools_7SNPCall_pos, 0, __Pyx_DOCSTR(__pyx_k_162), 0},
33876   {(char *)"reference_base", __pyx_getprop_9csamtools_7SNPCall_reference_base, 0, __Pyx_DOCSTR(__pyx_k_163), 0},
33877   {(char *)"genotype", __pyx_getprop_9csamtools_7SNPCall_genotype, 0, __Pyx_DOCSTR(__pyx_k_164), 0},
33878   {(char *)"consensus_quality", __pyx_getprop_9csamtools_7SNPCall_consensus_quality, 0, __Pyx_DOCSTR(__pyx_k_165), 0},
33879   {(char *)"snp_quality", __pyx_getprop_9csamtools_7SNPCall_snp_quality, 0, __Pyx_DOCSTR(__pyx_k_166), 0},
33880   {(char *)"mapping_quality", __pyx_getprop_9csamtools_7SNPCall_mapping_quality, 0, __Pyx_DOCSTR(__pyx_k_167), 0},
33881   {(char *)"coverage", __pyx_getprop_9csamtools_7SNPCall_coverage, 0, __Pyx_DOCSTR(__pyx_k_168), 0},
33882   {0, 0, 0, 0, 0}
33883 };
33884
33885 static PyNumberMethods __pyx_tp_as_number_SNPCall = {
33886   0, /*nb_add*/
33887   0, /*nb_subtract*/
33888   0, /*nb_multiply*/
33889   #if PY_MAJOR_VERSION < 3
33890   0, /*nb_divide*/
33891   #endif
33892   0, /*nb_remainder*/
33893   0, /*nb_divmod*/
33894   0, /*nb_power*/
33895   0, /*nb_negative*/
33896   0, /*nb_positive*/
33897   0, /*nb_absolute*/
33898   0, /*nb_nonzero*/
33899   0, /*nb_invert*/
33900   0, /*nb_lshift*/
33901   0, /*nb_rshift*/
33902   0, /*nb_and*/
33903   0, /*nb_xor*/
33904   0, /*nb_or*/
33905   #if PY_MAJOR_VERSION < 3
33906   0, /*nb_coerce*/
33907   #endif
33908   0, /*nb_int*/
33909   #if PY_MAJOR_VERSION < 3
33910   0, /*nb_long*/
33911   #else
33912   0, /*reserved*/
33913   #endif
33914   0, /*nb_float*/
33915   #if PY_MAJOR_VERSION < 3
33916   0, /*nb_oct*/
33917   #endif
33918   #if PY_MAJOR_VERSION < 3
33919   0, /*nb_hex*/
33920   #endif
33921   0, /*nb_inplace_add*/
33922   0, /*nb_inplace_subtract*/
33923   0, /*nb_inplace_multiply*/
33924   #if PY_MAJOR_VERSION < 3
33925   0, /*nb_inplace_divide*/
33926   #endif
33927   0, /*nb_inplace_remainder*/
33928   0, /*nb_inplace_power*/
33929   0, /*nb_inplace_lshift*/
33930   0, /*nb_inplace_rshift*/
33931   0, /*nb_inplace_and*/
33932   0, /*nb_inplace_xor*/
33933   0, /*nb_inplace_or*/
33934   0, /*nb_floor_divide*/
33935   0, /*nb_true_divide*/
33936   0, /*nb_inplace_floor_divide*/
33937   0, /*nb_inplace_true_divide*/
33938   #if PY_VERSION_HEX >= 0x02050000
33939   0, /*nb_index*/
33940   #endif
33941 };
33942
33943 static PySequenceMethods __pyx_tp_as_sequence_SNPCall = {
33944   0, /*sq_length*/
33945   0, /*sq_concat*/
33946   0, /*sq_repeat*/
33947   0, /*sq_item*/
33948   0, /*sq_slice*/
33949   0, /*sq_ass_item*/
33950   0, /*sq_ass_slice*/
33951   0, /*sq_contains*/
33952   0, /*sq_inplace_concat*/
33953   0, /*sq_inplace_repeat*/
33954 };
33955
33956 static PyMappingMethods __pyx_tp_as_mapping_SNPCall = {
33957   0, /*mp_length*/
33958   0, /*mp_subscript*/
33959   0, /*mp_ass_subscript*/
33960 };
33961
33962 static PyBufferProcs __pyx_tp_as_buffer_SNPCall = {
33963   #if PY_MAJOR_VERSION < 3
33964   0, /*bf_getreadbuffer*/
33965   #endif
33966   #if PY_MAJOR_VERSION < 3
33967   0, /*bf_getwritebuffer*/
33968   #endif
33969   #if PY_MAJOR_VERSION < 3
33970   0, /*bf_getsegcount*/
33971   #endif
33972   #if PY_MAJOR_VERSION < 3
33973   0, /*bf_getcharbuffer*/
33974   #endif
33975   #if PY_VERSION_HEX >= 0x02060000
33976   0, /*bf_getbuffer*/
33977   #endif
33978   #if PY_VERSION_HEX >= 0x02060000
33979   0, /*bf_releasebuffer*/
33980   #endif
33981 };
33982
33983 PyTypeObject __pyx_type_9csamtools_SNPCall = {
33984   PyVarObject_HEAD_INIT(0, 0)
33985   __Pyx_NAMESTR("csamtools.SNPCall"), /*tp_name*/
33986   sizeof(struct __pyx_obj_9csamtools_SNPCall), /*tp_basicsize*/
33987   0, /*tp_itemsize*/
33988   __pyx_tp_dealloc_9csamtools_SNPCall, /*tp_dealloc*/
33989   0, /*tp_print*/
33990   0, /*tp_getattr*/
33991   0, /*tp_setattr*/
33992   #if PY_MAJOR_VERSION < 3
33993   0, /*tp_compare*/
33994   #else
33995   0, /*reserved*/
33996   #endif
33997   0, /*tp_repr*/
33998   &__pyx_tp_as_number_SNPCall, /*tp_as_number*/
33999   &__pyx_tp_as_sequence_SNPCall, /*tp_as_sequence*/
34000   &__pyx_tp_as_mapping_SNPCall, /*tp_as_mapping*/
34001   0, /*tp_hash*/
34002   0, /*tp_call*/
34003   __pyx_pf_9csamtools_7SNPCall___str__, /*tp_str*/
34004   0, /*tp_getattro*/
34005   0, /*tp_setattro*/
34006   &__pyx_tp_as_buffer_SNPCall, /*tp_as_buffer*/
34007   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
34008   __Pyx_DOCSTR("the results of a SNP call."), /*tp_doc*/
34009   0, /*tp_traverse*/
34010   0, /*tp_clear*/
34011   0, /*tp_richcompare*/
34012   0, /*tp_weaklistoffset*/
34013   0, /*tp_iter*/
34014   0, /*tp_iternext*/
34015   __pyx_methods_9csamtools_SNPCall, /*tp_methods*/
34016   0, /*tp_members*/
34017   __pyx_getsets_9csamtools_SNPCall, /*tp_getset*/
34018   0, /*tp_base*/
34019   0, /*tp_dict*/
34020   0, /*tp_descr_get*/
34021   0, /*tp_descr_set*/
34022   0, /*tp_dictoffset*/
34023   0, /*tp_init*/
34024   0, /*tp_alloc*/
34025   __pyx_tp_new_9csamtools_SNPCall, /*tp_new*/
34026   0, /*tp_free*/
34027   0, /*tp_is_gc*/
34028   0, /*tp_bases*/
34029   0, /*tp_mro*/
34030   0, /*tp_cache*/
34031   0, /*tp_subclasses*/
34032   0, /*tp_weaklist*/
34033   0, /*tp_del*/
34034   #if PY_VERSION_HEX >= 0x02060000
34035   0, /*tp_version_tag*/
34036   #endif
34037 };
34038 static struct __pyx_vtabstruct_9csamtools_SNPCallerBase __pyx_vtable_9csamtools_SNPCallerBase;
34039
34040 static PyObject *__pyx_tp_new_9csamtools_SNPCallerBase(PyTypeObject *t, PyObject *a, PyObject *k) {
34041   struct __pyx_obj_9csamtools_SNPCallerBase *p;
34042   PyObject *o = (*t->tp_alloc)(t, 0);
34043   if (!o) return 0;
34044   p = ((struct __pyx_obj_9csamtools_SNPCallerBase *)o);
34045   p->__pyx_vtab = __pyx_vtabptr_9csamtools_SNPCallerBase;
34046   p->iter = ((struct __pyx_obj_9csamtools_IteratorColumn *)Py_None); Py_INCREF(Py_None);
34047   if (__pyx_pf_9csamtools_13SNPCallerBase___cinit__(o, a, k) < 0) {
34048     Py_DECREF(o); o = 0;
34049   }
34050   return o;
34051 }
34052
34053 static void __pyx_tp_dealloc_9csamtools_SNPCallerBase(PyObject *o) {
34054   struct __pyx_obj_9csamtools_SNPCallerBase *p = (struct __pyx_obj_9csamtools_SNPCallerBase *)o;
34055   {
34056     PyObject *etype, *eval, *etb;
34057     PyErr_Fetch(&etype, &eval, &etb);
34058     ++Py_REFCNT(o);
34059     __pyx_pf_9csamtools_13SNPCallerBase___dealloc__(o);
34060     if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
34061     --Py_REFCNT(o);
34062     PyErr_Restore(etype, eval, etb);
34063   }
34064   Py_XDECREF(((PyObject *)p->iter));
34065   (*Py_TYPE(o)->tp_free)(o);
34066 }
34067
34068 static int __pyx_tp_traverse_9csamtools_SNPCallerBase(PyObject *o, visitproc v, void *a) {
34069   int e;
34070   struct __pyx_obj_9csamtools_SNPCallerBase *p = (struct __pyx_obj_9csamtools_SNPCallerBase *)o;
34071   if (p->iter) {
34072     e = (*v)(((PyObject*)p->iter), a); if (e) return e;
34073   }
34074   return 0;
34075 }
34076
34077 static int __pyx_tp_clear_9csamtools_SNPCallerBase(PyObject *o) {
34078   struct __pyx_obj_9csamtools_SNPCallerBase *p = (struct __pyx_obj_9csamtools_SNPCallerBase *)o;
34079   PyObject* tmp;
34080   tmp = ((PyObject*)p->iter);
34081   p->iter = ((struct __pyx_obj_9csamtools_IteratorColumn *)Py_None); Py_INCREF(Py_None);
34082   Py_XDECREF(tmp);
34083   return 0;
34084 }
34085
34086 static PyMethodDef __pyx_methods_9csamtools_SNPCallerBase[] = {
34087   {0, 0, 0, 0}
34088 };
34089
34090 static PyNumberMethods __pyx_tp_as_number_SNPCallerBase = {
34091   0, /*nb_add*/
34092   0, /*nb_subtract*/
34093   0, /*nb_multiply*/
34094   #if PY_MAJOR_VERSION < 3
34095   0, /*nb_divide*/
34096   #endif
34097   0, /*nb_remainder*/
34098   0, /*nb_divmod*/
34099   0, /*nb_power*/
34100   0, /*nb_negative*/
34101   0, /*nb_positive*/
34102   0, /*nb_absolute*/
34103   0, /*nb_nonzero*/
34104   0, /*nb_invert*/
34105   0, /*nb_lshift*/
34106   0, /*nb_rshift*/
34107   0, /*nb_and*/
34108   0, /*nb_xor*/
34109   0, /*nb_or*/
34110   #if PY_MAJOR_VERSION < 3
34111   0, /*nb_coerce*/
34112   #endif
34113   0, /*nb_int*/
34114   #if PY_MAJOR_VERSION < 3
34115   0, /*nb_long*/
34116   #else
34117   0, /*reserved*/
34118   #endif
34119   0, /*nb_float*/
34120   #if PY_MAJOR_VERSION < 3
34121   0, /*nb_oct*/
34122   #endif
34123   #if PY_MAJOR_VERSION < 3
34124   0, /*nb_hex*/
34125   #endif
34126   0, /*nb_inplace_add*/
34127   0, /*nb_inplace_subtract*/
34128   0, /*nb_inplace_multiply*/
34129   #if PY_MAJOR_VERSION < 3
34130   0, /*nb_inplace_divide*/
34131   #endif
34132   0, /*nb_inplace_remainder*/
34133   0, /*nb_inplace_power*/
34134   0, /*nb_inplace_lshift*/
34135   0, /*nb_inplace_rshift*/
34136   0, /*nb_inplace_and*/
34137   0, /*nb_inplace_xor*/
34138   0, /*nb_inplace_or*/
34139   0, /*nb_floor_divide*/
34140   0, /*nb_true_divide*/
34141   0, /*nb_inplace_floor_divide*/
34142   0, /*nb_inplace_true_divide*/
34143   #if PY_VERSION_HEX >= 0x02050000
34144   0, /*nb_index*/
34145   #endif
34146 };
34147
34148 static PySequenceMethods __pyx_tp_as_sequence_SNPCallerBase = {
34149   0, /*sq_length*/
34150   0, /*sq_concat*/
34151   0, /*sq_repeat*/
34152   0, /*sq_item*/
34153   0, /*sq_slice*/
34154   0, /*sq_ass_item*/
34155   0, /*sq_ass_slice*/
34156   0, /*sq_contains*/
34157   0, /*sq_inplace_concat*/
34158   0, /*sq_inplace_repeat*/
34159 };
34160
34161 static PyMappingMethods __pyx_tp_as_mapping_SNPCallerBase = {
34162   0, /*mp_length*/
34163   0, /*mp_subscript*/
34164   0, /*mp_ass_subscript*/
34165 };
34166
34167 static PyBufferProcs __pyx_tp_as_buffer_SNPCallerBase = {
34168   #if PY_MAJOR_VERSION < 3
34169   0, /*bf_getreadbuffer*/
34170   #endif
34171   #if PY_MAJOR_VERSION < 3
34172   0, /*bf_getwritebuffer*/
34173   #endif
34174   #if PY_MAJOR_VERSION < 3
34175   0, /*bf_getsegcount*/
34176   #endif
34177   #if PY_MAJOR_VERSION < 3
34178   0, /*bf_getcharbuffer*/
34179   #endif
34180   #if PY_VERSION_HEX >= 0x02060000
34181   0, /*bf_getbuffer*/
34182   #endif
34183   #if PY_VERSION_HEX >= 0x02060000
34184   0, /*bf_releasebuffer*/
34185   #endif
34186 };
34187
34188 PyTypeObject __pyx_type_9csamtools_SNPCallerBase = {
34189   PyVarObject_HEAD_INIT(0, 0)
34190   __Pyx_NAMESTR("csamtools.SNPCallerBase"), /*tp_name*/
34191   sizeof(struct __pyx_obj_9csamtools_SNPCallerBase), /*tp_basicsize*/
34192   0, /*tp_itemsize*/
34193   __pyx_tp_dealloc_9csamtools_SNPCallerBase, /*tp_dealloc*/
34194   0, /*tp_print*/
34195   0, /*tp_getattr*/
34196   0, /*tp_setattr*/
34197   #if PY_MAJOR_VERSION < 3
34198   0, /*tp_compare*/
34199   #else
34200   0, /*reserved*/
34201   #endif
34202   0, /*tp_repr*/
34203   &__pyx_tp_as_number_SNPCallerBase, /*tp_as_number*/
34204   &__pyx_tp_as_sequence_SNPCallerBase, /*tp_as_sequence*/
34205   &__pyx_tp_as_mapping_SNPCallerBase, /*tp_as_mapping*/
34206   0, /*tp_hash*/
34207   0, /*tp_call*/
34208   0, /*tp_str*/
34209   0, /*tp_getattro*/
34210   0, /*tp_setattro*/
34211   &__pyx_tp_as_buffer_SNPCallerBase, /*tp_as_buffer*/
34212   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
34213   __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*/
34214   __pyx_tp_traverse_9csamtools_SNPCallerBase, /*tp_traverse*/
34215   __pyx_tp_clear_9csamtools_SNPCallerBase, /*tp_clear*/
34216   0, /*tp_richcompare*/
34217   0, /*tp_weaklistoffset*/
34218   0, /*tp_iter*/
34219   0, /*tp_iternext*/
34220   __pyx_methods_9csamtools_SNPCallerBase, /*tp_methods*/
34221   0, /*tp_members*/
34222   0, /*tp_getset*/
34223   0, /*tp_base*/
34224   0, /*tp_dict*/
34225   0, /*tp_descr_get*/
34226   0, /*tp_descr_set*/
34227   0, /*tp_dictoffset*/
34228   0, /*tp_init*/
34229   0, /*tp_alloc*/
34230   __pyx_tp_new_9csamtools_SNPCallerBase, /*tp_new*/
34231   0, /*tp_free*/
34232   0, /*tp_is_gc*/
34233   0, /*tp_bases*/
34234   0, /*tp_mro*/
34235   0, /*tp_cache*/
34236   0, /*tp_subclasses*/
34237   0, /*tp_weaklist*/
34238   0, /*tp_del*/
34239   #if PY_VERSION_HEX >= 0x02060000
34240   0, /*tp_version_tag*/
34241   #endif
34242 };
34243 static struct __pyx_vtabstruct_9csamtools_IteratorSNPCalls __pyx_vtable_9csamtools_IteratorSNPCalls;
34244
34245 static PyObject *__pyx_tp_new_9csamtools_IteratorSNPCalls(PyTypeObject *t, PyObject *a, PyObject *k) {
34246   struct __pyx_obj_9csamtools_IteratorSNPCalls *p;
34247   PyObject *o = __pyx_tp_new_9csamtools_SNPCallerBase(t, a, k);
34248   if (!o) return 0;
34249   p = ((struct __pyx_obj_9csamtools_IteratorSNPCalls *)o);
34250   p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_9csamtools_SNPCallerBase*)__pyx_vtabptr_9csamtools_IteratorSNPCalls;
34251   if (__pyx_pf_9csamtools_16IteratorSNPCalls___cinit__(o, a, k) < 0) {
34252     Py_DECREF(o); o = 0;
34253   }
34254   return o;
34255 }
34256
34257 static PyMethodDef __pyx_methods_9csamtools_IteratorSNPCalls[] = {
34258   {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_16IteratorSNPCalls___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_16IteratorSNPCalls___next__)},
34259   {0, 0, 0, 0}
34260 };
34261
34262 static PyNumberMethods __pyx_tp_as_number_IteratorSNPCalls = {
34263   0, /*nb_add*/
34264   0, /*nb_subtract*/
34265   0, /*nb_multiply*/
34266   #if PY_MAJOR_VERSION < 3
34267   0, /*nb_divide*/
34268   #endif
34269   0, /*nb_remainder*/
34270   0, /*nb_divmod*/
34271   0, /*nb_power*/
34272   0, /*nb_negative*/
34273   0, /*nb_positive*/
34274   0, /*nb_absolute*/
34275   0, /*nb_nonzero*/
34276   0, /*nb_invert*/
34277   0, /*nb_lshift*/
34278   0, /*nb_rshift*/
34279   0, /*nb_and*/
34280   0, /*nb_xor*/
34281   0, /*nb_or*/
34282   #if PY_MAJOR_VERSION < 3
34283   0, /*nb_coerce*/
34284   #endif
34285   0, /*nb_int*/
34286   #if PY_MAJOR_VERSION < 3
34287   0, /*nb_long*/
34288   #else
34289   0, /*reserved*/
34290   #endif
34291   0, /*nb_float*/
34292   #if PY_MAJOR_VERSION < 3
34293   0, /*nb_oct*/
34294   #endif
34295   #if PY_MAJOR_VERSION < 3
34296   0, /*nb_hex*/
34297   #endif
34298   0, /*nb_inplace_add*/
34299   0, /*nb_inplace_subtract*/
34300   0, /*nb_inplace_multiply*/
34301   #if PY_MAJOR_VERSION < 3
34302   0, /*nb_inplace_divide*/
34303   #endif
34304   0, /*nb_inplace_remainder*/
34305   0, /*nb_inplace_power*/
34306   0, /*nb_inplace_lshift*/
34307   0, /*nb_inplace_rshift*/
34308   0, /*nb_inplace_and*/
34309   0, /*nb_inplace_xor*/
34310   0, /*nb_inplace_or*/
34311   0, /*nb_floor_divide*/
34312   0, /*nb_true_divide*/
34313   0, /*nb_inplace_floor_divide*/
34314   0, /*nb_inplace_true_divide*/
34315   #if PY_VERSION_HEX >= 0x02050000
34316   0, /*nb_index*/
34317   #endif
34318 };
34319
34320 static PySequenceMethods __pyx_tp_as_sequence_IteratorSNPCalls = {
34321   0, /*sq_length*/
34322   0, /*sq_concat*/
34323   0, /*sq_repeat*/
34324   0, /*sq_item*/
34325   0, /*sq_slice*/
34326   0, /*sq_ass_item*/
34327   0, /*sq_ass_slice*/
34328   0, /*sq_contains*/
34329   0, /*sq_inplace_concat*/
34330   0, /*sq_inplace_repeat*/
34331 };
34332
34333 static PyMappingMethods __pyx_tp_as_mapping_IteratorSNPCalls = {
34334   0, /*mp_length*/
34335   0, /*mp_subscript*/
34336   0, /*mp_ass_subscript*/
34337 };
34338
34339 static PyBufferProcs __pyx_tp_as_buffer_IteratorSNPCalls = {
34340   #if PY_MAJOR_VERSION < 3
34341   0, /*bf_getreadbuffer*/
34342   #endif
34343   #if PY_MAJOR_VERSION < 3
34344   0, /*bf_getwritebuffer*/
34345   #endif
34346   #if PY_MAJOR_VERSION < 3
34347   0, /*bf_getsegcount*/
34348   #endif
34349   #if PY_MAJOR_VERSION < 3
34350   0, /*bf_getcharbuffer*/
34351   #endif
34352   #if PY_VERSION_HEX >= 0x02060000
34353   0, /*bf_getbuffer*/
34354   #endif
34355   #if PY_VERSION_HEX >= 0x02060000
34356   0, /*bf_releasebuffer*/
34357   #endif
34358 };
34359
34360 PyTypeObject __pyx_type_9csamtools_IteratorSNPCalls = {
34361   PyVarObject_HEAD_INIT(0, 0)
34362   __Pyx_NAMESTR("csamtools.IteratorSNPCalls"), /*tp_name*/
34363   sizeof(struct __pyx_obj_9csamtools_IteratorSNPCalls), /*tp_basicsize*/
34364   0, /*tp_itemsize*/
34365   __pyx_tp_dealloc_9csamtools_SNPCallerBase, /*tp_dealloc*/
34366   0, /*tp_print*/
34367   0, /*tp_getattr*/
34368   0, /*tp_setattr*/
34369   #if PY_MAJOR_VERSION < 3
34370   0, /*tp_compare*/
34371   #else
34372   0, /*reserved*/
34373   #endif
34374   0, /*tp_repr*/
34375   &__pyx_tp_as_number_IteratorSNPCalls, /*tp_as_number*/
34376   &__pyx_tp_as_sequence_IteratorSNPCalls, /*tp_as_sequence*/
34377   &__pyx_tp_as_mapping_IteratorSNPCalls, /*tp_as_mapping*/
34378   0, /*tp_hash*/
34379   0, /*tp_call*/
34380   0, /*tp_str*/
34381   0, /*tp_getattro*/
34382   0, /*tp_setattro*/
34383   &__pyx_tp_as_buffer_IteratorSNPCalls, /*tp_as_buffer*/
34384   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
34385   __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*/
34386   __pyx_tp_traverse_9csamtools_SNPCallerBase, /*tp_traverse*/
34387   __pyx_tp_clear_9csamtools_SNPCallerBase, /*tp_clear*/
34388   0, /*tp_richcompare*/
34389   0, /*tp_weaklistoffset*/
34390   __pyx_pf_9csamtools_16IteratorSNPCalls___iter__, /*tp_iter*/
34391   __pyx_pf_9csamtools_16IteratorSNPCalls___next__, /*tp_iternext*/
34392   __pyx_methods_9csamtools_IteratorSNPCalls, /*tp_methods*/
34393   0, /*tp_members*/
34394   0, /*tp_getset*/
34395   0, /*tp_base*/
34396   0, /*tp_dict*/
34397   0, /*tp_descr_get*/
34398   0, /*tp_descr_set*/
34399   0, /*tp_dictoffset*/
34400   0, /*tp_init*/
34401   0, /*tp_alloc*/
34402   __pyx_tp_new_9csamtools_IteratorSNPCalls, /*tp_new*/
34403   0, /*tp_free*/
34404   0, /*tp_is_gc*/
34405   0, /*tp_bases*/
34406   0, /*tp_mro*/
34407   0, /*tp_cache*/
34408   0, /*tp_subclasses*/
34409   0, /*tp_weaklist*/
34410   0, /*tp_del*/
34411   #if PY_VERSION_HEX >= 0x02060000
34412   0, /*tp_version_tag*/
34413   #endif
34414 };
34415 static struct __pyx_vtabstruct_9csamtools_SNPCaller __pyx_vtable_9csamtools_SNPCaller;
34416
34417 static PyObject *__pyx_tp_new_9csamtools_SNPCaller(PyTypeObject *t, PyObject *a, PyObject *k) {
34418   struct __pyx_obj_9csamtools_SNPCaller *p;
34419   PyObject *o = __pyx_tp_new_9csamtools_SNPCallerBase(t, a, k);
34420   if (!o) return 0;
34421   p = ((struct __pyx_obj_9csamtools_SNPCaller *)o);
34422   p->__pyx_base.__pyx_vtab = (struct __pyx_vtabstruct_9csamtools_SNPCallerBase*)__pyx_vtabptr_9csamtools_SNPCaller;
34423   if (__pyx_pf_9csamtools_9SNPCaller___cinit__(o, a, k) < 0) {
34424     Py_DECREF(o); o = 0;
34425   }
34426   return o;
34427 }
34428
34429 static PyMethodDef __pyx_methods_9csamtools_SNPCaller[] = {
34430   {__Pyx_NAMESTR("call"), (PyCFunction)__pyx_pf_9csamtools_9SNPCaller_call, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_9SNPCaller_call)},
34431   {0, 0, 0, 0}
34432 };
34433
34434 static PyNumberMethods __pyx_tp_as_number_SNPCaller = {
34435   0, /*nb_add*/
34436   0, /*nb_subtract*/
34437   0, /*nb_multiply*/
34438   #if PY_MAJOR_VERSION < 3
34439   0, /*nb_divide*/
34440   #endif
34441   0, /*nb_remainder*/
34442   0, /*nb_divmod*/
34443   0, /*nb_power*/
34444   0, /*nb_negative*/
34445   0, /*nb_positive*/
34446   0, /*nb_absolute*/
34447   0, /*nb_nonzero*/
34448   0, /*nb_invert*/
34449   0, /*nb_lshift*/
34450   0, /*nb_rshift*/
34451   0, /*nb_and*/
34452   0, /*nb_xor*/
34453   0, /*nb_or*/
34454   #if PY_MAJOR_VERSION < 3
34455   0, /*nb_coerce*/
34456   #endif
34457   0, /*nb_int*/
34458   #if PY_MAJOR_VERSION < 3
34459   0, /*nb_long*/
34460   #else
34461   0, /*reserved*/
34462   #endif
34463   0, /*nb_float*/
34464   #if PY_MAJOR_VERSION < 3
34465   0, /*nb_oct*/
34466   #endif
34467   #if PY_MAJOR_VERSION < 3
34468   0, /*nb_hex*/
34469   #endif
34470   0, /*nb_inplace_add*/
34471   0, /*nb_inplace_subtract*/
34472   0, /*nb_inplace_multiply*/
34473   #if PY_MAJOR_VERSION < 3
34474   0, /*nb_inplace_divide*/
34475   #endif
34476   0, /*nb_inplace_remainder*/
34477   0, /*nb_inplace_power*/
34478   0, /*nb_inplace_lshift*/
34479   0, /*nb_inplace_rshift*/
34480   0, /*nb_inplace_and*/
34481   0, /*nb_inplace_xor*/
34482   0, /*nb_inplace_or*/
34483   0, /*nb_floor_divide*/
34484   0, /*nb_true_divide*/
34485   0, /*nb_inplace_floor_divide*/
34486   0, /*nb_inplace_true_divide*/
34487   #if PY_VERSION_HEX >= 0x02050000
34488   0, /*nb_index*/
34489   #endif
34490 };
34491
34492 static PySequenceMethods __pyx_tp_as_sequence_SNPCaller = {
34493   0, /*sq_length*/
34494   0, /*sq_concat*/
34495   0, /*sq_repeat*/
34496   0, /*sq_item*/
34497   0, /*sq_slice*/
34498   0, /*sq_ass_item*/
34499   0, /*sq_ass_slice*/
34500   0, /*sq_contains*/
34501   0, /*sq_inplace_concat*/
34502   0, /*sq_inplace_repeat*/
34503 };
34504
34505 static PyMappingMethods __pyx_tp_as_mapping_SNPCaller = {
34506   0, /*mp_length*/
34507   0, /*mp_subscript*/
34508   0, /*mp_ass_subscript*/
34509 };
34510
34511 static PyBufferProcs __pyx_tp_as_buffer_SNPCaller = {
34512   #if PY_MAJOR_VERSION < 3
34513   0, /*bf_getreadbuffer*/
34514   #endif
34515   #if PY_MAJOR_VERSION < 3
34516   0, /*bf_getwritebuffer*/
34517   #endif
34518   #if PY_MAJOR_VERSION < 3
34519   0, /*bf_getsegcount*/
34520   #endif
34521   #if PY_MAJOR_VERSION < 3
34522   0, /*bf_getcharbuffer*/
34523   #endif
34524   #if PY_VERSION_HEX >= 0x02060000
34525   0, /*bf_getbuffer*/
34526   #endif
34527   #if PY_VERSION_HEX >= 0x02060000
34528   0, /*bf_releasebuffer*/
34529   #endif
34530 };
34531
34532 PyTypeObject __pyx_type_9csamtools_SNPCaller = {
34533   PyVarObject_HEAD_INIT(0, 0)
34534   __Pyx_NAMESTR("csamtools.SNPCaller"), /*tp_name*/
34535   sizeof(struct __pyx_obj_9csamtools_SNPCaller), /*tp_basicsize*/
34536   0, /*tp_itemsize*/
34537   __pyx_tp_dealloc_9csamtools_SNPCallerBase, /*tp_dealloc*/
34538   0, /*tp_print*/
34539   0, /*tp_getattr*/
34540   0, /*tp_setattr*/
34541   #if PY_MAJOR_VERSION < 3
34542   0, /*tp_compare*/
34543   #else
34544   0, /*reserved*/
34545   #endif
34546   0, /*tp_repr*/
34547   &__pyx_tp_as_number_SNPCaller, /*tp_as_number*/
34548   &__pyx_tp_as_sequence_SNPCaller, /*tp_as_sequence*/
34549   &__pyx_tp_as_mapping_SNPCaller, /*tp_as_mapping*/
34550   0, /*tp_hash*/
34551   0, /*tp_call*/
34552   0, /*tp_str*/
34553   0, /*tp_getattro*/
34554   0, /*tp_setattro*/
34555   &__pyx_tp_as_buffer_SNPCaller, /*tp_as_buffer*/
34556   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
34557   __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*/
34558   __pyx_tp_traverse_9csamtools_SNPCallerBase, /*tp_traverse*/
34559   __pyx_tp_clear_9csamtools_SNPCallerBase, /*tp_clear*/
34560   0, /*tp_richcompare*/
34561   0, /*tp_weaklistoffset*/
34562   0, /*tp_iter*/
34563   0, /*tp_iternext*/
34564   __pyx_methods_9csamtools_SNPCaller, /*tp_methods*/
34565   0, /*tp_members*/
34566   0, /*tp_getset*/
34567   0, /*tp_base*/
34568   0, /*tp_dict*/
34569   0, /*tp_descr_get*/
34570   0, /*tp_descr_set*/
34571   0, /*tp_dictoffset*/
34572   0, /*tp_init*/
34573   0, /*tp_alloc*/
34574   __pyx_tp_new_9csamtools_SNPCaller, /*tp_new*/
34575   0, /*tp_free*/
34576   0, /*tp_is_gc*/
34577   0, /*tp_bases*/
34578   0, /*tp_mro*/
34579   0, /*tp_cache*/
34580   0, /*tp_subclasses*/
34581   0, /*tp_weaklist*/
34582   0, /*tp_del*/
34583   #if PY_VERSION_HEX >= 0x02060000
34584   0, /*tp_version_tag*/
34585   #endif
34586 };
34587
34588 static PyObject *__pyx_tp_new_9csamtools_IndelCall(PyTypeObject *t, PyObject *a, PyObject *k) {
34589   PyObject *o = (*t->tp_alloc)(t, 0);
34590   if (!o) return 0;
34591   if (__pyx_pf_9csamtools_9IndelCall___cinit__(o, __pyx_empty_tuple, NULL) < 0) {
34592     Py_DECREF(o); o = 0;
34593   }
34594   return o;
34595 }
34596
34597 static void __pyx_tp_dealloc_9csamtools_IndelCall(PyObject *o) {
34598   {
34599     PyObject *etype, *eval, *etb;
34600     PyErr_Fetch(&etype, &eval, &etb);
34601     ++Py_REFCNT(o);
34602     __pyx_pf_9csamtools_9IndelCall___dealloc__(o);
34603     if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
34604     --Py_REFCNT(o);
34605     PyErr_Restore(etype, eval, etb);
34606   }
34607   (*Py_TYPE(o)->tp_free)(o);
34608 }
34609
34610 static PyObject *__pyx_getprop_9csamtools_9IndelCall_tid(PyObject *o, void *x) {
34611   return __pyx_pf_9csamtools_9IndelCall_3tid___get__(o);
34612 }
34613
34614 static PyObject *__pyx_getprop_9csamtools_9IndelCall_pos(PyObject *o, void *x) {
34615   return __pyx_pf_9csamtools_9IndelCall_3pos___get__(o);
34616 }
34617
34618 static PyObject *__pyx_getprop_9csamtools_9IndelCall_genotype(PyObject *o, void *x) {
34619   return __pyx_pf_9csamtools_9IndelCall_8genotype___get__(o);
34620 }
34621
34622 static PyObject *__pyx_getprop_9csamtools_9IndelCall_consensus_quality(PyObject *o, void *x) {
34623   return __pyx_pf_9csamtools_9IndelCall_17consensus_quality___get__(o);
34624 }
34625
34626 static PyObject *__pyx_getprop_9csamtools_9IndelCall_snp_quality(PyObject *o, void *x) {
34627   return __pyx_pf_9csamtools_9IndelCall_11snp_quality___get__(o);
34628 }
34629
34630 static PyObject *__pyx_getprop_9csamtools_9IndelCall_mapping_quality(PyObject *o, void *x) {
34631   return __pyx_pf_9csamtools_9IndelCall_15mapping_quality___get__(o);
34632 }
34633
34634 static PyObject *__pyx_getprop_9csamtools_9IndelCall_coverage(PyObject *o, void *x) {
34635   return __pyx_pf_9csamtools_9IndelCall_8coverage___get__(o);
34636 }
34637
34638 static PyObject *__pyx_getprop_9csamtools_9IndelCall_first_allele(PyObject *o, void *x) {
34639   return __pyx_pf_9csamtools_9IndelCall_12first_allele___get__(o);
34640 }
34641
34642 static PyObject *__pyx_getprop_9csamtools_9IndelCall_second_allele(PyObject *o, void *x) {
34643   return __pyx_pf_9csamtools_9IndelCall_13second_allele___get__(o);
34644 }
34645
34646 static PyObject *__pyx_getprop_9csamtools_9IndelCall_reads_first(PyObject *o, void *x) {
34647   return __pyx_pf_9csamtools_9IndelCall_11reads_first___get__(o);
34648 }
34649
34650 static PyObject *__pyx_getprop_9csamtools_9IndelCall_reads_second(PyObject *o, void *x) {
34651   return __pyx_pf_9csamtools_9IndelCall_12reads_second___get__(o);
34652 }
34653
34654 static PyObject *__pyx_getprop_9csamtools_9IndelCall_reads_diff(PyObject *o, void *x) {
34655   return __pyx_pf_9csamtools_9IndelCall_10reads_diff___get__(o);
34656 }
34657
34658 static PyMethodDef __pyx_methods_9csamtools_IndelCall[] = {
34659   {0, 0, 0, 0}
34660 };
34661
34662 static struct PyGetSetDef __pyx_getsets_9csamtools_IndelCall[] = {
34663   {(char *)"tid", __pyx_getprop_9csamtools_9IndelCall_tid, 0, __Pyx_DOCSTR(__pyx_k_154), 0},
34664   {(char *)"pos", __pyx_getprop_9csamtools_9IndelCall_pos, 0, __Pyx_DOCSTR(__pyx_k_162), 0},
34665   {(char *)"genotype", __pyx_getprop_9csamtools_9IndelCall_genotype, 0, __Pyx_DOCSTR(__pyx_k_164), 0},
34666   {(char *)"consensus_quality", __pyx_getprop_9csamtools_9IndelCall_consensus_quality, 0, __Pyx_DOCSTR(__pyx_k_165), 0},
34667   {(char *)"snp_quality", __pyx_getprop_9csamtools_9IndelCall_snp_quality, 0, __Pyx_DOCSTR(__pyx_k_166), 0},
34668   {(char *)"mapping_quality", __pyx_getprop_9csamtools_9IndelCall_mapping_quality, 0, __Pyx_DOCSTR(__pyx_k_167), 0},
34669   {(char *)"coverage", __pyx_getprop_9csamtools_9IndelCall_coverage, 0, __Pyx_DOCSTR(__pyx_k_168), 0},
34670   {(char *)"first_allele", __pyx_getprop_9csamtools_9IndelCall_first_allele, 0, __Pyx_DOCSTR(__pyx_k_169), 0},
34671   {(char *)"second_allele", __pyx_getprop_9csamtools_9IndelCall_second_allele, 0, __Pyx_DOCSTR(__pyx_k_170), 0},
34672   {(char *)"reads_first", __pyx_getprop_9csamtools_9IndelCall_reads_first, 0, __Pyx_DOCSTR(__pyx_k_171), 0},
34673   {(char *)"reads_second", __pyx_getprop_9csamtools_9IndelCall_reads_second, 0, __Pyx_DOCSTR(__pyx_k_171), 0},
34674   {(char *)"reads_diff", __pyx_getprop_9csamtools_9IndelCall_reads_diff, 0, __Pyx_DOCSTR(__pyx_k_171), 0},
34675   {0, 0, 0, 0, 0}
34676 };
34677
34678 static PyNumberMethods __pyx_tp_as_number_IndelCall = {
34679   0, /*nb_add*/
34680   0, /*nb_subtract*/
34681   0, /*nb_multiply*/
34682   #if PY_MAJOR_VERSION < 3
34683   0, /*nb_divide*/
34684   #endif
34685   0, /*nb_remainder*/
34686   0, /*nb_divmod*/
34687   0, /*nb_power*/
34688   0, /*nb_negative*/
34689   0, /*nb_positive*/
34690   0, /*nb_absolute*/
34691   0, /*nb_nonzero*/
34692   0, /*nb_invert*/
34693   0, /*nb_lshift*/
34694   0, /*nb_rshift*/
34695   0, /*nb_and*/
34696   0, /*nb_xor*/
34697   0, /*nb_or*/
34698   #if PY_MAJOR_VERSION < 3
34699   0, /*nb_coerce*/
34700   #endif
34701   0, /*nb_int*/
34702   #if PY_MAJOR_VERSION < 3
34703   0, /*nb_long*/
34704   #else
34705   0, /*reserved*/
34706   #endif
34707   0, /*nb_float*/
34708   #if PY_MAJOR_VERSION < 3
34709   0, /*nb_oct*/
34710   #endif
34711   #if PY_MAJOR_VERSION < 3
34712   0, /*nb_hex*/
34713   #endif
34714   0, /*nb_inplace_add*/
34715   0, /*nb_inplace_subtract*/
34716   0, /*nb_inplace_multiply*/
34717   #if PY_MAJOR_VERSION < 3
34718   0, /*nb_inplace_divide*/
34719   #endif
34720   0, /*nb_inplace_remainder*/
34721   0, /*nb_inplace_power*/
34722   0, /*nb_inplace_lshift*/
34723   0, /*nb_inplace_rshift*/
34724   0, /*nb_inplace_and*/
34725   0, /*nb_inplace_xor*/
34726   0, /*nb_inplace_or*/
34727   0, /*nb_floor_divide*/
34728   0, /*nb_true_divide*/
34729   0, /*nb_inplace_floor_divide*/
34730   0, /*nb_inplace_true_divide*/
34731   #if PY_VERSION_HEX >= 0x02050000
34732   0, /*nb_index*/
34733   #endif
34734 };
34735
34736 static PySequenceMethods __pyx_tp_as_sequence_IndelCall = {
34737   0, /*sq_length*/
34738   0, /*sq_concat*/
34739   0, /*sq_repeat*/
34740   0, /*sq_item*/
34741   0, /*sq_slice*/
34742   0, /*sq_ass_item*/
34743   0, /*sq_ass_slice*/
34744   0, /*sq_contains*/
34745   0, /*sq_inplace_concat*/
34746   0, /*sq_inplace_repeat*/
34747 };
34748
34749 static PyMappingMethods __pyx_tp_as_mapping_IndelCall = {
34750   0, /*mp_length*/
34751   0, /*mp_subscript*/
34752   0, /*mp_ass_subscript*/
34753 };
34754
34755 static PyBufferProcs __pyx_tp_as_buffer_IndelCall = {
34756   #if PY_MAJOR_VERSION < 3
34757   0, /*bf_getreadbuffer*/
34758   #endif
34759   #if PY_MAJOR_VERSION < 3
34760   0, /*bf_getwritebuffer*/
34761   #endif
34762   #if PY_MAJOR_VERSION < 3
34763   0, /*bf_getsegcount*/
34764   #endif
34765   #if PY_MAJOR_VERSION < 3
34766   0, /*bf_getcharbuffer*/
34767   #endif
34768   #if PY_VERSION_HEX >= 0x02060000
34769   0, /*bf_getbuffer*/
34770   #endif
34771   #if PY_VERSION_HEX >= 0x02060000
34772   0, /*bf_releasebuffer*/
34773   #endif
34774 };
34775
34776 PyTypeObject __pyx_type_9csamtools_IndelCall = {
34777   PyVarObject_HEAD_INIT(0, 0)
34778   __Pyx_NAMESTR("csamtools.IndelCall"), /*tp_name*/
34779   sizeof(struct __pyx_obj_9csamtools_IndelCall), /*tp_basicsize*/
34780   0, /*tp_itemsize*/
34781   __pyx_tp_dealloc_9csamtools_IndelCall, /*tp_dealloc*/
34782   0, /*tp_print*/
34783   0, /*tp_getattr*/
34784   0, /*tp_setattr*/
34785   #if PY_MAJOR_VERSION < 3
34786   0, /*tp_compare*/
34787   #else
34788   0, /*reserved*/
34789   #endif
34790   0, /*tp_repr*/
34791   &__pyx_tp_as_number_IndelCall, /*tp_as_number*/
34792   &__pyx_tp_as_sequence_IndelCall, /*tp_as_sequence*/
34793   &__pyx_tp_as_mapping_IndelCall, /*tp_as_mapping*/
34794   0, /*tp_hash*/
34795   0, /*tp_call*/
34796   __pyx_pf_9csamtools_9IndelCall___str__, /*tp_str*/
34797   0, /*tp_getattro*/
34798   0, /*tp_setattro*/
34799   &__pyx_tp_as_buffer_IndelCall, /*tp_as_buffer*/
34800   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
34801   __Pyx_DOCSTR("the results of an indel call."), /*tp_doc*/
34802   0, /*tp_traverse*/
34803   0, /*tp_clear*/
34804   0, /*tp_richcompare*/
34805   0, /*tp_weaklistoffset*/
34806   0, /*tp_iter*/
34807   0, /*tp_iternext*/
34808   __pyx_methods_9csamtools_IndelCall, /*tp_methods*/
34809   0, /*tp_members*/
34810   __pyx_getsets_9csamtools_IndelCall, /*tp_getset*/
34811   0, /*tp_base*/
34812   0, /*tp_dict*/
34813   0, /*tp_descr_get*/
34814   0, /*tp_descr_set*/
34815   0, /*tp_dictoffset*/
34816   0, /*tp_init*/
34817   0, /*tp_alloc*/
34818   __pyx_tp_new_9csamtools_IndelCall, /*tp_new*/
34819   0, /*tp_free*/
34820   0, /*tp_is_gc*/
34821   0, /*tp_bases*/
34822   0, /*tp_mro*/
34823   0, /*tp_cache*/
34824   0, /*tp_subclasses*/
34825   0, /*tp_weaklist*/
34826   0, /*tp_del*/
34827   #if PY_VERSION_HEX >= 0x02060000
34828   0, /*tp_version_tag*/
34829   #endif
34830 };
34831
34832 static PyObject *__pyx_tp_new_9csamtools_IndelCallerBase(PyTypeObject *t, PyObject *a, PyObject *k) {
34833   struct __pyx_obj_9csamtools_IndelCallerBase *p;
34834   PyObject *o = (*t->tp_alloc)(t, 0);
34835   if (!o) return 0;
34836   p = ((struct __pyx_obj_9csamtools_IndelCallerBase *)o);
34837   p->iter = ((struct __pyx_obj_9csamtools_IteratorColumn *)Py_None); Py_INCREF(Py_None);
34838   if (__pyx_pf_9csamtools_15IndelCallerBase___cinit__(o, a, k) < 0) {
34839     Py_DECREF(o); o = 0;
34840   }
34841   return o;
34842 }
34843
34844 static void __pyx_tp_dealloc_9csamtools_IndelCallerBase(PyObject *o) {
34845   struct __pyx_obj_9csamtools_IndelCallerBase *p = (struct __pyx_obj_9csamtools_IndelCallerBase *)o;
34846   {
34847     PyObject *etype, *eval, *etb;
34848     PyErr_Fetch(&etype, &eval, &etb);
34849     ++Py_REFCNT(o);
34850     __pyx_pf_9csamtools_15IndelCallerBase___dealloc__(o);
34851     if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
34852     --Py_REFCNT(o);
34853     PyErr_Restore(etype, eval, etb);
34854   }
34855   Py_XDECREF(((PyObject *)p->iter));
34856   (*Py_TYPE(o)->tp_free)(o);
34857 }
34858
34859 static int __pyx_tp_traverse_9csamtools_IndelCallerBase(PyObject *o, visitproc v, void *a) {
34860   int e;
34861   struct __pyx_obj_9csamtools_IndelCallerBase *p = (struct __pyx_obj_9csamtools_IndelCallerBase *)o;
34862   if (p->iter) {
34863     e = (*v)(((PyObject*)p->iter), a); if (e) return e;
34864   }
34865   return 0;
34866 }
34867
34868 static int __pyx_tp_clear_9csamtools_IndelCallerBase(PyObject *o) {
34869   struct __pyx_obj_9csamtools_IndelCallerBase *p = (struct __pyx_obj_9csamtools_IndelCallerBase *)o;
34870   PyObject* tmp;
34871   tmp = ((PyObject*)p->iter);
34872   p->iter = ((struct __pyx_obj_9csamtools_IteratorColumn *)Py_None); Py_INCREF(Py_None);
34873   Py_XDECREF(tmp);
34874   return 0;
34875 }
34876
34877 static PyMethodDef __pyx_methods_9csamtools_IndelCallerBase[] = {
34878   {__Pyx_NAMESTR("_call"), (PyCFunction)__pyx_pf_9csamtools_15IndelCallerBase__call, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_15IndelCallerBase__call)},
34879   {0, 0, 0, 0}
34880 };
34881
34882 static PyNumberMethods __pyx_tp_as_number_IndelCallerBase = {
34883   0, /*nb_add*/
34884   0, /*nb_subtract*/
34885   0, /*nb_multiply*/
34886   #if PY_MAJOR_VERSION < 3
34887   0, /*nb_divide*/
34888   #endif
34889   0, /*nb_remainder*/
34890   0, /*nb_divmod*/
34891   0, /*nb_power*/
34892   0, /*nb_negative*/
34893   0, /*nb_positive*/
34894   0, /*nb_absolute*/
34895   0, /*nb_nonzero*/
34896   0, /*nb_invert*/
34897   0, /*nb_lshift*/
34898   0, /*nb_rshift*/
34899   0, /*nb_and*/
34900   0, /*nb_xor*/
34901   0, /*nb_or*/
34902   #if PY_MAJOR_VERSION < 3
34903   0, /*nb_coerce*/
34904   #endif
34905   0, /*nb_int*/
34906   #if PY_MAJOR_VERSION < 3
34907   0, /*nb_long*/
34908   #else
34909   0, /*reserved*/
34910   #endif
34911   0, /*nb_float*/
34912   #if PY_MAJOR_VERSION < 3
34913   0, /*nb_oct*/
34914   #endif
34915   #if PY_MAJOR_VERSION < 3
34916   0, /*nb_hex*/
34917   #endif
34918   0, /*nb_inplace_add*/
34919   0, /*nb_inplace_subtract*/
34920   0, /*nb_inplace_multiply*/
34921   #if PY_MAJOR_VERSION < 3
34922   0, /*nb_inplace_divide*/
34923   #endif
34924   0, /*nb_inplace_remainder*/
34925   0, /*nb_inplace_power*/
34926   0, /*nb_inplace_lshift*/
34927   0, /*nb_inplace_rshift*/
34928   0, /*nb_inplace_and*/
34929   0, /*nb_inplace_xor*/
34930   0, /*nb_inplace_or*/
34931   0, /*nb_floor_divide*/
34932   0, /*nb_true_divide*/
34933   0, /*nb_inplace_floor_divide*/
34934   0, /*nb_inplace_true_divide*/
34935   #if PY_VERSION_HEX >= 0x02050000
34936   0, /*nb_index*/
34937   #endif
34938 };
34939
34940 static PySequenceMethods __pyx_tp_as_sequence_IndelCallerBase = {
34941   0, /*sq_length*/
34942   0, /*sq_concat*/
34943   0, /*sq_repeat*/
34944   0, /*sq_item*/
34945   0, /*sq_slice*/
34946   0, /*sq_ass_item*/
34947   0, /*sq_ass_slice*/
34948   0, /*sq_contains*/
34949   0, /*sq_inplace_concat*/
34950   0, /*sq_inplace_repeat*/
34951 };
34952
34953 static PyMappingMethods __pyx_tp_as_mapping_IndelCallerBase = {
34954   0, /*mp_length*/
34955   0, /*mp_subscript*/
34956   0, /*mp_ass_subscript*/
34957 };
34958
34959 static PyBufferProcs __pyx_tp_as_buffer_IndelCallerBase = {
34960   #if PY_MAJOR_VERSION < 3
34961   0, /*bf_getreadbuffer*/
34962   #endif
34963   #if PY_MAJOR_VERSION < 3
34964   0, /*bf_getwritebuffer*/
34965   #endif
34966   #if PY_MAJOR_VERSION < 3
34967   0, /*bf_getsegcount*/
34968   #endif
34969   #if PY_MAJOR_VERSION < 3
34970   0, /*bf_getcharbuffer*/
34971   #endif
34972   #if PY_VERSION_HEX >= 0x02060000
34973   0, /*bf_getbuffer*/
34974   #endif
34975   #if PY_VERSION_HEX >= 0x02060000
34976   0, /*bf_releasebuffer*/
34977   #endif
34978 };
34979
34980 PyTypeObject __pyx_type_9csamtools_IndelCallerBase = {
34981   PyVarObject_HEAD_INIT(0, 0)
34982   __Pyx_NAMESTR("csamtools.IndelCallerBase"), /*tp_name*/
34983   sizeof(struct __pyx_obj_9csamtools_IndelCallerBase), /*tp_basicsize*/
34984   0, /*tp_itemsize*/
34985   __pyx_tp_dealloc_9csamtools_IndelCallerBase, /*tp_dealloc*/
34986   0, /*tp_print*/
34987   0, /*tp_getattr*/
34988   0, /*tp_setattr*/
34989   #if PY_MAJOR_VERSION < 3
34990   0, /*tp_compare*/
34991   #else
34992   0, /*reserved*/
34993   #endif
34994   0, /*tp_repr*/
34995   &__pyx_tp_as_number_IndelCallerBase, /*tp_as_number*/
34996   &__pyx_tp_as_sequence_IndelCallerBase, /*tp_as_sequence*/
34997   &__pyx_tp_as_mapping_IndelCallerBase, /*tp_as_mapping*/
34998   0, /*tp_hash*/
34999   0, /*tp_call*/
35000   0, /*tp_str*/
35001   0, /*tp_getattro*/
35002   0, /*tp_setattro*/
35003   &__pyx_tp_as_buffer_IndelCallerBase, /*tp_as_buffer*/
35004   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
35005   __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*/
35006   __pyx_tp_traverse_9csamtools_IndelCallerBase, /*tp_traverse*/
35007   __pyx_tp_clear_9csamtools_IndelCallerBase, /*tp_clear*/
35008   0, /*tp_richcompare*/
35009   0, /*tp_weaklistoffset*/
35010   0, /*tp_iter*/
35011   0, /*tp_iternext*/
35012   __pyx_methods_9csamtools_IndelCallerBase, /*tp_methods*/
35013   0, /*tp_members*/
35014   0, /*tp_getset*/
35015   0, /*tp_base*/
35016   0, /*tp_dict*/
35017   0, /*tp_descr_get*/
35018   0, /*tp_descr_set*/
35019   0, /*tp_dictoffset*/
35020   0, /*tp_init*/
35021   0, /*tp_alloc*/
35022   __pyx_tp_new_9csamtools_IndelCallerBase, /*tp_new*/
35023   0, /*tp_free*/
35024   0, /*tp_is_gc*/
35025   0, /*tp_bases*/
35026   0, /*tp_mro*/
35027   0, /*tp_cache*/
35028   0, /*tp_subclasses*/
35029   0, /*tp_weaklist*/
35030   0, /*tp_del*/
35031   #if PY_VERSION_HEX >= 0x02060000
35032   0, /*tp_version_tag*/
35033   #endif
35034 };
35035
35036 static PyObject *__pyx_tp_new_9csamtools_IndelCaller(PyTypeObject *t, PyObject *a, PyObject *k) {
35037   PyObject *o = __pyx_tp_new_9csamtools_IndelCallerBase(t, a, k);
35038   if (!o) return 0;
35039   if (__pyx_pf_9csamtools_11IndelCaller___cinit__(o, a, k) < 0) {
35040     Py_DECREF(o); o = 0;
35041   }
35042   return o;
35043 }
35044
35045 static PyMethodDef __pyx_methods_9csamtools_IndelCaller[] = {
35046   {__Pyx_NAMESTR("call"), (PyCFunction)__pyx_pf_9csamtools_11IndelCaller_call, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools_11IndelCaller_call)},
35047   {0, 0, 0, 0}
35048 };
35049
35050 static PyNumberMethods __pyx_tp_as_number_IndelCaller = {
35051   0, /*nb_add*/
35052   0, /*nb_subtract*/
35053   0, /*nb_multiply*/
35054   #if PY_MAJOR_VERSION < 3
35055   0, /*nb_divide*/
35056   #endif
35057   0, /*nb_remainder*/
35058   0, /*nb_divmod*/
35059   0, /*nb_power*/
35060   0, /*nb_negative*/
35061   0, /*nb_positive*/
35062   0, /*nb_absolute*/
35063   0, /*nb_nonzero*/
35064   0, /*nb_invert*/
35065   0, /*nb_lshift*/
35066   0, /*nb_rshift*/
35067   0, /*nb_and*/
35068   0, /*nb_xor*/
35069   0, /*nb_or*/
35070   #if PY_MAJOR_VERSION < 3
35071   0, /*nb_coerce*/
35072   #endif
35073   0, /*nb_int*/
35074   #if PY_MAJOR_VERSION < 3
35075   0, /*nb_long*/
35076   #else
35077   0, /*reserved*/
35078   #endif
35079   0, /*nb_float*/
35080   #if PY_MAJOR_VERSION < 3
35081   0, /*nb_oct*/
35082   #endif
35083   #if PY_MAJOR_VERSION < 3
35084   0, /*nb_hex*/
35085   #endif
35086   0, /*nb_inplace_add*/
35087   0, /*nb_inplace_subtract*/
35088   0, /*nb_inplace_multiply*/
35089   #if PY_MAJOR_VERSION < 3
35090   0, /*nb_inplace_divide*/
35091   #endif
35092   0, /*nb_inplace_remainder*/
35093   0, /*nb_inplace_power*/
35094   0, /*nb_inplace_lshift*/
35095   0, /*nb_inplace_rshift*/
35096   0, /*nb_inplace_and*/
35097   0, /*nb_inplace_xor*/
35098   0, /*nb_inplace_or*/
35099   0, /*nb_floor_divide*/
35100   0, /*nb_true_divide*/
35101   0, /*nb_inplace_floor_divide*/
35102   0, /*nb_inplace_true_divide*/
35103   #if PY_VERSION_HEX >= 0x02050000
35104   0, /*nb_index*/
35105   #endif
35106 };
35107
35108 static PySequenceMethods __pyx_tp_as_sequence_IndelCaller = {
35109   0, /*sq_length*/
35110   0, /*sq_concat*/
35111   0, /*sq_repeat*/
35112   0, /*sq_item*/
35113   0, /*sq_slice*/
35114   0, /*sq_ass_item*/
35115   0, /*sq_ass_slice*/
35116   0, /*sq_contains*/
35117   0, /*sq_inplace_concat*/
35118   0, /*sq_inplace_repeat*/
35119 };
35120
35121 static PyMappingMethods __pyx_tp_as_mapping_IndelCaller = {
35122   0, /*mp_length*/
35123   0, /*mp_subscript*/
35124   0, /*mp_ass_subscript*/
35125 };
35126
35127 static PyBufferProcs __pyx_tp_as_buffer_IndelCaller = {
35128   #if PY_MAJOR_VERSION < 3
35129   0, /*bf_getreadbuffer*/
35130   #endif
35131   #if PY_MAJOR_VERSION < 3
35132   0, /*bf_getwritebuffer*/
35133   #endif
35134   #if PY_MAJOR_VERSION < 3
35135   0, /*bf_getsegcount*/
35136   #endif
35137   #if PY_MAJOR_VERSION < 3
35138   0, /*bf_getcharbuffer*/
35139   #endif
35140   #if PY_VERSION_HEX >= 0x02060000
35141   0, /*bf_getbuffer*/
35142   #endif
35143   #if PY_VERSION_HEX >= 0x02060000
35144   0, /*bf_releasebuffer*/
35145   #endif
35146 };
35147
35148 PyTypeObject __pyx_type_9csamtools_IndelCaller = {
35149   PyVarObject_HEAD_INIT(0, 0)
35150   __Pyx_NAMESTR("csamtools.IndelCaller"), /*tp_name*/
35151   sizeof(struct __pyx_obj_9csamtools_IndelCaller), /*tp_basicsize*/
35152   0, /*tp_itemsize*/
35153   __pyx_tp_dealloc_9csamtools_IndelCallerBase, /*tp_dealloc*/
35154   0, /*tp_print*/
35155   0, /*tp_getattr*/
35156   0, /*tp_setattr*/
35157   #if PY_MAJOR_VERSION < 3
35158   0, /*tp_compare*/
35159   #else
35160   0, /*reserved*/
35161   #endif
35162   0, /*tp_repr*/
35163   &__pyx_tp_as_number_IndelCaller, /*tp_as_number*/
35164   &__pyx_tp_as_sequence_IndelCaller, /*tp_as_sequence*/
35165   &__pyx_tp_as_mapping_IndelCaller, /*tp_as_mapping*/
35166   0, /*tp_hash*/
35167   0, /*tp_call*/
35168   0, /*tp_str*/
35169   0, /*tp_getattro*/
35170   0, /*tp_setattro*/
35171   &__pyx_tp_as_buffer_IndelCaller, /*tp_as_buffer*/
35172   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
35173   __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*/
35174   __pyx_tp_traverse_9csamtools_IndelCallerBase, /*tp_traverse*/
35175   __pyx_tp_clear_9csamtools_IndelCallerBase, /*tp_clear*/
35176   0, /*tp_richcompare*/
35177   0, /*tp_weaklistoffset*/
35178   0, /*tp_iter*/
35179   0, /*tp_iternext*/
35180   __pyx_methods_9csamtools_IndelCaller, /*tp_methods*/
35181   0, /*tp_members*/
35182   0, /*tp_getset*/
35183   0, /*tp_base*/
35184   0, /*tp_dict*/
35185   0, /*tp_descr_get*/
35186   0, /*tp_descr_set*/
35187   0, /*tp_dictoffset*/
35188   0, /*tp_init*/
35189   0, /*tp_alloc*/
35190   __pyx_tp_new_9csamtools_IndelCaller, /*tp_new*/
35191   0, /*tp_free*/
35192   0, /*tp_is_gc*/
35193   0, /*tp_bases*/
35194   0, /*tp_mro*/
35195   0, /*tp_cache*/
35196   0, /*tp_subclasses*/
35197   0, /*tp_weaklist*/
35198   0, /*tp_del*/
35199   #if PY_VERSION_HEX >= 0x02060000
35200   0, /*tp_version_tag*/
35201   #endif
35202 };
35203
35204 static PyObject *__pyx_tp_new_9csamtools_IteratorIndelCalls(PyTypeObject *t, PyObject *a, PyObject *k) {
35205   PyObject *o = __pyx_tp_new_9csamtools_IndelCallerBase(t, a, k);
35206   if (!o) return 0;
35207   if (__pyx_pf_9csamtools_18IteratorIndelCalls___cinit__(o, a, k) < 0) {
35208     Py_DECREF(o); o = 0;
35209   }
35210   return o;
35211 }
35212
35213 static PyMethodDef __pyx_methods_9csamtools_IteratorIndelCalls[] = {
35214   {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_9csamtools_18IteratorIndelCalls___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_9csamtools_18IteratorIndelCalls___next__)},
35215   {0, 0, 0, 0}
35216 };
35217
35218 static PyNumberMethods __pyx_tp_as_number_IteratorIndelCalls = {
35219   0, /*nb_add*/
35220   0, /*nb_subtract*/
35221   0, /*nb_multiply*/
35222   #if PY_MAJOR_VERSION < 3
35223   0, /*nb_divide*/
35224   #endif
35225   0, /*nb_remainder*/
35226   0, /*nb_divmod*/
35227   0, /*nb_power*/
35228   0, /*nb_negative*/
35229   0, /*nb_positive*/
35230   0, /*nb_absolute*/
35231   0, /*nb_nonzero*/
35232   0, /*nb_invert*/
35233   0, /*nb_lshift*/
35234   0, /*nb_rshift*/
35235   0, /*nb_and*/
35236   0, /*nb_xor*/
35237   0, /*nb_or*/
35238   #if PY_MAJOR_VERSION < 3
35239   0, /*nb_coerce*/
35240   #endif
35241   0, /*nb_int*/
35242   #if PY_MAJOR_VERSION < 3
35243   0, /*nb_long*/
35244   #else
35245   0, /*reserved*/
35246   #endif
35247   0, /*nb_float*/
35248   #if PY_MAJOR_VERSION < 3
35249   0, /*nb_oct*/
35250   #endif
35251   #if PY_MAJOR_VERSION < 3
35252   0, /*nb_hex*/
35253   #endif
35254   0, /*nb_inplace_add*/
35255   0, /*nb_inplace_subtract*/
35256   0, /*nb_inplace_multiply*/
35257   #if PY_MAJOR_VERSION < 3
35258   0, /*nb_inplace_divide*/
35259   #endif
35260   0, /*nb_inplace_remainder*/
35261   0, /*nb_inplace_power*/
35262   0, /*nb_inplace_lshift*/
35263   0, /*nb_inplace_rshift*/
35264   0, /*nb_inplace_and*/
35265   0, /*nb_inplace_xor*/
35266   0, /*nb_inplace_or*/
35267   0, /*nb_floor_divide*/
35268   0, /*nb_true_divide*/
35269   0, /*nb_inplace_floor_divide*/
35270   0, /*nb_inplace_true_divide*/
35271   #if PY_VERSION_HEX >= 0x02050000
35272   0, /*nb_index*/
35273   #endif
35274 };
35275
35276 static PySequenceMethods __pyx_tp_as_sequence_IteratorIndelCalls = {
35277   0, /*sq_length*/
35278   0, /*sq_concat*/
35279   0, /*sq_repeat*/
35280   0, /*sq_item*/
35281   0, /*sq_slice*/
35282   0, /*sq_ass_item*/
35283   0, /*sq_ass_slice*/
35284   0, /*sq_contains*/
35285   0, /*sq_inplace_concat*/
35286   0, /*sq_inplace_repeat*/
35287 };
35288
35289 static PyMappingMethods __pyx_tp_as_mapping_IteratorIndelCalls = {
35290   0, /*mp_length*/
35291   0, /*mp_subscript*/
35292   0, /*mp_ass_subscript*/
35293 };
35294
35295 static PyBufferProcs __pyx_tp_as_buffer_IteratorIndelCalls = {
35296   #if PY_MAJOR_VERSION < 3
35297   0, /*bf_getreadbuffer*/
35298   #endif
35299   #if PY_MAJOR_VERSION < 3
35300   0, /*bf_getwritebuffer*/
35301   #endif
35302   #if PY_MAJOR_VERSION < 3
35303   0, /*bf_getsegcount*/
35304   #endif
35305   #if PY_MAJOR_VERSION < 3
35306   0, /*bf_getcharbuffer*/
35307   #endif
35308   #if PY_VERSION_HEX >= 0x02060000
35309   0, /*bf_getbuffer*/
35310   #endif
35311   #if PY_VERSION_HEX >= 0x02060000
35312   0, /*bf_releasebuffer*/
35313   #endif
35314 };
35315
35316 PyTypeObject __pyx_type_9csamtools_IteratorIndelCalls = {
35317   PyVarObject_HEAD_INIT(0, 0)
35318   __Pyx_NAMESTR("csamtools.IteratorIndelCalls"), /*tp_name*/
35319   sizeof(struct __pyx_obj_9csamtools_IteratorIndelCalls), /*tp_basicsize*/
35320   0, /*tp_itemsize*/
35321   __pyx_tp_dealloc_9csamtools_IndelCallerBase, /*tp_dealloc*/
35322   0, /*tp_print*/
35323   0, /*tp_getattr*/
35324   0, /*tp_setattr*/
35325   #if PY_MAJOR_VERSION < 3
35326   0, /*tp_compare*/
35327   #else
35328   0, /*reserved*/
35329   #endif
35330   0, /*tp_repr*/
35331   &__pyx_tp_as_number_IteratorIndelCalls, /*tp_as_number*/
35332   &__pyx_tp_as_sequence_IteratorIndelCalls, /*tp_as_sequence*/
35333   &__pyx_tp_as_mapping_IteratorIndelCalls, /*tp_as_mapping*/
35334   0, /*tp_hash*/
35335   0, /*tp_call*/
35336   0, /*tp_str*/
35337   0, /*tp_getattro*/
35338   0, /*tp_setattro*/
35339   &__pyx_tp_as_buffer_IteratorIndelCalls, /*tp_as_buffer*/
35340   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
35341   __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*/
35342   __pyx_tp_traverse_9csamtools_IndelCallerBase, /*tp_traverse*/
35343   __pyx_tp_clear_9csamtools_IndelCallerBase, /*tp_clear*/
35344   0, /*tp_richcompare*/
35345   0, /*tp_weaklistoffset*/
35346   __pyx_pf_9csamtools_18IteratorIndelCalls___iter__, /*tp_iter*/
35347   __pyx_pf_9csamtools_18IteratorIndelCalls___next__, /*tp_iternext*/
35348   __pyx_methods_9csamtools_IteratorIndelCalls, /*tp_methods*/
35349   0, /*tp_members*/
35350   0, /*tp_getset*/
35351   0, /*tp_base*/
35352   0, /*tp_dict*/
35353   0, /*tp_descr_get*/
35354   0, /*tp_descr_set*/
35355   0, /*tp_dictoffset*/
35356   0, /*tp_init*/
35357   0, /*tp_alloc*/
35358   __pyx_tp_new_9csamtools_IteratorIndelCalls, /*tp_new*/
35359   0, /*tp_free*/
35360   0, /*tp_is_gc*/
35361   0, /*tp_bases*/
35362   0, /*tp_mro*/
35363   0, /*tp_cache*/
35364   0, /*tp_subclasses*/
35365   0, /*tp_weaklist*/
35366   0, /*tp_del*/
35367   #if PY_VERSION_HEX >= 0x02060000
35368   0, /*tp_version_tag*/
35369   #endif
35370 };
35371
35372 static PyObject *__pyx_tp_new_9csamtools_IndexedReads(PyTypeObject *t, PyObject *a, PyObject *k) {
35373   struct __pyx_obj_9csamtools_IndexedReads *p;
35374   PyObject *o = (*t->tp_alloc)(t, 0);
35375   if (!o) return 0;
35376   p = ((struct __pyx_obj_9csamtools_IndexedReads *)o);
35377   p->samfile = ((struct __pyx_obj_9csamtools_Samfile *)Py_None); Py_INCREF(Py_None);
35378   p->index = Py_None; Py_INCREF(Py_None);
35379   return o;
35380 }
35381
35382 static void __pyx_tp_dealloc_9csamtools_IndexedReads(PyObject *o) {
35383   struct __pyx_obj_9csamtools_IndexedReads *p = (struct __pyx_obj_9csamtools_IndexedReads *)o;
35384   {
35385     PyObject *etype, *eval, *etb;
35386     PyErr_Fetch(&etype, &eval, &etb);
35387     ++Py_REFCNT(o);
35388     __pyx_pf_9csamtools_12IndexedReads___dealloc__(o);
35389     if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
35390     --Py_REFCNT(o);
35391     PyErr_Restore(etype, eval, etb);
35392   }
35393   Py_XDECREF(((PyObject *)p->samfile));
35394   Py_XDECREF(p->index);
35395   (*Py_TYPE(o)->tp_free)(o);
35396 }
35397
35398 static int __pyx_tp_traverse_9csamtools_IndexedReads(PyObject *o, visitproc v, void *a) {
35399   int e;
35400   struct __pyx_obj_9csamtools_IndexedReads *p = (struct __pyx_obj_9csamtools_IndexedReads *)o;
35401   if (p->samfile) {
35402     e = (*v)(((PyObject*)p->samfile), a); if (e) return e;
35403   }
35404   if (p->index) {
35405     e = (*v)(p->index, a); if (e) return e;
35406   }
35407   return 0;
35408 }
35409
35410 static int __pyx_tp_clear_9csamtools_IndexedReads(PyObject *o) {
35411   struct __pyx_obj_9csamtools_IndexedReads *p = (struct __pyx_obj_9csamtools_IndexedReads *)o;
35412   PyObject* tmp;
35413   tmp = ((PyObject*)p->samfile);
35414   p->samfile = ((struct __pyx_obj_9csamtools_Samfile *)Py_None); Py_INCREF(Py_None);
35415   Py_XDECREF(tmp);
35416   tmp = ((PyObject*)p->index);
35417   p->index = Py_None; Py_INCREF(Py_None);
35418   Py_XDECREF(tmp);
35419   return 0;
35420 }
35421
35422 static PyMethodDef __pyx_methods_9csamtools_IndexedReads[] = {
35423   {__Pyx_NAMESTR("build"), (PyCFunction)__pyx_pf_9csamtools_12IndexedReads_build, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_9csamtools_12IndexedReads_build)},
35424   {__Pyx_NAMESTR("find"), (PyCFunction)__pyx_pf_9csamtools_12IndexedReads_find, METH_O, __Pyx_DOCSTR(__pyx_doc_9csamtools_12IndexedReads_find)},
35425   {0, 0, 0, 0}
35426 };
35427
35428 static PyNumberMethods __pyx_tp_as_number_IndexedReads = {
35429   0, /*nb_add*/
35430   0, /*nb_subtract*/
35431   0, /*nb_multiply*/
35432   #if PY_MAJOR_VERSION < 3
35433   0, /*nb_divide*/
35434   #endif
35435   0, /*nb_remainder*/
35436   0, /*nb_divmod*/
35437   0, /*nb_power*/
35438   0, /*nb_negative*/
35439   0, /*nb_positive*/
35440   0, /*nb_absolute*/
35441   0, /*nb_nonzero*/
35442   0, /*nb_invert*/
35443   0, /*nb_lshift*/
35444   0, /*nb_rshift*/
35445   0, /*nb_and*/
35446   0, /*nb_xor*/
35447   0, /*nb_or*/
35448   #if PY_MAJOR_VERSION < 3
35449   0, /*nb_coerce*/
35450   #endif
35451   0, /*nb_int*/
35452   #if PY_MAJOR_VERSION < 3
35453   0, /*nb_long*/
35454   #else
35455   0, /*reserved*/
35456   #endif
35457   0, /*nb_float*/
35458   #if PY_MAJOR_VERSION < 3
35459   0, /*nb_oct*/
35460   #endif
35461   #if PY_MAJOR_VERSION < 3
35462   0, /*nb_hex*/
35463   #endif
35464   0, /*nb_inplace_add*/
35465   0, /*nb_inplace_subtract*/
35466   0, /*nb_inplace_multiply*/
35467   #if PY_MAJOR_VERSION < 3
35468   0, /*nb_inplace_divide*/
35469   #endif
35470   0, /*nb_inplace_remainder*/
35471   0, /*nb_inplace_power*/
35472   0, /*nb_inplace_lshift*/
35473   0, /*nb_inplace_rshift*/
35474   0, /*nb_inplace_and*/
35475   0, /*nb_inplace_xor*/
35476   0, /*nb_inplace_or*/
35477   0, /*nb_floor_divide*/
35478   0, /*nb_true_divide*/
35479   0, /*nb_inplace_floor_divide*/
35480   0, /*nb_inplace_true_divide*/
35481   #if PY_VERSION_HEX >= 0x02050000
35482   0, /*nb_index*/
35483   #endif
35484 };
35485
35486 static PySequenceMethods __pyx_tp_as_sequence_IndexedReads = {
35487   0, /*sq_length*/
35488   0, /*sq_concat*/
35489   0, /*sq_repeat*/
35490   0, /*sq_item*/
35491   0, /*sq_slice*/
35492   0, /*sq_ass_item*/
35493   0, /*sq_ass_slice*/
35494   0, /*sq_contains*/
35495   0, /*sq_inplace_concat*/
35496   0, /*sq_inplace_repeat*/
35497 };
35498
35499 static PyMappingMethods __pyx_tp_as_mapping_IndexedReads = {
35500   0, /*mp_length*/
35501   0, /*mp_subscript*/
35502   0, /*mp_ass_subscript*/
35503 };
35504
35505 static PyBufferProcs __pyx_tp_as_buffer_IndexedReads = {
35506   #if PY_MAJOR_VERSION < 3
35507   0, /*bf_getreadbuffer*/
35508   #endif
35509   #if PY_MAJOR_VERSION < 3
35510   0, /*bf_getwritebuffer*/
35511   #endif
35512   #if PY_MAJOR_VERSION < 3
35513   0, /*bf_getsegcount*/
35514   #endif
35515   #if PY_MAJOR_VERSION < 3
35516   0, /*bf_getcharbuffer*/
35517   #endif
35518   #if PY_VERSION_HEX >= 0x02060000
35519   0, /*bf_getbuffer*/
35520   #endif
35521   #if PY_VERSION_HEX >= 0x02060000
35522   0, /*bf_releasebuffer*/
35523   #endif
35524 };
35525
35526 PyTypeObject __pyx_type_9csamtools_IndexedReads = {
35527   PyVarObject_HEAD_INIT(0, 0)
35528   __Pyx_NAMESTR("csamtools.IndexedReads"), /*tp_name*/
35529   sizeof(struct __pyx_obj_9csamtools_IndexedReads), /*tp_basicsize*/
35530   0, /*tp_itemsize*/
35531   __pyx_tp_dealloc_9csamtools_IndexedReads, /*tp_dealloc*/
35532   0, /*tp_print*/
35533   0, /*tp_getattr*/
35534   0, /*tp_setattr*/
35535   #if PY_MAJOR_VERSION < 3
35536   0, /*tp_compare*/
35537   #else
35538   0, /*reserved*/
35539   #endif
35540   0, /*tp_repr*/
35541   &__pyx_tp_as_number_IndexedReads, /*tp_as_number*/
35542   &__pyx_tp_as_sequence_IndexedReads, /*tp_as_sequence*/
35543   &__pyx_tp_as_mapping_IndexedReads, /*tp_as_mapping*/
35544   0, /*tp_hash*/
35545   0, /*tp_call*/
35546   0, /*tp_str*/
35547   0, /*tp_getattro*/
35548   0, /*tp_setattro*/
35549   &__pyx_tp_as_buffer_IndexedReads, /*tp_as_buffer*/
35550   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
35551   __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*/
35552   __pyx_tp_traverse_9csamtools_IndexedReads, /*tp_traverse*/
35553   __pyx_tp_clear_9csamtools_IndexedReads, /*tp_clear*/
35554   0, /*tp_richcompare*/
35555   0, /*tp_weaklistoffset*/
35556   0, /*tp_iter*/
35557   0, /*tp_iternext*/
35558   __pyx_methods_9csamtools_IndexedReads, /*tp_methods*/
35559   0, /*tp_members*/
35560   0, /*tp_getset*/
35561   0, /*tp_base*/
35562   0, /*tp_dict*/
35563   0, /*tp_descr_get*/
35564   0, /*tp_descr_set*/
35565   0, /*tp_dictoffset*/
35566   __pyx_pf_9csamtools_12IndexedReads___init__, /*tp_init*/
35567   0, /*tp_alloc*/
35568   __pyx_tp_new_9csamtools_IndexedReads, /*tp_new*/
35569   0, /*tp_free*/
35570   0, /*tp_is_gc*/
35571   0, /*tp_bases*/
35572   0, /*tp_mro*/
35573   0, /*tp_cache*/
35574   0, /*tp_subclasses*/
35575   0, /*tp_weaklist*/
35576   0, /*tp_del*/
35577   #if PY_VERSION_HEX >= 0x02060000
35578   0, /*tp_version_tag*/
35579   #endif
35580 };
35581
35582 static PyMethodDef __pyx_methods[] = {
35583   {__Pyx_NAMESTR("_samtools_dispatch"), (PyCFunction)__pyx_pf_9csamtools__samtools_dispatch, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_9csamtools__samtools_dispatch)},
35584   {0, 0, 0, 0}
35585 };
35586
35587 #if PY_MAJOR_VERSION >= 3
35588 static struct PyModuleDef __pyx_moduledef = {
35589     PyModuleDef_HEAD_INIT,
35590     __Pyx_NAMESTR("csamtools"),
35591     0, /* m_doc */
35592     -1, /* m_size */
35593     __pyx_methods /* m_methods */,
35594     NULL, /* m_reload */
35595     NULL, /* m_traverse */
35596     NULL, /* m_clear */
35597     NULL /* m_free */
35598 };
35599 #endif
35600
35601 static __Pyx_StringTabEntry __pyx_string_tab[] = {
35602   {&__pyx_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0},
35603   {&__pyx_kp_s_10, __pyx_k_10, sizeof(__pyx_k_10), 0, 0, 1, 0},
35604   {&__pyx_kp_s_100, __pyx_k_100, sizeof(__pyx_k_100), 0, 0, 1, 0},
35605   {&__pyx_kp_s_101, __pyx_k_101, sizeof(__pyx_k_101), 0, 0, 1, 0},
35606   {&__pyx_kp_s_102, __pyx_k_102, sizeof(__pyx_k_102), 0, 0, 1, 0},
35607   {&__pyx_n_s_103, __pyx_k_103, sizeof(__pyx_k_103), 0, 0, 1, 1},
35608   {&__pyx_kp_s_104, __pyx_k_104, sizeof(__pyx_k_104), 0, 0, 1, 0},
35609   {&__pyx_kp_s_105, __pyx_k_105, sizeof(__pyx_k_105), 0, 0, 1, 0},
35610   {&__pyx_kp_s_107, __pyx_k_107, sizeof(__pyx_k_107), 0, 0, 1, 0},
35611   {&__pyx_kp_s_108, __pyx_k_108, sizeof(__pyx_k_108), 0, 0, 1, 0},
35612   {&__pyx_kp_s_109, __pyx_k_109, sizeof(__pyx_k_109), 0, 0, 1, 0},
35613   {&__pyx_kp_s_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 0, 1, 0},
35614   {&__pyx_kp_s_110, __pyx_k_110, sizeof(__pyx_k_110), 0, 0, 1, 0},
35615   {&__pyx_kp_s_111, __pyx_k_111, sizeof(__pyx_k_111), 0, 0, 1, 0},
35616   {&__pyx_kp_s_112, __pyx_k_112, sizeof(__pyx_k_112), 0, 0, 1, 0},
35617   {&__pyx_kp_s_113, __pyx_k_113, sizeof(__pyx_k_113), 0, 0, 1, 0},
35618   {&__pyx_kp_s_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 0, 1, 0},
35619   {&__pyx_kp_s_15, __pyx_k_15, sizeof(__pyx_k_15), 0, 0, 1, 0},
35620   {&__pyx_kp_s_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 1, 0},
35621   {&__pyx_kp_s_173, __pyx_k_173, sizeof(__pyx_k_173), 0, 0, 1, 0},
35622   {&__pyx_kp_s_174, __pyx_k_174, sizeof(__pyx_k_174), 0, 0, 1, 0},
35623   {&__pyx_kp_s_175, __pyx_k_175, sizeof(__pyx_k_175), 0, 0, 1, 0},
35624   {&__pyx_kp_s_176, __pyx_k_176, sizeof(__pyx_k_176), 0, 0, 1, 0},
35625   {&__pyx_kp_u_177, __pyx_k_177, sizeof(__pyx_k_177), 0, 1, 0, 0},
35626   {&__pyx_kp_u_178, __pyx_k_178, sizeof(__pyx_k_178), 0, 1, 0, 0},
35627   {&__pyx_kp_u_179, __pyx_k_179, sizeof(__pyx_k_179), 0, 1, 0, 0},
35628   {&__pyx_kp_s_18, __pyx_k_18, sizeof(__pyx_k_18), 0, 0, 1, 0},
35629   {&__pyx_kp_u_180, __pyx_k_180, sizeof(__pyx_k_180), 0, 1, 0, 0},
35630   {&__pyx_kp_u_181, __pyx_k_181, sizeof(__pyx_k_181), 0, 1, 0, 0},
35631   {&__pyx_kp_u_182, __pyx_k_182, sizeof(__pyx_k_182), 0, 1, 0, 0},
35632   {&__pyx_kp_u_183, __pyx_k_183, sizeof(__pyx_k_183), 0, 1, 0, 0},
35633   {&__pyx_kp_u_184, __pyx_k_184, sizeof(__pyx_k_184), 0, 1, 0, 0},
35634   {&__pyx_kp_u_185, __pyx_k_185, sizeof(__pyx_k_185), 0, 1, 0, 0},
35635   {&__pyx_kp_u_186, __pyx_k_186, sizeof(__pyx_k_186), 0, 1, 0, 0},
35636   {&__pyx_kp_u_187, __pyx_k_187, sizeof(__pyx_k_187), 0, 1, 0, 0},
35637   {&__pyx_kp_u_188, __pyx_k_188, sizeof(__pyx_k_188), 0, 1, 0, 0},
35638   {&__pyx_kp_u_189, __pyx_k_189, sizeof(__pyx_k_189), 0, 1, 0, 0},
35639   {&__pyx_kp_s_19, __pyx_k_19, sizeof(__pyx_k_19), 0, 0, 1, 0},
35640   {&__pyx_kp_u_190, __pyx_k_190, sizeof(__pyx_k_190), 0, 1, 0, 0},
35641   {&__pyx_kp_u_191, __pyx_k_191, sizeof(__pyx_k_191), 0, 1, 0, 0},
35642   {&__pyx_kp_u_192, __pyx_k_192, sizeof(__pyx_k_192), 0, 1, 0, 0},
35643   {&__pyx_kp_u_193, __pyx_k_193, sizeof(__pyx_k_193), 0, 1, 0, 0},
35644   {&__pyx_kp_u_194, __pyx_k_194, sizeof(__pyx_k_194), 0, 1, 0, 0},
35645   {&__pyx_kp_u_195, __pyx_k_195, sizeof(__pyx_k_195), 0, 1, 0, 0},
35646   {&__pyx_kp_u_196, __pyx_k_196, sizeof(__pyx_k_196), 0, 1, 0, 0},
35647   {&__pyx_kp_u_197, __pyx_k_197, sizeof(__pyx_k_197), 0, 1, 0, 0},
35648   {&__pyx_kp_u_198, __pyx_k_198, sizeof(__pyx_k_198), 0, 1, 0, 0},
35649   {&__pyx_kp_u_199, __pyx_k_199, sizeof(__pyx_k_199), 0, 1, 0, 0},
35650   {&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0},
35651   {&__pyx_kp_s_20, __pyx_k_20, sizeof(__pyx_k_20), 0, 0, 1, 0},
35652   {&__pyx_n_s_200, __pyx_k_200, sizeof(__pyx_k_200), 0, 0, 1, 1},
35653   {&__pyx_kp_u_201, __pyx_k_201, sizeof(__pyx_k_201), 0, 1, 0, 0},
35654   {&__pyx_kp_u_202, __pyx_k_202, sizeof(__pyx_k_202), 0, 1, 0, 0},
35655   {&__pyx_kp_u_203, __pyx_k_203, sizeof(__pyx_k_203), 0, 1, 0, 0},
35656   {&__pyx_n_s_204, __pyx_k_204, sizeof(__pyx_k_204), 0, 0, 1, 1},
35657   {&__pyx_kp_u_205, __pyx_k_205, sizeof(__pyx_k_205), 0, 1, 0, 0},
35658   {&__pyx_n_s_206, __pyx_k_206, sizeof(__pyx_k_206), 0, 0, 1, 1},
35659   {&__pyx_kp_u_207, __pyx_k_207, sizeof(__pyx_k_207), 0, 1, 0, 0},
35660   {&__pyx_kp_u_208, __pyx_k_208, sizeof(__pyx_k_208), 0, 1, 0, 0},
35661   {&__pyx_kp_u_209, __pyx_k_209, sizeof(__pyx_k_209), 0, 1, 0, 0},
35662   {&__pyx_kp_s_21, __pyx_k_21, sizeof(__pyx_k_21), 0, 0, 1, 0},
35663   {&__pyx_kp_u_210, __pyx_k_210, sizeof(__pyx_k_210), 0, 1, 0, 0},
35664   {&__pyx_kp_u_211, __pyx_k_211, sizeof(__pyx_k_211), 0, 1, 0, 0},
35665   {&__pyx_kp_u_212, __pyx_k_212, sizeof(__pyx_k_212), 0, 1, 0, 0},
35666   {&__pyx_kp_u_213, __pyx_k_213, sizeof(__pyx_k_213), 0, 1, 0, 0},
35667   {&__pyx_kp_u_214, __pyx_k_214, sizeof(__pyx_k_214), 0, 1, 0, 0},
35668   {&__pyx_kp_u_215, __pyx_k_215, sizeof(__pyx_k_215), 0, 1, 0, 0},
35669   {&__pyx_kp_u_216, __pyx_k_216, sizeof(__pyx_k_216), 0, 1, 0, 0},
35670   {&__pyx_kp_u_217, __pyx_k_217, sizeof(__pyx_k_217), 0, 1, 0, 0},
35671   {&__pyx_kp_u_218, __pyx_k_218, sizeof(__pyx_k_218), 0, 1, 0, 0},
35672   {&__pyx_kp_u_219, __pyx_k_219, sizeof(__pyx_k_219), 0, 1, 0, 0},
35673   {&__pyx_kp_s_22, __pyx_k_22, sizeof(__pyx_k_22), 0, 0, 1, 0},
35674   {&__pyx_kp_u_220, __pyx_k_220, sizeof(__pyx_k_220), 0, 1, 0, 0},
35675   {&__pyx_kp_s_23, __pyx_k_23, sizeof(__pyx_k_23), 0, 0, 1, 0},
35676   {&__pyx_kp_s_24, __pyx_k_24, sizeof(__pyx_k_24), 0, 0, 1, 0},
35677   {&__pyx_kp_s_25, __pyx_k_25, sizeof(__pyx_k_25), 0, 0, 1, 0},
35678   {&__pyx_kp_s_26, __pyx_k_26, sizeof(__pyx_k_26), 0, 0, 1, 0},
35679   {&__pyx_kp_s_27, __pyx_k_27, sizeof(__pyx_k_27), 0, 0, 1, 0},
35680   {&__pyx_kp_s_28, __pyx_k_28, sizeof(__pyx_k_28), 0, 0, 1, 0},
35681   {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0},
35682   {&__pyx_kp_s_30, __pyx_k_30, sizeof(__pyx_k_30), 0, 0, 1, 0},
35683   {&__pyx_kp_s_31, __pyx_k_31, sizeof(__pyx_k_31), 0, 0, 1, 0},
35684   {&__pyx_kp_s_32, __pyx_k_32, sizeof(__pyx_k_32), 0, 0, 1, 0},
35685   {&__pyx_kp_s_33, __pyx_k_33, sizeof(__pyx_k_33), 0, 0, 1, 0},
35686   {&__pyx_kp_s_34, __pyx_k_34, sizeof(__pyx_k_34), 0, 0, 1, 0},
35687   {&__pyx_kp_s_35, __pyx_k_35, sizeof(__pyx_k_35), 0, 0, 1, 0},
35688   {&__pyx_kp_s_36, __pyx_k_36, sizeof(__pyx_k_36), 0, 0, 1, 0},
35689   {&__pyx_kp_s_37, __pyx_k_37, sizeof(__pyx_k_37), 0, 0, 1, 0},
35690   {&__pyx_kp_s_38, __pyx_k_38, sizeof(__pyx_k_38), 0, 0, 1, 0},
35691   {&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0},
35692   {&__pyx_kp_s_40, __pyx_k_40, sizeof(__pyx_k_40), 0, 0, 1, 0},
35693   {&__pyx_kp_s_41, __pyx_k_41, sizeof(__pyx_k_41), 0, 0, 1, 0},
35694   {&__pyx_kp_s_42, __pyx_k_42, sizeof(__pyx_k_42), 0, 0, 1, 0},
35695   {&__pyx_kp_s_43, __pyx_k_43, sizeof(__pyx_k_43), 0, 0, 1, 0},
35696   {&__pyx_kp_s_44, __pyx_k_44, sizeof(__pyx_k_44), 0, 0, 1, 0},
35697   {&__pyx_kp_s_45, __pyx_k_45, sizeof(__pyx_k_45), 0, 0, 1, 0},
35698   {&__pyx_kp_s_46, __pyx_k_46, sizeof(__pyx_k_46), 0, 0, 1, 0},
35699   {&__pyx_kp_s_47, __pyx_k_47, sizeof(__pyx_k_47), 0, 0, 1, 0},
35700   {&__pyx_kp_s_48, __pyx_k_48, sizeof(__pyx_k_48), 0, 0, 1, 0},
35701   {&__pyx_kp_s_49, __pyx_k_49, sizeof(__pyx_k_49), 0, 0, 1, 0},
35702   {&__pyx_kp_s_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 0, 1, 0},
35703   {&__pyx_kp_s_50, __pyx_k_50, sizeof(__pyx_k_50), 0, 0, 1, 0},
35704   {&__pyx_kp_s_51, __pyx_k_51, sizeof(__pyx_k_51), 0, 0, 1, 0},
35705   {&__pyx_kp_s_52, __pyx_k_52, sizeof(__pyx_k_52), 0, 0, 1, 0},
35706   {&__pyx_kp_s_53, __pyx_k_53, sizeof(__pyx_k_53), 0, 0, 1, 0},
35707   {&__pyx_kp_s_54, __pyx_k_54, sizeof(__pyx_k_54), 0, 0, 1, 0},
35708   {&__pyx_kp_s_55, __pyx_k_55, sizeof(__pyx_k_55), 0, 0, 1, 0},
35709   {&__pyx_kp_s_56, __pyx_k_56, sizeof(__pyx_k_56), 0, 0, 1, 0},
35710   {&__pyx_kp_s_57, __pyx_k_57, sizeof(__pyx_k_57), 0, 0, 1, 0},
35711   {&__pyx_kp_s_59, __pyx_k_59, sizeof(__pyx_k_59), 0, 0, 1, 0},
35712   {&__pyx_kp_s_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 1, 0},
35713   {&__pyx_kp_s_61, __pyx_k_61, sizeof(__pyx_k_61), 0, 0, 1, 0},
35714   {&__pyx_kp_s_62, __pyx_k_62, sizeof(__pyx_k_62), 0, 0, 1, 0},
35715   {&__pyx_n_s_63, __pyx_k_63, sizeof(__pyx_k_63), 0, 0, 1, 1},
35716   {&__pyx_kp_s_64, __pyx_k_64, sizeof(__pyx_k_64), 0, 0, 1, 0},
35717   {&__pyx_kp_s_65, __pyx_k_65, sizeof(__pyx_k_65), 0, 0, 1, 0},
35718   {&__pyx_kp_s_66, __pyx_k_66, sizeof(__pyx_k_66), 0, 0, 1, 0},
35719   {&__pyx_kp_s_67, __pyx_k_67, sizeof(__pyx_k_67), 0, 0, 1, 0},
35720   {&__pyx_kp_s_68, __pyx_k_68, sizeof(__pyx_k_68), 0, 0, 1, 0},
35721   {&__pyx_kp_s_69, __pyx_k_69, sizeof(__pyx_k_69), 0, 0, 1, 0},
35722   {&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0},
35723   {&__pyx_kp_s_70, __pyx_k_70, sizeof(__pyx_k_70), 0, 0, 1, 0},
35724   {&__pyx_kp_s_71, __pyx_k_71, sizeof(__pyx_k_71), 0, 0, 1, 0},
35725   {&__pyx_kp_s_72, __pyx_k_72, sizeof(__pyx_k_72), 0, 0, 1, 0},
35726   {&__pyx_kp_s_73, __pyx_k_73, sizeof(__pyx_k_73), 0, 0, 1, 0},
35727   {&__pyx_kp_s_74, __pyx_k_74, sizeof(__pyx_k_74), 0, 0, 1, 0},
35728   {&__pyx_kp_s_75, __pyx_k_75, sizeof(__pyx_k_75), 0, 0, 1, 0},
35729   {&__pyx_kp_s_76, __pyx_k_76, sizeof(__pyx_k_76), 0, 0, 1, 0},
35730   {&__pyx_kp_s_77, __pyx_k_77, sizeof(__pyx_k_77), 0, 0, 1, 0},
35731   {&__pyx_kp_s_78, __pyx_k_78, sizeof(__pyx_k_78), 0, 0, 1, 0},
35732   {&__pyx_kp_s_79, __pyx_k_79, sizeof(__pyx_k_79), 0, 0, 1, 0},
35733   {&__pyx_kp_s_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 0, 1, 0},
35734   {&__pyx_kp_s_80, __pyx_k_80, sizeof(__pyx_k_80), 0, 0, 1, 0},
35735   {&__pyx_kp_s_81, __pyx_k_81, sizeof(__pyx_k_81), 0, 0, 1, 0},
35736   {&__pyx_kp_s_82, __pyx_k_82, sizeof(__pyx_k_82), 0, 0, 1, 0},
35737   {&__pyx_kp_s_83, __pyx_k_83, sizeof(__pyx_k_83), 0, 0, 1, 0},
35738   {&__pyx_kp_s_84, __pyx_k_84, sizeof(__pyx_k_84), 0, 0, 1, 0},
35739   {&__pyx_kp_s_85, __pyx_k_85, sizeof(__pyx_k_85), 0, 0, 1, 0},
35740   {&__pyx_kp_s_86, __pyx_k_86, sizeof(__pyx_k_86), 0, 0, 1, 0},
35741   {&__pyx_kp_s_87, __pyx_k_87, sizeof(__pyx_k_87), 0, 0, 1, 0},
35742   {&__pyx_kp_s_88, __pyx_k_88, sizeof(__pyx_k_88), 0, 0, 1, 0},
35743   {&__pyx_kp_s_89, __pyx_k_89, sizeof(__pyx_k_89), 0, 0, 1, 0},
35744   {&__pyx_kp_s_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 1, 0},
35745   {&__pyx_kp_s_90, __pyx_k_90, sizeof(__pyx_k_90), 0, 0, 1, 0},
35746   {&__pyx_kp_s_91, __pyx_k_91, sizeof(__pyx_k_91), 0, 0, 1, 0},
35747   {&__pyx_kp_s_92, __pyx_k_92, sizeof(__pyx_k_92), 0, 0, 1, 0},
35748   {&__pyx_kp_s_93, __pyx_k_93, sizeof(__pyx_k_93), 0, 0, 1, 0},
35749   {&__pyx_kp_s_94, __pyx_k_94, sizeof(__pyx_k_94), 0, 0, 1, 0},
35750   {&__pyx_kp_s_95, __pyx_k_95, sizeof(__pyx_k_95), 0, 0, 1, 0},
35751   {&__pyx_kp_s_96, __pyx_k_96, sizeof(__pyx_k_96), 0, 0, 1, 0},
35752   {&__pyx_kp_s_97, __pyx_k_97, sizeof(__pyx_k_97), 0, 0, 1, 0},
35753   {&__pyx_n_s__A, __pyx_k__A, sizeof(__pyx_k__A), 0, 0, 1, 1},
35754   {&__pyx_n_s__AS, __pyx_k__AS, sizeof(__pyx_k__AS), 0, 0, 1, 1},
35755   {&__pyx_n_s__AlignedRead, __pyx_k__AlignedRead, sizeof(__pyx_k__AlignedRead), 0, 0, 1, 1},
35756   {&__pyx_n_s__C, __pyx_k__C, sizeof(__pyx_k__C), 0, 0, 1, 1},
35757   {&__pyx_n_s__CL, __pyx_k__CL, sizeof(__pyx_k__CL), 0, 0, 1, 1},
35758   {&__pyx_n_s__CN, __pyx_k__CN, sizeof(__pyx_k__CN), 0, 0, 1, 1},
35759   {&__pyx_n_s__CO, __pyx_k__CO, sizeof(__pyx_k__CO), 0, 0, 1, 1},
35760   {&__pyx_n_s__D, __pyx_k__D, sizeof(__pyx_k__D), 0, 0, 1, 1},
35761   {&__pyx_n_s__DS, __pyx_k__DS, sizeof(__pyx_k__DS), 0, 0, 1, 1},
35762   {&__pyx_n_s__DT, __pyx_k__DT, sizeof(__pyx_k__DT), 0, 0, 1, 1},
35763   {&__pyx_n_s__DictType, __pyx_k__DictType, sizeof(__pyx_k__DictType), 0, 0, 1, 1},
35764   {&__pyx_n_s__F, __pyx_k__F, sizeof(__pyx_k__F), 0, 0, 1, 1},
35765   {&__pyx_n_s__Fastafile, __pyx_k__Fastafile, sizeof(__pyx_k__Fastafile), 0, 0, 1, 1},
35766   {&__pyx_n_s__FloatType, __pyx_k__FloatType, sizeof(__pyx_k__FloatType), 0, 0, 1, 1},
35767   {&__pyx_n_s__GO, __pyx_k__GO, sizeof(__pyx_k__GO), 0, 0, 1, 1},
35768   {&__pyx_n_s__HD, __pyx_k__HD, sizeof(__pyx_k__HD), 0, 0, 1, 1},
35769   {&__pyx_n_s__I, __pyx_k__I, sizeof(__pyx_k__I), 0, 0, 1, 1},
35770   {&__pyx_n_s__ID, __pyx_k__ID, sizeof(__pyx_k__ID), 0, 0, 1, 1},
35771   {&__pyx_n_s__IOError, __pyx_k__IOError, sizeof(__pyx_k__IOError), 0, 0, 1, 1},
35772   {&__pyx_n_s__IndelCaller, __pyx_k__IndelCaller, sizeof(__pyx_k__IndelCaller), 0, 0, 1, 1},
35773   {&__pyx_n_s__IndexedReads, __pyx_k__IndexedReads, sizeof(__pyx_k__IndexedReads), 0, 0, 1, 1},
35774   {&__pyx_n_s__IntType, __pyx_k__IntType, sizeof(__pyx_k__IntType), 0, 0, 1, 1},
35775   {&__pyx_n_s__IteratorColumn, __pyx_k__IteratorColumn, sizeof(__pyx_k__IteratorColumn), 0, 0, 1, 1},
35776   {&__pyx_n_s__IteratorIndelCalls, __pyx_k__IteratorIndelCalls, sizeof(__pyx_k__IteratorIndelCalls), 0, 0, 1, 1},
35777   {&__pyx_n_s__IteratorRow, __pyx_k__IteratorRow, sizeof(__pyx_k__IteratorRow), 0, 0, 1, 1},
35778   {&__pyx_n_s__IteratorRowAll, __pyx_k__IteratorRowAll, sizeof(__pyx_k__IteratorRowAll), 0, 0, 1, 1},
35779   {&__pyx_n_s__IteratorRowAllRefs, __pyx_k__IteratorRowAllRefs, sizeof(__pyx_k__IteratorRowAllRefs), 0, 0, 1, 1},
35780   {&__pyx_n_s__IteratorRowRegion, __pyx_k__IteratorRowRegion, sizeof(__pyx_k__IteratorRowRegion), 0, 0, 1, 1},
35781   {&__pyx_n_s__IteratorSNPCalls, __pyx_k__IteratorSNPCalls, sizeof(__pyx_k__IteratorSNPCalls), 0, 0, 1, 1},
35782   {&__pyx_n_s__KeyError, __pyx_k__KeyError, sizeof(__pyx_k__KeyError), 0, 0, 1, 1},
35783   {&__pyx_n_s__LB, __pyx_k__LB, sizeof(__pyx_k__LB), 0, 0, 1, 1},
35784   {&__pyx_n_s__LN, __pyx_k__LN, sizeof(__pyx_k__LN), 0, 0, 1, 1},
35785   {&__pyx_n_s__M5, __pyx_k__M5, sizeof(__pyx_k__M5), 0, 0, 1, 1},
35786   {&__pyx_n_s__NotImplementedError, __pyx_k__NotImplementedError, sizeof(__pyx_k__NotImplementedError), 0, 0, 1, 1},
35787   {&__pyx_n_s__O_CREAT, __pyx_k__O_CREAT, sizeof(__pyx_k__O_CREAT), 0, 0, 1, 1},
35788   {&__pyx_n_s__O_WRONLY, __pyx_k__O_WRONLY, sizeof(__pyx_k__O_WRONLY), 0, 0, 1, 1},
35789   {&__pyx_n_s__Outs, __pyx_k__Outs, sizeof(__pyx_k__Outs), 0, 0, 1, 1},
35790   {&__pyx_n_s__OverflowError, __pyx_k__OverflowError, sizeof(__pyx_k__OverflowError), 0, 0, 1, 1},
35791   {&__pyx_n_s__PG, __pyx_k__PG, sizeof(__pyx_k__PG), 0, 0, 1, 1},
35792   {&__pyx_n_s__PI, __pyx_k__PI, sizeof(__pyx_k__PI), 0, 0, 1, 1},
35793   {&__pyx_n_s__PL, __pyx_k__PL, sizeof(__pyx_k__PL), 0, 0, 1, 1},
35794   {&__pyx_n_s__PN, __pyx_k__PN, sizeof(__pyx_k__PN), 0, 0, 1, 1},
35795   {&__pyx_n_s__PU, __pyx_k__PU, sizeof(__pyx_k__PU), 0, 0, 1, 1},
35796   {&__pyx_n_s__PileupColumn, __pyx_k__PileupColumn, sizeof(__pyx_k__PileupColumn), 0, 0, 1, 1},
35797   {&__pyx_n_s__PileupProxy, __pyx_k__PileupProxy, sizeof(__pyx_k__PileupProxy), 0, 0, 1, 1},
35798   {&__pyx_n_s__PileupRead, __pyx_k__PileupRead, sizeof(__pyx_k__PileupRead), 0, 0, 1, 1},
35799   {&__pyx_n_s__RG, __pyx_k__RG, sizeof(__pyx_k__RG), 0, 0, 1, 1},
35800   {&__pyx_n_s__S, __pyx_k__S, sizeof(__pyx_k__S), 0, 0, 1, 1},
35801   {&__pyx_n_s__SM, __pyx_k__SM, sizeof(__pyx_k__SM), 0, 0, 1, 1},
35802   {&__pyx_n_s__SN, __pyx_k__SN, sizeof(__pyx_k__SN), 0, 0, 1, 1},
35803   {&__pyx_n_s__SNPCaller, __pyx_k__SNPCaller, sizeof(__pyx_k__SNPCaller), 0, 0, 1, 1},
35804   {&__pyx_n_s__SO, __pyx_k__SO, sizeof(__pyx_k__SO), 0, 0, 1, 1},
35805   {&__pyx_n_s__SP, __pyx_k__SP, sizeof(__pyx_k__SP), 0, 0, 1, 1},
35806   {&__pyx_n_s__SQ, __pyx_k__SQ, sizeof(__pyx_k__SQ), 0, 0, 1, 1},
35807   {&__pyx_n_s__Samfile, __pyx_k__Samfile, sizeof(__pyx_k__Samfile), 0, 0, 1, 1},
35808   {&__pyx_n_s__StderrStore, __pyx_k__StderrStore, sizeof(__pyx_k__StderrStore), 0, 0, 1, 1},
35809   {&__pyx_n_s__StderrStoreWindows, __pyx_k__StderrStoreWindows, sizeof(__pyx_k__StderrStoreWindows), 0, 0, 1, 1},
35810   {&__pyx_n_s__StopIteration, __pyx_k__StopIteration, sizeof(__pyx_k__StopIteration), 0, 0, 1, 1},
35811   {&__pyx_n_s__TypeError, __pyx_k__TypeError, sizeof(__pyx_k__TypeError), 0, 0, 1, 1},
35812   {&__pyx_n_s__UR, __pyx_k__UR, sizeof(__pyx_k__UR), 0, 0, 1, 1},
35813   {&__pyx_n_s__VALID_HEADERS, __pyx_k__VALID_HEADERS, sizeof(__pyx_k__VALID_HEADERS), 0, 0, 1, 1},
35814   {&__pyx_n_s__VALID_HEADER_FIELDS, __pyx_k__VALID_HEADER_FIELDS, sizeof(__pyx_k__VALID_HEADER_FIELDS), 0, 0, 1, 1},
35815   {&__pyx_n_s__VALID_HEADER_ORDER, __pyx_k__VALID_HEADER_ORDER, sizeof(__pyx_k__VALID_HEADER_ORDER), 0, 0, 1, 1},
35816   {&__pyx_n_s__VALID_HEADER_TYPES, __pyx_k__VALID_HEADER_TYPES, sizeof(__pyx_k__VALID_HEADER_TYPES), 0, 0, 1, 1},
35817   {&__pyx_n_s__VN, __pyx_k__VN, sizeof(__pyx_k__VN), 0, 0, 1, 1},
35818   {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1},
35819   {&__pyx_n_s__Windows, __pyx_k__Windows, sizeof(__pyx_k__Windows), 0, 0, 1, 1},
35820   {&__pyx_n_s__Z, __pyx_k__Z, sizeof(__pyx_k__Z), 0, 0, 1, 1},
35821   {&__pyx_n_s____all__, __pyx_k____all__, sizeof(__pyx_k____all__), 0, 0, 1, 1},
35822   {&__pyx_n_s____del__, __pyx_k____del__, sizeof(__pyx_k____del__), 0, 0, 1, 1},
35823   {&__pyx_n_s____dict__, __pyx_k____dict__, sizeof(__pyx_k____dict__), 0, 0, 1, 1},
35824   {&__pyx_n_s____getattribute__, __pyx_k____getattribute__, sizeof(__pyx_k____getattribute__), 0, 0, 1, 1},
35825   {&__pyx_n_s____init__, __pyx_k____init__, sizeof(__pyx_k____init__), 0, 0, 1, 1},
35826   {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
35827   {&__pyx_n_s____next__, __pyx_k____next__, sizeof(__pyx_k____next__), 0, 0, 1, 1},
35828   {&__pyx_n_s____str__, __pyx_k____str__, sizeof(__pyx_k____str__), 0, 0, 1, 1},
35829   {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
35830   {&__pyx_n_s___alignment, __pyx_k___alignment, sizeof(__pyx_k___alignment), 0, 0, 1, 1},
35831   {&__pyx_n_s___buildHeader, __pyx_k___buildHeader, sizeof(__pyx_k___buildHeader), 0, 0, 1, 1},
35832   {&__pyx_n_s___buildLine, __pyx_k___buildLine, sizeof(__pyx_k___buildLine), 0, 0, 1, 1},
35833   {&__pyx_n_s___call, __pyx_k___call, sizeof(__pyx_k___call), 0, 0, 1, 1},
35834   {&__pyx_n_s___consensus_quality, __pyx_k___consensus_quality, sizeof(__pyx_k___consensus_quality), 0, 0, 1, 1},
35835   {&__pyx_n_s___coverage, __pyx_k___coverage, sizeof(__pyx_k___coverage), 0, 0, 1, 1},
35836   {&__pyx_n_s___delegate, __pyx_k___delegate, sizeof(__pyx_k___delegate), 0, 0, 1, 1},
35837   {&__pyx_n_s___filename, __pyx_k___filename, sizeof(__pyx_k___filename), 0, 0, 1, 1},
35838   {&__pyx_n_s___genotype, __pyx_k___genotype, sizeof(__pyx_k___genotype), 0, 0, 1, 1},
35839   {&__pyx_n_s___hasIndex, __pyx_k___hasIndex, sizeof(__pyx_k___hasIndex), 0, 0, 1, 1},
35840   {&__pyx_n_s___indel, __pyx_k___indel, sizeof(__pyx_k___indel), 0, 0, 1, 1},
35841   {&__pyx_n_s___isOpen, __pyx_k___isOpen, sizeof(__pyx_k___isOpen), 0, 0, 1, 1},
35842   {&__pyx_n_s___is_del, __pyx_k___is_del, sizeof(__pyx_k___is_del), 0, 0, 1, 1},
35843   {&__pyx_n_s___is_head, __pyx_k___is_head, sizeof(__pyx_k___is_head), 0, 0, 1, 1},
35844   {&__pyx_n_s___is_tail, __pyx_k___is_tail, sizeof(__pyx_k___is_tail), 0, 0, 1, 1},
35845   {&__pyx_n_s___level, __pyx_k___level, sizeof(__pyx_k___level), 0, 0, 1, 1},
35846   {&__pyx_n_s___logfile, __pyx_k___logfile, sizeof(__pyx_k___logfile), 0, 0, 1, 1},
35847   {&__pyx_n_s___open, __pyx_k___open, sizeof(__pyx_k___open), 0, 0, 1, 1},
35848   {&__pyx_n_s___parseRegion, __pyx_k___parseRegion, sizeof(__pyx_k___parseRegion), 0, 0, 1, 1},
35849   {&__pyx_n_s___pos, __pyx_k___pos, sizeof(__pyx_k___pos), 0, 0, 1, 1},
35850   {&__pyx_n_s___qpos, __pyx_k___qpos, sizeof(__pyx_k___qpos), 0, 0, 1, 1},
35851   {&__pyx_n_s___r, __pyx_k___r, sizeof(__pyx_k___r), 0, 0, 1, 1},
35852   {&__pyx_n_s___reference_base, __pyx_k___reference_base, sizeof(__pyx_k___reference_base), 0, 0, 1, 1},
35853   {&__pyx_n_s___samtools_dispatch, __pyx_k___samtools_dispatch, sizeof(__pyx_k___samtools_dispatch), 0, 0, 1, 1},
35854   {&__pyx_n_s___snp_quality, __pyx_k___snp_quality, sizeof(__pyx_k___snp_quality), 0, 0, 1, 1},
35855   {&__pyx_n_s___tid, __pyx_k___tid, sizeof(__pyx_k___tid), 0, 0, 1, 1},
35856   {&__pyx_n_s__addReference, __pyx_k__addReference, sizeof(__pyx_k__addReference), 0, 0, 1, 1},
35857   {&__pyx_n_s__alignment, __pyx_k__alignment, sizeof(__pyx_k__alignment), 0, 0, 1, 1},
35858   {&__pyx_n_s__all, __pyx_k__all, sizeof(__pyx_k__all), 0, 0, 1, 1},
35859   {&__pyx_n_s__args, __pyx_k__args, sizeof(__pyx_k__args), 0, 0, 1, 1},
35860   {&__pyx_n_s__b, __pyx_k__b, sizeof(__pyx_k__b), 0, 0, 1, 1},
35861   {&__pyx_n_s__bam, __pyx_k__bam, sizeof(__pyx_k__bam), 0, 0, 1, 1},
35862   {&__pyx_n_s__beg, __pyx_k__beg, sizeof(__pyx_k__beg), 0, 0, 1, 1},
35863   {&__pyx_n_s__bin, __pyx_k__bin, sizeof(__pyx_k__bin), 0, 0, 1, 1},
35864   {&__pyx_n_s__bqual, __pyx_k__bqual, sizeof(__pyx_k__bqual), 0, 0, 1, 1},
35865   {&__pyx_n_s__build, __pyx_k__build, sizeof(__pyx_k__build), 0, 0, 1, 1},
35866   {&__pyx_n_s__c, __pyx_k__c, sizeof(__pyx_k__c), 0, 0, 1, 1},
35867   {&__pyx_n_s__calcsize, __pyx_k__calcsize, sizeof(__pyx_k__calcsize), 0, 0, 1, 1},
35868   {&__pyx_n_s__call, __pyx_k__call, sizeof(__pyx_k__call), 0, 0, 1, 1},
35869   {&__pyx_n_s__callback, __pyx_k__callback, sizeof(__pyx_k__callback), 0, 0, 1, 1},
35870   {&__pyx_n_s__cap_mapQ, __pyx_k__cap_mapQ, sizeof(__pyx_k__cap_mapQ), 0, 0, 1, 1},
35871   {&__pyx_n_s__catch_stderr, __pyx_k__catch_stderr, sizeof(__pyx_k__catch_stderr), 0, 0, 1, 1},
35872   {&__pyx_n_s__catch_stdout, __pyx_k__catch_stdout, sizeof(__pyx_k__catch_stdout), 0, 0, 1, 1},
35873   {&__pyx_n_s__chr, __pyx_k__chr, sizeof(__pyx_k__chr), 0, 0, 1, 1},
35874   {&__pyx_n_s__cigar, __pyx_k__cigar, sizeof(__pyx_k__cigar), 0, 0, 1, 1},
35875   {&__pyx_n_s__close, __pyx_k__close, sizeof(__pyx_k__close), 0, 0, 1, 1},
35876   {&__pyx_n_s__cmp, __pyx_k__cmp, sizeof(__pyx_k__cmp), 0, 0, 1, 1},
35877   {&__pyx_n_s__cnext, __pyx_k__cnext, sizeof(__pyx_k__cnext), 0, 0, 1, 1},
35878   {&__pyx_n_s__cnt1, __pyx_k__cnt1, sizeof(__pyx_k__cnt1), 0, 0, 1, 1},
35879   {&__pyx_n_s__cnt2, __pyx_k__cnt2, sizeof(__pyx_k__cnt2), 0, 0, 1, 1},
35880   {&__pyx_n_s__cnt_anti, __pyx_k__cnt_anti, sizeof(__pyx_k__cnt_anti), 0, 0, 1, 1},
35881   {&__pyx_n_s__collections, __pyx_k__collections, sizeof(__pyx_k__collections), 0, 0, 1, 1},
35882   {&__pyx_n_s__compare, __pyx_k__compare, sizeof(__pyx_k__compare), 0, 0, 1, 1},
35883   {&__pyx_n_s__consensus_quality, __pyx_k__consensus_quality, sizeof(__pyx_k__consensus_quality), 0, 0, 1, 1},
35884   {&__pyx_n_s__core, __pyx_k__core, sizeof(__pyx_k__core), 0, 0, 1, 1},
35885   {&__pyx_n_s__count, __pyx_k__count, sizeof(__pyx_k__count), 0, 0, 1, 1},
35886   {&__pyx_n_s__coverage, __pyx_k__coverage, sizeof(__pyx_k__coverage), 0, 0, 1, 1},
35887   {&__pyx_n_s__ctypes, __pyx_k__ctypes, sizeof(__pyx_k__ctypes), 0, 0, 1, 1},
35888   {&__pyx_n_s__current_pos, __pyx_k__current_pos, sizeof(__pyx_k__current_pos), 0, 0, 1, 1},
35889   {&__pyx_n_s__d, __pyx_k__d, sizeof(__pyx_k__d), 0, 0, 1, 1},
35890   {&__pyx_n_s__data, __pyx_k__data, sizeof(__pyx_k__data), 0, 0, 1, 1},
35891   {&__pyx_n_s__data_len, __pyx_k__data_len, sizeof(__pyx_k__data_len), 0, 0, 1, 1},
35892   {&__pyx_n_s__defaultdict, __pyx_k__defaultdict, sizeof(__pyx_k__defaultdict), 0, 0, 1, 1},
35893   {&__pyx_n_s__devnull, __pyx_k__devnull, sizeof(__pyx_k__devnull), 0, 0, 1, 1},
35894   {&__pyx_n_s__dup, __pyx_k__dup, sizeof(__pyx_k__dup), 0, 0, 1, 1},
35895   {&__pyx_n_s__dup2, __pyx_k__dup2, sizeof(__pyx_k__dup2), 0, 0, 1, 1},
35896   {&__pyx_n_s__end, __pyx_k__end, sizeof(__pyx_k__end), 0, 0, 1, 1},
35897   {&__pyx_n_s__errmod, __pyx_k__errmod, sizeof(__pyx_k__errmod), 0, 0, 1, 1},
35898   {&__pyx_n_s__exc_type, __pyx_k__exc_type, sizeof(__pyx_k__exc_type), 0, 0, 1, 1},
35899   {&__pyx_n_s__exc_value, __pyx_k__exc_value, sizeof(__pyx_k__exc_value), 0, 0, 1, 1},
35900   {&__pyx_n_s__exists, __pyx_k__exists, sizeof(__pyx_k__exists), 0, 0, 1, 1},
35901   {&__pyx_n_s__f, __pyx_k__f, sizeof(__pyx_k__f), 0, 0, 1, 1},
35902   {&__pyx_n_s__fancy_str, __pyx_k__fancy_str, sizeof(__pyx_k__fancy_str), 0, 0, 1, 1},
35903   {&__pyx_n_s__fastafile, __pyx_k__fastafile, sizeof(__pyx_k__fastafile), 0, 0, 1, 1},
35904   {&__pyx_n_s__fd, __pyx_k__fd, sizeof(__pyx_k__fd), 0, 0, 1, 1},
35905   {&__pyx_n_s__fetch, __pyx_k__fetch, sizeof(__pyx_k__fetch), 0, 0, 1, 1},
35906   {&__pyx_n_s__fields, __pyx_k__fields, sizeof(__pyx_k__fields), 0, 0, 1, 1},
35907   {&__pyx_n_s__filename, __pyx_k__filename, sizeof(__pyx_k__filename), 0, 0, 1, 1},
35908   {&__pyx_n_s__fileno, __pyx_k__fileno, sizeof(__pyx_k__fileno), 0, 0, 1, 1},
35909   {&__pyx_n_s__first_allele, __pyx_k__first_allele, sizeof(__pyx_k__first_allele), 0, 0, 1, 1},
35910   {&__pyx_n_s__flag, __pyx_k__flag, sizeof(__pyx_k__flag), 0, 0, 1, 1},
35911   {&__pyx_n_s__flush, __pyx_k__flush, sizeof(__pyx_k__flush), 0, 0, 1, 1},
35912   {&__pyx_n_s__fp, __pyx_k__fp, sizeof(__pyx_k__fp), 0, 0, 1, 1},
35913   {&__pyx_n_s__genotype, __pyx_k__genotype, sizeof(__pyx_k__genotype), 0, 0, 1, 1},
35914   {&__pyx_n_s__getSequence, __pyx_k__getSequence, sizeof(__pyx_k__getSequence), 0, 0, 1, 1},
35915   {&__pyx_n_s__getrname, __pyx_k__getrname, sizeof(__pyx_k__getrname), 0, 0, 1, 1},
35916   {&__pyx_n_s__gettid, __pyx_k__gettid, sizeof(__pyx_k__gettid), 0, 0, 1, 1},
35917   {&__pyx_n_s__hasReference, __pyx_k__hasReference, sizeof(__pyx_k__hasReference), 0, 0, 1, 1},
35918   {&__pyx_n_s__hash, __pyx_k__hash, sizeof(__pyx_k__hash), 0, 0, 1, 1},
35919   {&__pyx_n_s__header, __pyx_k__header, sizeof(__pyx_k__header), 0, 0, 1, 1},
35920   {&__pyx_n_s__het_rate, __pyx_k__het_rate, sizeof(__pyx_k__het_rate), 0, 0, 1, 1},
35921   {&__pyx_n_s__i, __pyx_k__i, sizeof(__pyx_k__i), 0, 0, 1, 1},
35922   {&__pyx_n_s__id, __pyx_k__id, sizeof(__pyx_k__id), 0, 0, 1, 1},
35923   {&__pyx_n_s__indel, __pyx_k__indel, sizeof(__pyx_k__indel), 0, 0, 1, 1},
35924   {&__pyx_n_s__indel1, __pyx_k__indel1, sizeof(__pyx_k__indel1), 0, 0, 1, 1},
35925   {&__pyx_n_s__indel2, __pyx_k__indel2, sizeof(__pyx_k__indel2), 0, 0, 1, 1},
35926   {&__pyx_n_s__index, __pyx_k__index, sizeof(__pyx_k__index), 0, 0, 1, 1},
35927   {&__pyx_n_s__is_del, __pyx_k__is_del, sizeof(__pyx_k__is_del), 0, 0, 1, 1},
35928   {&__pyx_n_s__is_head, __pyx_k__is_head, sizeof(__pyx_k__is_head), 0, 0, 1, 1},
35929   {&__pyx_n_s__is_tail, __pyx_k__is_tail, sizeof(__pyx_k__is_tail), 0, 0, 1, 1},
35930   {&__pyx_n_s__isbam, __pyx_k__isbam, sizeof(__pyx_k__isbam), 0, 0, 1, 1},
35931   {&__pyx_n_s__isize, __pyx_k__isize, sizeof(__pyx_k__isize), 0, 0, 1, 1},
35932   {&__pyx_n_s__isremote, __pyx_k__isremote, sizeof(__pyx_k__isremote), 0, 0, 1, 1},
35933   {&__pyx_n_s__isupper, __pyx_k__isupper, sizeof(__pyx_k__isupper), 0, 0, 1, 1},
35934   {&__pyx_n_s__iter, __pyx_k__iter, sizeof(__pyx_k__iter), 0, 0, 1, 1},
35935   {&__pyx_n_s__iterator_column, __pyx_k__iterator_column, sizeof(__pyx_k__iterator_column), 0, 0, 1, 1},
35936   {&__pyx_n_s__iterdata, __pyx_k__iterdata, sizeof(__pyx_k__iterdata), 0, 0, 1, 1},
35937   {&__pyx_n_s__itertools, __pyx_k__itertools, sizeof(__pyx_k__itertools), 0, 0, 1, 1},
35938   {&__pyx_n_s__join, __pyx_k__join, sizeof(__pyx_k__join), 0, 0, 1, 1},
35939   {&__pyx_n_s__l_aux, __pyx_k__l_aux, sizeof(__pyx_k__l_aux), 0, 0, 1, 1},
35940   {&__pyx_n_s__l_qname, __pyx_k__l_qname, sizeof(__pyx_k__l_qname), 0, 0, 1, 1},
35941   {&__pyx_n_s__l_qseq, __pyx_k__l_qseq, sizeof(__pyx_k__l_qseq), 0, 0, 1, 1},
35942   {&__pyx_n_s__l_text, __pyx_k__l_text, sizeof(__pyx_k__l_text), 0, 0, 1, 1},
35943   {&__pyx_n_s__level, __pyx_k__level, sizeof(__pyx_k__level), 0, 0, 1, 1},
35944   {&__pyx_n_s__m_data, __pyx_k__m_data, sizeof(__pyx_k__m_data), 0, 0, 1, 1},
35945   {&__pyx_n_s__map, __pyx_k__map, sizeof(__pyx_k__map), 0, 0, 1, 1},
35946   {&__pyx_n_s__mapping_quality, __pyx_k__mapping_quality, sizeof(__pyx_k__mapping_quality), 0, 0, 1, 1},
35947   {&__pyx_n_s__mapq, __pyx_k__mapq, sizeof(__pyx_k__mapq), 0, 0, 1, 1},
35948   {&__pyx_n_s__mask, __pyx_k__mask, sizeof(__pyx_k__mask), 0, 0, 1, 1},
35949   {&__pyx_n_s__mate, __pyx_k__mate, sizeof(__pyx_k__mate), 0, 0, 1, 1},
35950   {&__pyx_n_s__max_depth, __pyx_k__max_depth, sizeof(__pyx_k__max_depth), 0, 0, 1, 1},
35951   {&__pyx_n_s__method, __pyx_k__method, sizeof(__pyx_k__method), 0, 0, 1, 1},
35952   {&__pyx_n_s__min_baseQ, __pyx_k__min_baseQ, sizeof(__pyx_k__min_baseQ), 0, 0, 1, 1},
35953   {&__pyx_n_s__mkstemp, __pyx_k__mkstemp, sizeof(__pyx_k__mkstemp), 0, 0, 1, 1},
35954   {&__pyx_n_s__mode, __pyx_k__mode, sizeof(__pyx_k__mode), 0, 0, 1, 1},
35955   {&__pyx_n_s__mpos, __pyx_k__mpos, sizeof(__pyx_k__mpos), 0, 0, 1, 1},
35956   {&__pyx_n_s__mrnm, __pyx_k__mrnm, sizeof(__pyx_k__mrnm), 0, 0, 1, 1},
35957   {&__pyx_n_s__mtid, __pyx_k__mtid, sizeof(__pyx_k__mtid), 0, 0, 1, 1},
35958   {&__pyx_n_s__n, __pyx_k__n, sizeof(__pyx_k__n), 0, 0, 1, 1},
35959   {&__pyx_n_s__n_cigar, __pyx_k__n_cigar, sizeof(__pyx_k__n_cigar), 0, 0, 1, 1},
35960   {&__pyx_n_s__n_hap, __pyx_k__n_hap, sizeof(__pyx_k__n_hap), 0, 0, 1, 1},
35961   {&__pyx_n_s__n_haplotypes, __pyx_k__n_haplotypes, sizeof(__pyx_k__n_haplotypes), 0, 0, 1, 1},
35962   {&__pyx_n_s__n_plp, __pyx_k__n_plp, sizeof(__pyx_k__n_plp), 0, 0, 1, 1},
35963   {&__pyx_n_s__n_pu, __pyx_k__n_pu, sizeof(__pyx_k__n_pu), 0, 0, 1, 1},
35964   {&__pyx_n_s__n_targets, __pyx_k__n_targets, sizeof(__pyx_k__n_targets), 0, 0, 1, 1},
35965   {&__pyx_n_s__name, __pyx_k__name, sizeof(__pyx_k__name), 0, 0, 1, 1},
35966   {&__pyx_n_s__nextiter, __pyx_k__nextiter, sizeof(__pyx_k__nextiter), 0, 0, 1, 1},
35967   {&__pyx_n_s__nreferences, __pyx_k__nreferences, sizeof(__pyx_k__nreferences), 0, 0, 1, 1},
35968   {&__pyx_n_s__object, __pyx_k__object, sizeof(__pyx_k__object), 0, 0, 1, 1},
35969   {&__pyx_n_s__offset, __pyx_k__offset, sizeof(__pyx_k__offset), 0, 0, 1, 1},
35970   {&__pyx_n_s__open, __pyx_k__open, sizeof(__pyx_k__open), 0, 0, 1, 1},
35971   {&__pyx_n_s__opt, __pyx_k__opt, sizeof(__pyx_k__opt), 0, 0, 1, 1},
35972   {&__pyx_n_s__options, __pyx_k__options, sizeof(__pyx_k__options), 0, 0, 1, 1},
35973   {&__pyx_n_s__os, __pyx_k__os, sizeof(__pyx_k__os), 0, 0, 1, 1},
35974   {&__pyx_n_s__overlap, __pyx_k__overlap, sizeof(__pyx_k__overlap), 0, 0, 1, 1},
35975   {&__pyx_n_s__owns_samfile, __pyx_k__owns_samfile, sizeof(__pyx_k__owns_samfile), 0, 0, 1, 1},
35976   {&__pyx_n_s__pack_into, __pyx_k__pack_into, sizeof(__pyx_k__pack_into), 0, 0, 1, 1},
35977   {&__pyx_n_s__path, __pyx_k__path, sizeof(__pyx_k__path), 0, 0, 1, 1},
35978   {&__pyx_n_s__pileup, __pyx_k__pileup, sizeof(__pyx_k__pileup), 0, 0, 1, 1},
35979   {&__pyx_n_s__pileup_iter, __pyx_k__pileup_iter, sizeof(__pyx_k__pileup_iter), 0, 0, 1, 1},
35980   {&__pyx_n_s__pileups, __pyx_k__pileups, sizeof(__pyx_k__pileups), 0, 0, 1, 1},
35981   {&__pyx_n_s__platform, __pyx_k__platform, sizeof(__pyx_k__platform), 0, 0, 1, 1},
35982   {&__pyx_n_s__plp, __pyx_k__plp, sizeof(__pyx_k__plp), 0, 0, 1, 1},
35983   {&__pyx_n_s__port, __pyx_k__port, sizeof(__pyx_k__port), 0, 0, 1, 1},
35984   {&__pyx_n_s__pos, __pyx_k__pos, sizeof(__pyx_k__pos), 0, 0, 1, 1},
35985   {&__pyx_n_s__positions, __pyx_k__positions, sizeof(__pyx_k__positions), 0, 0, 1, 1},
35986   {&__pyx_n_s__q_cns, __pyx_k__q_cns, sizeof(__pyx_k__q_cns), 0, 0, 1, 1},
35987   {&__pyx_n_s__q_indel, __pyx_k__q_indel, sizeof(__pyx_k__q_indel), 0, 0, 1, 1},
35988   {&__pyx_n_s__q_r, __pyx_k__q_r, sizeof(__pyx_k__q_r), 0, 0, 1, 1},
35989   {&__pyx_n_s__q_ref, __pyx_k__q_ref, sizeof(__pyx_k__q_ref), 0, 0, 1, 1},
35990   {&__pyx_n_s__qname, __pyx_k__qname, sizeof(__pyx_k__qname), 0, 0, 1, 1},
35991   {&__pyx_n_s__qpos, __pyx_k__qpos, sizeof(__pyx_k__qpos), 0, 0, 1, 1},
35992   {&__pyx_n_s__qseq, __pyx_k__qseq, sizeof(__pyx_k__qseq), 0, 0, 1, 1},
35993   {&__pyx_n_s__qual, __pyx_k__qual, sizeof(__pyx_k__qual), 0, 0, 1, 1},
35994   {&__pyx_n_s__r, __pyx_k__r, sizeof(__pyx_k__r), 0, 0, 1, 1},
35995   {&__pyx_n_s__r_indel, __pyx_k__r_indel, sizeof(__pyx_k__r_indel), 0, 0, 1, 1},
35996   {&__pyx_n_s__range, __pyx_k__range, sizeof(__pyx_k__range), 0, 0, 1, 1},
35997   {&__pyx_n_s__raw, __pyx_k__raw, sizeof(__pyx_k__raw), 0, 0, 1, 1},
35998   {&__pyx_n_s__rb, __pyx_k__rb, sizeof(__pyx_k__rb), 0, 0, 1, 1},
35999   {&__pyx_n_s__re, __pyx_k__re, sizeof(__pyx_k__re), 0, 0, 1, 1},
36000   {&__pyx_n_s__readAndRelease, __pyx_k__readAndRelease, sizeof(__pyx_k__readAndRelease), 0, 0, 1, 1},
36001   {&__pyx_n_s__readlines, __pyx_k__readlines, sizeof(__pyx_k__readlines), 0, 0, 1, 1},
36002   {&__pyx_n_s__reads_diff, __pyx_k__reads_diff, sizeof(__pyx_k__reads_diff), 0, 0, 1, 1},
36003   {&__pyx_n_s__reads_first, __pyx_k__reads_first, sizeof(__pyx_k__reads_first), 0, 0, 1, 1},
36004   {&__pyx_n_s__reads_second, __pyx_k__reads_second, sizeof(__pyx_k__reads_second), 0, 0, 1, 1},
36005   {&__pyx_n_s__record, __pyx_k__record, sizeof(__pyx_k__record), 0, 0, 1, 1},
36006   {&__pyx_n_s__reference, __pyx_k__reference, sizeof(__pyx_k__reference), 0, 0, 1, 1},
36007   {&__pyx_n_s__reference_base, __pyx_k__reference_base, sizeof(__pyx_k__reference_base), 0, 0, 1, 1},
36008   {&__pyx_n_s__referencelengths, __pyx_k__referencelengths, sizeof(__pyx_k__referencelengths), 0, 0, 1, 1},
36009   {&__pyx_n_s__referencenames, __pyx_k__referencenames, sizeof(__pyx_k__referencenames), 0, 0, 1, 1},
36010   {&__pyx_n_s__region, __pyx_k__region, sizeof(__pyx_k__region), 0, 0, 1, 1},
36011   {&__pyx_n_s__release, __pyx_k__release, sizeof(__pyx_k__release), 0, 0, 1, 1},
36012   {&__pyx_n_s__remove, __pyx_k__remove, sizeof(__pyx_k__remove), 0, 0, 1, 1},
36013   {&__pyx_n_s__reopen, __pyx_k__reopen, sizeof(__pyx_k__reopen), 0, 0, 1, 1},
36014   {&__pyx_n_s__reset, __pyx_k__reset, sizeof(__pyx_k__reset), 0, 0, 1, 1},
36015   {&__pyx_n_s__restore, __pyx_k__restore, sizeof(__pyx_k__restore), 0, 0, 1, 1},
36016   {&__pyx_n_s__retval, __pyx_k__retval, sizeof(__pyx_k__retval), 0, 0, 1, 1},
36017   {&__pyx_n_s__rg2lib, __pyx_k__rg2lib, sizeof(__pyx_k__rg2lib), 0, 0, 1, 1},
36018   {&__pyx_n_s__rlen, __pyx_k__rlen, sizeof(__pyx_k__rlen), 0, 0, 1, 1},
36019   {&__pyx_n_s__rname, __pyx_k__rname, sizeof(__pyx_k__rname), 0, 0, 1, 1},
36020   {&__pyx_n_s__rowiter, __pyx_k__rowiter, sizeof(__pyx_k__rowiter), 0, 0, 1, 1},
36021   {&__pyx_n_s__s, __pyx_k__s, sizeof(__pyx_k__s), 0, 0, 1, 1},
36022   {&__pyx_n_s__samfile, __pyx_k__samfile, sizeof(__pyx_k__samfile), 0, 0, 1, 1},
36023   {&__pyx_n_s__samtools, __pyx_k__samtools, sizeof(__pyx_k__samtools), 0, 0, 1, 1},
36024   {&__pyx_n_s__second_allele, __pyx_k__second_allele, sizeof(__pyx_k__second_allele), 0, 0, 1, 1},
36025   {&__pyx_n_s__seek, __pyx_k__seek, sizeof(__pyx_k__seek), 0, 0, 1, 1},
36026   {&__pyx_n_s__self, __pyx_k__self, sizeof(__pyx_k__self), 0, 0, 1, 1},
36027   {&__pyx_n_s__seq, __pyx_k__seq, sizeof(__pyx_k__seq), 0, 0, 1, 1},
36028   {&__pyx_n_s__seq_len, __pyx_k__seq_len, sizeof(__pyx_k__seq_len), 0, 0, 1, 1},
36029   {&__pyx_n_s__setdevice, __pyx_k__setdevice, sizeof(__pyx_k__setdevice), 0, 0, 1, 1},
36030   {&__pyx_n_s__setfd, __pyx_k__setfd, sizeof(__pyx_k__setfd), 0, 0, 1, 1},
36031   {&__pyx_n_s__setfile, __pyx_k__setfile, sizeof(__pyx_k__setfile), 0, 0, 1, 1},
36032   {&__pyx_n_s__setupIteratorData, __pyx_k__setupIteratorData, sizeof(__pyx_k__setupIteratorData), 0, 0, 1, 1},
36033   {&__pyx_n_s__snp_quality, __pyx_k__snp_quality, sizeof(__pyx_k__snp_quality), 0, 0, 1, 1},
36034   {&__pyx_n_s__split, __pyx_k__split, sizeof(__pyx_k__split), 0, 0, 1, 1},
36035   {&__pyx_n_s__start, __pyx_k__start, sizeof(__pyx_k__start), 0, 0, 1, 1},
36036   {&__pyx_n_s__startswith, __pyx_k__startswith, sizeof(__pyx_k__startswith), 0, 0, 1, 1},
36037   {&__pyx_n_s__stderr, __pyx_k__stderr, sizeof(__pyx_k__stderr), 0, 0, 1, 1},
36038   {&__pyx_n_s__stderr_f, __pyx_k__stderr_f, sizeof(__pyx_k__stderr_f), 0, 0, 1, 1},
36039   {&__pyx_n_s__stderr_h, __pyx_k__stderr_h, sizeof(__pyx_k__stderr_h), 0, 0, 1, 1},
36040   {&__pyx_n_s__stderr_save, __pyx_k__stderr_save, sizeof(__pyx_k__stderr_save), 0, 0, 1, 1},
36041   {&__pyx_n_s__stdout, __pyx_k__stdout, sizeof(__pyx_k__stdout), 0, 0, 1, 1},
36042   {&__pyx_n_s__stepper, __pyx_k__stepper, sizeof(__pyx_k__stepper), 0, 0, 1, 1},
36043   {&__pyx_n_s__streams, __pyx_k__streams, sizeof(__pyx_k__streams), 0, 0, 1, 1},
36044   {&__pyx_n_s__strip, __pyx_k__strip, sizeof(__pyx_k__strip), 0, 0, 1, 1},
36045   {&__pyx_n_s__struct, __pyx_k__struct, sizeof(__pyx_k__struct), 0, 0, 1, 1},
36046   {&__pyx_n_s__sys, __pyx_k__sys, sizeof(__pyx_k__sys), 0, 0, 1, 1},
36047   {&__pyx_n_s__system, __pyx_k__system, sizeof(__pyx_k__system), 0, 0, 1, 1},
36048   {&__pyx_n_s__tags, __pyx_k__tags, sizeof(__pyx_k__tags), 0, 0, 1, 1},
36049   {&__pyx_n_s__target_len, __pyx_k__target_len, sizeof(__pyx_k__target_len), 0, 0, 1, 1},
36050   {&__pyx_n_s__target_name, __pyx_k__target_name, sizeof(__pyx_k__target_name), 0, 0, 1, 1},
36051   {&__pyx_n_s__tell, __pyx_k__tell, sizeof(__pyx_k__tell), 0, 0, 1, 1},
36052   {&__pyx_n_s__tempfile, __pyx_k__tempfile, sizeof(__pyx_k__tempfile), 0, 0, 1, 1},
36053   {&__pyx_n_s__template, __pyx_k__template, sizeof(__pyx_k__template), 0, 0, 1, 1},
36054   {&__pyx_n_s__text, __pyx_k__text, sizeof(__pyx_k__text), 0, 0, 1, 1},
36055   {&__pyx_n_s__theta, __pyx_k__theta, sizeof(__pyx_k__theta), 0, 0, 1, 1},
36056   {&__pyx_n_s__tid, __pyx_k__tid, sizeof(__pyx_k__tid), 0, 0, 1, 1},
36057   {&__pyx_n_s__traceback, __pyx_k__traceback, sizeof(__pyx_k__traceback), 0, 0, 1, 1},
36058   {&__pyx_n_s__types, __pyx_k__types, sizeof(__pyx_k__types), 0, 0, 1, 1},
36059   {&__pyx_n_s__until_eof, __pyx_k__until_eof, sizeof(__pyx_k__until_eof), 0, 0, 1, 1},
36060   {&__pyx_n_s__view, __pyx_k__view, sizeof(__pyx_k__view), 0, 0, 1, 1},
36061   {&__pyx_n_s__w, __pyx_k__w, sizeof(__pyx_k__w), 0, 0, 1, 1},
36062   {&__pyx_n_s__wb, __pyx_k__wb, sizeof(__pyx_k__wb), 0, 0, 1, 1},
36063   {&__pyx_n_s__wbu, __pyx_k__wbu, sizeof(__pyx_k__wbu), 0, 0, 1, 1},
36064   {&__pyx_n_s__wh, __pyx_k__wh, sizeof(__pyx_k__wh), 0, 0, 1, 1},
36065   {&__pyx_n_s__where, __pyx_k__where, sizeof(__pyx_k__where), 0, 0, 1, 1},
36066   {&__pyx_n_s__write, __pyx_k__write, sizeof(__pyx_k__write), 0, 0, 1, 1},
36067   {&__pyx_n_s__x, __pyx_k__x, sizeof(__pyx_k__x), 0, 0, 1, 1},
36068   {0, 0, 0, 0, 0, 0, 0}
36069 };
36070 static int __Pyx_InitCachedBuiltins(void) {
36071   __pyx_builtin_open = __Pyx_GetName(__pyx_b, __pyx_n_s__open); if (!__pyx_builtin_open) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
36072   __pyx_builtin_object = __Pyx_GetName(__pyx_b, __pyx_n_s__object); if (!__pyx_builtin_object) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
36073   __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;}
36074   __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;}
36075   __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;}
36076   __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;}
36077   __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;}
36078   __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;}
36079   __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;}
36080   __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;}
36081   __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;}
36082   __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;}
36083   __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;}
36084   return 0;
36085   __pyx_L1_error:;
36086   return -1;
36087 }
36088
36089 static int __Pyx_InitGlobals(void) {
36090   if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
36091   __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;};
36092   __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;};
36093   __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;};
36094   __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;};
36095   __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;};
36096   __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;};
36097   __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;};
36098   __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;};
36099   __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;};
36100   __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;};
36101   __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;};
36102   __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;};
36103   __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;};
36104   __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;};
36105   __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;};
36106   __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;};
36107   __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;};
36108   __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;};
36109   __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;};
36110   __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;};
36111   __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;};
36112   __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;};
36113   __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;};
36114   return 0;
36115   __pyx_L1_error:;
36116   return -1;
36117 }
36118
36119 #if PY_MAJOR_VERSION < 3
36120 PyMODINIT_FUNC initcsamtools(void); /*proto*/
36121 PyMODINIT_FUNC initcsamtools(void)
36122 #else
36123 PyMODINIT_FUNC PyInit_csamtools(void); /*proto*/
36124 PyMODINIT_FUNC PyInit_csamtools(void)
36125 #endif
36126 {
36127   PyObject *__pyx_t_1 = NULL;
36128   PyObject *__pyx_t_2 = NULL;
36129   PyObject *__pyx_t_3 = NULL;
36130   PyObject *__pyx_t_4 = NULL;
36131   int __pyx_t_5;
36132   #if CYTHON_REFNANNY
36133   void* __pyx_refnanny = NULL;
36134   __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
36135   if (!__Pyx_RefNanny) {
36136       PyErr_Clear();
36137       __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
36138       if (!__Pyx_RefNanny)
36139           Py_FatalError("failed to import 'refnanny' module");
36140   }
36141   __pyx_refnanny = __Pyx_RefNanny->SetupContext("PyMODINIT_FUNC PyInit_csamtools(void)", __LINE__, __FILE__);
36142   #endif
36143   __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;}
36144   __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;}
36145   #ifdef __pyx_binding_PyCFunctionType_USED
36146   if (__pyx_binding_PyCFunctionType_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
36147   #endif
36148   /*--- Library function declarations ---*/
36149   /*--- Threads initialization code ---*/
36150   #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
36151   #ifdef WITH_THREAD /* Python build with threading support? */
36152   PyEval_InitThreads();
36153   #endif
36154   #endif
36155   /*--- Module creation code ---*/
36156   #if PY_MAJOR_VERSION < 3
36157   __pyx_m = Py_InitModule4(__Pyx_NAMESTR("csamtools"), __pyx_methods, 0, 0, PYTHON_API_VERSION);
36158   #else
36159   __pyx_m = PyModule_Create(&__pyx_moduledef);
36160   #endif
36161   if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
36162   #if PY_MAJOR_VERSION < 3
36163   Py_INCREF(__pyx_m);
36164   #endif
36165   __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME));
36166   if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
36167   if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
36168   /*--- Initialize various global constants etc. ---*/
36169   if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
36170   if (__pyx_module_is_main_csamtools) {
36171     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;};
36172   }
36173   /*--- Builtin init code ---*/
36174   if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
36175   /*--- Global init code ---*/
36176   /*--- Function export code ---*/
36177   /*--- Type init code ---*/
36178   __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;}
36179   if (PyType_Ready(&__pyx_type_9csamtools_AlignedRead) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
36180   {
36181     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;}
36182     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
36183       __pyx_wrapperbase_9csamtools_11AlignedRead___str__ = *((PyWrapperDescrObject *)wrapper)->d_base;
36184       __pyx_wrapperbase_9csamtools_11AlignedRead___str__.doc = __pyx_doc_9csamtools_11AlignedRead___str__;
36185       ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_11AlignedRead___str__;
36186     }
36187   }
36188   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;}
36189   __pyx_ptype_9csamtools_AlignedRead = &__pyx_type_9csamtools_AlignedRead;
36190   __pyx_vtabptr_9csamtools_Samfile = &__pyx_vtable_9csamtools_Samfile;
36191   #if PY_MAJOR_VERSION >= 3
36192   __pyx_vtable_9csamtools_Samfile._buildHeader = (bam_header_t *(*)(struct __pyx_obj_9csamtools_Samfile *, PyObject *))__pyx_f_9csamtools_7Samfile__buildHeader;
36193   __pyx_vtable_9csamtools_Samfile.getCurrent = (bam1_t *(*)(struct __pyx_obj_9csamtools_Samfile *))__pyx_f_9csamtools_7Samfile_getCurrent;
36194   __pyx_vtable_9csamtools_Samfile.cnext = (int (*)(struct __pyx_obj_9csamtools_Samfile *))__pyx_f_9csamtools_7Samfile_cnext;
36195   __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;
36196   __pyx_vtable_9csamtools_Samfile._getrname = (char *(*)(struct __pyx_obj_9csamtools_Samfile *, int))__pyx_f_9csamtools_7Samfile__getrname;
36197   #else
36198   *(void(**)(void))&__pyx_vtable_9csamtools_Samfile._buildHeader = (void(*)(void))__pyx_f_9csamtools_7Samfile__buildHeader;
36199   *(void(**)(void))&__pyx_vtable_9csamtools_Samfile.getCurrent = (void(*)(void))__pyx_f_9csamtools_7Samfile_getCurrent;
36200   *(void(**)(void))&__pyx_vtable_9csamtools_Samfile.cnext = (void(*)(void))__pyx_f_9csamtools_7Samfile_cnext;
36201   *(void(**)(void))&__pyx_vtable_9csamtools_Samfile.write = (void(*)(void))__pyx_f_9csamtools_7Samfile_write;
36202   *(void(**)(void))&__pyx_vtable_9csamtools_Samfile._getrname = (void(*)(void))__pyx_f_9csamtools_7Samfile__getrname;
36203   #endif
36204   if (PyType_Ready(&__pyx_type_9csamtools_Samfile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
36205   {
36206     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;}
36207     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
36208       __pyx_wrapperbase_9csamtools_7Samfile___next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
36209       __pyx_wrapperbase_9csamtools_7Samfile___next__.doc = __pyx_doc_9csamtools_7Samfile___next__;
36210       ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_7Samfile___next__;
36211     }
36212   }
36213   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;}
36214   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;}
36215   __pyx_ptype_9csamtools_Samfile = &__pyx_type_9csamtools_Samfile;
36216   if (PyType_Ready(&__pyx_type_9csamtools_PileupProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
36217   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;}
36218   __pyx_ptype_9csamtools_PileupProxy = &__pyx_type_9csamtools_PileupProxy;
36219   if (PyType_Ready(&__pyx_type_9csamtools_PileupRead) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
36220   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;}
36221   __pyx_ptype_9csamtools_PileupRead = &__pyx_type_9csamtools_PileupRead;
36222   __pyx_vtabptr_9csamtools_Fastafile = &__pyx_vtable_9csamtools_Fastafile;
36223   #if PY_MAJOR_VERSION >= 3
36224   __pyx_vtable_9csamtools_Fastafile._fetch = (char *(*)(struct __pyx_obj_9csamtools_Fastafile *, char *, int, int, int *))__pyx_f_9csamtools_9Fastafile__fetch;
36225   #else
36226   *(void(**)(void))&__pyx_vtable_9csamtools_Fastafile._fetch = (void(*)(void))__pyx_f_9csamtools_9Fastafile__fetch;
36227   #endif
36228   if (PyType_Ready(&__pyx_type_9csamtools_Fastafile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
36229   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;}
36230   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;}
36231   __pyx_ptype_9csamtools_Fastafile = &__pyx_type_9csamtools_Fastafile;
36232   if (PyType_Ready(&__pyx_type_9csamtools_IteratorRow) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
36233   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;}
36234   __pyx_ptype_9csamtools_IteratorRow = &__pyx_type_9csamtools_IteratorRow;
36235   __pyx_vtabptr_9csamtools_IteratorRowRegion = &__pyx_vtable_9csamtools_IteratorRowRegion;
36236   #if PY_MAJOR_VERSION >= 3
36237   __pyx_vtable_9csamtools_IteratorRowRegion.getCurrent = (bam1_t *(*)(struct __pyx_obj_9csamtools_IteratorRowRegion *))__pyx_f_9csamtools_17IteratorRowRegion_getCurrent;
36238   __pyx_vtable_9csamtools_IteratorRowRegion.cnext = (int (*)(struct __pyx_obj_9csamtools_IteratorRowRegion *))__pyx_f_9csamtools_17IteratorRowRegion_cnext;
36239   #else
36240   *(void(**)(void))&__pyx_vtable_9csamtools_IteratorRowRegion.getCurrent = (void(*)(void))__pyx_f_9csamtools_17IteratorRowRegion_getCurrent;
36241   *(void(**)(void))&__pyx_vtable_9csamtools_IteratorRowRegion.cnext = (void(*)(void))__pyx_f_9csamtools_17IteratorRowRegion_cnext;
36242   #endif
36243   __pyx_type_9csamtools_IteratorRowRegion.tp_base = __pyx_ptype_9csamtools_IteratorRow;
36244   if (PyType_Ready(&__pyx_type_9csamtools_IteratorRowRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
36245   {
36246     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;}
36247     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
36248       __pyx_wrapperbase_9csamtools_17IteratorRowRegion___next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
36249       __pyx_wrapperbase_9csamtools_17IteratorRowRegion___next__.doc = __pyx_doc_9csamtools_17IteratorRowRegion___next__;
36250       ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_17IteratorRowRegion___next__;
36251     }
36252   }
36253   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;}
36254   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;}
36255   __pyx_ptype_9csamtools_IteratorRowRegion = &__pyx_type_9csamtools_IteratorRowRegion;
36256   __pyx_vtabptr_9csamtools_IteratorRowAll = &__pyx_vtable_9csamtools_IteratorRowAll;
36257   #if PY_MAJOR_VERSION >= 3
36258   __pyx_vtable_9csamtools_IteratorRowAll.getCurrent = (bam1_t *(*)(struct __pyx_obj_9csamtools_IteratorRowAll *))__pyx_f_9csamtools_14IteratorRowAll_getCurrent;
36259   __pyx_vtable_9csamtools_IteratorRowAll.cnext = (int (*)(struct __pyx_obj_9csamtools_IteratorRowAll *))__pyx_f_9csamtools_14IteratorRowAll_cnext;
36260   #else
36261   *(void(**)(void))&__pyx_vtable_9csamtools_IteratorRowAll.getCurrent = (void(*)(void))__pyx_f_9csamtools_14IteratorRowAll_getCurrent;
36262   *(void(**)(void))&__pyx_vtable_9csamtools_IteratorRowAll.cnext = (void(*)(void))__pyx_f_9csamtools_14IteratorRowAll_cnext;
36263   #endif
36264   __pyx_type_9csamtools_IteratorRowAll.tp_base = __pyx_ptype_9csamtools_IteratorRow;
36265   if (PyType_Ready(&__pyx_type_9csamtools_IteratorRowAll) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
36266   {
36267     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;}
36268     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
36269       __pyx_wrapperbase_9csamtools_14IteratorRowAll___next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
36270       __pyx_wrapperbase_9csamtools_14IteratorRowAll___next__.doc = __pyx_doc_9csamtools_14IteratorRowAll___next__;
36271       ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_14IteratorRowAll___next__;
36272     }
36273   }
36274   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;}
36275   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;}
36276   __pyx_ptype_9csamtools_IteratorRowAll = &__pyx_type_9csamtools_IteratorRowAll;
36277   __pyx_type_9csamtools_IteratorRowAllRefs.tp_base = __pyx_ptype_9csamtools_IteratorRow;
36278   if (PyType_Ready(&__pyx_type_9csamtools_IteratorRowAllRefs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
36279   {
36280     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;}
36281     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
36282       __pyx_wrapperbase_9csamtools_18IteratorRowAllRefs___next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
36283       __pyx_wrapperbase_9csamtools_18IteratorRowAllRefs___next__.doc = __pyx_doc_9csamtools_18IteratorRowAllRefs___next__;
36284       ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_18IteratorRowAllRefs___next__;
36285     }
36286   }
36287   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;}
36288   __pyx_ptype_9csamtools_IteratorRowAllRefs = &__pyx_type_9csamtools_IteratorRowAllRefs;
36289   __pyx_vtabptr_9csamtools_IteratorRowSelection = &__pyx_vtable_9csamtools_IteratorRowSelection;
36290   #if PY_MAJOR_VERSION >= 3
36291   __pyx_vtable_9csamtools_IteratorRowSelection.getCurrent = (bam1_t *(*)(struct __pyx_obj_9csamtools_IteratorRowSelection *))__pyx_f_9csamtools_20IteratorRowSelection_getCurrent;
36292   __pyx_vtable_9csamtools_IteratorRowSelection.cnext = (int (*)(struct __pyx_obj_9csamtools_IteratorRowSelection *))__pyx_f_9csamtools_20IteratorRowSelection_cnext;
36293   #else
36294   *(void(**)(void))&__pyx_vtable_9csamtools_IteratorRowSelection.getCurrent = (void(*)(void))__pyx_f_9csamtools_20IteratorRowSelection_getCurrent;
36295   *(void(**)(void))&__pyx_vtable_9csamtools_IteratorRowSelection.cnext = (void(*)(void))__pyx_f_9csamtools_20IteratorRowSelection_cnext;
36296   #endif
36297   __pyx_type_9csamtools_IteratorRowSelection.tp_base = __pyx_ptype_9csamtools_IteratorRow;
36298   if (PyType_Ready(&__pyx_type_9csamtools_IteratorRowSelection) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
36299   {
36300     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;}
36301     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
36302       __pyx_wrapperbase_9csamtools_20IteratorRowSelection___next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
36303       __pyx_wrapperbase_9csamtools_20IteratorRowSelection___next__.doc = __pyx_doc_9csamtools_20IteratorRowSelection___next__;
36304       ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_20IteratorRowSelection___next__;
36305     }
36306   }
36307   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;}
36308   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;}
36309   __pyx_ptype_9csamtools_IteratorRowSelection = &__pyx_type_9csamtools_IteratorRowSelection;
36310   __pyx_vtabptr_9csamtools_IteratorColumn = &__pyx_vtable_9csamtools_IteratorColumn;
36311   #if PY_MAJOR_VERSION >= 3
36312   __pyx_vtable_9csamtools_IteratorColumn.cnext = (int (*)(struct __pyx_obj_9csamtools_IteratorColumn *))__pyx_f_9csamtools_14IteratorColumn_cnext;
36313   __pyx_vtable_9csamtools_IteratorColumn.getSequence = (char *(*)(struct __pyx_obj_9csamtools_IteratorColumn *))__pyx_f_9csamtools_14IteratorColumn_getSequence;
36314   __pyx_vtable_9csamtools_IteratorColumn.setMask = (PyObject *(*)(struct __pyx_obj_9csamtools_IteratorColumn *, PyObject *))__pyx_f_9csamtools_14IteratorColumn_setMask;
36315   __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;
36316   __pyx_vtable_9csamtools_IteratorColumn.reset = (PyObject *(*)(struct __pyx_obj_9csamtools_IteratorColumn *, PyObject *, PyObject *, PyObject *))__pyx_f_9csamtools_14IteratorColumn_reset;
36317   #else
36318   *(void(**)(void))&__pyx_vtable_9csamtools_IteratorColumn.cnext = (void(*)(void))__pyx_f_9csamtools_14IteratorColumn_cnext;
36319   *(void(**)(void))&__pyx_vtable_9csamtools_IteratorColumn.getSequence = (void(*)(void))__pyx_f_9csamtools_14IteratorColumn_getSequence;
36320   *(void(**)(void))&__pyx_vtable_9csamtools_IteratorColumn.setMask = (void(*)(void))__pyx_f_9csamtools_14IteratorColumn_setMask;
36321   *(void(**)(void))&__pyx_vtable_9csamtools_IteratorColumn.setupIteratorData = (void(*)(void))__pyx_f_9csamtools_14IteratorColumn_setupIteratorData;
36322   *(void(**)(void))&__pyx_vtable_9csamtools_IteratorColumn.reset = (void(*)(void))__pyx_f_9csamtools_14IteratorColumn_reset;
36323   #endif
36324   if (PyType_Ready(&__pyx_type_9csamtools_IteratorColumn) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
36325   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;}
36326   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;}
36327   __pyx_ptype_9csamtools_IteratorColumn = &__pyx_type_9csamtools_IteratorColumn;
36328   __pyx_vtabptr_9csamtools_IteratorColumnRegion = &__pyx_vtable_9csamtools_IteratorColumnRegion;
36329   __pyx_vtable_9csamtools_IteratorColumnRegion.__pyx_base = *__pyx_vtabptr_9csamtools_IteratorColumn;
36330   __pyx_type_9csamtools_IteratorColumnRegion.tp_base = __pyx_ptype_9csamtools_IteratorColumn;
36331   if (PyType_Ready(&__pyx_type_9csamtools_IteratorColumnRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
36332   {
36333     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;}
36334     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
36335       __pyx_wrapperbase_9csamtools_20IteratorColumnRegion___next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
36336       __pyx_wrapperbase_9csamtools_20IteratorColumnRegion___next__.doc = __pyx_doc_9csamtools_20IteratorColumnRegion___next__;
36337       ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_20IteratorColumnRegion___next__;
36338     }
36339   }
36340   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;}
36341   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;}
36342   __pyx_ptype_9csamtools_IteratorColumnRegion = &__pyx_type_9csamtools_IteratorColumnRegion;
36343   __pyx_vtabptr_9csamtools_IteratorColumnAllRefs = &__pyx_vtable_9csamtools_IteratorColumnAllRefs;
36344   __pyx_vtable_9csamtools_IteratorColumnAllRefs.__pyx_base = *__pyx_vtabptr_9csamtools_IteratorColumn;
36345   __pyx_type_9csamtools_IteratorColumnAllRefs.tp_base = __pyx_ptype_9csamtools_IteratorColumn;
36346   if (PyType_Ready(&__pyx_type_9csamtools_IteratorColumnAllRefs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
36347   {
36348     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;}
36349     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
36350       __pyx_wrapperbase_9csamtools_21IteratorColumnAllRefs___next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
36351       __pyx_wrapperbase_9csamtools_21IteratorColumnAllRefs___next__.doc = __pyx_doc_9csamtools_21IteratorColumnAllRefs___next__;
36352       ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_21IteratorColumnAllRefs___next__;
36353     }
36354   }
36355   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;}
36356   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;}
36357   __pyx_ptype_9csamtools_IteratorColumnAllRefs = &__pyx_type_9csamtools_IteratorColumnAllRefs;
36358   if (PyType_Ready(&__pyx_type_9csamtools_SNPCall) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
36359   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;}
36360   __pyx_ptype_9csamtools_SNPCall = &__pyx_type_9csamtools_SNPCall;
36361   __pyx_vtabptr_9csamtools_SNPCallerBase = &__pyx_vtable_9csamtools_SNPCallerBase;
36362   #if PY_MAJOR_VERSION >= 3
36363   __pyx_vtable_9csamtools_SNPCallerBase.__dump = (PyObject *(*)(struct __pyx_obj_9csamtools_SNPCallerBase *, glf1_t *, uint32_t, int))__pyx_f_9csamtools_13SNPCallerBase___dump;
36364   #else
36365   *(void(**)(void))&__pyx_vtable_9csamtools_SNPCallerBase.__dump = (void(*)(void))__pyx_f_9csamtools_13SNPCallerBase___dump;
36366   #endif
36367   if (PyType_Ready(&__pyx_type_9csamtools_SNPCallerBase) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
36368   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;}
36369   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;}
36370   __pyx_ptype_9csamtools_SNPCallerBase = &__pyx_type_9csamtools_SNPCallerBase;
36371   __pyx_vtabptr_9csamtools_IteratorSNPCalls = &__pyx_vtable_9csamtools_IteratorSNPCalls;
36372   __pyx_vtable_9csamtools_IteratorSNPCalls.__pyx_base = *__pyx_vtabptr_9csamtools_SNPCallerBase;
36373   __pyx_type_9csamtools_IteratorSNPCalls.tp_base = __pyx_ptype_9csamtools_SNPCallerBase;
36374   if (PyType_Ready(&__pyx_type_9csamtools_IteratorSNPCalls) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2946; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
36375   {
36376     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;}
36377     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
36378       __pyx_wrapperbase_9csamtools_16IteratorSNPCalls___next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
36379       __pyx_wrapperbase_9csamtools_16IteratorSNPCalls___next__.doc = __pyx_doc_9csamtools_16IteratorSNPCalls___next__;
36380       ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_16IteratorSNPCalls___next__;
36381     }
36382   }
36383   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;}
36384   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;}
36385   __pyx_ptype_9csamtools_IteratorSNPCalls = &__pyx_type_9csamtools_IteratorSNPCalls;
36386   __pyx_vtabptr_9csamtools_SNPCaller = &__pyx_vtable_9csamtools_SNPCaller;
36387   __pyx_vtable_9csamtools_SNPCaller.__pyx_base = *__pyx_vtabptr_9csamtools_SNPCallerBase;
36388   __pyx_type_9csamtools_SNPCaller.tp_base = __pyx_ptype_9csamtools_SNPCallerBase;
36389   if (PyType_Ready(&__pyx_type_9csamtools_SNPCaller) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
36390   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;}
36391   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;}
36392   __pyx_ptype_9csamtools_SNPCaller = &__pyx_type_9csamtools_SNPCaller;
36393   if (PyType_Ready(&__pyx_type_9csamtools_IndelCall) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
36394   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;}
36395   __pyx_ptype_9csamtools_IndelCall = &__pyx_type_9csamtools_IndelCall;
36396   if (PyType_Ready(&__pyx_type_9csamtools_IndelCallerBase) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
36397   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;}
36398   __pyx_ptype_9csamtools_IndelCallerBase = &__pyx_type_9csamtools_IndelCallerBase;
36399   __pyx_type_9csamtools_IndelCaller.tp_base = __pyx_ptype_9csamtools_IndelCallerBase;
36400   if (PyType_Ready(&__pyx_type_9csamtools_IndelCaller) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
36401   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;}
36402   __pyx_ptype_9csamtools_IndelCaller = &__pyx_type_9csamtools_IndelCaller;
36403   __pyx_type_9csamtools_IteratorIndelCalls.tp_base = __pyx_ptype_9csamtools_IndelCallerBase;
36404   if (PyType_Ready(&__pyx_type_9csamtools_IteratorIndelCalls) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
36405   {
36406     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;}
36407     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
36408       __pyx_wrapperbase_9csamtools_18IteratorIndelCalls___next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
36409       __pyx_wrapperbase_9csamtools_18IteratorIndelCalls___next__.doc = __pyx_doc_9csamtools_18IteratorIndelCalls___next__;
36410       ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_9csamtools_18IteratorIndelCalls___next__;
36411     }
36412   }
36413   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;}
36414   __pyx_ptype_9csamtools_IteratorIndelCalls = &__pyx_type_9csamtools_IteratorIndelCalls;
36415   if (PyType_Ready(&__pyx_type_9csamtools_IndexedReads) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
36416   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;}
36417   __pyx_ptype_9csamtools_IndexedReads = &__pyx_type_9csamtools_IndexedReads;
36418   /*--- Type import code ---*/
36419   __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;}
36420   /*--- Function import code ---*/
36421   /*--- Execution code ---*/
36422
36423   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":4
36424  * # cython: profile=True
36425  * # adds doc-strings for sphinx
36426  * import tempfile             # <<<<<<<<<<<<<<
36427  * import os
36428  * import sys
36429  */
36430   __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;}
36431   __Pyx_GOTREF(__pyx_t_1);
36432   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;}
36433   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36434
36435   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":5
36436  * # adds doc-strings for sphinx
36437  * import tempfile
36438  * import os             # <<<<<<<<<<<<<<
36439  * import sys
36440  * import types
36441  */
36442   __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;}
36443   __Pyx_GOTREF(__pyx_t_1);
36444   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;}
36445   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36446
36447   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":6
36448  * import tempfile
36449  * import os
36450  * import sys             # <<<<<<<<<<<<<<
36451  * import types
36452  * import itertools
36453  */
36454   __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;}
36455   __Pyx_GOTREF(__pyx_t_1);
36456   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;}
36457   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36458
36459   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":7
36460  * import os
36461  * import sys
36462  * import types             # <<<<<<<<<<<<<<
36463  * import itertools
36464  * import struct
36465  */
36466   __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;}
36467   __Pyx_GOTREF(__pyx_t_1);
36468   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;}
36469   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36470
36471   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":8
36472  * import sys
36473  * import types
36474  * import itertools             # <<<<<<<<<<<<<<
36475  * import struct
36476  * import ctypes
36477  */
36478   __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;}
36479   __Pyx_GOTREF(__pyx_t_1);
36480   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;}
36481   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36482
36483   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":9
36484  * import types
36485  * import itertools
36486  * import struct             # <<<<<<<<<<<<<<
36487  * import ctypes
36488  * import collections
36489  */
36490   __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;}
36491   __Pyx_GOTREF(__pyx_t_1);
36492   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;}
36493   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36494
36495   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":10
36496  * import itertools
36497  * import struct
36498  * import ctypes             # <<<<<<<<<<<<<<
36499  * import collections
36500  * import re
36501  */
36502   __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;}
36503   __Pyx_GOTREF(__pyx_t_1);
36504   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;}
36505   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36506
36507   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":11
36508  * import struct
36509  * import ctypes
36510  * import collections             # <<<<<<<<<<<<<<
36511  * import re
36512  * import platform
36513  */
36514   __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;}
36515   __Pyx_GOTREF(__pyx_t_1);
36516   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;}
36517   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36518
36519   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":12
36520  * import ctypes
36521  * import collections
36522  * import re             # <<<<<<<<<<<<<<
36523  * import platform
36524  * from cpython cimport PyString_FromStringAndSize, PyString_AS_STRING
36525  */
36526   __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;}
36527   __Pyx_GOTREF(__pyx_t_1);
36528   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;}
36529   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36530
36531   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":13
36532  * import collections
36533  * import re
36534  * import platform             # <<<<<<<<<<<<<<
36535  * from cpython cimport PyString_FromStringAndSize, PyString_AS_STRING
36536  * from cpython cimport PyErr_SetString
36537  */
36538   __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;}
36539   __Pyx_GOTREF(__pyx_t_1);
36540   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;}
36541   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36542
36543   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":63
36544  * #####################################################################
36545  * # hard-coded constants
36546  * cdef char * bam_nt16_rev_table = "=ACMGRSVTWYHKDBN"             # <<<<<<<<<<<<<<
36547  * cdef int max_pos = 2 << 29
36548  * 
36549  */
36550   __pyx_v_9csamtools_bam_nt16_rev_table = __pyx_k_172;
36551
36552   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":64
36553  * # hard-coded constants
36554  * cdef char * bam_nt16_rev_table = "=ACMGRSVTWYHKDBN"
36555  * cdef int max_pos = 2 << 29             # <<<<<<<<<<<<<<
36556  * 
36557  * # redirect stderr to 0
36558  */
36559   __pyx_v_9csamtools_max_pos = 1073741824;
36560
36561   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":67
36562  * 
36563  * # redirect stderr to 0
36564  * _logfile = open(os.path.devnull, "w")             # <<<<<<<<<<<<<<
36565  * pysam_set_stderr( PyFile_AsFile( _logfile ) )
36566  * 
36567  */
36568   __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;}
36569   __Pyx_GOTREF(__pyx_t_1);
36570   __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;}
36571   __Pyx_GOTREF(__pyx_t_2);
36572   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36573   __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;}
36574   __Pyx_GOTREF(__pyx_t_1);
36575   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
36576   __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;}
36577   __Pyx_GOTREF(__pyx_t_2);
36578   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
36579   __Pyx_GIVEREF(__pyx_t_1);
36580   __Pyx_INCREF(((PyObject *)__pyx_n_s__w));
36581   PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)__pyx_n_s__w));
36582   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__w));
36583   __pyx_t_1 = 0;
36584   __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;}
36585   __Pyx_GOTREF(__pyx_t_1);
36586   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
36587   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;}
36588   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36589
36590   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":68
36591  * # redirect stderr to 0
36592  * _logfile = open(os.path.devnull, "w")
36593  * pysam_set_stderr( PyFile_AsFile( _logfile ) )             # <<<<<<<<<<<<<<
36594  * 
36595  * #####################################################################
36596  */
36597   __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;}
36598   __Pyx_GOTREF(__pyx_t_1);
36599   pysam_set_stderr(PyFile_AsFile(__pyx_t_1));
36600   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36601
36602   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":117
36603  *     (<object>f)(a)
36604  * 
36605  * class PileupColumn(object):             # <<<<<<<<<<<<<<
36606  *     '''A pileup column. A pileup column contains
36607  *     all the reads that map to a certain target base.
36608  */
36609   __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;}
36610   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
36611   __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;}
36612   __Pyx_GOTREF(__pyx_t_2);
36613   __Pyx_INCREF(__pyx_builtin_object);
36614   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_builtin_object);
36615   __Pyx_GIVEREF(__pyx_builtin_object);
36616   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;}
36617   __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;}
36618   __Pyx_GOTREF(__pyx_t_3);
36619   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
36620
36621   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":130
36622  *         list of reads (:class:`pysam.PileupRead`) aligned to this column
36623  *     '''
36624  *     def __str__(self):             # <<<<<<<<<<<<<<
36625  *         return "\t".join( map(str, (self.tid, self.pos, self.n))) +\
36626  *             "\n" + "\n".join( map(str, self.pileups) )
36627  */
36628   __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;}
36629   __Pyx_GOTREF(__pyx_t_2);
36630   __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;}
36631   __Pyx_GOTREF(__pyx_t_4);
36632   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
36633   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;}
36634   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
36635   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;}
36636   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
36637   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
36638
36639   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":174
36640  *     return 0
36641  * 
36642  * class StderrStore():             # <<<<<<<<<<<<<<
36643  *     '''
36644  *     stderr is captured.
36645  */
36646   __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;}
36647   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
36648   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;}
36649   __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;}
36650   __Pyx_GOTREF(__pyx_t_3);
36651
36652   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":178
36653  *     stderr is captured.
36654  *     '''
36655  *     def __init__(self):             # <<<<<<<<<<<<<<
36656  *         return
36657  *         self.stderr_h, self.stderr_f = tempfile.mkstemp()
36658  */
36659   __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;}
36660   __Pyx_GOTREF(__pyx_t_4);
36661   __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;}
36662   __Pyx_GOTREF(__pyx_t_2);
36663   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
36664   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;}
36665   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
36666
36667   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":184
36668  *         self.stderr_save.setfd( self.stderr_h )
36669  * 
36670  *     def readAndRelease( self ):             # <<<<<<<<<<<<<<
36671  *         return []
36672  *         self.stderr_save.restore()
36673  */
36674   __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;}
36675   __Pyx_GOTREF(__pyx_t_2);
36676   __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;}
36677   __Pyx_GOTREF(__pyx_t_4);
36678   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
36679   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;}
36680   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
36681
36682   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":193
36683  *         return lines
36684  * 
36685  *     def release(self):             # <<<<<<<<<<<<<<
36686  *         return
36687  *         self.stderr_save.restore()
36688  */
36689   __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;}
36690   __Pyx_GOTREF(__pyx_t_4);
36691   __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;}
36692   __Pyx_GOTREF(__pyx_t_2);
36693   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
36694   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;}
36695   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
36696
36697   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":199
36698  *             os.remove( self.stderr_f )
36699  * 
36700  *     def __del__(self):             # <<<<<<<<<<<<<<
36701  *         self.release()
36702  * 
36703  */
36704   __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;}
36705   __Pyx_GOTREF(__pyx_t_2);
36706   __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;}
36707   __Pyx_GOTREF(__pyx_t_4);
36708   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
36709   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;}
36710   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
36711   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;}
36712   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
36713   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
36714
36715   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":202
36716  *         self.release()
36717  * 
36718  * class StderrStoreWindows():             # <<<<<<<<<<<<<<
36719  *     '''does nothing. stderr can't be redirected on windows'''
36720  *     def __init__(self): pass
36721  */
36722   __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;}
36723   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
36724   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;}
36725   __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;}
36726   __Pyx_GOTREF(__pyx_t_3);
36727
36728   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":204
36729  * class StderrStoreWindows():
36730  *     '''does nothing. stderr can't be redirected on windows'''
36731  *     def __init__(self): pass             # <<<<<<<<<<<<<<
36732  *     def readAndRelease(self): return []
36733  *     def release(self): pass
36734  */
36735   __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;}
36736   __Pyx_GOTREF(__pyx_t_4);
36737   __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;}
36738   __Pyx_GOTREF(__pyx_t_2);
36739   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
36740   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;}
36741   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
36742
36743   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":205
36744  *     '''does nothing. stderr can't be redirected on windows'''
36745  *     def __init__(self): pass
36746  *     def readAndRelease(self): return []             # <<<<<<<<<<<<<<
36747  *     def release(self): pass
36748  * 
36749  */
36750   __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;}
36751   __Pyx_GOTREF(__pyx_t_2);
36752   __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;}
36753   __Pyx_GOTREF(__pyx_t_4);
36754   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
36755   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;}
36756   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
36757
36758   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":206
36759  *     def __init__(self): pass
36760  *     def readAndRelease(self): return []
36761  *     def release(self): pass             # <<<<<<<<<<<<<<
36762  * 
36763  * if platform.system()=='Windows':
36764  */
36765   __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;}
36766   __Pyx_GOTREF(__pyx_t_4);
36767   __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;}
36768   __Pyx_GOTREF(__pyx_t_2);
36769   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
36770   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;}
36771   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
36772   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;}
36773   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
36774   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
36775
36776   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":208
36777  *     def release(self): pass
36778  * 
36779  * if platform.system()=='Windows':             # <<<<<<<<<<<<<<
36780  *     del StderrStore
36781  *     StderrStore = StderrStoreWindows
36782  */
36783   __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;}
36784   __Pyx_GOTREF(__pyx_t_1);
36785   __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;}
36786   __Pyx_GOTREF(__pyx_t_3);
36787   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36788   __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;}
36789   __Pyx_GOTREF(__pyx_t_1);
36790   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
36791   __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;}
36792   __Pyx_GOTREF(__pyx_t_3);
36793   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36794   __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;}
36795   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
36796   if (__pyx_t_5) {
36797
36798     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":209
36799  * 
36800  * if platform.system()=='Windows':
36801  *     del StderrStore             # <<<<<<<<<<<<<<
36802  *     StderrStore = StderrStoreWindows
36803  * 
36804  */
36805     if (__Pyx_DelAttrString(__pyx_m, "StderrStore") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
36806
36807     /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":210
36808  * if platform.system()=='Windows':
36809  *     del StderrStore
36810  *     StderrStore = StderrStoreWindows             # <<<<<<<<<<<<<<
36811  * 
36812  * 
36813  */
36814     __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;}
36815     __Pyx_GOTREF(__pyx_t_3);
36816     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;}
36817     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
36818     goto __pyx_L2;
36819   }
36820   __pyx_L2:;
36821
36822   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":217
36823  * ######################################################################
36824  * # valid types for sam headers
36825  * VALID_HEADER_TYPES = { "HD" : dict,             # <<<<<<<<<<<<<<
36826  *                        "SQ" : list,
36827  *                        "RG" : list,
36828  */
36829   __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;}
36830   __Pyx_GOTREF(((PyObject *)__pyx_t_3));
36831   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;}
36832
36833   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":218
36834  * # valid types for sam headers
36835  * VALID_HEADER_TYPES = { "HD" : dict,
36836  *                        "SQ" : list,             # <<<<<<<<<<<<<<
36837  *                        "RG" : list,
36838  *                        "PG" : list,
36839  */
36840   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;}
36841
36842   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":219
36843  * VALID_HEADER_TYPES = { "HD" : dict,
36844  *                        "SQ" : list,
36845  *                        "RG" : list,             # <<<<<<<<<<<<<<
36846  *                        "PG" : list,
36847  *                        "CO" : list }
36848  */
36849   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;}
36850
36851   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":220
36852  *                        "SQ" : list,
36853  *                        "RG" : list,
36854  *                        "PG" : list,             # <<<<<<<<<<<<<<
36855  *                        "CO" : list }
36856  * 
36857  */
36858   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;}
36859
36860   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":221
36861  *                        "RG" : list,
36862  *                        "PG" : list,
36863  *                        "CO" : list }             # <<<<<<<<<<<<<<
36864  * 
36865  * # order of records within sam headers
36866  */
36867   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;}
36868   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;}
36869   __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
36870
36871   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":224
36872  * 
36873  * # order of records within sam headers
36874  * VALID_HEADERS = ("HD", "SQ", "RG", "PG", "CO" )             # <<<<<<<<<<<<<<
36875  * 
36876  * # type conversions within sam header records
36877  */
36878   __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;}
36879   __Pyx_GOTREF(__pyx_t_3);
36880   __Pyx_INCREF(((PyObject *)__pyx_n_s__HD));
36881   PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_n_s__HD));
36882   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__HD));
36883   __Pyx_INCREF(((PyObject *)__pyx_n_s__SQ));
36884   PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_n_s__SQ));
36885   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__SQ));
36886   __Pyx_INCREF(((PyObject *)__pyx_n_s__RG));
36887   PyTuple_SET_ITEM(__pyx_t_3, 2, ((PyObject *)__pyx_n_s__RG));
36888   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__RG));
36889   __Pyx_INCREF(((PyObject *)__pyx_n_s__PG));
36890   PyTuple_SET_ITEM(__pyx_t_3, 3, ((PyObject *)__pyx_n_s__PG));
36891   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PG));
36892   __Pyx_INCREF(((PyObject *)__pyx_n_s__CO));
36893   PyTuple_SET_ITEM(__pyx_t_3, 4, ((PyObject *)__pyx_n_s__CO));
36894   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__CO));
36895   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;}
36896   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
36897
36898   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":227
36899  * 
36900  * # type conversions within sam header records
36901  * VALID_HEADER_FIELDS = { "HD" : { "VN" : str, "SO" : str, "GO" : str },             # <<<<<<<<<<<<<<
36902  *                         "SQ" : { "SN" : str, "LN" : int, "AS" : str, "M5" : str, "UR" : str, "SP" : str },
36903  *                         "RG" : { "ID" : str, "SM" : str, "LB" : str, "DS" : str, "PU" : str, "PI" : str, "CN" : str, "DT" : str, "PL" : str, },
36904  */
36905   __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;}
36906   __Pyx_GOTREF(((PyObject *)__pyx_t_3));
36907   __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;}
36908   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
36909   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;}
36910   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;}
36911   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;}
36912   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;}
36913   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
36914
36915   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":228
36916  * # type conversions within sam header records
36917  * VALID_HEADER_FIELDS = { "HD" : { "VN" : str, "SO" : str, "GO" : str },
36918  *                         "SQ" : { "SN" : str, "LN" : int, "AS" : str, "M5" : str, "UR" : str, "SP" : str },             # <<<<<<<<<<<<<<
36919  *                         "RG" : { "ID" : str, "SM" : str, "LB" : str, "DS" : str, "PU" : str, "PI" : str, "CN" : str, "DT" : str, "PL" : str, },
36920  *                         "PG" : { "PN" : str, "ID" : str, "VN" : str, "CL" : str }, }
36921  */
36922   __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;}
36923   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
36924   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;}
36925   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;}
36926   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;}
36927   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;}
36928   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;}
36929   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;}
36930   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;}
36931   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
36932
36933   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":229
36934  * VALID_HEADER_FIELDS = { "HD" : { "VN" : str, "SO" : str, "GO" : str },
36935  *                         "SQ" : { "SN" : str, "LN" : int, "AS" : str, "M5" : str, "UR" : str, "SP" : str },
36936  *                         "RG" : { "ID" : str, "SM" : str, "LB" : str, "DS" : str, "PU" : str, "PI" : str, "CN" : str, "DT" : str, "PL" : str, },             # <<<<<<<<<<<<<<
36937  *                         "PG" : { "PN" : str, "ID" : str, "VN" : str, "CL" : str }, }
36938  * 
36939  */
36940   __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;}
36941   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
36942   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;}
36943   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;}
36944   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;}
36945   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;}
36946   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;}
36947   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;}
36948   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;}
36949   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;}
36950   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;}
36951   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;}
36952   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
36953
36954   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":230
36955  *                         "SQ" : { "SN" : str, "LN" : int, "AS" : str, "M5" : str, "UR" : str, "SP" : str },
36956  *                         "RG" : { "ID" : str, "SM" : str, "LB" : str, "DS" : str, "PU" : str, "PI" : str, "CN" : str, "DT" : str, "PL" : str, },
36957  *                         "PG" : { "PN" : str, "ID" : str, "VN" : str, "CL" : str }, }             # <<<<<<<<<<<<<<
36958  * 
36959  * # output order of fields within records
36960  */
36961   __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;}
36962   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
36963   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;}
36964   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;}
36965   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;}
36966   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;}
36967   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;}
36968   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
36969   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;}
36970   __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
36971
36972   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":233
36973  * 
36974  * # output order of fields within records
36975  * VALID_HEADER_ORDER = { "HD" : ( "VN", "SO", "GO" ),             # <<<<<<<<<<<<<<
36976  *                        "SQ" : ( "SN", "LN", "AS", "M5" , "UR" , "SP" ),
36977  *                        "RG" : ( "ID", "SM", "LB", "DS" , "PU" , "PI" , "CN" , "DT", "PL" ),
36978  */
36979   __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;}
36980   __Pyx_GOTREF(((PyObject *)__pyx_t_3));
36981   __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;}
36982   __Pyx_GOTREF(__pyx_t_1);
36983   __Pyx_INCREF(((PyObject *)__pyx_n_s__VN));
36984   PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__VN));
36985   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__VN));
36986   __Pyx_INCREF(((PyObject *)__pyx_n_s__SO));
36987   PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__SO));
36988   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__SO));
36989   __Pyx_INCREF(((PyObject *)__pyx_n_s__GO));
36990   PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_n_s__GO));
36991   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__GO));
36992   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;}
36993   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
36994
36995   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":234
36996  * # output order of fields within records
36997  * VALID_HEADER_ORDER = { "HD" : ( "VN", "SO", "GO" ),
36998  *                        "SQ" : ( "SN", "LN", "AS", "M5" , "UR" , "SP" ),             # <<<<<<<<<<<<<<
36999  *                        "RG" : ( "ID", "SM", "LB", "DS" , "PU" , "PI" , "CN" , "DT", "PL" ),
37000  *                        "PG" : ( "PN", "ID", "VN", "CL" ), }
37001  */
37002   __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;}
37003   __Pyx_GOTREF(__pyx_t_1);
37004   __Pyx_INCREF(((PyObject *)__pyx_n_s__SN));
37005   PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__SN));
37006   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__SN));
37007   __Pyx_INCREF(((PyObject *)__pyx_n_s__LN));
37008   PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__LN));
37009   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__LN));
37010   __Pyx_INCREF(((PyObject *)__pyx_n_s__AS));
37011   PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_n_s__AS));
37012   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__AS));
37013   __Pyx_INCREF(((PyObject *)__pyx_n_s__M5));
37014   PyTuple_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_n_s__M5));
37015   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__M5));
37016   __Pyx_INCREF(((PyObject *)__pyx_n_s__UR));
37017   PyTuple_SET_ITEM(__pyx_t_1, 4, ((PyObject *)__pyx_n_s__UR));
37018   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__UR));
37019   __Pyx_INCREF(((PyObject *)__pyx_n_s__SP));
37020   PyTuple_SET_ITEM(__pyx_t_1, 5, ((PyObject *)__pyx_n_s__SP));
37021   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__SP));
37022   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;}
37023   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37024
37025   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":235
37026  * VALID_HEADER_ORDER = { "HD" : ( "VN", "SO", "GO" ),
37027  *                        "SQ" : ( "SN", "LN", "AS", "M5" , "UR" , "SP" ),
37028  *                        "RG" : ( "ID", "SM", "LB", "DS" , "PU" , "PI" , "CN" , "DT", "PL" ),             # <<<<<<<<<<<<<<
37029  *                        "PG" : ( "PN", "ID", "VN", "CL" ), }
37030  * 
37031  */
37032   __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;}
37033   __Pyx_GOTREF(__pyx_t_1);
37034   __Pyx_INCREF(((PyObject *)__pyx_n_s__ID));
37035   PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__ID));
37036   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ID));
37037   __Pyx_INCREF(((PyObject *)__pyx_n_s__SM));
37038   PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__SM));
37039   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__SM));
37040   __Pyx_INCREF(((PyObject *)__pyx_n_s__LB));
37041   PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_n_s__LB));
37042   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__LB));
37043   __Pyx_INCREF(((PyObject *)__pyx_n_s__DS));
37044   PyTuple_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_n_s__DS));
37045   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__DS));
37046   __Pyx_INCREF(((PyObject *)__pyx_n_s__PU));
37047   PyTuple_SET_ITEM(__pyx_t_1, 4, ((PyObject *)__pyx_n_s__PU));
37048   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PU));
37049   __Pyx_INCREF(((PyObject *)__pyx_n_s__PI));
37050   PyTuple_SET_ITEM(__pyx_t_1, 5, ((PyObject *)__pyx_n_s__PI));
37051   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PI));
37052   __Pyx_INCREF(((PyObject *)__pyx_n_s__CN));
37053   PyTuple_SET_ITEM(__pyx_t_1, 6, ((PyObject *)__pyx_n_s__CN));
37054   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__CN));
37055   __Pyx_INCREF(((PyObject *)__pyx_n_s__DT));
37056   PyTuple_SET_ITEM(__pyx_t_1, 7, ((PyObject *)__pyx_n_s__DT));
37057   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__DT));
37058   __Pyx_INCREF(((PyObject *)__pyx_n_s__PL));
37059   PyTuple_SET_ITEM(__pyx_t_1, 8, ((PyObject *)__pyx_n_s__PL));
37060   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PL));
37061   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;}
37062   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37063
37064   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":236
37065  *                        "SQ" : ( "SN", "LN", "AS", "M5" , "UR" , "SP" ),
37066  *                        "RG" : ( "ID", "SM", "LB", "DS" , "PU" , "PI" , "CN" , "DT", "PL" ),
37067  *                        "PG" : ( "PN", "ID", "VN", "CL" ), }             # <<<<<<<<<<<<<<
37068  * 
37069  * 
37070  */
37071   __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;}
37072   __Pyx_GOTREF(__pyx_t_1);
37073   __Pyx_INCREF(((PyObject *)__pyx_n_s__PN));
37074   PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__PN));
37075   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PN));
37076   __Pyx_INCREF(((PyObject *)__pyx_n_s__ID));
37077   PyTuple_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__ID));
37078   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__ID));
37079   __Pyx_INCREF(((PyObject *)__pyx_n_s__VN));
37080   PyTuple_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_n_s__VN));
37081   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__VN));
37082   __Pyx_INCREF(((PyObject *)__pyx_n_s__CL));
37083   PyTuple_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_n_s__CL));
37084   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__CL));
37085   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;}
37086   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37087   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;}
37088   __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
37089
37090   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":719
37091  *                region = None,
37092  *                callback = None,
37093  *                until_eof = False ):             # <<<<<<<<<<<<<<
37094  *         '''
37095  *         fetch aligned reads in a :term:`region` using 0-based indexing. The region is specified by
37096  */
37097   __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;}
37098   __Pyx_GOTREF(__pyx_t_3);
37099   __pyx_k_29 = __pyx_t_3;
37100   __Pyx_GIVEREF(__pyx_t_3);
37101   __pyx_t_3 = 0;
37102
37103   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":830
37104  *                end = None,
37105  *                region = None,
37106  *                until_eof = False ):             # <<<<<<<<<<<<<<
37107  *         '''*(reference = None, start = None, end = None, region = None, callback = None, until_eof = False)*
37108  * 
37109  */
37110   __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;}
37111   __Pyx_GOTREF(__pyx_t_3);
37112   __pyx_k_39 = __pyx_t_3;
37113   __Pyx_GIVEREF(__pyx_t_3);
37114   __pyx_t_3 = 0;
37115
37116   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1718
37117  *                   int tid = 0,
37118  *                   int start = 0,
37119  *                   int end = max_pos,             # <<<<<<<<<<<<<<
37120  *                   **kwargs ):
37121  * 
37122  */
37123   __pyx_k_58 = __pyx_v_9csamtools_max_pos;
37124
37125   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2699
37126  *             return self._level
37127  * 
37128  * class Outs:             # <<<<<<<<<<<<<<
37129  *     '''http://mail.python.org/pipermail/python-list/2000-June/038406.html'''
37130  *     def __init__(self, id = 1):
37131  */
37132   __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;}
37133   __Pyx_GOTREF(((PyObject *)__pyx_t_3));
37134   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;}
37135   __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;}
37136   __Pyx_GOTREF(__pyx_t_1);
37137
37138   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2701
37139  * class Outs:
37140  *     '''http://mail.python.org/pipermail/python-list/2000-June/038406.html'''
37141  *     def __init__(self, id = 1):             # <<<<<<<<<<<<<<
37142  *         self.streams = []
37143  *         self.id = id
37144  */
37145   __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;}
37146   __Pyx_GOTREF(__pyx_t_2);
37147   __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;}
37148   __Pyx_GOTREF(__pyx_t_4);
37149   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
37150   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;}
37151   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37152
37153   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2705
37154  *         self.id = id
37155  * 
37156  *     def setdevice(self, filename):             # <<<<<<<<<<<<<<
37157  *         '''open an existing file, like "/dev/null"'''
37158  *         fd = os.open(filename, os.O_WRONLY)
37159  */
37160   __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;}
37161   __Pyx_GOTREF(__pyx_t_4);
37162   __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;}
37163   __Pyx_GOTREF(__pyx_t_2);
37164   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37165   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;}
37166   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
37167
37168   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2710
37169  *         self.setfd(fd)
37170  * 
37171  *     def setfile(self, filename):             # <<<<<<<<<<<<<<
37172  *         '''open a new file.'''
37173  *         fd = os.open(filename, os.O_WRONLY|os.O_CREAT, 0660);
37174  */
37175   __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;}
37176   __Pyx_GOTREF(__pyx_t_2);
37177   __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;}
37178   __Pyx_GOTREF(__pyx_t_4);
37179   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
37180   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;}
37181   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37182
37183   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2715
37184  *         self.setfd(fd)
37185  * 
37186  *     def setfd(self, fd):             # <<<<<<<<<<<<<<
37187  *         ofd = os.dup(self.id)      #  Save old stream on new unit.
37188  *         self.streams.append(ofd)
37189  */
37190   __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;}
37191   __Pyx_GOTREF(__pyx_t_4);
37192   __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;}
37193   __Pyx_GOTREF(__pyx_t_2);
37194   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37195   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;}
37196   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
37197
37198   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2723
37199  *         os.close(fd)                #  Close other unit (look out, caller.)
37200  * 
37201  *     def restore(self):             # <<<<<<<<<<<<<<
37202  *         '''restore previous output stream'''
37203  *         if self.streams:
37204  */
37205   __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;}
37206   __Pyx_GOTREF(__pyx_t_2);
37207   __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;}
37208   __Pyx_GOTREF(__pyx_t_4);
37209   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
37210   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;}
37211   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37212   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;}
37213   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37214   __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
37215
37216   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2736
37217  * def _samtools_dispatch( method,
37218  *                         args = (),
37219  *                         catch_stdout = True,             # <<<<<<<<<<<<<<
37220  *                         catch_stderr = False,
37221  *                         ):
37222  */
37223   __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;}
37224   __Pyx_GOTREF(__pyx_t_3);
37225   __pyx_k_98 = __pyx_t_3;
37226   __Pyx_GIVEREF(__pyx_t_3);
37227   __pyx_t_3 = 0;
37228
37229   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":2737
37230  *                         args = (),
37231  *                         catch_stdout = True,
37232  *                         catch_stderr = False,             # <<<<<<<<<<<<<<
37233  *                         ):
37234  *     '''call ``method`` in samtools providing arguments in args.
37235  */
37236   __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;}
37237   __Pyx_GOTREF(__pyx_t_3);
37238   __pyx_k_99 = __pyx_t_3;
37239   __Pyx_GIVEREF(__pyx_t_3);
37240   __pyx_t_3 = 0;
37241
37242   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":3436
37243  *         if self.owns_samfile: samclose( self.fp )
37244  * 
37245  * __all__ = ["Samfile",             # <<<<<<<<<<<<<<
37246  *            "Fastafile",
37247  *            "IteratorRow",
37248  */
37249   __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;}
37250   __Pyx_GOTREF(((PyObject *)__pyx_t_3));
37251   __Pyx_INCREF(((PyObject *)__pyx_n_s__Samfile));
37252   PyList_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_n_s__Samfile));
37253   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Samfile));
37254   __Pyx_INCREF(((PyObject *)__pyx_n_s__Fastafile));
37255   PyList_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_n_s__Fastafile));
37256   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Fastafile));
37257   __Pyx_INCREF(((PyObject *)__pyx_n_s__IteratorRow));
37258   PyList_SET_ITEM(__pyx_t_3, 2, ((PyObject *)__pyx_n_s__IteratorRow));
37259   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__IteratorRow));
37260   __Pyx_INCREF(((PyObject *)__pyx_n_s__IteratorColumn));
37261   PyList_SET_ITEM(__pyx_t_3, 3, ((PyObject *)__pyx_n_s__IteratorColumn));
37262   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__IteratorColumn));
37263   __Pyx_INCREF(((PyObject *)__pyx_n_s__AlignedRead));
37264   PyList_SET_ITEM(__pyx_t_3, 4, ((PyObject *)__pyx_n_s__AlignedRead));
37265   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__AlignedRead));
37266   __Pyx_INCREF(((PyObject *)__pyx_n_s__PileupColumn));
37267   PyList_SET_ITEM(__pyx_t_3, 5, ((PyObject *)__pyx_n_s__PileupColumn));
37268   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PileupColumn));
37269   __Pyx_INCREF(((PyObject *)__pyx_n_s__PileupProxy));
37270   PyList_SET_ITEM(__pyx_t_3, 6, ((PyObject *)__pyx_n_s__PileupProxy));
37271   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PileupProxy));
37272   __Pyx_INCREF(((PyObject *)__pyx_n_s__PileupRead));
37273   PyList_SET_ITEM(__pyx_t_3, 7, ((PyObject *)__pyx_n_s__PileupRead));
37274   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PileupRead));
37275   __Pyx_INCREF(((PyObject *)__pyx_n_s__IteratorSNPCalls));
37276   PyList_SET_ITEM(__pyx_t_3, 8, ((PyObject *)__pyx_n_s__IteratorSNPCalls));
37277   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__IteratorSNPCalls));
37278   __Pyx_INCREF(((PyObject *)__pyx_n_s__SNPCaller));
37279   PyList_SET_ITEM(__pyx_t_3, 9, ((PyObject *)__pyx_n_s__SNPCaller));
37280   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__SNPCaller));
37281   __Pyx_INCREF(((PyObject *)__pyx_n_s__IndelCaller));
37282   PyList_SET_ITEM(__pyx_t_3, 10, ((PyObject *)__pyx_n_s__IndelCaller));
37283   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__IndelCaller));
37284   __Pyx_INCREF(((PyObject *)__pyx_n_s__IteratorIndelCalls));
37285   PyList_SET_ITEM(__pyx_t_3, 11, ((PyObject *)__pyx_n_s__IteratorIndelCalls));
37286   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__IteratorIndelCalls));
37287   __Pyx_INCREF(((PyObject *)__pyx_n_s__IndexedReads));
37288   PyList_SET_ITEM(__pyx_t_3, 12, ((PyObject *)__pyx_n_s__IndexedReads));
37289   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__IndexedReads));
37290   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;}
37291   __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
37292
37293   /* "/ifs/devel/pysam/pysam/pysam/csamtools.pyx":1
37294  * # cython: embedsignature=True             # <<<<<<<<<<<<<<
37295  * # cython: profile=True
37296  * # adds doc-strings for sphinx
37297  */
37298   __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;}
37299   __Pyx_GOTREF(((PyObject *)__pyx_t_3));
37300   __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;}
37301   __Pyx_GOTREF(__pyx_t_1);
37302   __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;}
37303   __Pyx_GOTREF(__pyx_t_4);
37304   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37305   __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;}
37306   __Pyx_GOTREF(__pyx_t_1);
37307   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37308   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;}
37309   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37310   __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;}
37311   __Pyx_GOTREF(__pyx_t_1);
37312   __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;}
37313   __Pyx_GOTREF(__pyx_t_4);
37314   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37315   __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;}
37316   __Pyx_GOTREF(__pyx_t_1);
37317   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37318   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;}
37319   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37320   __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;}
37321   __Pyx_GOTREF(__pyx_t_1);
37322   __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;}
37323   __Pyx_GOTREF(__pyx_t_4);
37324   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37325   __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;}
37326   __Pyx_GOTREF(__pyx_t_1);
37327   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37328   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;}
37329   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37330   __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;}
37331   __Pyx_GOTREF(__pyx_t_1);
37332   __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;}
37333   __Pyx_GOTREF(__pyx_t_4);
37334   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37335   __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;}
37336   __Pyx_GOTREF(__pyx_t_1);
37337   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37338   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;}
37339   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37340   __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;}
37341   __Pyx_GOTREF(__pyx_t_1);
37342   __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;}
37343   __Pyx_GOTREF(__pyx_t_4);
37344   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37345   __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;}
37346   __Pyx_GOTREF(__pyx_t_1);
37347   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37348   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;}
37349   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37350   __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;}
37351   __Pyx_GOTREF(__pyx_t_1);
37352   __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;}
37353   __Pyx_GOTREF(__pyx_t_4);
37354   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37355   __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;}
37356   __Pyx_GOTREF(__pyx_t_1);
37357   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37358   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;}
37359   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37360   __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;}
37361   __Pyx_GOTREF(__pyx_t_1);
37362   __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;}
37363   __Pyx_GOTREF(__pyx_t_4);
37364   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37365   __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;}
37366   __Pyx_GOTREF(__pyx_t_1);
37367   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37368   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;}
37369   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37370   __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;}
37371   __Pyx_GOTREF(__pyx_t_1);
37372   __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;}
37373   __Pyx_GOTREF(__pyx_t_4);
37374   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37375   __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;}
37376   __Pyx_GOTREF(__pyx_t_1);
37377   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37378   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;}
37379   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37380   __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;}
37381   __Pyx_GOTREF(__pyx_t_1);
37382   __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;}
37383   __Pyx_GOTREF(__pyx_t_4);
37384   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37385   __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;}
37386   __Pyx_GOTREF(__pyx_t_1);
37387   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37388   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;}
37389   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37390   __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;}
37391   __Pyx_GOTREF(__pyx_t_1);
37392   __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;}
37393   __Pyx_GOTREF(__pyx_t_4);
37394   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37395   __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;}
37396   __Pyx_GOTREF(__pyx_t_1);
37397   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37398   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;}
37399   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37400   __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;}
37401   __Pyx_GOTREF(__pyx_t_1);
37402   __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;}
37403   __Pyx_GOTREF(__pyx_t_4);
37404   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37405   __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;}
37406   __Pyx_GOTREF(__pyx_t_1);
37407   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37408   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;}
37409   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37410   __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;}
37411   __Pyx_GOTREF(__pyx_t_1);
37412   __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;}
37413   __Pyx_GOTREF(__pyx_t_4);
37414   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37415   __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;}
37416   __Pyx_GOTREF(__pyx_t_1);
37417   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37418   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;}
37419   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37420   __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;}
37421   __Pyx_GOTREF(__pyx_t_1);
37422   __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;}
37423   __Pyx_GOTREF(__pyx_t_4);
37424   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37425   __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;}
37426   __Pyx_GOTREF(__pyx_t_1);
37427   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37428   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;}
37429   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37430   __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;}
37431   __Pyx_GOTREF(__pyx_t_1);
37432   __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;}
37433   __Pyx_GOTREF(__pyx_t_4);
37434   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37435   __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;}
37436   __Pyx_GOTREF(__pyx_t_1);
37437   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37438   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;}
37439   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37440   __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;}
37441   __Pyx_GOTREF(__pyx_t_1);
37442   __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;}
37443   __Pyx_GOTREF(__pyx_t_4);
37444   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37445   __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;}
37446   __Pyx_GOTREF(__pyx_t_1);
37447   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37448   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;}
37449   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37450   __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;}
37451   __Pyx_GOTREF(__pyx_t_1);
37452   __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;}
37453   __Pyx_GOTREF(__pyx_t_4);
37454   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37455   __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;}
37456   __Pyx_GOTREF(__pyx_t_1);
37457   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37458   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;}
37459   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37460   __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;}
37461   __Pyx_GOTREF(__pyx_t_1);
37462   __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;}
37463   __Pyx_GOTREF(__pyx_t_4);
37464   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37465   __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;}
37466   __Pyx_GOTREF(__pyx_t_1);
37467   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37468   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;}
37469   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37470   __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;}
37471   __Pyx_GOTREF(__pyx_t_1);
37472   __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;}
37473   __Pyx_GOTREF(__pyx_t_4);
37474   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37475   __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;}
37476   __Pyx_GOTREF(__pyx_t_1);
37477   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37478   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;}
37479   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37480   __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;}
37481   __Pyx_GOTREF(__pyx_t_1);
37482   __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;}
37483   __Pyx_GOTREF(__pyx_t_4);
37484   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37485   __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;}
37486   __Pyx_GOTREF(__pyx_t_1);
37487   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37488   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;}
37489   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37490   __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;}
37491   __Pyx_GOTREF(__pyx_t_1);
37492   __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;}
37493   __Pyx_GOTREF(__pyx_t_4);
37494   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37495   __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;}
37496   __Pyx_GOTREF(__pyx_t_1);
37497   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37498   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;}
37499   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37500   __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;}
37501   __Pyx_GOTREF(__pyx_t_1);
37502   __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;}
37503   __Pyx_GOTREF(__pyx_t_4);
37504   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37505   __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;}
37506   __Pyx_GOTREF(__pyx_t_1);
37507   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37508   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;}
37509   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37510   __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;}
37511   __Pyx_GOTREF(__pyx_t_1);
37512   __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;}
37513   __Pyx_GOTREF(__pyx_t_4);
37514   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37515   __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;}
37516   __Pyx_GOTREF(__pyx_t_1);
37517   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37518   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;}
37519   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37520   __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;}
37521   __Pyx_GOTREF(__pyx_t_1);
37522   __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;}
37523   __Pyx_GOTREF(__pyx_t_4);
37524   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37525   __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;}
37526   __Pyx_GOTREF(__pyx_t_1);
37527   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37528   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;}
37529   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37530   __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;}
37531   __Pyx_GOTREF(__pyx_t_1);
37532   __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;}
37533   __Pyx_GOTREF(__pyx_t_4);
37534   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37535   __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;}
37536   __Pyx_GOTREF(__pyx_t_1);
37537   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37538   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;}
37539   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37540   __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;}
37541   __Pyx_GOTREF(__pyx_t_1);
37542   __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;}
37543   __Pyx_GOTREF(__pyx_t_4);
37544   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37545   __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;}
37546   __Pyx_GOTREF(__pyx_t_1);
37547   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37548   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;}
37549   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37550   __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;}
37551   __Pyx_GOTREF(__pyx_t_1);
37552   __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;}
37553   __Pyx_GOTREF(__pyx_t_4);
37554   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37555   __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;}
37556   __Pyx_GOTREF(__pyx_t_1);
37557   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37558   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;}
37559   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37560   __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;}
37561   __Pyx_GOTREF(__pyx_t_1);
37562   __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;}
37563   __Pyx_GOTREF(__pyx_t_4);
37564   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37565   __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;}
37566   __Pyx_GOTREF(__pyx_t_1);
37567   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37568   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;}
37569   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37570   __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;}
37571   __Pyx_GOTREF(__pyx_t_1);
37572   __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;}
37573   __Pyx_GOTREF(__pyx_t_4);
37574   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37575   __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;}
37576   __Pyx_GOTREF(__pyx_t_1);
37577   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37578   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;}
37579   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37580   __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;}
37581   __Pyx_GOTREF(__pyx_t_1);
37582   __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;}
37583   __Pyx_GOTREF(__pyx_t_4);
37584   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37585   __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;}
37586   __Pyx_GOTREF(__pyx_t_1);
37587   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37588   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;}
37589   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37590   __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;}
37591   __Pyx_GOTREF(__pyx_t_1);
37592   __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;}
37593   __Pyx_GOTREF(__pyx_t_4);
37594   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37595   __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;}
37596   __Pyx_GOTREF(__pyx_t_1);
37597   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37598   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;}
37599   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37600   __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;}
37601   __Pyx_GOTREF(__pyx_t_1);
37602   __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;}
37603   __Pyx_GOTREF(__pyx_t_4);
37604   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37605   __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;}
37606   __Pyx_GOTREF(__pyx_t_1);
37607   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37608   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;}
37609   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37610   __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;}
37611   __Pyx_GOTREF(__pyx_t_1);
37612   __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;}
37613   __Pyx_GOTREF(__pyx_t_4);
37614   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37615   __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;}
37616   __Pyx_GOTREF(__pyx_t_1);
37617   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37618   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;}
37619   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37620   __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;}
37621   __Pyx_GOTREF(__pyx_t_1);
37622   __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;}
37623   __Pyx_GOTREF(__pyx_t_4);
37624   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37625   __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;}
37626   __Pyx_GOTREF(__pyx_t_1);
37627   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37628   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;}
37629   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37630   __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;}
37631   __Pyx_GOTREF(__pyx_t_1);
37632   __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;}
37633   __Pyx_GOTREF(__pyx_t_4);
37634   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37635   __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;}
37636   __Pyx_GOTREF(__pyx_t_1);
37637   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37638   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;}
37639   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37640   __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;}
37641   __Pyx_GOTREF(__pyx_t_1);
37642   __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;}
37643   __Pyx_GOTREF(__pyx_t_4);
37644   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37645   __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;}
37646   __Pyx_GOTREF(__pyx_t_1);
37647   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37648   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;}
37649   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37650   __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;}
37651   __Pyx_GOTREF(__pyx_t_1);
37652   __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;}
37653   __Pyx_GOTREF(__pyx_t_4);
37654   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37655   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;}
37656   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37657   __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;}
37658   __Pyx_GOTREF(__pyx_t_4);
37659   __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;}
37660   __Pyx_GOTREF(__pyx_t_1);
37661   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37662   __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;}
37663   __Pyx_GOTREF(__pyx_t_4);
37664   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37665   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;}
37666   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37667   __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;}
37668   __Pyx_GOTREF(__pyx_t_4);
37669   __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;}
37670   __Pyx_GOTREF(__pyx_t_1);
37671   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37672   __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;}
37673   __Pyx_GOTREF(__pyx_t_4);
37674   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37675   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;}
37676   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37677   __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;}
37678   __Pyx_GOTREF(__pyx_t_4);
37679   __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;}
37680   __Pyx_GOTREF(__pyx_t_1);
37681   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37682   __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;}
37683   __Pyx_GOTREF(__pyx_t_4);
37684   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37685   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;}
37686   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37687   __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;}
37688   __Pyx_GOTREF(__pyx_t_4);
37689   __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;}
37690   __Pyx_GOTREF(__pyx_t_1);
37691   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37692   __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;}
37693   __Pyx_GOTREF(__pyx_t_4);
37694   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37695   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;}
37696   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37697   __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;}
37698   __Pyx_GOTREF(__pyx_t_4);
37699   __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;}
37700   __Pyx_GOTREF(__pyx_t_1);
37701   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37702   __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;}
37703   __Pyx_GOTREF(__pyx_t_4);
37704   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
37705   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;}
37706   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
37707   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;}
37708   __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
37709
37710   /* "/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
37711  * 
37712  * cdef extern from "Python.h":             # <<<<<<<<<<<<<<
37713  *     # The C structure of the objects used to describe built-in types.
37714  * 
37715  */
37716   goto __pyx_L0;
37717   __pyx_L1_error:;
37718   __Pyx_XDECREF(__pyx_t_1);
37719   __Pyx_XDECREF(__pyx_t_2);
37720   __Pyx_XDECREF(__pyx_t_3);
37721   __Pyx_XDECREF(__pyx_t_4);
37722   if (__pyx_m) {
37723     __Pyx_AddTraceback("init csamtools");
37724     Py_DECREF(__pyx_m); __pyx_m = 0;
37725   } else if (!PyErr_Occurred()) {
37726     PyErr_SetString(PyExc_ImportError, "init csamtools");
37727   }
37728   __pyx_L0:;
37729   __Pyx_RefNannyFinishContext();
37730   #if PY_MAJOR_VERSION < 3
37731   return;
37732   #else
37733   return __pyx_m;
37734   #endif
37735 }
37736
37737 /* Runtime support code */
37738
37739 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
37740     PyObject *result;
37741     result = PyObject_GetAttr(dict, name);
37742     if (!result)
37743         PyErr_SetObject(PyExc_NameError, name);
37744     return result;
37745 }
37746
37747
37748 #if CYTHON_PROFILE
37749
37750 static int __Pyx_TraceSetupAndCall(PyCodeObject** code,
37751                                    PyFrameObject** frame,
37752                                    const char *funcname,
37753                                    const char *srcfile,
37754                                    int firstlineno) {
37755     if (*frame == NULL || !CYTHON_PROFILE_REUSE_FRAME) {
37756         if (*code == NULL) {
37757             *code = __Pyx_createFrameCodeObject(funcname, srcfile, firstlineno);
37758             if (*code == NULL) return 0;
37759         }
37760         *frame = PyFrame_New(
37761             PyThreadState_GET(),            /*PyThreadState *tstate*/
37762             *code,                          /*PyCodeObject *code*/
37763             PyModule_GetDict(__pyx_m),      /*PyObject *globals*/
37764             0                               /*PyObject *locals*/
37765         );
37766         if (*frame == NULL) return 0;
37767     }
37768     else {
37769         (*frame)->f_tstate = PyThreadState_GET();
37770     }
37771     return PyThreadState_GET()->c_profilefunc(PyThreadState_GET()->c_profileobj, *frame, PyTrace_CALL, NULL) == 0;
37772 }
37773
37774 static PyCodeObject *__Pyx_createFrameCodeObject(const char *funcname, const char *srcfile, int firstlineno) {
37775     PyObject *py_srcfile = 0;
37776     PyObject *py_funcname = 0;
37777     PyCodeObject *py_code = 0;
37778
37779     #if PY_MAJOR_VERSION < 3
37780     py_funcname = PyString_FromString(funcname);
37781     py_srcfile = PyString_FromString(srcfile);
37782     #else
37783     py_funcname = PyUnicode_FromString(funcname);
37784     py_srcfile = PyUnicode_FromString(srcfile);
37785     #endif
37786     if (!py_funcname | !py_srcfile) goto bad;
37787
37788     py_code = PyCode_New(
37789         0,                /*int argcount,*/
37790         #if PY_MAJOR_VERSION >= 3
37791         0,                /*int kwonlyargcount,*/
37792         #endif
37793         0,                /*int nlocals,*/
37794         0,                /*int stacksize,*/
37795         0,                /*int flags,*/
37796         __pyx_empty_bytes,  /*PyObject *code,*/
37797         __pyx_empty_tuple,  /*PyObject *consts,*/
37798         __pyx_empty_tuple,  /*PyObject *names,*/
37799         __pyx_empty_tuple,  /*PyObject *varnames,*/
37800         __pyx_empty_tuple,  /*PyObject *freevars,*/
37801         __pyx_empty_tuple,  /*PyObject *cellvars,*/
37802         py_srcfile,       /*PyObject *filename,*/
37803         py_funcname,      /*PyObject *name,*/
37804         firstlineno,      /*int firstlineno,*/
37805         __pyx_empty_bytes   /*PyObject *lnotab*/
37806     );
37807
37808 bad: 
37809     Py_XDECREF(py_srcfile);
37810     Py_XDECREF(py_funcname);
37811     
37812     return py_code;
37813 }
37814
37815 #endif /* CYTHON_PROFILE */
37816
37817 static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) {
37818     if (unlikely(!type)) {
37819         PyErr_Format(PyExc_SystemError, "Missing type object");
37820         return 0;
37821     }
37822     if (likely(PyObject_TypeCheck(obj, type)))
37823         return 1;
37824     PyErr_Format(PyExc_TypeError, "Cannot convert %.200s to %.200s",
37825                  Py_TYPE(obj)->tp_name, type->tp_name);
37826     return 0;
37827 }
37828
37829 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
37830     PyErr_Format(PyExc_ValueError,
37831         #if PY_VERSION_HEX < 0x02050000
37832                  "need more than %d value%s to unpack", (int)index,
37833         #else
37834                  "need more than %zd value%s to unpack", index,
37835         #endif
37836                  (index == 1) ? "" : "s");
37837 }
37838
37839 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
37840     PyErr_Format(PyExc_ValueError,
37841         #if PY_VERSION_HEX < 0x02050000
37842             "too many values to unpack (expected %d)", (int)expected);
37843         #else
37844             "too many values to unpack (expected %zd)", expected);
37845         #endif
37846 }
37847
37848 static PyObject *__Pyx_UnpackItem(PyObject *iter, Py_ssize_t index) {
37849     PyObject *item;
37850     if (!(item = PyIter_Next(iter))) {
37851         if (!PyErr_Occurred()) {
37852             __Pyx_RaiseNeedMoreValuesError(index);
37853         }
37854     }
37855     return item;
37856 }
37857
37858 static int __Pyx_EndUnpack(PyObject *iter, Py_ssize_t expected) {
37859     PyObject *item;
37860     if ((item = PyIter_Next(iter))) {
37861         Py_DECREF(item);
37862         __Pyx_RaiseTooManyValuesError(expected);
37863         return -1;
37864     }
37865     else if (!PyErr_Occurred())
37866         return 0;
37867     else
37868         return -1;
37869 }
37870
37871 static CYTHON_INLINE int __Pyx_CheckKeywordStrings(
37872     PyObject *kwdict,
37873     const char* function_name,
37874     int kw_allowed)
37875 {
37876     PyObject* key = 0;
37877     Py_ssize_t pos = 0;
37878     while (PyDict_Next(kwdict, &pos, &key, 0)) {
37879         #if PY_MAJOR_VERSION < 3
37880         if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key)))
37881         #else
37882         if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key)))
37883         #endif
37884             goto invalid_keyword_type;
37885     }
37886     if ((!kw_allowed) && unlikely(key))
37887         goto invalid_keyword;
37888     return 1;
37889 invalid_keyword_type:
37890     PyErr_Format(PyExc_TypeError,
37891         "%s() keywords must be strings", function_name);
37892     return 0;
37893 invalid_keyword:
37894     PyErr_Format(PyExc_TypeError,
37895     #if PY_MAJOR_VERSION < 3
37896         "%s() got an unexpected keyword argument '%s'",
37897         function_name, PyString_AsString(key));
37898     #else
37899         "%s() got an unexpected keyword argument '%U'",
37900         function_name, key);
37901     #endif
37902     return 0;
37903 }
37904
37905 static void __Pyx_RaiseDoubleKeywordsError(
37906     const char* func_name,
37907     PyObject* kw_name)
37908 {
37909     PyErr_Format(PyExc_TypeError,
37910         #if PY_MAJOR_VERSION >= 3
37911         "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
37912         #else
37913         "%s() got multiple values for keyword argument '%s'", func_name,
37914         PyString_AS_STRING(kw_name));
37915         #endif
37916 }
37917
37918 static void __Pyx_RaiseArgtupleInvalid(
37919     const char* func_name,
37920     int exact,
37921     Py_ssize_t num_min,
37922     Py_ssize_t num_max,
37923     Py_ssize_t num_found)
37924 {
37925     Py_ssize_t num_expected;
37926     const char *number, *more_or_less;
37927
37928     if (num_found < num_min) {
37929         num_expected = num_min;
37930         more_or_less = "at least";
37931     } else {
37932         num_expected = num_max;
37933         more_or_less = "at most";
37934     }
37935     if (exact) {
37936         more_or_less = "exactly";
37937     }
37938     number = (num_expected == 1) ? "" : "s";
37939     PyErr_Format(PyExc_TypeError,
37940         #if PY_VERSION_HEX < 0x02050000
37941             "%s() takes %s %d positional argument%s (%d given)",
37942         #else
37943             "%s() takes %s %zd positional argument%s (%zd given)",
37944         #endif
37945         func_name, more_or_less, num_expected, number, num_found);
37946 }
37947
37948 static int __Pyx_ParseOptionalKeywords(
37949     PyObject *kwds,
37950     PyObject **argnames[],
37951     PyObject *kwds2,
37952     PyObject *values[],
37953     Py_ssize_t num_pos_args,
37954     const char* function_name)
37955 {
37956     PyObject *key = 0, *value = 0;
37957     Py_ssize_t pos = 0;
37958     PyObject*** name;
37959     PyObject*** first_kw_arg = argnames + num_pos_args;
37960
37961     while (PyDict_Next(kwds, &pos, &key, &value)) {
37962         name = first_kw_arg;
37963         while (*name && (**name != key)) name++;
37964         if (*name) {
37965             values[name-argnames] = value;
37966         } else {
37967             #if PY_MAJOR_VERSION < 3
37968             if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) {
37969             #else
37970             if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key))) {
37971             #endif
37972                 goto invalid_keyword_type;
37973             } else {
37974                 for (name = first_kw_arg; *name; name++) {
37975                     #if PY_MAJOR_VERSION >= 3
37976                     if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
37977                         PyUnicode_Compare(**name, key) == 0) break;
37978                     #else
37979                     if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
37980                         _PyString_Eq(**name, key)) break;
37981                     #endif
37982                 }
37983                 if (*name) {
37984                     values[name-argnames] = value;
37985                 } else {
37986                     /* unexpected keyword found */
37987                     for (name=argnames; name != first_kw_arg; name++) {
37988                         if (**name == key) goto arg_passed_twice;
37989                         #if PY_MAJOR_VERSION >= 3
37990                         if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
37991                             PyUnicode_Compare(**name, key) == 0) goto arg_passed_twice;
37992                         #else
37993                         if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
37994                             _PyString_Eq(**name, key)) goto arg_passed_twice;
37995                         #endif
37996                     }
37997                     if (kwds2) {
37998                         if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
37999                     } else {
38000                         goto invalid_keyword;
38001                     }
38002                 }
38003             }
38004         }
38005     }
38006     return 0;
38007 arg_passed_twice:
38008     __Pyx_RaiseDoubleKeywordsError(function_name, **name);
38009     goto bad;
38010 invalid_keyword_type:
38011     PyErr_Format(PyExc_TypeError,
38012         "%s() keywords must be strings", function_name);
38013     goto bad;
38014 invalid_keyword:
38015     PyErr_Format(PyExc_TypeError,
38016     #if PY_MAJOR_VERSION < 3
38017         "%s() got an unexpected keyword argument '%s'",
38018         function_name, PyString_AsString(key));
38019     #else
38020         "%s() got an unexpected keyword argument '%U'",
38021         function_name, key);
38022     #endif
38023 bad:
38024     return -1;
38025 }
38026
38027 static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
38028     PyObject *tmp_type, *tmp_value, *tmp_tb;
38029     PyThreadState *tstate = PyThreadState_GET();
38030
38031     tmp_type = tstate->curexc_type;
38032     tmp_value = tstate->curexc_value;
38033     tmp_tb = tstate->curexc_traceback;
38034     tstate->curexc_type = type;
38035     tstate->curexc_value = value;
38036     tstate->curexc_traceback = tb;
38037     Py_XDECREF(tmp_type);
38038     Py_XDECREF(tmp_value);
38039     Py_XDECREF(tmp_tb);
38040 }
38041
38042 static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
38043     PyThreadState *tstate = PyThreadState_GET();
38044     *type = tstate->curexc_type;
38045     *value = tstate->curexc_value;
38046     *tb = tstate->curexc_traceback;
38047
38048     tstate->curexc_type = 0;
38049     tstate->curexc_value = 0;
38050     tstate->curexc_traceback = 0;
38051 }
38052
38053
38054 static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
38055     const char *name, int exact)
38056 {
38057     if (!type) {
38058         PyErr_Format(PyExc_SystemError, "Missing type object");
38059         return 0;
38060     }
38061     if (none_allowed && obj == Py_None) return 1;
38062     else if (exact) {
38063         if (Py_TYPE(obj) == type) return 1;
38064     }
38065     else {
38066         if (PyObject_TypeCheck(obj, type)) return 1;
38067     }
38068     PyErr_Format(PyExc_TypeError,
38069         "Argument '%s' has incorrect type (expected %s, got %s)",
38070         name, type->tp_name, Py_TYPE(obj)->tp_name);
38071     return 0;
38072 }
38073
38074 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
38075     PyObject *local_type, *local_value, *local_tb;
38076     PyObject *tmp_type, *tmp_value, *tmp_tb;
38077     PyThreadState *tstate = PyThreadState_GET();
38078     local_type = tstate->curexc_type;
38079     local_value = tstate->curexc_value;
38080     local_tb = tstate->curexc_traceback;
38081     tstate->curexc_type = 0;
38082     tstate->curexc_value = 0;
38083     tstate->curexc_traceback = 0;
38084     PyErr_NormalizeException(&local_type, &local_value, &local_tb);
38085     if (unlikely(tstate->curexc_type))
38086         goto bad;
38087     #if PY_MAJOR_VERSION >= 3
38088     if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
38089         goto bad;
38090     #endif
38091     *type = local_type;
38092     *value = local_value;
38093     *tb = local_tb;
38094     Py_INCREF(local_type);
38095     Py_INCREF(local_value);
38096     Py_INCREF(local_tb);
38097     tmp_type = tstate->exc_type;
38098     tmp_value = tstate->exc_value;
38099     tmp_tb = tstate->exc_traceback;
38100     tstate->exc_type = local_type;
38101     tstate->exc_value = local_value;
38102     tstate->exc_traceback = local_tb;
38103     /* Make sure tstate is in a consistent state when we XDECREF
38104        these objects (XDECREF may run arbitrary code). */
38105     Py_XDECREF(tmp_type);
38106     Py_XDECREF(tmp_value);
38107     Py_XDECREF(tmp_tb);
38108     return 0;
38109 bad:
38110     *type = 0;
38111     *value = 0;
38112     *tb = 0;
38113     Py_XDECREF(local_type);
38114     Py_XDECREF(local_value);
38115     Py_XDECREF(local_tb);
38116     return -1;
38117 }
38118
38119
38120
38121 static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
38122     PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
38123 }
38124
38125 static CYTHON_INLINE void __Pyx_RaiseNoneIndexingError(void) {
38126     PyErr_SetString(PyExc_TypeError, "'NoneType' object is unsubscriptable");
38127 }
38128
38129 static CYTHON_INLINE long __Pyx_div_long(long a, long b) {
38130     long q = a / b;
38131     long r = a - q*b;
38132     q -= ((r != 0) & ((r ^ b) < 0));
38133     return q;
38134 }
38135
38136 static CYTHON_INLINE long __Pyx_mod_long(long a, long b) {
38137     long r = a % b;
38138     r += ((r != 0) & ((r ^ b) < 0)) * b;
38139     return r;
38140 }
38141
38142
38143 static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) {
38144     PyThreadState *tstate = PyThreadState_GET();
38145     *type = tstate->exc_type;
38146     *value = tstate->exc_value;
38147     *tb = tstate->exc_traceback;
38148     Py_XINCREF(*type);
38149     Py_XINCREF(*value);
38150     Py_XINCREF(*tb);
38151 }
38152
38153 static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) {
38154     PyObject *tmp_type, *tmp_value, *tmp_tb;
38155     PyThreadState *tstate = PyThreadState_GET();
38156     tmp_type = tstate->exc_type;
38157     tmp_value = tstate->exc_value;
38158     tmp_tb = tstate->exc_traceback;
38159     tstate->exc_type = type;
38160     tstate->exc_value = value;
38161     tstate->exc_traceback = tb;
38162     Py_XDECREF(tmp_type);
38163     Py_XDECREF(tmp_value);
38164     Py_XDECREF(tmp_tb);
38165 }
38166
38167 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {
38168     PyObject *py_import = 0;
38169     PyObject *empty_list = 0;
38170     PyObject *module = 0;
38171     PyObject *global_dict = 0;
38172     PyObject *empty_dict = 0;
38173     PyObject *list;
38174     py_import = __Pyx_GetAttrString(__pyx_b, "__import__");
38175     if (!py_import)
38176         goto bad;
38177     if (from_list)
38178         list = from_list;
38179     else {
38180         empty_list = PyList_New(0);
38181         if (!empty_list)
38182             goto bad;
38183         list = empty_list;
38184     }
38185     global_dict = PyModule_GetDict(__pyx_m);
38186     if (!global_dict)
38187         goto bad;
38188     empty_dict = PyDict_New();
38189     if (!empty_dict)
38190         goto bad;
38191     module = PyObject_CallFunctionObjArgs(py_import,
38192         name, global_dict, empty_dict, list, NULL);
38193 bad:
38194     Py_XDECREF(empty_list);
38195     Py_XDECREF(py_import);
38196     Py_XDECREF(empty_dict);
38197     return module;
38198 }
38199
38200 static PyObject *__Pyx_CreateClass(
38201     PyObject *bases, PyObject *dict, PyObject *name, const char *modname)
38202 {
38203     PyObject *py_modname;
38204     PyObject *result = 0;
38205
38206     #if PY_MAJOR_VERSION < 3
38207     py_modname = PyString_FromString(modname);
38208     #else
38209     py_modname = PyUnicode_FromString(modname);
38210     #endif
38211     if (!py_modname)
38212         goto bad;
38213     if (PyDict_SetItemString(dict, "__module__", py_modname) < 0)
38214         goto bad;
38215     #if PY_MAJOR_VERSION < 3
38216     result = PyClass_New(bases, dict, name);
38217     #else
38218     result = PyObject_CallFunctionObjArgs((PyObject *)&PyType_Type, name, bases, dict, NULL);
38219     #endif
38220 bad:
38221     Py_XDECREF(py_modname);
38222     return result;
38223 }
38224
38225 static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint32_t(uint32_t val) {
38226     const uint32_t neg_one = (uint32_t)-1, const_zero = (uint32_t)0;
38227     const int is_unsigned = const_zero < neg_one;
38228     if ((sizeof(uint32_t) == sizeof(char))  ||
38229         (sizeof(uint32_t) == sizeof(short))) {
38230         return PyInt_FromLong((long)val);
38231     } else if ((sizeof(uint32_t) == sizeof(int)) ||
38232                (sizeof(uint32_t) == sizeof(long))) {
38233         if (is_unsigned)
38234             return PyLong_FromUnsignedLong((unsigned long)val);
38235         else
38236             return PyInt_FromLong((long)val);
38237     } else if (sizeof(uint32_t) == sizeof(PY_LONG_LONG)) {
38238         if (is_unsigned)
38239             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val);
38240         else
38241             return PyLong_FromLongLong((PY_LONG_LONG)val);
38242     } else {
38243         int one = 1; int little = (int)*(unsigned char *)&one;
38244         unsigned char *bytes = (unsigned char *)&val;
38245         return _PyLong_FromByteArray(bytes, sizeof(uint32_t), 
38246                                      little, !is_unsigned);
38247     }
38248 }
38249
38250 #if PY_MAJOR_VERSION < 3
38251 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
38252     Py_XINCREF(type);
38253     Py_XINCREF(value);
38254     Py_XINCREF(tb);
38255     /* First, check the traceback argument, replacing None with NULL. */
38256     if (tb == Py_None) {
38257         Py_DECREF(tb);
38258         tb = 0;
38259     }
38260     else if (tb != NULL && !PyTraceBack_Check(tb)) {
38261         PyErr_SetString(PyExc_TypeError,
38262             "raise: arg 3 must be a traceback or None");
38263         goto raise_error;
38264     }
38265     /* Next, replace a missing value with None */
38266     if (value == NULL) {
38267         value = Py_None;
38268         Py_INCREF(value);
38269     }
38270     #if PY_VERSION_HEX < 0x02050000
38271     if (!PyClass_Check(type))
38272     #else
38273     if (!PyType_Check(type))
38274     #endif
38275     {
38276         /* Raising an instance.  The value should be a dummy. */
38277         if (value != Py_None) {
38278             PyErr_SetString(PyExc_TypeError,
38279                 "instance exception may not have a separate value");
38280             goto raise_error;
38281         }
38282         /* Normalize to raise <class>, <instance> */
38283         Py_DECREF(value);
38284         value = type;
38285         #if PY_VERSION_HEX < 0x02050000
38286             if (PyInstance_Check(type)) {
38287                 type = (PyObject*) ((PyInstanceObject*)type)->in_class;
38288                 Py_INCREF(type);
38289             }
38290             else {
38291                 type = 0;
38292                 PyErr_SetString(PyExc_TypeError,
38293                     "raise: exception must be an old-style class or instance");
38294                 goto raise_error;
38295             }
38296         #else
38297             type = (PyObject*) Py_TYPE(type);
38298             Py_INCREF(type);
38299             if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
38300                 PyErr_SetString(PyExc_TypeError,
38301                     "raise: exception class must be a subclass of BaseException");
38302                 goto raise_error;
38303             }
38304         #endif
38305     }
38306
38307     __Pyx_ErrRestore(type, value, tb);
38308     return;
38309 raise_error:
38310     Py_XDECREF(value);
38311     Py_XDECREF(type);
38312     Py_XDECREF(tb);
38313     return;
38314 }
38315
38316 #else /* Python 3+ */
38317
38318 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
38319     if (tb == Py_None) {
38320         tb = 0;
38321     } else if (tb && !PyTraceBack_Check(tb)) {
38322         PyErr_SetString(PyExc_TypeError,
38323             "raise: arg 3 must be a traceback or None");
38324         goto bad;
38325     }
38326     if (value == Py_None)
38327         value = 0;
38328
38329     if (PyExceptionInstance_Check(type)) {
38330         if (value) {
38331             PyErr_SetString(PyExc_TypeError,
38332                 "instance exception may not have a separate value");
38333             goto bad;
38334         }
38335         value = type;
38336         type = (PyObject*) Py_TYPE(value);
38337     } else if (!PyExceptionClass_Check(type)) {
38338         PyErr_SetString(PyExc_TypeError,
38339             "raise: exception class must be a subclass of BaseException");
38340         goto bad;
38341     }
38342
38343     PyErr_SetObject(type, value);
38344
38345     if (tb) {
38346         PyThreadState *tstate = PyThreadState_GET();
38347         PyObject* tmp_tb = tstate->curexc_traceback;
38348         if (tb != tmp_tb) {
38349             Py_INCREF(tb);
38350             tstate->curexc_traceback = tb;
38351             Py_XDECREF(tmp_tb);
38352         }
38353     }
38354
38355 bad:
38356     return;
38357 }
38358 #endif
38359
38360 static CYTHON_INLINE uint32_t __Pyx_PyInt_from_py_uint32_t(PyObject* x) {
38361     const uint32_t neg_one = (uint32_t)-1, const_zero = (uint32_t)0;
38362     const int is_unsigned = const_zero < neg_one;
38363     if (sizeof(uint32_t) == sizeof(char)) {
38364         if (is_unsigned)
38365             return (uint32_t)__Pyx_PyInt_AsUnsignedChar(x);
38366         else
38367             return (uint32_t)__Pyx_PyInt_AsSignedChar(x);
38368     } else if (sizeof(uint32_t) == sizeof(short)) {
38369         if (is_unsigned)
38370             return (uint32_t)__Pyx_PyInt_AsUnsignedShort(x);
38371         else
38372             return (uint32_t)__Pyx_PyInt_AsSignedShort(x);
38373     } else if (sizeof(uint32_t) == sizeof(int)) {
38374         if (is_unsigned)
38375             return (uint32_t)__Pyx_PyInt_AsUnsignedInt(x);
38376         else
38377             return (uint32_t)__Pyx_PyInt_AsSignedInt(x);
38378     } else if (sizeof(uint32_t) == sizeof(long)) {
38379         if (is_unsigned)
38380             return (uint32_t)__Pyx_PyInt_AsUnsignedLong(x);
38381         else
38382             return (uint32_t)__Pyx_PyInt_AsSignedLong(x);
38383     } else if (sizeof(uint32_t) == sizeof(PY_LONG_LONG)) {
38384         if (is_unsigned)
38385             return (uint32_t)__Pyx_PyInt_AsUnsignedLongLong(x);
38386         else
38387             return (uint32_t)__Pyx_PyInt_AsSignedLongLong(x);
38388     }  else {
38389         uint32_t val;
38390         PyObject *v = __Pyx_PyNumber_Int(x);
38391         #if PY_VERSION_HEX < 0x03000000
38392         if (likely(v) && !PyLong_Check(v)) {
38393             PyObject *tmp = v;
38394             v = PyNumber_Long(tmp);
38395             Py_DECREF(tmp);
38396         }
38397         #endif
38398         if (likely(v)) {
38399             int one = 1; int is_little = (int)*(unsigned char *)&one;
38400             unsigned char *bytes = (unsigned char *)&val;
38401             int ret = _PyLong_AsByteArray((PyLongObject *)v,
38402                                           bytes, sizeof(val),
38403                                           is_little, !is_unsigned);
38404             Py_DECREF(v);
38405             if (likely(!ret))
38406                 return val;
38407         }
38408         return (uint32_t)-1;
38409     }
38410 }
38411
38412 static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_int32_t(int32_t val) {
38413     const int32_t neg_one = (int32_t)-1, const_zero = (int32_t)0;
38414     const int is_unsigned = const_zero < neg_one;
38415     if ((sizeof(int32_t) == sizeof(char))  ||
38416         (sizeof(int32_t) == sizeof(short))) {
38417         return PyInt_FromLong((long)val);
38418     } else if ((sizeof(int32_t) == sizeof(int)) ||
38419                (sizeof(int32_t) == sizeof(long))) {
38420         if (is_unsigned)
38421             return PyLong_FromUnsignedLong((unsigned long)val);
38422         else
38423             return PyInt_FromLong((long)val);
38424     } else if (sizeof(int32_t) == sizeof(PY_LONG_LONG)) {
38425         if (is_unsigned)
38426             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val);
38427         else
38428             return PyLong_FromLongLong((PY_LONG_LONG)val);
38429     } else {
38430         int one = 1; int little = (int)*(unsigned char *)&one;
38431         unsigned char *bytes = (unsigned char *)&val;
38432         return _PyLong_FromByteArray(bytes, sizeof(int32_t), 
38433                                      little, !is_unsigned);
38434     }
38435 }
38436
38437 static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_int64_t(int64_t val) {
38438     const int64_t neg_one = (int64_t)-1, const_zero = (int64_t)0;
38439     const int is_unsigned = const_zero < neg_one;
38440     if ((sizeof(int64_t) == sizeof(char))  ||
38441         (sizeof(int64_t) == sizeof(short))) {
38442         return PyInt_FromLong((long)val);
38443     } else if ((sizeof(int64_t) == sizeof(int)) ||
38444                (sizeof(int64_t) == sizeof(long))) {
38445         if (is_unsigned)
38446             return PyLong_FromUnsignedLong((unsigned long)val);
38447         else
38448             return PyInt_FromLong((long)val);
38449     } else if (sizeof(int64_t) == sizeof(PY_LONG_LONG)) {
38450         if (is_unsigned)
38451             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val);
38452         else
38453             return PyLong_FromLongLong((PY_LONG_LONG)val);
38454     } else {
38455         int one = 1; int little = (int)*(unsigned char *)&one;
38456         unsigned char *bytes = (unsigned char *)&val;
38457         return _PyLong_FromByteArray(bytes, sizeof(int64_t), 
38458                                      little, !is_unsigned);
38459     }
38460 }
38461
38462 static CYTHON_INLINE uint64_t __Pyx_PyInt_from_py_uint64_t(PyObject* x) {
38463     const uint64_t neg_one = (uint64_t)-1, const_zero = (uint64_t)0;
38464     const int is_unsigned = const_zero < neg_one;
38465     if (sizeof(uint64_t) == sizeof(char)) {
38466         if (is_unsigned)
38467             return (uint64_t)__Pyx_PyInt_AsUnsignedChar(x);
38468         else
38469             return (uint64_t)__Pyx_PyInt_AsSignedChar(x);
38470     } else if (sizeof(uint64_t) == sizeof(short)) {
38471         if (is_unsigned)
38472             return (uint64_t)__Pyx_PyInt_AsUnsignedShort(x);
38473         else
38474             return (uint64_t)__Pyx_PyInt_AsSignedShort(x);
38475     } else if (sizeof(uint64_t) == sizeof(int)) {
38476         if (is_unsigned)
38477             return (uint64_t)__Pyx_PyInt_AsUnsignedInt(x);
38478         else
38479             return (uint64_t)__Pyx_PyInt_AsSignedInt(x);
38480     } else if (sizeof(uint64_t) == sizeof(long)) {
38481         if (is_unsigned)
38482             return (uint64_t)__Pyx_PyInt_AsUnsignedLong(x);
38483         else
38484             return (uint64_t)__Pyx_PyInt_AsSignedLong(x);
38485     } else if (sizeof(uint64_t) == sizeof(PY_LONG_LONG)) {
38486         if (is_unsigned)
38487             return (uint64_t)__Pyx_PyInt_AsUnsignedLongLong(x);
38488         else
38489             return (uint64_t)__Pyx_PyInt_AsSignedLongLong(x);
38490     }  else {
38491         uint64_t val;
38492         PyObject *v = __Pyx_PyNumber_Int(x);
38493         #if PY_VERSION_HEX < 0x03000000
38494         if (likely(v) && !PyLong_Check(v)) {
38495             PyObject *tmp = v;
38496             v = PyNumber_Long(tmp);
38497             Py_DECREF(tmp);
38498         }
38499         #endif
38500         if (likely(v)) {
38501             int one = 1; int is_little = (int)*(unsigned char *)&one;
38502             unsigned char *bytes = (unsigned char *)&val;
38503             int ret = _PyLong_AsByteArray((PyLongObject *)v,
38504                                           bytes, sizeof(val),
38505                                           is_little, !is_unsigned);
38506             Py_DECREF(v);
38507             if (likely(!ret))
38508                 return val;
38509         }
38510         return (uint64_t)-1;
38511     }
38512 }
38513
38514 static CYTHON_INLINE int32_t __Pyx_PyInt_from_py_int32_t(PyObject* x) {
38515     const int32_t neg_one = (int32_t)-1, const_zero = (int32_t)0;
38516     const int is_unsigned = const_zero < neg_one;
38517     if (sizeof(int32_t) == sizeof(char)) {
38518         if (is_unsigned)
38519             return (int32_t)__Pyx_PyInt_AsUnsignedChar(x);
38520         else
38521             return (int32_t)__Pyx_PyInt_AsSignedChar(x);
38522     } else if (sizeof(int32_t) == sizeof(short)) {
38523         if (is_unsigned)
38524             return (int32_t)__Pyx_PyInt_AsUnsignedShort(x);
38525         else
38526             return (int32_t)__Pyx_PyInt_AsSignedShort(x);
38527     } else if (sizeof(int32_t) == sizeof(int)) {
38528         if (is_unsigned)
38529             return (int32_t)__Pyx_PyInt_AsUnsignedInt(x);
38530         else
38531             return (int32_t)__Pyx_PyInt_AsSignedInt(x);
38532     } else if (sizeof(int32_t) == sizeof(long)) {
38533         if (is_unsigned)
38534             return (int32_t)__Pyx_PyInt_AsUnsignedLong(x);
38535         else
38536             return (int32_t)__Pyx_PyInt_AsSignedLong(x);
38537     } else if (sizeof(int32_t) == sizeof(PY_LONG_LONG)) {
38538         if (is_unsigned)
38539             return (int32_t)__Pyx_PyInt_AsUnsignedLongLong(x);
38540         else
38541             return (int32_t)__Pyx_PyInt_AsSignedLongLong(x);
38542     }  else {
38543         int32_t val;
38544         PyObject *v = __Pyx_PyNumber_Int(x);
38545         #if PY_VERSION_HEX < 0x03000000
38546         if (likely(v) && !PyLong_Check(v)) {
38547             PyObject *tmp = v;
38548             v = PyNumber_Long(tmp);
38549             Py_DECREF(tmp);
38550         }
38551         #endif
38552         if (likely(v)) {
38553             int one = 1; int is_little = (int)*(unsigned char *)&one;
38554             unsigned char *bytes = (unsigned char *)&val;
38555             int ret = _PyLong_AsByteArray((PyLongObject *)v,
38556                                           bytes, sizeof(val),
38557                                           is_little, !is_unsigned);
38558             Py_DECREF(v);
38559             if (likely(!ret))
38560                 return val;
38561         }
38562         return (int32_t)-1;
38563     }
38564 }
38565
38566 static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint8_t(uint8_t val) {
38567     const uint8_t neg_one = (uint8_t)-1, const_zero = (uint8_t)0;
38568     const int is_unsigned = const_zero < neg_one;
38569     if ((sizeof(uint8_t) == sizeof(char))  ||
38570         (sizeof(uint8_t) == sizeof(short))) {
38571         return PyInt_FromLong((long)val);
38572     } else if ((sizeof(uint8_t) == sizeof(int)) ||
38573                (sizeof(uint8_t) == sizeof(long))) {
38574         if (is_unsigned)
38575             return PyLong_FromUnsignedLong((unsigned long)val);
38576         else
38577             return PyInt_FromLong((long)val);
38578     } else if (sizeof(uint8_t) == sizeof(PY_LONG_LONG)) {
38579         if (is_unsigned)
38580             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val);
38581         else
38582             return PyLong_FromLongLong((PY_LONG_LONG)val);
38583     } else {
38584         int one = 1; int little = (int)*(unsigned char *)&one;
38585         unsigned char *bytes = (unsigned char *)&val;
38586         return _PyLong_FromByteArray(bytes, sizeof(uint8_t), 
38587                                      little, !is_unsigned);
38588     }
38589 }
38590
38591 #if PY_MAJOR_VERSION < 3
38592 static PyObject *__Pyx_GetStdout(void) {
38593     PyObject *f = PySys_GetObject((char *)"stdout");
38594     if (!f) {
38595         PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout");
38596     }
38597     return f;
38598 }
38599
38600 static int __Pyx_Print(PyObject* f, PyObject *arg_tuple, int newline) {
38601     PyObject* v;
38602     int i;
38603
38604     if (!f) {
38605         if (!(f = __Pyx_GetStdout()))
38606             return -1;
38607     }
38608     for (i=0; i < PyTuple_GET_SIZE(arg_tuple); i++) {
38609         if (PyFile_SoftSpace(f, 1)) {
38610             if (PyFile_WriteString(" ", f) < 0)
38611                 return -1;
38612         }
38613         v = PyTuple_GET_ITEM(arg_tuple, i);
38614         if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0)
38615             return -1;
38616         if (PyString_Check(v)) {
38617             char *s = PyString_AsString(v);
38618             Py_ssize_t len = PyString_Size(v);
38619             if (len > 0 &&
38620                 isspace(Py_CHARMASK(s[len-1])) &&
38621                 s[len-1] != ' ')
38622                     PyFile_SoftSpace(f, 0);
38623         }
38624     }
38625     if (newline) {
38626         if (PyFile_WriteString("\n", f) < 0)
38627             return -1;
38628         PyFile_SoftSpace(f, 0);
38629     }
38630     return 0;
38631 }
38632
38633 #else /* Python 3 has a print function */
38634
38635 static int __Pyx_Print(PyObject* stream, PyObject *arg_tuple, int newline) {
38636     PyObject* kwargs = 0;
38637     PyObject* result = 0;
38638     PyObject* end_string;
38639     if (unlikely(!__pyx_print)) {
38640         __pyx_print = __Pyx_GetAttrString(__pyx_b, "print");
38641         if (!__pyx_print)
38642             return -1;
38643     }
38644     if (stream) {
38645         kwargs = PyDict_New();
38646         if (unlikely(!kwargs))
38647             return -1;
38648         if (unlikely(PyDict_SetItemString(kwargs, "file", stream) < 0))
38649             goto bad;
38650         if (!newline) {
38651             end_string = PyUnicode_FromStringAndSize(" ", 1);
38652             if (unlikely(!end_string))
38653                 goto bad;
38654             if (PyDict_SetItemString(kwargs, "end", end_string) < 0) {
38655                 Py_DECREF(end_string);
38656                 goto bad;
38657             }
38658             Py_DECREF(end_string);
38659         }
38660     } else if (!newline) {
38661         if (unlikely(!__pyx_print_kwargs)) {
38662             __pyx_print_kwargs = PyDict_New();
38663             if (unlikely(!__pyx_print_kwargs))
38664                 return -1;
38665             end_string = PyUnicode_FromStringAndSize(" ", 1);
38666             if (unlikely(!end_string))
38667                 return -1;
38668             if (PyDict_SetItemString(__pyx_print_kwargs, "end", end_string) < 0) {
38669                 Py_DECREF(end_string);
38670                 return -1;
38671             }
38672             Py_DECREF(end_string);
38673         }
38674         kwargs = __pyx_print_kwargs;
38675     }
38676     result = PyObject_Call(__pyx_print, arg_tuple, kwargs);
38677     if (unlikely(kwargs) && (kwargs != __pyx_print_kwargs))
38678         Py_DECREF(kwargs);
38679     if (!result)
38680         return -1;
38681     Py_DECREF(result);
38682     return 0;
38683 bad:
38684     if (kwargs != __pyx_print_kwargs)
38685         Py_XDECREF(kwargs);
38686     return -1;
38687 }
38688
38689 #endif
38690
38691 #if PY_MAJOR_VERSION < 3
38692
38693 static int __Pyx_PrintOne(PyObject* f, PyObject *o) {
38694     if (!f) {
38695         if (!(f = __Pyx_GetStdout()))
38696             return -1;
38697     }
38698     if (PyFile_SoftSpace(f, 0)) {
38699         if (PyFile_WriteString(" ", f) < 0)
38700             return -1;
38701     }
38702     if (PyFile_WriteObject(o, f, Py_PRINT_RAW) < 0)
38703         return -1;
38704     if (PyFile_WriteString("\n", f) < 0)
38705         return -1;
38706     return 0;
38707     /* the line below is just to avoid compiler
38708      * compiler warnings about unused functions */
38709     return __Pyx_Print(f, NULL, 0);
38710 }
38711
38712 #else /* Python 3 has a print function */
38713
38714 static int __Pyx_PrintOne(PyObject* stream, PyObject *o) {
38715     int res;
38716     PyObject* arg_tuple = PyTuple_New(1);
38717     if (unlikely(!arg_tuple))
38718         return -1;
38719     Py_INCREF(o);
38720     PyTuple_SET_ITEM(arg_tuple, 0, o);
38721     res = __Pyx_Print(stream, arg_tuple, 1);
38722     Py_DECREF(arg_tuple);
38723     return res;
38724 }
38725
38726 #endif
38727
38728 static CYTHON_INLINE PyObject *__Pyx_PyInt_to_py_uint64_t(uint64_t val) {
38729     const uint64_t neg_one = (uint64_t)-1, const_zero = (uint64_t)0;
38730     const int is_unsigned = const_zero < neg_one;
38731     if ((sizeof(uint64_t) == sizeof(char))  ||
38732         (sizeof(uint64_t) == sizeof(short))) {
38733         return PyInt_FromLong((long)val);
38734     } else if ((sizeof(uint64_t) == sizeof(int)) ||
38735                (sizeof(uint64_t) == sizeof(long))) {
38736         if (is_unsigned)
38737             return PyLong_FromUnsignedLong((unsigned long)val);
38738         else
38739             return PyInt_FromLong((long)val);
38740     } else if (sizeof(uint64_t) == sizeof(PY_LONG_LONG)) {
38741         if (is_unsigned)
38742             return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG)val);
38743         else
38744             return PyLong_FromLongLong((PY_LONG_LONG)val);
38745     } else {
38746         int one = 1; int little = (int)*(unsigned char *)&one;
38747         unsigned char *bytes = (unsigned char *)&val;
38748         return _PyLong_FromByteArray(bytes, sizeof(uint64_t), 
38749                                      little, !is_unsigned);
38750     }
38751 }
38752
38753 static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) {
38754     const unsigned char neg_one = (unsigned char)-1, const_zero = 0;
38755     const int is_unsigned = neg_one > const_zero;
38756     if (sizeof(unsigned char) < sizeof(long)) {
38757         long val = __Pyx_PyInt_AsLong(x);
38758         if (unlikely(val != (long)(unsigned char)val)) {
38759             if (!unlikely(val == -1 && PyErr_Occurred())) {
38760                 PyErr_SetString(PyExc_OverflowError,
38761                     (is_unsigned && unlikely(val < 0)) ?
38762                     "can't convert negative value to unsigned char" :
38763                     "value too large to convert to unsigned char");
38764             }
38765             return (unsigned char)-1;
38766         }
38767         return (unsigned char)val;
38768     }
38769     return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x);
38770 }
38771
38772 static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) {
38773     const unsigned short neg_one = (unsigned short)-1, const_zero = 0;
38774     const int is_unsigned = neg_one > const_zero;
38775     if (sizeof(unsigned short) < sizeof(long)) {
38776         long val = __Pyx_PyInt_AsLong(x);
38777         if (unlikely(val != (long)(unsigned short)val)) {
38778             if (!unlikely(val == -1 && PyErr_Occurred())) {
38779                 PyErr_SetString(PyExc_OverflowError,
38780                     (is_unsigned && unlikely(val < 0)) ?
38781                     "can't convert negative value to unsigned short" :
38782                     "value too large to convert to unsigned short");
38783             }
38784             return (unsigned short)-1;
38785         }
38786         return (unsigned short)val;
38787     }
38788     return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x);
38789 }
38790
38791 static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) {
38792     const unsigned int neg_one = (unsigned int)-1, const_zero = 0;
38793     const int is_unsigned = neg_one > const_zero;
38794     if (sizeof(unsigned int) < sizeof(long)) {
38795         long val = __Pyx_PyInt_AsLong(x);
38796         if (unlikely(val != (long)(unsigned int)val)) {
38797             if (!unlikely(val == -1 && PyErr_Occurred())) {
38798                 PyErr_SetString(PyExc_OverflowError,
38799                     (is_unsigned && unlikely(val < 0)) ?
38800                     "can't convert negative value to unsigned int" :
38801                     "value too large to convert to unsigned int");
38802             }
38803             return (unsigned int)-1;
38804         }
38805         return (unsigned int)val;
38806     }
38807     return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x);
38808 }
38809
38810 static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) {
38811     const char neg_one = (char)-1, const_zero = 0;
38812     const int is_unsigned = neg_one > const_zero;
38813     if (sizeof(char) < sizeof(long)) {
38814         long val = __Pyx_PyInt_AsLong(x);
38815         if (unlikely(val != (long)(char)val)) {
38816             if (!unlikely(val == -1 && PyErr_Occurred())) {
38817                 PyErr_SetString(PyExc_OverflowError,
38818                     (is_unsigned && unlikely(val < 0)) ?
38819                     "can't convert negative value to char" :
38820                     "value too large to convert to char");
38821             }
38822             return (char)-1;
38823         }
38824         return (char)val;
38825     }
38826     return (char)__Pyx_PyInt_AsLong(x);
38827 }
38828
38829 static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) {
38830     const short neg_one = (short)-1, const_zero = 0;
38831     const int is_unsigned = neg_one > const_zero;
38832     if (sizeof(short) < sizeof(long)) {
38833         long val = __Pyx_PyInt_AsLong(x);
38834         if (unlikely(val != (long)(short)val)) {
38835             if (!unlikely(val == -1 && PyErr_Occurred())) {
38836                 PyErr_SetString(PyExc_OverflowError,
38837                     (is_unsigned && unlikely(val < 0)) ?
38838                     "can't convert negative value to short" :
38839                     "value too large to convert to short");
38840             }
38841             return (short)-1;
38842         }
38843         return (short)val;
38844     }
38845     return (short)__Pyx_PyInt_AsLong(x);
38846 }
38847
38848 static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) {
38849     const int neg_one = (int)-1, const_zero = 0;
38850     const int is_unsigned = neg_one > const_zero;
38851     if (sizeof(int) < sizeof(long)) {
38852         long val = __Pyx_PyInt_AsLong(x);
38853         if (unlikely(val != (long)(int)val)) {
38854             if (!unlikely(val == -1 && PyErr_Occurred())) {
38855                 PyErr_SetString(PyExc_OverflowError,
38856                     (is_unsigned && unlikely(val < 0)) ?
38857                     "can't convert negative value to int" :
38858                     "value too large to convert to int");
38859             }
38860             return (int)-1;
38861         }
38862         return (int)val;
38863     }
38864     return (int)__Pyx_PyInt_AsLong(x);
38865 }
38866
38867 static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) {
38868     const signed char neg_one = (signed char)-1, const_zero = 0;
38869     const int is_unsigned = neg_one > const_zero;
38870     if (sizeof(signed char) < sizeof(long)) {
38871         long val = __Pyx_PyInt_AsLong(x);
38872         if (unlikely(val != (long)(signed char)val)) {
38873             if (!unlikely(val == -1 && PyErr_Occurred())) {
38874                 PyErr_SetString(PyExc_OverflowError,
38875                     (is_unsigned && unlikely(val < 0)) ?
38876                     "can't convert negative value to signed char" :
38877                     "value too large to convert to signed char");
38878             }
38879             return (signed char)-1;
38880         }
38881         return (signed char)val;
38882     }
38883     return (signed char)__Pyx_PyInt_AsSignedLong(x);
38884 }
38885
38886 static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) {
38887     const signed short neg_one = (signed short)-1, const_zero = 0;
38888     const int is_unsigned = neg_one > const_zero;
38889     if (sizeof(signed short) < sizeof(long)) {
38890         long val = __Pyx_PyInt_AsLong(x);
38891         if (unlikely(val != (long)(signed short)val)) {
38892             if (!unlikely(val == -1 && PyErr_Occurred())) {
38893                 PyErr_SetString(PyExc_OverflowError,
38894                     (is_unsigned && unlikely(val < 0)) ?
38895                     "can't convert negative value to signed short" :
38896                     "value too large to convert to signed short");
38897             }
38898             return (signed short)-1;
38899         }
38900         return (signed short)val;
38901     }
38902     return (signed short)__Pyx_PyInt_AsSignedLong(x);
38903 }
38904
38905 static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) {
38906     const signed int neg_one = (signed int)-1, const_zero = 0;
38907     const int is_unsigned = neg_one > const_zero;
38908     if (sizeof(signed int) < sizeof(long)) {
38909         long val = __Pyx_PyInt_AsLong(x);
38910         if (unlikely(val != (long)(signed int)val)) {
38911             if (!unlikely(val == -1 && PyErr_Occurred())) {
38912                 PyErr_SetString(PyExc_OverflowError,
38913                     (is_unsigned && unlikely(val < 0)) ?
38914                     "can't convert negative value to signed int" :
38915                     "value too large to convert to signed int");
38916             }
38917             return (signed int)-1;
38918         }
38919         return (signed int)val;
38920     }
38921     return (signed int)__Pyx_PyInt_AsSignedLong(x);
38922 }
38923
38924 static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) {
38925     const int neg_one = (int)-1, const_zero = 0;
38926     const int is_unsigned = neg_one > const_zero;
38927     if (sizeof(int) < sizeof(long)) {
38928         long val = __Pyx_PyInt_AsLong(x);
38929         if (unlikely(val != (long)(int)val)) {
38930             if (!unlikely(val == -1 && PyErr_Occurred())) {
38931                 PyErr_SetString(PyExc_OverflowError,
38932                     (is_unsigned && unlikely(val < 0)) ?
38933                     "can't convert negative value to int" :
38934                     "value too large to convert to int");
38935             }
38936             return (int)-1;
38937         }
38938         return (int)val;
38939     }
38940     return (int)__Pyx_PyInt_AsLong(x);
38941 }
38942
38943 static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) {
38944     const unsigned long neg_one = (unsigned long)-1, const_zero = 0;
38945     const int is_unsigned = neg_one > const_zero;
38946 #if PY_VERSION_HEX < 0x03000000
38947     if (likely(PyInt_Check(x))) {
38948         long val = PyInt_AS_LONG(x);
38949         if (is_unsigned && unlikely(val < 0)) {
38950             PyErr_SetString(PyExc_OverflowError,
38951                             "can't convert negative value to unsigned long");
38952             return (unsigned long)-1;
38953         }
38954         return (unsigned long)val;
38955     } else
38956 #endif
38957     if (likely(PyLong_Check(x))) {
38958         if (is_unsigned) {
38959             if (unlikely(Py_SIZE(x) < 0)) {
38960                 PyErr_SetString(PyExc_OverflowError,
38961                                 "can't convert negative value to unsigned long");
38962                 return (unsigned long)-1;
38963             }
38964             return PyLong_AsUnsignedLong(x);
38965         } else {
38966             return PyLong_AsLong(x);
38967         }
38968     } else {
38969         unsigned long val;
38970         PyObject *tmp = __Pyx_PyNumber_Int(x);
38971         if (!tmp) return (unsigned long)-1;
38972         val = __Pyx_PyInt_AsUnsignedLong(tmp);
38973         Py_DECREF(tmp);
38974         return val;
38975     }
38976 }
38977
38978 static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
38979     const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0;
38980     const int is_unsigned = neg_one > const_zero;
38981 #if PY_VERSION_HEX < 0x03000000
38982     if (likely(PyInt_Check(x))) {
38983         long val = PyInt_AS_LONG(x);
38984         if (is_unsigned && unlikely(val < 0)) {
38985             PyErr_SetString(PyExc_OverflowError,
38986                             "can't convert negative value to unsigned PY_LONG_LONG");
38987             return (unsigned PY_LONG_LONG)-1;
38988         }
38989         return (unsigned PY_LONG_LONG)val;
38990     } else
38991 #endif
38992     if (likely(PyLong_Check(x))) {
38993         if (is_unsigned) {
38994             if (unlikely(Py_SIZE(x) < 0)) {
38995                 PyErr_SetString(PyExc_OverflowError,
38996                                 "can't convert negative value to unsigned PY_LONG_LONG");
38997                 return (unsigned PY_LONG_LONG)-1;
38998             }
38999             return PyLong_AsUnsignedLongLong(x);
39000         } else {
39001             return PyLong_AsLongLong(x);
39002         }
39003     } else {
39004         unsigned PY_LONG_LONG val;
39005         PyObject *tmp = __Pyx_PyNumber_Int(x);
39006         if (!tmp) return (unsigned PY_LONG_LONG)-1;
39007         val = __Pyx_PyInt_AsUnsignedLongLong(tmp);
39008         Py_DECREF(tmp);
39009         return val;
39010     }
39011 }
39012
39013 static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) {
39014     const long neg_one = (long)-1, const_zero = 0;
39015     const int is_unsigned = neg_one > const_zero;
39016 #if PY_VERSION_HEX < 0x03000000
39017     if (likely(PyInt_Check(x))) {
39018         long val = PyInt_AS_LONG(x);
39019         if (is_unsigned && unlikely(val < 0)) {
39020             PyErr_SetString(PyExc_OverflowError,
39021                             "can't convert negative value to long");
39022             return (long)-1;
39023         }
39024         return (long)val;
39025     } else
39026 #endif
39027     if (likely(PyLong_Check(x))) {
39028         if (is_unsigned) {
39029             if (unlikely(Py_SIZE(x) < 0)) {
39030                 PyErr_SetString(PyExc_OverflowError,
39031                                 "can't convert negative value to long");
39032                 return (long)-1;
39033             }
39034             return PyLong_AsUnsignedLong(x);
39035         } else {
39036             return PyLong_AsLong(x);
39037         }
39038     } else {
39039         long val;
39040         PyObject *tmp = __Pyx_PyNumber_Int(x);
39041         if (!tmp) return (long)-1;
39042         val = __Pyx_PyInt_AsLong(tmp);
39043         Py_DECREF(tmp);
39044         return val;
39045     }
39046 }
39047
39048 static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) {
39049     const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0;
39050     const int is_unsigned = neg_one > const_zero;
39051 #if PY_VERSION_HEX < 0x03000000
39052     if (likely(PyInt_Check(x))) {
39053         long val = PyInt_AS_LONG(x);
39054         if (is_unsigned && unlikely(val < 0)) {
39055             PyErr_SetString(PyExc_OverflowError,
39056                             "can't convert negative value to PY_LONG_LONG");
39057             return (PY_LONG_LONG)-1;
39058         }
39059         return (PY_LONG_LONG)val;
39060     } else
39061 #endif
39062     if (likely(PyLong_Check(x))) {
39063         if (is_unsigned) {
39064             if (unlikely(Py_SIZE(x) < 0)) {
39065                 PyErr_SetString(PyExc_OverflowError,
39066                                 "can't convert negative value to PY_LONG_LONG");
39067                 return (PY_LONG_LONG)-1;
39068             }
39069             return PyLong_AsUnsignedLongLong(x);
39070         } else {
39071             return PyLong_AsLongLong(x);
39072         }
39073     } else {
39074         PY_LONG_LONG val;
39075         PyObject *tmp = __Pyx_PyNumber_Int(x);
39076         if (!tmp) return (PY_LONG_LONG)-1;
39077         val = __Pyx_PyInt_AsLongLong(tmp);
39078         Py_DECREF(tmp);
39079         return val;
39080     }
39081 }
39082
39083 static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) {
39084     const signed long neg_one = (signed long)-1, const_zero = 0;
39085     const int is_unsigned = neg_one > const_zero;
39086 #if PY_VERSION_HEX < 0x03000000
39087     if (likely(PyInt_Check(x))) {
39088         long val = PyInt_AS_LONG(x);
39089         if (is_unsigned && unlikely(val < 0)) {
39090             PyErr_SetString(PyExc_OverflowError,
39091                             "can't convert negative value to signed long");
39092             return (signed long)-1;
39093         }
39094         return (signed long)val;
39095     } else
39096 #endif
39097     if (likely(PyLong_Check(x))) {
39098         if (is_unsigned) {
39099             if (unlikely(Py_SIZE(x) < 0)) {
39100                 PyErr_SetString(PyExc_OverflowError,
39101                                 "can't convert negative value to signed long");
39102                 return (signed long)-1;
39103             }
39104             return PyLong_AsUnsignedLong(x);
39105         } else {
39106             return PyLong_AsLong(x);
39107         }
39108     } else {
39109         signed long val;
39110         PyObject *tmp = __Pyx_PyNumber_Int(x);
39111         if (!tmp) return (signed long)-1;
39112         val = __Pyx_PyInt_AsSignedLong(tmp);
39113         Py_DECREF(tmp);
39114         return val;
39115     }
39116 }
39117
39118 static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) {
39119     const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0;
39120     const int is_unsigned = neg_one > const_zero;
39121 #if PY_VERSION_HEX < 0x03000000
39122     if (likely(PyInt_Check(x))) {
39123         long val = PyInt_AS_LONG(x);
39124         if (is_unsigned && unlikely(val < 0)) {
39125             PyErr_SetString(PyExc_OverflowError,
39126                             "can't convert negative value to signed PY_LONG_LONG");
39127             return (signed PY_LONG_LONG)-1;
39128         }
39129         return (signed PY_LONG_LONG)val;
39130     } else
39131 #endif
39132     if (likely(PyLong_Check(x))) {
39133         if (is_unsigned) {
39134             if (unlikely(Py_SIZE(x) < 0)) {
39135                 PyErr_SetString(PyExc_OverflowError,
39136                                 "can't convert negative value to signed PY_LONG_LONG");
39137                 return (signed PY_LONG_LONG)-1;
39138             }
39139             return PyLong_AsUnsignedLongLong(x);
39140         } else {
39141             return PyLong_AsLongLong(x);
39142         }
39143     } else {
39144         signed PY_LONG_LONG val;
39145         PyObject *tmp = __Pyx_PyNumber_Int(x);
39146         if (!tmp) return (signed PY_LONG_LONG)-1;
39147         val = __Pyx_PyInt_AsSignedLongLong(tmp);
39148         Py_DECREF(tmp);
39149         return val;
39150     }
39151 }
39152
39153 static void __Pyx_WriteUnraisable(const char *name) {
39154     PyObject *old_exc, *old_val, *old_tb;
39155     PyObject *ctx;
39156     __Pyx_ErrFetch(&old_exc, &old_val, &old_tb);
39157     #if PY_MAJOR_VERSION < 3
39158     ctx = PyString_FromString(name);
39159     #else
39160     ctx = PyUnicode_FromString(name);
39161     #endif
39162     __Pyx_ErrRestore(old_exc, old_val, old_tb);
39163     if (!ctx) {
39164         PyErr_WriteUnraisable(Py_None);
39165     } else {
39166         PyErr_WriteUnraisable(ctx);
39167         Py_DECREF(ctx);
39168     }
39169 }
39170
39171 #ifndef __PYX_HAVE_RT_ImportType
39172 #define __PYX_HAVE_RT_ImportType
39173 static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
39174     long size, int strict)
39175 {
39176     PyObject *py_module = 0;
39177     PyObject *result = 0;
39178     PyObject *py_name = 0;
39179     char warning[200];
39180
39181     py_module = __Pyx_ImportModule(module_name);
39182     if (!py_module)
39183         goto bad;
39184     #if PY_MAJOR_VERSION < 3
39185     py_name = PyString_FromString(class_name);
39186     #else
39187     py_name = PyUnicode_FromString(class_name);
39188     #endif
39189     if (!py_name)
39190         goto bad;
39191     result = PyObject_GetAttr(py_module, py_name);
39192     Py_DECREF(py_name);
39193     py_name = 0;
39194     Py_DECREF(py_module);
39195     py_module = 0;
39196     if (!result)
39197         goto bad;
39198     if (!PyType_Check(result)) {
39199         PyErr_Format(PyExc_TypeError, 
39200             "%s.%s is not a type object",
39201             module_name, class_name);
39202         goto bad;
39203     }
39204     if (!strict && ((PyTypeObject *)result)->tp_basicsize > size) {
39205         PyOS_snprintf(warning, sizeof(warning), 
39206             "%s.%s size changed, may indicate binary incompatibility",
39207             module_name, class_name);
39208         #if PY_VERSION_HEX < 0x02050000
39209         PyErr_Warn(NULL, warning);
39210         #else
39211         PyErr_WarnEx(NULL, warning, 0);
39212         #endif
39213     }
39214     else if (((PyTypeObject *)result)->tp_basicsize != size) {
39215         PyErr_Format(PyExc_ValueError, 
39216             "%s.%s has the wrong size, try recompiling",
39217             module_name, class_name);
39218         goto bad;
39219     }
39220     return (PyTypeObject *)result;
39221 bad:
39222     Py_XDECREF(py_module);
39223     Py_XDECREF(result);
39224     return 0;
39225 }
39226 #endif
39227
39228 #ifndef __PYX_HAVE_RT_ImportModule
39229 #define __PYX_HAVE_RT_ImportModule
39230 static PyObject *__Pyx_ImportModule(const char *name) {
39231     PyObject *py_name = 0;
39232     PyObject *py_module = 0;
39233
39234     #if PY_MAJOR_VERSION < 3
39235     py_name = PyString_FromString(name);
39236     #else
39237     py_name = PyUnicode_FromString(name);
39238     #endif
39239     if (!py_name)
39240         goto bad;
39241     py_module = PyImport_Import(py_name);
39242     Py_DECREF(py_name);
39243     return py_module;
39244 bad:
39245     Py_XDECREF(py_name);
39246     return 0;
39247 }
39248 #endif
39249
39250 static int __Pyx_SetVtable(PyObject *dict, void *vtable) {
39251 #if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
39252     PyObject *ob = PyCapsule_New(vtable, 0, 0);
39253 #else
39254     PyObject *ob = PyCObject_FromVoidPtr(vtable, 0);
39255 #endif
39256     if (!ob)
39257         goto bad;
39258     if (PyDict_SetItemString(dict, "__pyx_vtable__", ob) < 0)
39259         goto bad;
39260     Py_DECREF(ob);
39261     return 0;
39262 bad:
39263     Py_XDECREF(ob);
39264     return -1;
39265 }
39266
39267 #include "compile.h"
39268 #include "frameobject.h"
39269 #include "traceback.h"
39270
39271 static void __Pyx_AddTraceback(const char *funcname) {
39272     PyObject *py_srcfile = 0;
39273     PyObject *py_funcname = 0;
39274     PyObject *py_globals = 0;
39275     PyCodeObject *py_code = 0;
39276     PyFrameObject *py_frame = 0;
39277
39278     #if PY_MAJOR_VERSION < 3
39279     py_srcfile = PyString_FromString(__pyx_filename);
39280     #else
39281     py_srcfile = PyUnicode_FromString(__pyx_filename);
39282     #endif
39283     if (!py_srcfile) goto bad;
39284     if (__pyx_clineno) {
39285         #if PY_MAJOR_VERSION < 3
39286         py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
39287         #else
39288         py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
39289         #endif
39290     }
39291     else {
39292         #if PY_MAJOR_VERSION < 3
39293         py_funcname = PyString_FromString(funcname);
39294         #else
39295         py_funcname = PyUnicode_FromString(funcname);
39296         #endif
39297     }
39298     if (!py_funcname) goto bad;
39299     py_globals = PyModule_GetDict(__pyx_m);
39300     if (!py_globals) goto bad;
39301     py_code = PyCode_New(
39302         0,            /*int argcount,*/
39303         #if PY_MAJOR_VERSION >= 3
39304         0,            /*int kwonlyargcount,*/
39305         #endif
39306         0,            /*int nlocals,*/
39307         0,            /*int stacksize,*/
39308         0,            /*int flags,*/
39309         __pyx_empty_bytes, /*PyObject *code,*/
39310         __pyx_empty_tuple,  /*PyObject *consts,*/
39311         __pyx_empty_tuple,  /*PyObject *names,*/
39312         __pyx_empty_tuple,  /*PyObject *varnames,*/
39313         __pyx_empty_tuple,  /*PyObject *freevars,*/
39314         __pyx_empty_tuple,  /*PyObject *cellvars,*/
39315         py_srcfile,   /*PyObject *filename,*/
39316         py_funcname,  /*PyObject *name,*/
39317         __pyx_lineno,   /*int firstlineno,*/
39318         __pyx_empty_bytes  /*PyObject *lnotab*/
39319     );
39320     if (!py_code) goto bad;
39321     py_frame = PyFrame_New(
39322         PyThreadState_GET(), /*PyThreadState *tstate,*/
39323         py_code,             /*PyCodeObject *code,*/
39324         py_globals,          /*PyObject *globals,*/
39325         0                    /*PyObject *locals*/
39326     );
39327     if (!py_frame) goto bad;
39328     py_frame->f_lineno = __pyx_lineno;
39329     PyTraceBack_Here(py_frame);
39330 bad:
39331     Py_XDECREF(py_srcfile);
39332     Py_XDECREF(py_funcname);
39333     Py_XDECREF(py_code);
39334     Py_XDECREF(py_frame);
39335 }
39336
39337 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
39338     while (t->p) {
39339         #if PY_MAJOR_VERSION < 3
39340         if (t->is_unicode) {
39341             *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
39342         } else if (t->intern) {
39343             *t->p = PyString_InternFromString(t->s);
39344         } else {
39345             *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
39346         }
39347         #else  /* Python 3+ has unicode identifiers */
39348         if (t->is_unicode | t->is_str) {
39349             if (t->intern) {
39350                 *t->p = PyUnicode_InternFromString(t->s);
39351             } else if (t->encoding) {
39352                 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
39353             } else {
39354                 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
39355             }
39356         } else {
39357             *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
39358         }
39359         #endif
39360         if (!*t->p)
39361             return -1;
39362         ++t;
39363     }
39364     return 0;
39365 }
39366
39367 /* Type Conversion Functions */
39368
39369 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
39370    int is_true = x == Py_True;
39371    if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
39372    else return PyObject_IsTrue(x);
39373 }
39374
39375 static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
39376   PyNumberMethods *m;
39377   const char *name = NULL;
39378   PyObject *res = NULL;
39379 #if PY_VERSION_HEX < 0x03000000
39380   if (PyInt_Check(x) || PyLong_Check(x))
39381 #else
39382   if (PyLong_Check(x))
39383 #endif
39384     return Py_INCREF(x), x;
39385   m = Py_TYPE(x)->tp_as_number;
39386 #if PY_VERSION_HEX < 0x03000000
39387   if (m && m->nb_int) {
39388     name = "int";
39389     res = PyNumber_Int(x);
39390   }
39391   else if (m && m->nb_long) {
39392     name = "long";
39393     res = PyNumber_Long(x);
39394   }
39395 #else
39396   if (m && m->nb_int) {
39397     name = "int";
39398     res = PyNumber_Long(x);
39399   }
39400 #endif
39401   if (res) {
39402 #if PY_VERSION_HEX < 0x03000000
39403     if (!PyInt_Check(res) && !PyLong_Check(res)) {
39404 #else
39405     if (!PyLong_Check(res)) {
39406 #endif
39407       PyErr_Format(PyExc_TypeError,
39408                    "__%s__ returned non-%s (type %.200s)",
39409                    name, name, Py_TYPE(res)->tp_name);
39410       Py_DECREF(res);
39411       return NULL;
39412     }
39413   }
39414   else if (!PyErr_Occurred()) {
39415     PyErr_SetString(PyExc_TypeError,
39416                     "an integer is required");
39417   }
39418   return res;
39419 }
39420
39421 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
39422   Py_ssize_t ival;
39423   PyObject* x = PyNumber_Index(b);
39424   if (!x) return -1;
39425   ival = PyInt_AsSsize_t(x);
39426   Py_DECREF(x);
39427   return ival;
39428 }
39429
39430 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
39431 #if PY_VERSION_HEX < 0x02050000
39432    if (ival <= LONG_MAX)
39433        return PyInt_FromLong((long)ival);
39434    else {
39435        unsigned char *bytes = (unsigned char *) &ival;
39436        int one = 1; int little = (int)*(unsigned char*)&one;
39437        return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0);
39438    }
39439 #else
39440    return PyInt_FromSize_t(ival);
39441 #endif
39442 }
39443
39444 static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) {
39445    unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x);
39446    if (unlikely(val == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())) {
39447        return (size_t)-1;
39448    } else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) {
39449        PyErr_SetString(PyExc_OverflowError,
39450                        "value too large to convert to size_t");
39451        return (size_t)-1;
39452    }
39453    return (size_t)val;
39454 }
39455
39456
39457 #endif /* Py_PYTHON_H */