Imported Upstream version 0.5
[pysam.git] / pysam / ctabix.c
1 /* Generated by Cython 0.13 on Thu May  5 14:57:46 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__ctabix
199 #include "string.h"
200 #include "stdlib.h"
201 #include "stdio.h"
202 #include "ctype.h"
203 #include "sys/types.h"
204 #include "sys/stat.h"
205 #include "fcntl.h"
206 #include "unistd.h"
207 #include "stdint.h"
208 #include "bgzf.h"
209 #include "tabix.h"
210 #include "pythread.h"
211
212 /* inline attribute */
213 #ifndef CYTHON_INLINE
214   #if defined(__GNUC__)
215     #define CYTHON_INLINE __inline__
216   #elif defined(_MSC_VER)
217     #define CYTHON_INLINE __inline
218   #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
219     #define CYTHON_INLINE inline
220   #else
221     #define CYTHON_INLINE 
222   #endif
223 #endif
224
225 /* unused attribute */
226 #ifndef CYTHON_UNUSED
227 # if defined(__GNUC__)
228 #   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
229 #     define CYTHON_UNUSED __attribute__ ((__unused__)) 
230 #   else
231 #     define CYTHON_UNUSED
232 #   endif
233 # elif defined(__ICC) || defined(__INTEL_COMPILER)
234 #   define CYTHON_UNUSED __attribute__ ((__unused__)) 
235 # else
236 #   define CYTHON_UNUSED 
237 # endif
238 #endif
239
240 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*/
241
242
243 /* Type Conversion Predeclarations */
244
245 #define __Pyx_PyBytes_FromUString(s) PyBytes_FromString((char*)s)
246 #define __Pyx_PyBytes_AsUString(s)   ((unsigned char*) PyBytes_AsString(s))
247
248 #define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
249 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
250 static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
251
252 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
253 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
254 static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);
255
256 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
257
258
259 #ifdef __GNUC__
260 /* Test for GCC > 2.95 */
261 #if __GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) 
262 #define likely(x)   __builtin_expect(!!(x), 1)
263 #define unlikely(x) __builtin_expect(!!(x), 0)
264 #else /* __GNUC__ > 2 ... */
265 #define likely(x)   (x)
266 #define unlikely(x) (x)
267 #endif /* __GNUC__ > 2 ... */
268 #else /* __GNUC__ */
269 #define likely(x)   (x)
270 #define unlikely(x) (x)
271 #endif /* __GNUC__ */
272     
273 static PyObject *__pyx_m;
274 static PyObject *__pyx_b;
275 static PyObject *__pyx_empty_tuple;
276 static PyObject *__pyx_empty_bytes;
277 static int __pyx_lineno;
278 static int __pyx_clineno = 0;
279 static const char * __pyx_cfilenm= __FILE__;
280 static const char *__pyx_filename;
281
282
283 static const char *__pyx_f[] = {
284   "ctabix.pyx",
285   "bool.pxd",
286   "TabProxies.pxd",
287 };
288
289 /* Type declarations */
290
291 /* "pysam/ctabix.pxd":178
292  *     cdef tabix_t * tabixfile
293  * 
294  * cdef class Parser:             # <<<<<<<<<<<<<<
295  *      pass
296  */
297
298 struct __pyx_obj_6ctabix_Parser {
299   PyObject_HEAD
300 };
301
302 /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":293
303  *         return r
304  * 
305  * cdef class asVCF( Parser ):             # <<<<<<<<<<<<<<
306  *     '''converts a :term:`tabix row` into a VCF record.'''
307  *     def __call__(self, char * buffer, int len ):
308  */
309
310 struct __pyx_obj_6ctabix_asVCF {
311   struct __pyx_obj_6ctabix_Parser __pyx_base;
312 };
313
314 /* "pysam/TabProxies.pxd":42
315  *   ctypedef int uint64_t
316  * 
317  * cdef class TupleProxy:             # <<<<<<<<<<<<<<
318  * 
319  *     cdef:
320  */
321
322 struct __pyx_obj_10TabProxies_TupleProxy {
323   PyObject_HEAD
324   struct __pyx_vtabstruct_10TabProxies_TupleProxy *__pyx_vtab;
325   char *data;
326   char **fields;
327   int nfields;
328   int index;
329   int nbytes;
330   int offset;
331   int is_modified;
332 };
333
334 /* "pysam/TabProxies.pxd":77
335  *     cdef update( self, char * buffer, size_t nbytes )
336  * 
337  * cdef class NamedTupleProxy( TupleProxy) :             # <<<<<<<<<<<<<<
338  *     pass
339  * 
340  */
341
342 struct __pyx_obj_10TabProxies_NamedTupleProxy {
343   struct __pyx_obj_10TabProxies_TupleProxy __pyx_base;
344 };
345
346 /* "pysam/TabProxies.pxd":80
347  *     pass
348  * 
349  * cdef class BedProxy( NamedTupleProxy) :             # <<<<<<<<<<<<<<
350  * 
351  *     cdef:
352  */
353
354 struct __pyx_obj_10TabProxies_BedProxy {
355   struct __pyx_obj_10TabProxies_NamedTupleProxy __pyx_base;
356   char *contig;
357   uint32_t start;
358   uint32_t end;
359   int bedfields;
360 };
361
362 /* "pysam/TabProxies.pxd":91
363  *     cdef update( self, char * buffer, size_t nbytes )
364  * 
365  * cdef class VCFProxy( NamedTupleProxy) :             # <<<<<<<<<<<<<<
366  * 
367  *     cdef:
368  */
369
370 struct __pyx_obj_10TabProxies_VCFProxy {
371   struct __pyx_obj_10TabProxies_NamedTupleProxy __pyx_base;
372   char *contig;
373   uint32_t pos;
374 };
375
376 /* "pysam/TabProxies.pxd":60
377  *     cdef update( self, char * buffer, size_t nbytes )
378  * 
379  * cdef class GTFProxy( TupleProxy) :             # <<<<<<<<<<<<<<
380  * 
381  *     cdef:
382  */
383
384 struct __pyx_obj_10TabProxies_GTFProxy {
385   struct __pyx_obj_10TabProxies_TupleProxy __pyx_base;
386   char *contig;
387   char *source;
388   char *feature;
389   uint32_t start;
390   uint32_t end;
391   char *score;
392   char *strand;
393   char *frame;
394   char *attributes;
395   int hasOwnAttributes;
396 };
397
398 /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":161
399  *             return result
400  * 
401  * cdef class TabixIterator:             # <<<<<<<<<<<<<<
402  *     """iterates over rows in *tabixfile* in region
403  *     given by *tid*, *start* and *end*.
404  */
405
406 struct __pyx_obj_6ctabix_TabixIterator {
407   PyObject_HEAD
408   ti_iter_t iterator;
409   tabix_t *tabixfile;
410 };
411
412 /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":304
413  * #########################################################
414  * #########################################################
415  * cdef class TabixIteratorParsed:             # <<<<<<<<<<<<<<
416  *     """iterates over mapped reads in a region.
417  * 
418  */
419
420 struct __pyx_obj_6ctabix_TabixIteratorParsed {
421   PyObject_HEAD
422   ti_iter_t iterator;
423   tabix_t *tabixfile;
424   struct __pyx_obj_6ctabix_Parser *parser;
425 };
426
427 /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":216
428  *             ti_iter_destroy(self.iterator)
429  * 
430  * cdef class TabixHeaderIterator:             # <<<<<<<<<<<<<<
431  *     """return header lines.
432  *     """
433  */
434
435 struct __pyx_obj_6ctabix_TabixHeaderIterator {
436   PyObject_HEAD
437   ti_iter_t iterator;
438   tabix_t *tabixfile;
439 };
440
441 /* "pysam/ctabix.pxd":172
442  *   # char *ti_iter_read(BGZF *fp, ti_iter_t iter, int *len)
443  * 
444  * cdef class Tabixfile:             # <<<<<<<<<<<<<<
445  *     cdef char * filename
446  * 
447  */
448
449 struct __pyx_obj_6ctabix_Tabixfile {
450   PyObject_HEAD
451   char *filename;
452   tabix_t *tabixfile;
453 };
454
455 /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":277
456  *         return r
457  * 
458  * cdef class asGTF(Parser):             # <<<<<<<<<<<<<<
459  *     '''converts a :term:`tabix row` into a GTF record.'''
460  *     def __call__(self, char * buffer, int len):
461  */
462
463 struct __pyx_obj_6ctabix_asGTF {
464   struct __pyx_obj_6ctabix_Parser __pyx_base;
465 };
466
467 /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":285
468  *         return r
469  * 
470  * cdef class asBed( Parser ):             # <<<<<<<<<<<<<<
471  *     '''converts a :term:`tabix row` into a GTF record.'''
472  *     def __call__(self, char * buffer, int len):
473  */
474
475 struct __pyx_obj_6ctabix_asBed {
476   struct __pyx_obj_6ctabix_Parser __pyx_base;
477 };
478
479 /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":267
480  *     pass
481  * 
482  * cdef class asTuple(Parser):             # <<<<<<<<<<<<<<
483  *     '''converts a :term:`tabix row` into a python tuple.'''
484  *     def __call__(self, char * buffer, int len):
485  */
486
487 struct __pyx_obj_6ctabix_asTuple {
488   struct __pyx_obj_6ctabix_Parser __pyx_base;
489 };
490
491
492 /* "pysam/TabProxies.pxd":42
493  *   ctypedef int uint64_t
494  * 
495  * cdef class TupleProxy:             # <<<<<<<<<<<<<<
496  * 
497  *     cdef:
498  */
499
500 struct __pyx_vtabstruct_10TabProxies_TupleProxy {
501   int (*getMaxFields)(struct __pyx_obj_10TabProxies_TupleProxy *, size_t);
502   PyObject *(*take)(struct __pyx_obj_10TabProxies_TupleProxy *, char *, size_t);
503   PyObject *(*present)(struct __pyx_obj_10TabProxies_TupleProxy *, char *, size_t);
504   PyObject *(*copy)(struct __pyx_obj_10TabProxies_TupleProxy *, char *, size_t);
505   PyObject *(*update)(struct __pyx_obj_10TabProxies_TupleProxy *, char *, size_t);
506 };
507 static struct __pyx_vtabstruct_10TabProxies_TupleProxy *__pyx_vtabptr_10TabProxies_TupleProxy;
508
509
510 /* "pysam/TabProxies.pxd":77
511  *     cdef update( self, char * buffer, size_t nbytes )
512  * 
513  * cdef class NamedTupleProxy( TupleProxy) :             # <<<<<<<<<<<<<<
514  *     pass
515  * 
516  */
517
518 struct __pyx_vtabstruct_10TabProxies_NamedTupleProxy {
519   struct __pyx_vtabstruct_10TabProxies_TupleProxy __pyx_base;
520 };
521 static struct __pyx_vtabstruct_10TabProxies_NamedTupleProxy *__pyx_vtabptr_10TabProxies_NamedTupleProxy;
522
523
524 /* "pysam/TabProxies.pxd":91
525  *     cdef update( self, char * buffer, size_t nbytes )
526  * 
527  * cdef class VCFProxy( NamedTupleProxy) :             # <<<<<<<<<<<<<<
528  * 
529  *     cdef:
530  */
531
532 struct __pyx_vtabstruct_10TabProxies_VCFProxy {
533   struct __pyx_vtabstruct_10TabProxies_NamedTupleProxy __pyx_base;
534 };
535 static struct __pyx_vtabstruct_10TabProxies_VCFProxy *__pyx_vtabptr_10TabProxies_VCFProxy;
536
537
538 /* "pysam/TabProxies.pxd":80
539  *     pass
540  * 
541  * cdef class BedProxy( NamedTupleProxy) :             # <<<<<<<<<<<<<<
542  * 
543  *     cdef:
544  */
545
546 struct __pyx_vtabstruct_10TabProxies_BedProxy {
547   struct __pyx_vtabstruct_10TabProxies_NamedTupleProxy __pyx_base;
548 };
549 static struct __pyx_vtabstruct_10TabProxies_BedProxy *__pyx_vtabptr_10TabProxies_BedProxy;
550
551
552 /* "pysam/TabProxies.pxd":60
553  *     cdef update( self, char * buffer, size_t nbytes )
554  * 
555  * cdef class GTFProxy( TupleProxy) :             # <<<<<<<<<<<<<<
556  * 
557  *     cdef:
558  */
559
560 struct __pyx_vtabstruct_10TabProxies_GTFProxy {
561   struct __pyx_vtabstruct_10TabProxies_TupleProxy __pyx_base;
562 };
563 static struct __pyx_vtabstruct_10TabProxies_GTFProxy *__pyx_vtabptr_10TabProxies_GTFProxy;
564
565 #ifndef CYTHON_REFNANNY
566   #define CYTHON_REFNANNY 0
567 #endif
568
569 #if CYTHON_REFNANNY
570   typedef struct {
571     void (*INCREF)(void*, PyObject*, int);
572     void (*DECREF)(void*, PyObject*, int);
573     void (*GOTREF)(void*, PyObject*, int);
574     void (*GIVEREF)(void*, PyObject*, int);
575     void* (*SetupContext)(const char*, int, const char*);
576     void (*FinishContext)(void**);
577   } __Pyx_RefNannyAPIStruct;
578   static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
579   static __Pyx_RefNannyAPIStruct * __Pyx_RefNannyImportAPI(const char *modname) {
580     PyObject *m = NULL, *p = NULL;
581     void *r = NULL;
582     m = PyImport_ImportModule((char *)modname);
583     if (!m) goto end;
584     p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
585     if (!p) goto end;
586     r = PyLong_AsVoidPtr(p);
587   end:
588     Py_XDECREF(p);
589     Py_XDECREF(m);
590     return (__Pyx_RefNannyAPIStruct *)r;
591   }
592   #define __Pyx_RefNannySetupContext(name)           void *__pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
593   #define __Pyx_RefNannyFinishContext()           __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
594   #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
595   #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
596   #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
597   #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
598   #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r);} } while(0)
599 #else
600   #define __Pyx_RefNannySetupContext(name)
601   #define __Pyx_RefNannyFinishContext()
602   #define __Pyx_INCREF(r) Py_INCREF(r)
603   #define __Pyx_DECREF(r) Py_DECREF(r)
604   #define __Pyx_GOTREF(r)
605   #define __Pyx_GIVEREF(r)
606   #define __Pyx_XDECREF(r) Py_XDECREF(r)
607 #endif /* CYTHON_REFNANNY */
608 #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);} } while(0)
609 #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r);} } while(0)
610
611 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
612
613 static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict,
614     const char* function_name, int kw_allowed); /*proto*/
615
616 static void __Pyx_RaiseDoubleKeywordsError(
617     const char* func_name, PyObject* kw_name); /*proto*/
618
619 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
620     Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/
621
622 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,     const char* function_name); /*proto*/
623
624
625 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
626     PyObject *r;
627     if (!j) return NULL;
628     r = PyObject_GetItem(o, j);
629     Py_DECREF(j);
630     return r;
631 }
632
633
634 #define __Pyx_GetItemInt_List(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
635                                                     __Pyx_GetItemInt_List_Fast(o, i) : \
636                                                     __Pyx_GetItemInt_Generic(o, to_py_func(i)))
637
638 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i) {
639     if (likely(o != Py_None)) {
640         if (likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
641             PyObject *r = PyList_GET_ITEM(o, i);
642             Py_INCREF(r);
643             return r;
644         }
645         else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) {
646             PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i);
647             Py_INCREF(r);
648             return r;
649         }
650     }
651     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
652 }
653
654 #define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
655                                                     __Pyx_GetItemInt_Tuple_Fast(o, i) : \
656                                                     __Pyx_GetItemInt_Generic(o, to_py_func(i)))
657
658 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i) {
659     if (likely(o != Py_None)) {
660         if (likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
661             PyObject *r = PyTuple_GET_ITEM(o, i);
662             Py_INCREF(r);
663             return r;
664         }
665         else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) {
666             PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i);
667             Py_INCREF(r);
668             return r;
669         }
670     }
671     return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
672 }
673
674
675 #define __Pyx_GetItemInt(o, i, size, to_py_func) (((size) <= sizeof(Py_ssize_t)) ? \
676                                                     __Pyx_GetItemInt_Fast(o, i) : \
677                                                     __Pyx_GetItemInt_Generic(o, to_py_func(i)))
678
679 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i) {
680     PyObject *r;
681     if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) {
682         r = PyList_GET_ITEM(o, i);
683         Py_INCREF(r);
684     }
685     else if (PyTuple_CheckExact(o) && ((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
686         r = PyTuple_GET_ITEM(o, i);
687         Py_INCREF(r);
688     }
689     else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_item && (likely(i >= 0))) {
690         r = PySequence_GetItem(o, i);
691     }
692     else {
693         r = __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
694     }
695     return r;
696 }
697
698 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
699
700 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
701
702 static PyObject *__Pyx_UnpackItem(PyObject *, Py_ssize_t index); /*proto*/
703 static int __Pyx_EndUnpack(PyObject *, Py_ssize_t expected); /*proto*/
704
705 static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
706     const char *name, int exact); /*proto*/
707
708 static CYTHON_INLINE void __Pyx_RaiseNoneIndexingError(void);
709
710
711 #if PY_MAJOR_VERSION >= 3
712 static PyObject *__Pyx_PyDict_GetItem(PyObject *d, PyObject* key) {
713     PyObject *value;
714     if (unlikely(d == Py_None)) {
715         __Pyx_RaiseNoneIndexingError();
716         return NULL;
717     }
718     value = PyDict_GetItemWithError(d, key);
719     if (unlikely(!value)) {
720         if (!PyErr_Occurred())
721             PyErr_SetObject(PyExc_KeyError, key);
722         return NULL;
723     }
724     Py_INCREF(value);
725     return value;
726 }
727 #else
728     #define __Pyx_PyDict_GetItem(d, key) PyObject_GetItem(d, key)
729 #endif
730
731 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
732
733 static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
734 static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
735
736 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/
737
738 static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
739 static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
740
741 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
742
743 static CYTHON_INLINE int32_t __Pyx_PyInt_from_py_int32_t(PyObject *);
744
745 static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);
746
747 static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);
748
749 static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);
750
751 static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject *);
752
753 static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject *);
754
755 static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject *);
756
757 static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);
758
759 static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);
760
761 static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);
762
763 static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject *);
764
765 static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);
766
767 static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);
768
769 static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject *);
770
771 static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);
772
773 static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);
774
775 static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);
776
777 static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, long size, int strict);  /*proto*/
778
779 static PyObject *__Pyx_ImportModule(const char *name); /*proto*/
780
781 static int __Pyx_GetVtable(PyObject *dict, void *vtabptr); /*proto*/
782
783 static void __Pyx_AddTraceback(const char *funcname); /*proto*/
784
785 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
786 /* Module declarations from cpython.version */
787
788 /* Module declarations from cpython.ref */
789
790 /* Module declarations from cpython.exc */
791
792 /* Module declarations from cpython.module */
793
794 /* Module declarations from cpython.mem */
795
796 /* Module declarations from cpython.tuple */
797
798 /* Module declarations from cpython.list */
799
800 /* Module declarations from libc.stdio */
801
802 /* Module declarations from cpython.object */
803
804 /* Module declarations from cpython.sequence */
805
806 /* Module declarations from cpython.mapping */
807
808 /* Module declarations from cpython.iterator */
809
810 /* Module declarations from cpython.type */
811
812 /* Module declarations from cpython.number */
813
814 /* Module declarations from cpython.int */
815
816 /* Module declarations from __builtin__ */
817
818 /* Module declarations from cpython.bool */
819
820 static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0;
821 /* Module declarations from cpython.long */
822
823 /* Module declarations from cpython.float */
824
825 /* Module declarations from cpython.complex */
826
827 /* Module declarations from cpython.string */
828
829 /* Module declarations from cpython.unicode */
830
831 /* Module declarations from cpython.dict */
832
833 /* Module declarations from cpython.instance */
834
835 /* Module declarations from cpython.function */
836
837 /* Module declarations from cpython.method */
838
839 /* Module declarations from cpython.weakref */
840
841 /* Module declarations from cpython.getargs */
842
843 /* Module declarations from cpython.pythread */
844
845 /* Module declarations from cpython.cobject */
846
847 /* Module declarations from cpython.oldbuffer */
848
849 /* Module declarations from cpython.set */
850
851 /* Module declarations from cpython.buffer */
852
853 /* Module declarations from cpython.bytes */
854
855 /* Module declarations from cpython.pycapsule */
856
857 /* Module declarations from cpython */
858
859 /* Module declarations from TabProxies */
860
861 static PyTypeObject *__pyx_ptype_10TabProxies_TupleProxy = 0;
862 static PyTypeObject *__pyx_ptype_10TabProxies_GTFProxy = 0;
863 static PyTypeObject *__pyx_ptype_10TabProxies_NamedTupleProxy = 0;
864 static PyTypeObject *__pyx_ptype_10TabProxies_BedProxy = 0;
865 static PyTypeObject *__pyx_ptype_10TabProxies_VCFProxy = 0;
866 /* Module declarations from ctabix */
867
868 static PyTypeObject *__pyx_ptype_6ctabix_Tabixfile = 0;
869 static PyTypeObject *__pyx_ptype_6ctabix_Parser = 0;
870 static PyTypeObject *__pyx_ptype_6ctabix_TabixIterator = 0;
871 static PyTypeObject *__pyx_ptype_6ctabix_TabixHeaderIterator = 0;
872 static PyTypeObject *__pyx_ptype_6ctabix_asTuple = 0;
873 static PyTypeObject *__pyx_ptype_6ctabix_asGTF = 0;
874 static PyTypeObject *__pyx_ptype_6ctabix_asBed = 0;
875 static PyTypeObject *__pyx_ptype_6ctabix_asVCF = 0;
876 static PyTypeObject *__pyx_ptype_6ctabix_TabixIteratorParsed = 0;
877 #define __Pyx_MODULE_NAME "ctabix"
878 int __pyx_module_is_main_ctabix = 0;
879
880 /* Implementation of ctabix */
881 static PyObject *__pyx_builtin_IOError;
882 static PyObject *__pyx_builtin_ValueError;
883 static PyObject *__pyx_builtin_StopIteration;
884 static PyObject *__pyx_builtin_OSError;
885 static PyObject *__pyx_builtin_ord;
886 static PyObject *__pyx_builtin_KeyError;
887 static char __pyx_k_1[] = "invalid file opening mode `%s`";
888 static char __pyx_k_2[] = ".tbi";
889 static char __pyx_k_3[] = "file `%s` not found";
890 static char __pyx_k_4[] = "index `%s` not found";
891 static char __pyx_k_5[] = "could not open file `%s`";
892 static char __pyx_k_6[] = "%s:%i-%i";
893 static char __pyx_k_7[] = "invalid region `%s`";
894 static char __pyx_k_8[] = "invalid region: start (%i) > end (%i)";
895 static char __pyx_k_9[] = "start out of range (%i)";
896 static char __pyx_k_10[] = "end out of range (%i)";
897 static char __pyx_k_11[] = "I/O operation on closed file";
898 static char __pyx_k_12[] = "malformatted query or wrong sequence name.\n";
899 static char __pyx_k_13[] = "can't open header.\n";
900 static char __pyx_k_15[] = "Filename '%s' already exists, use *force* to overwrite";
901 static char __pyx_k_16[] = "could not open '%s' for writing";
902 static char __pyx_k_17[] = "could not open '%s' for reading";
903 static char __pyx_k_18[] = "writing failed";
904 static char __pyx_k_20[] = "#";
905 static char __pyx_k_22[] = "No such file '%s'";
906 static char __pyx_k_23[] = ".gz";
907 static char __pyx_k_24[] = "Filename '%s.tbi' already exists, use *force* to overwrite";
908 static char __pyx_k_25[] = "unknown preset '%s', valid presets are '%s'";
909 static char __pyx_k_26[] = ",";
910 static char __pyx_k_27[] = "chromosome names";
911 static char __pyx_k_28[] = "Tabixfile._isOpen (line 19)";
912 static char __pyx_k_29[] = "Tabixfile._open (line 23)";
913 static char __pyx_k_30[] = "Tabixfile._parseRegion (line 57)";
914 static char __pyx_k_31[] = "Tabixfile.fetch (line 102)";
915 static char __pyx_k_32[] = "Tabixfile.header.__get__ (line 140)";
916 static char __pyx_k_33[] = "TabixIterator.__next__ (line 192)";
917 static char __pyx_k_34[] = "TabixHeaderIterator.__next__ (line 239)";
918 static char __pyx_k_35[] = "TabixIteratorParsed.__next__ (line 342)";
919 static char __pyx_k_36[] = "tabix_compress (line 362)";
920 static char __pyx_k_37[] = "tabix_index (line 407)";
921 static char __pyx_k__r[] = "r";
922 static char __pyx_k__w[] = "w";
923 static char __pyx_k__bc[] = "bc";
924 static char __pyx_k__ec[] = "ec";
925 static char __pyx_k__fp[] = "fp";
926 static char __pyx_k__os[] = "os";
927 static char __pyx_k__sc[] = "sc";
928 static char __pyx_k__bed[] = "bed";
929 static char __pyx_k__end[] = "end";
930 static char __pyx_k__gff[] = "gff";
931 static char __pyx_k__idx[] = "idx";
932 static char __pyx_k__len[] = "len";
933 static char __pyx_k__ord[] = "ord";
934 static char __pyx_k__sam[] = "sam";
935 static char __pyx_k__sys[] = "sys";
936 static char __pyx_k__tid[] = "tid";
937 static char __pyx_k__vcf[] = "vcf";
938 static char __pyx_k__copy[] = "copy";
939 static char __pyx_k__gzip[] = "gzip";
940 static char __pyx_k__join[] = "join";
941 static char __pyx_k__keys[] = "keys";
942 static char __pyx_k__mode[] = "mode";
943 static char __pyx_k__path[] = "path";
944 static char __pyx_k___open[] = "_open";
945 static char __pyx_k__asBed[] = "asBed";
946 static char __pyx_k__asGTF[] = "asGTF";
947 static char __pyx_k__asVCF[] = "asVCF";
948 static char __pyx_k__close[] = "close";
949 static char __pyx_k__fetch[] = "fetch";
950 static char __pyx_k__force[] = "force";
951 static char __pyx_k__start[] = "start";
952 static char __pyx_k__types[] = "types";
953 static char __pyx_k__buffer[] = "buffer";
954 static char __pyx_k__ctypes[] = "ctypes";
955 static char __pyx_k__exists[] = "exists";
956 static char __pyx_k__header[] = "header";
957 static char __pyx_k__parser[] = "parser";
958 static char __pyx_k__pileup[] = "pileup";
959 static char __pyx_k__preset[] = "preset";
960 static char __pyx_k__psltbl[] = "psltbl";
961 static char __pyx_k__region[] = "region";
962 static char __pyx_k__struct[] = "struct";
963 static char __pyx_k__unlink[] = "unlink";
964 static char __pyx_k__IOError[] = "IOError";
965 static char __pyx_k__OSError[] = "OSError";
966 static char __pyx_k____all__[] = "__all__";
967 static char __pyx_k____get__[] = "__get__";
968 static char __pyx_k___isOpen[] = "_isOpen";
969 static char __pyx_k__asTuple[] = "asTuple";
970 static char __pyx_k__end_col[] = "end_col";
971 static char __pyx_k__seq_col[] = "seq_col";
972 static char __pyx_k__KeyError[] = "KeyError";
973 static char __pyx_k__O_RDONLY[] = "O_RDONLY";
974 static char __pyx_k____main__[] = "__main__";
975 static char __pyx_k____next__[] = "__next__";
976 static char __pyx_k____test__[] = "__test__";
977 static char __pyx_k__endswith[] = "endswith";
978 static char __pyx_k__filename[] = "filename";
979 static char __pyx_k__iterator[] = "iterator";
980 static char __pyx_k__tempfile[] = "tempfile";
981 static char __pyx_k__Tabixfile[] = "Tabixfile";
982 static char __pyx_k__itertools[] = "itertools";
983 static char __pyx_k__line_skip[] = "line_skip";
984 static char __pyx_k__meta_char[] = "meta_char";
985 static char __pyx_k__reference[] = "reference";
986 static char __pyx_k__start_col[] = "start_col";
987 static char __pyx_k__tabixfile[] = "tabixfile";
988 static char __pyx_k__zerobased[] = "zerobased";
989 static char __pyx_k__ValueError[] = "ValueError";
990 static char __pyx_k__filename_in[] = "filename_in";
991 static char __pyx_k__tabix_index[] = "tabix_index";
992 static char __pyx_k___parseRegion[] = "_parseRegion";
993 static char __pyx_k__filename_out[] = "filename_out";
994 static char __pyx_k__StopIteration[] = "StopIteration";
995 static char __pyx_k__TabixIterator[] = "TabixIterator";
996 static char __pyx_k__tabix_compress[] = "tabix_compress";
997 static char __pyx_k__TabixHeaderIterator[] = "TabixHeaderIterator";
998 static char __pyx_k__TabixIteratorParsed[] = "TabixIteratorParsed";
999 static PyObject *__pyx_kp_s_1;
1000 static PyObject *__pyx_kp_s_10;
1001 static PyObject *__pyx_kp_s_11;
1002 static PyObject *__pyx_kp_s_12;
1003 static PyObject *__pyx_kp_s_13;
1004 static PyObject *__pyx_kp_s_15;
1005 static PyObject *__pyx_kp_s_16;
1006 static PyObject *__pyx_kp_s_17;
1007 static PyObject *__pyx_kp_s_18;
1008 static PyObject *__pyx_kp_s_2;
1009 static PyObject *__pyx_kp_s_20;
1010 static PyObject *__pyx_kp_s_22;
1011 static PyObject *__pyx_kp_s_23;
1012 static PyObject *__pyx_kp_s_24;
1013 static PyObject *__pyx_kp_s_25;
1014 static PyObject *__pyx_kp_s_26;
1015 static PyObject *__pyx_kp_u_28;
1016 static PyObject *__pyx_kp_u_29;
1017 static PyObject *__pyx_kp_s_3;
1018 static PyObject *__pyx_kp_u_30;
1019 static PyObject *__pyx_kp_u_31;
1020 static PyObject *__pyx_kp_u_32;
1021 static PyObject *__pyx_kp_u_33;
1022 static PyObject *__pyx_kp_u_34;
1023 static PyObject *__pyx_kp_u_35;
1024 static PyObject *__pyx_kp_u_36;
1025 static PyObject *__pyx_kp_u_37;
1026 static PyObject *__pyx_kp_s_4;
1027 static PyObject *__pyx_kp_s_5;
1028 static PyObject *__pyx_kp_s_6;
1029 static PyObject *__pyx_kp_s_7;
1030 static PyObject *__pyx_kp_s_8;
1031 static PyObject *__pyx_kp_s_9;
1032 static PyObject *__pyx_n_s__IOError;
1033 static PyObject *__pyx_n_s__KeyError;
1034 static PyObject *__pyx_n_s__OSError;
1035 static PyObject *__pyx_n_s__O_RDONLY;
1036 static PyObject *__pyx_n_s__StopIteration;
1037 static PyObject *__pyx_n_s__TabixHeaderIterator;
1038 static PyObject *__pyx_n_s__TabixIterator;
1039 static PyObject *__pyx_n_s__TabixIteratorParsed;
1040 static PyObject *__pyx_n_s__Tabixfile;
1041 static PyObject *__pyx_n_s__ValueError;
1042 static PyObject *__pyx_n_s____all__;
1043 static PyObject *__pyx_n_s____get__;
1044 static PyObject *__pyx_n_s____main__;
1045 static PyObject *__pyx_n_s____next__;
1046 static PyObject *__pyx_n_s____test__;
1047 static PyObject *__pyx_n_s___isOpen;
1048 static PyObject *__pyx_n_s___open;
1049 static PyObject *__pyx_n_s___parseRegion;
1050 static PyObject *__pyx_n_s__asBed;
1051 static PyObject *__pyx_n_s__asGTF;
1052 static PyObject *__pyx_n_s__asTuple;
1053 static PyObject *__pyx_n_s__asVCF;
1054 static PyObject *__pyx_n_s__bc;
1055 static PyObject *__pyx_n_s__bed;
1056 static PyObject *__pyx_n_s__buffer;
1057 static PyObject *__pyx_n_s__close;
1058 static PyObject *__pyx_n_s__copy;
1059 static PyObject *__pyx_n_s__ctypes;
1060 static PyObject *__pyx_n_s__ec;
1061 static PyObject *__pyx_n_s__end;
1062 static PyObject *__pyx_n_s__end_col;
1063 static PyObject *__pyx_n_s__endswith;
1064 static PyObject *__pyx_n_s__exists;
1065 static PyObject *__pyx_n_s__fetch;
1066 static PyObject *__pyx_n_s__filename;
1067 static PyObject *__pyx_n_s__filename_in;
1068 static PyObject *__pyx_n_s__filename_out;
1069 static PyObject *__pyx_n_s__force;
1070 static PyObject *__pyx_n_s__fp;
1071 static PyObject *__pyx_n_s__gff;
1072 static PyObject *__pyx_n_s__gzip;
1073 static PyObject *__pyx_n_s__header;
1074 static PyObject *__pyx_n_s__idx;
1075 static PyObject *__pyx_n_s__iterator;
1076 static PyObject *__pyx_n_s__itertools;
1077 static PyObject *__pyx_n_s__join;
1078 static PyObject *__pyx_n_s__keys;
1079 static PyObject *__pyx_n_s__len;
1080 static PyObject *__pyx_n_s__line_skip;
1081 static PyObject *__pyx_n_s__meta_char;
1082 static PyObject *__pyx_n_s__mode;
1083 static PyObject *__pyx_n_s__ord;
1084 static PyObject *__pyx_n_s__os;
1085 static PyObject *__pyx_n_s__parser;
1086 static PyObject *__pyx_n_s__path;
1087 static PyObject *__pyx_n_s__pileup;
1088 static PyObject *__pyx_n_s__preset;
1089 static PyObject *__pyx_n_s__psltbl;
1090 static PyObject *__pyx_n_s__r;
1091 static PyObject *__pyx_n_s__reference;
1092 static PyObject *__pyx_n_s__region;
1093 static PyObject *__pyx_n_s__sam;
1094 static PyObject *__pyx_n_s__sc;
1095 static PyObject *__pyx_n_s__seq_col;
1096 static PyObject *__pyx_n_s__start;
1097 static PyObject *__pyx_n_s__start_col;
1098 static PyObject *__pyx_n_s__struct;
1099 static PyObject *__pyx_n_s__sys;
1100 static PyObject *__pyx_n_s__tabix_compress;
1101 static PyObject *__pyx_n_s__tabix_index;
1102 static PyObject *__pyx_n_s__tabixfile;
1103 static PyObject *__pyx_n_s__tempfile;
1104 static PyObject *__pyx_n_s__tid;
1105 static PyObject *__pyx_n_s__types;
1106 static PyObject *__pyx_n_s__unlink;
1107 static PyObject *__pyx_n_s__vcf;
1108 static PyObject *__pyx_n_s__w;
1109 static PyObject *__pyx_n_s__zerobased;
1110 static PyObject *__pyx_int_0;
1111 static PyObject *__pyx_int_1;
1112 static PyObject *__pyx_int_2;
1113 static PyObject *__pyx_int_3;
1114 static PyObject *__pyx_int_4;
1115 static PyObject *__pyx_int_5;
1116 static PyObject *__pyx_int_neg_1;
1117 static PyObject *__pyx_int_15;
1118 static PyObject *__pyx_int_17;
1119 static PyObject *__pyx_int_18;
1120 static PyObject *__pyx_int_0x10000;
1121 static PyObject *__pyx_k_14;
1122 static PyObject *__pyx_k_19;
1123 static PyObject *__pyx_k_21;
1124
1125 /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":15
1126  *     '''
1127  * 
1128  *     def __cinit__(self, *args, **kwargs ):             # <<<<<<<<<<<<<<
1129  *         self.tabixfile = NULL
1130  *         self._open( *args, **kwargs )
1131  */
1132
1133 static int __pyx_pf_6ctabix_9Tabixfile___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
1134 static int __pyx_pf_6ctabix_9Tabixfile___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1135   PyObject *__pyx_v_args = 0;
1136   PyObject *__pyx_v_kwargs = 0;
1137   int __pyx_r;
1138   PyObject *__pyx_t_1 = NULL;
1139   PyObject *__pyx_t_2 = NULL;
1140   PyObject *__pyx_t_3 = NULL;
1141   __Pyx_RefNannySetupContext("__cinit__");
1142   if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 1))) return -1;
1143   __pyx_v_kwargs = (__pyx_kwds) ? PyDict_Copy(__pyx_kwds) : PyDict_New();
1144   if (unlikely(!__pyx_v_kwargs)) return -1;
1145   __Pyx_GOTREF(__pyx_v_kwargs);
1146   __Pyx_INCREF(__pyx_args);
1147   __pyx_v_args = __pyx_args;
1148
1149   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":16
1150  * 
1151  *     def __cinit__(self, *args, **kwargs ):
1152  *         self.tabixfile = NULL             # <<<<<<<<<<<<<<
1153  *         self._open( *args, **kwargs )
1154  * 
1155  */
1156   ((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->tabixfile = NULL;
1157
1158   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":17
1159  *     def __cinit__(self, *args, **kwargs ):
1160  *         self.tabixfile = NULL
1161  *         self._open( *args, **kwargs )             # <<<<<<<<<<<<<<
1162  * 
1163  *     def _isOpen( self ):
1164  */
1165   __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___open); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1166   __Pyx_GOTREF(__pyx_t_1);
1167   __pyx_t_2 = PySequence_Tuple(((PyObject *)__pyx_v_args)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1168   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
1169   __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 = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1170   __Pyx_GOTREF(__pyx_t_3);
1171   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1172   __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
1173   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1174
1175   __pyx_r = 0;
1176   goto __pyx_L0;
1177   __pyx_L1_error:;
1178   __Pyx_XDECREF(__pyx_t_1);
1179   __Pyx_XDECREF(__pyx_t_2);
1180   __Pyx_XDECREF(__pyx_t_3);
1181   __Pyx_AddTraceback("ctabix.Tabixfile.__cinit__");
1182   __pyx_r = -1;
1183   __pyx_L0:;
1184   __Pyx_DECREF(__pyx_v_args);
1185   __Pyx_DECREF(__pyx_v_kwargs);
1186   __Pyx_RefNannyFinishContext();
1187   return __pyx_r;
1188 }
1189
1190 /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":19
1191  *         self._open( *args, **kwargs )
1192  * 
1193  *     def _isOpen( self ):             # <<<<<<<<<<<<<<
1194  *         '''return true if samfile has been opened.'''
1195  *         return self.tabixfile != NULL
1196  */
1197
1198 static PyObject *__pyx_pf_6ctabix_9Tabixfile__isOpen(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
1199 static char __pyx_doc_6ctabix_9Tabixfile__isOpen[] = "Tabixfile._isOpen(self)\nreturn true if samfile has been opened.";
1200 static PyObject *__pyx_pf_6ctabix_9Tabixfile__isOpen(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
1201   PyObject *__pyx_r = NULL;
1202   PyObject *__pyx_t_1 = NULL;
1203   __Pyx_RefNannySetupContext("_isOpen");
1204
1205   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":21
1206  *     def _isOpen( self ):
1207  *         '''return true if samfile has been opened.'''
1208  *         return self.tabixfile != NULL             # <<<<<<<<<<<<<<
1209  * 
1210  *     def _open( self,
1211  */
1212   __Pyx_XDECREF(__pyx_r);
1213   __pyx_t_1 = __Pyx_PyBool_FromLong((((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->tabixfile != NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1214   __Pyx_GOTREF(__pyx_t_1);
1215   __pyx_r = __pyx_t_1;
1216   __pyx_t_1 = 0;
1217   goto __pyx_L0;
1218
1219   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1220   goto __pyx_L0;
1221   __pyx_L1_error:;
1222   __Pyx_XDECREF(__pyx_t_1);
1223   __Pyx_AddTraceback("ctabix.Tabixfile._isOpen");
1224   __pyx_r = NULL;
1225   __pyx_L0:;
1226   __Pyx_XGIVEREF(__pyx_r);
1227   __Pyx_RefNannyFinishContext();
1228   return __pyx_r;
1229 }
1230
1231 /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":23
1232  *         return self.tabixfile != NULL
1233  * 
1234  *     def _open( self,             # <<<<<<<<<<<<<<
1235  *                char * filename,
1236  *                mode ='r',
1237  */
1238
1239 static PyObject *__pyx_pf_6ctabix_9Tabixfile__open(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
1240 static char __pyx_doc_6ctabix_9Tabixfile__open[] = "Tabixfile._open(self, char *filename, mode='r')\nopen a :term:`tabix file` for reading.\n        ";
1241 static PyObject *__pyx_pf_6ctabix_9Tabixfile__open(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1242   char *__pyx_v_filename;
1243   PyObject *__pyx_v_mode = 0;
1244   PyObject *__pyx_v_filename_index;
1245   PyObject *__pyx_r = NULL;
1246   PyObject *__pyx_t_1 = NULL;
1247   PyObject *__pyx_t_2 = NULL;
1248   int __pyx_t_3;
1249   PyObject *__pyx_t_4 = NULL;
1250   int __pyx_t_5;
1251   char *__pyx_t_6;
1252   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__filename,&__pyx_n_s__mode,0};
1253   __Pyx_RefNannySetupContext("_open");
1254   if (unlikely(__pyx_kwds)) {
1255     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
1256     PyObject* values[2] = {0,0};
1257     values[1] = ((PyObject *)__pyx_n_s__r);
1258     switch (PyTuple_GET_SIZE(__pyx_args)) {
1259       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1260       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1261       case  0: break;
1262       default: goto __pyx_L5_argtuple_error;
1263     }
1264     switch (PyTuple_GET_SIZE(__pyx_args)) {
1265       case  0:
1266       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filename);
1267       if (likely(values[0])) kw_args--;
1268       else goto __pyx_L5_argtuple_error;
1269       case  1:
1270       if (kw_args > 0) {
1271         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__mode);
1272         if (value) { values[1] = value; kw_args--; }
1273       }
1274     }
1275     if (unlikely(kw_args > 0)) {
1276       if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_open") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
1277     }
1278     __pyx_v_filename = PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_filename) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
1279     __pyx_v_mode = values[1];
1280   } else {
1281     __pyx_v_mode = ((PyObject *)__pyx_n_s__r);
1282     switch (PyTuple_GET_SIZE(__pyx_args)) {
1283       case  2: __pyx_v_mode = PyTuple_GET_ITEM(__pyx_args, 1);
1284       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 = 24; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
1285       break;
1286       default: goto __pyx_L5_argtuple_error;
1287     }
1288   }
1289   goto __pyx_L4_argument_unpacking_done;
1290   __pyx_L5_argtuple_error:;
1291   __Pyx_RaiseArgtupleInvalid("_open", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 23; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
1292   __pyx_L3_error:;
1293   __Pyx_AddTraceback("ctabix.Tabixfile._open");
1294   __Pyx_RefNannyFinishContext();
1295   return NULL;
1296   __pyx_L4_argument_unpacking_done:;
1297   __pyx_v_filename_index = Py_None; __Pyx_INCREF(Py_None);
1298
1299   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":30
1300  *         '''
1301  * 
1302  *         assert mode in ( "r",), "invalid file opening mode `%s`" % mode             # <<<<<<<<<<<<<<
1303  * 
1304  *         # close a previously opened file
1305  */
1306   #ifndef PYREX_WITHOUT_ASSERTIONS
1307   __Pyx_INCREF(__pyx_v_mode);
1308   __pyx_t_1 = __pyx_v_mode;
1309   __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)__pyx_n_s__r), Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1310   __Pyx_GOTREF(__pyx_t_2);
1311   __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1312   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1313   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1314   if (unlikely(!__pyx_t_3)) {
1315     __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_1), __pyx_v_mode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1316     __Pyx_GOTREF(((PyObject *)__pyx_t_1));
1317     PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_t_1));
1318     __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
1319     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1320   }
1321   #endif
1322
1323   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":33
1324  * 
1325  *         # close a previously opened file
1326  *         if self.tabixfile != NULL: self.close()             # <<<<<<<<<<<<<<
1327  *         self.tabixfile = NULL
1328  * 
1329  */
1330   __pyx_t_3 = (((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->tabixfile != NULL);
1331   if (__pyx_t_3) {
1332     __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__close); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1333     __Pyx_GOTREF(__pyx_t_1);
1334     __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 = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1335     __Pyx_GOTREF(__pyx_t_2);
1336     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1337     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1338     goto __pyx_L6;
1339   }
1340   __pyx_L6:;
1341
1342   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":34
1343  *         # close a previously opened file
1344  *         if self.tabixfile != NULL: self.close()
1345  *         self.tabixfile = NULL             # <<<<<<<<<<<<<<
1346  * 
1347  *         self.filename = filename
1348  */
1349   ((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->tabixfile = NULL;
1350
1351   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":36
1352  *         self.tabixfile = NULL
1353  * 
1354  *         self.filename = filename             # <<<<<<<<<<<<<<
1355  *         filename_index = filename + ".tbi"
1356  * 
1357  */
1358   ((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->filename = __pyx_v_filename;
1359
1360   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":37
1361  * 
1362  *         self.filename = filename
1363  *         filename_index = filename + ".tbi"             # <<<<<<<<<<<<<<
1364  * 
1365  *         if mode[0] == 'w':
1366  */
1367   __pyx_t_2 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1368   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
1369   __pyx_t_1 = PyNumber_Add(((PyObject *)__pyx_t_2), ((PyObject *)__pyx_kp_s_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1370   __Pyx_GOTREF(__pyx_t_1);
1371   __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
1372   __Pyx_DECREF(__pyx_v_filename_index);
1373   __pyx_v_filename_index = __pyx_t_1;
1374   __pyx_t_1 = 0;
1375
1376   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":39
1377  *         filename_index = filename + ".tbi"
1378  * 
1379  *         if mode[0] == 'w':             # <<<<<<<<<<<<<<
1380  *             # open file for writing
1381  *             pass
1382  */
1383   __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_mode, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1384   __Pyx_GOTREF(__pyx_t_1);
1385   __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)__pyx_n_s__w), Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1386   __Pyx_GOTREF(__pyx_t_2);
1387   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1388   __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1389   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1390   if (__pyx_t_3) {
1391     goto __pyx_L7;
1392   }
1393
1394   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":43
1395  *             pass
1396  * 
1397  *         elif mode[0] == "r":             # <<<<<<<<<<<<<<
1398  *             # open file for reading
1399  *             if not os.path.exists( self.filename ):
1400  */
1401   __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_mode, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1402   __Pyx_GOTREF(__pyx_t_2);
1403   __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, ((PyObject *)__pyx_n_s__r), Py_EQ); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1404   __Pyx_GOTREF(__pyx_t_1);
1405   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1406   __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1407   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1408   if (__pyx_t_3) {
1409
1410     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":45
1411  *         elif mode[0] == "r":
1412  *             # open file for reading
1413  *             if not os.path.exists( self.filename ):             # <<<<<<<<<<<<<<
1414  *                 raise IOError( "file `%s` not found" % self.filename)
1415  * 
1416  */
1417     __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1418     __Pyx_GOTREF(__pyx_t_1);
1419     __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__path); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1420     __Pyx_GOTREF(__pyx_t_2);
1421     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1422     __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__exists); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1423     __Pyx_GOTREF(__pyx_t_1);
1424     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1425     __pyx_t_2 = PyBytes_FromString(((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->filename); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1426     __Pyx_GOTREF(((PyObject *)__pyx_t_2));
1427     __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1428     __Pyx_GOTREF(__pyx_t_4);
1429     PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_2));
1430     __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
1431     __pyx_t_2 = 0;
1432     __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1433     __Pyx_GOTREF(__pyx_t_2);
1434     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1435     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1436     __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1437     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1438     __pyx_t_5 = (!__pyx_t_3);
1439     if (__pyx_t_5) {
1440
1441       /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":46
1442  *             # open file for reading
1443  *             if not os.path.exists( self.filename ):
1444  *                 raise IOError( "file `%s` not found" % self.filename)             # <<<<<<<<<<<<<<
1445  * 
1446  *             if not os.path.exists( filename_index ):
1447  */
1448       __pyx_t_2 = PyBytes_FromString(((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->filename); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1449       __Pyx_GOTREF(((PyObject *)__pyx_t_2));
1450       __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_3), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1451       __Pyx_GOTREF(((PyObject *)__pyx_t_4));
1452       __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
1453       __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1454       __Pyx_GOTREF(__pyx_t_2);
1455       PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_4));
1456       __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
1457       __pyx_t_4 = 0;
1458       __pyx_t_4 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1459       __Pyx_GOTREF(__pyx_t_4);
1460       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1461       __Pyx_Raise(__pyx_t_4, 0, 0);
1462       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1463       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1464       goto __pyx_L8;
1465     }
1466     __pyx_L8:;
1467
1468     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":48
1469  *                 raise IOError( "file `%s` not found" % self.filename)
1470  * 
1471  *             if not os.path.exists( filename_index ):             # <<<<<<<<<<<<<<
1472  *                 raise IOError( "index `%s` not found" % filename_index)
1473  * 
1474  */
1475     __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1476     __Pyx_GOTREF(__pyx_t_4);
1477     __pyx_t_2 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__path); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1478     __Pyx_GOTREF(__pyx_t_2);
1479     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1480     __pyx_t_4 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__exists); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1481     __Pyx_GOTREF(__pyx_t_4);
1482     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1483     __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1484     __Pyx_GOTREF(__pyx_t_2);
1485     __Pyx_INCREF(__pyx_v_filename_index);
1486     PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_filename_index);
1487     __Pyx_GIVEREF(__pyx_v_filename_index);
1488     __pyx_t_1 = PyObject_Call(__pyx_t_4, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1489     __Pyx_GOTREF(__pyx_t_1);
1490     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1491     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1492     __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1493     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1494     __pyx_t_3 = (!__pyx_t_5);
1495     if (__pyx_t_3) {
1496
1497       /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":49
1498  * 
1499  *             if not os.path.exists( filename_index ):
1500  *                 raise IOError( "index `%s` not found" % filename_index)             # <<<<<<<<<<<<<<
1501  * 
1502  *             # open file and load index
1503  */
1504       __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_4), __pyx_v_filename_index); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1505       __Pyx_GOTREF(((PyObject *)__pyx_t_1));
1506       __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1507       __Pyx_GOTREF(__pyx_t_2);
1508       PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
1509       __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
1510       __pyx_t_1 = 0;
1511       __pyx_t_1 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1512       __Pyx_GOTREF(__pyx_t_1);
1513       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1514       __Pyx_Raise(__pyx_t_1, 0, 0);
1515       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1516       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1517       goto __pyx_L9;
1518     }
1519     __pyx_L9:;
1520
1521     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":52
1522  * 
1523  *             # open file and load index
1524  *             self.tabixfile = ti_open( self.filename, filename_index )             # <<<<<<<<<<<<<<
1525  * 
1526  *         if self.tabixfile == NULL:
1527  */
1528     __pyx_t_6 = PyBytes_AsString(__pyx_v_filename_index); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1529     ((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->tabixfile = ti_open(((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->filename, __pyx_t_6);
1530     goto __pyx_L7;
1531   }
1532   __pyx_L7:;
1533
1534   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":54
1535  *             self.tabixfile = ti_open( self.filename, filename_index )
1536  * 
1537  *         if self.tabixfile == NULL:             # <<<<<<<<<<<<<<
1538  *             raise IOError("could not open file `%s`" % filename )
1539  * 
1540  */
1541   __pyx_t_3 = (((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->tabixfile == NULL);
1542   if (__pyx_t_3) {
1543
1544     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":55
1545  * 
1546  *         if self.tabixfile == NULL:
1547  *             raise IOError("could not open file `%s`" % filename )             # <<<<<<<<<<<<<<
1548  * 
1549  *     def _parseRegion( self,
1550  */
1551     __pyx_t_1 = PyBytes_FromString(__pyx_v_filename); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1552     __Pyx_GOTREF(((PyObject *)__pyx_t_1));
1553     __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_5), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1554     __Pyx_GOTREF(((PyObject *)__pyx_t_2));
1555     __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
1556     __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1557     __Pyx_GOTREF(__pyx_t_1);
1558     PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_2));
1559     __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
1560     __pyx_t_2 = 0;
1561     __pyx_t_2 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1562     __Pyx_GOTREF(__pyx_t_2);
1563     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1564     __Pyx_Raise(__pyx_t_2, 0, 0);
1565     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1566     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 55; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1567     goto __pyx_L10;
1568   }
1569   __pyx_L10:;
1570
1571   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1572   goto __pyx_L0;
1573   __pyx_L1_error:;
1574   __Pyx_XDECREF(__pyx_t_1);
1575   __Pyx_XDECREF(__pyx_t_2);
1576   __Pyx_XDECREF(__pyx_t_4);
1577   __Pyx_AddTraceback("ctabix.Tabixfile._open");
1578   __pyx_r = NULL;
1579   __pyx_L0:;
1580   __Pyx_DECREF(__pyx_v_filename_index);
1581   __Pyx_XGIVEREF(__pyx_r);
1582   __Pyx_RefNannyFinishContext();
1583   return __pyx_r;
1584 }
1585
1586 /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":57
1587  *             raise IOError("could not open file `%s`" % filename )
1588  * 
1589  *     def _parseRegion( self,             # <<<<<<<<<<<<<<
1590  *                       reference = None,
1591  *                       start = None,
1592  */
1593
1594 static PyObject *__pyx_pf_6ctabix_9Tabixfile__parseRegion(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
1595 static char __pyx_doc_6ctabix_9Tabixfile__parseRegion[] = "Tabixfile._parseRegion(self, reference=None, start=None, end=None, region=None)\nparse region information.\n\n        raise ValueError for for invalid regions.\n\n        returns a tuple of region, tid, start and end. Region\n        is a valid samtools :term:`region` or None if the region\n        extends over the whole file.\n\n        Note that regions are 1-based, while start,end are python coordinates.\n        ";
1596 static PyObject *__pyx_pf_6ctabix_9Tabixfile__parseRegion(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1597   PyObject *__pyx_v_reference = 0;
1598   PyObject *__pyx_v_start = 0;
1599   PyObject *__pyx_v_end = 0;
1600   PyObject *__pyx_v_region = 0;
1601   int __pyx_v_rtid;
1602   int __pyx_v_rstart;
1603   int __pyx_v_rend;
1604   int __pyx_v_max_pos;
1605   PyObject *__pyx_r = NULL;
1606   int __pyx_t_1;
1607   PyObject *__pyx_t_2 = NULL;
1608   int __pyx_t_3;
1609   int __pyx_t_4;
1610   PyObject *__pyx_t_5 = NULL;
1611   PyObject *__pyx_t_6 = NULL;
1612   char *__pyx_t_7;
1613   PyObject *__pyx_t_8 = NULL;
1614   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__reference,&__pyx_n_s__start,&__pyx_n_s__end,&__pyx_n_s__region,0};
1615   __Pyx_RefNannySetupContext("_parseRegion");
1616   if (unlikely(__pyx_kwds)) {
1617     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
1618     PyObject* values[4] = {0,0,0,0};
1619
1620     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":58
1621  * 
1622  *     def _parseRegion( self,
1623  *                       reference = None,             # <<<<<<<<<<<<<<
1624  *                       start = None,
1625  *                       end = None,
1626  */
1627     values[0] = ((PyObject *)Py_None);
1628
1629     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":59
1630  *     def _parseRegion( self,
1631  *                       reference = None,
1632  *                       start = None,             # <<<<<<<<<<<<<<
1633  *                       end = None,
1634  *                       region = None ):
1635  */
1636     values[1] = ((PyObject *)Py_None);
1637
1638     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":60
1639  *                       reference = None,
1640  *                       start = None,
1641  *                       end = None,             # <<<<<<<<<<<<<<
1642  *                       region = None ):
1643  *         '''parse region information.
1644  */
1645     values[2] = ((PyObject *)Py_None);
1646
1647     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":61
1648  *                       start = None,
1649  *                       end = None,
1650  *                       region = None ):             # <<<<<<<<<<<<<<
1651  *         '''parse region information.
1652  * 
1653  */
1654     values[3] = ((PyObject *)Py_None);
1655     switch (PyTuple_GET_SIZE(__pyx_args)) {
1656       case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
1657       case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
1658       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1659       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1660       case  0: break;
1661       default: goto __pyx_L5_argtuple_error;
1662     }
1663     switch (PyTuple_GET_SIZE(__pyx_args)) {
1664       case  0:
1665       if (kw_args > 0) {
1666         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reference);
1667         if (value) { values[0] = value; kw_args--; }
1668       }
1669       case  1:
1670       if (kw_args > 0) {
1671         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start);
1672         if (value) { values[1] = value; kw_args--; }
1673       }
1674       case  2:
1675       if (kw_args > 0) {
1676         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end);
1677         if (value) { values[2] = value; kw_args--; }
1678       }
1679       case  3:
1680       if (kw_args > 0) {
1681         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__region);
1682         if (value) { values[3] = value; kw_args--; }
1683       }
1684     }
1685     if (unlikely(kw_args > 0)) {
1686       if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "_parseRegion") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
1687     }
1688     __pyx_v_reference = values[0];
1689     __pyx_v_start = values[1];
1690     __pyx_v_end = values[2];
1691     __pyx_v_region = values[3];
1692   } else {
1693
1694     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":58
1695  * 
1696  *     def _parseRegion( self,
1697  *                       reference = None,             # <<<<<<<<<<<<<<
1698  *                       start = None,
1699  *                       end = None,
1700  */
1701     __pyx_v_reference = ((PyObject *)Py_None);
1702
1703     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":59
1704  *     def _parseRegion( self,
1705  *                       reference = None,
1706  *                       start = None,             # <<<<<<<<<<<<<<
1707  *                       end = None,
1708  *                       region = None ):
1709  */
1710     __pyx_v_start = ((PyObject *)Py_None);
1711
1712     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":60
1713  *                       reference = None,
1714  *                       start = None,
1715  *                       end = None,             # <<<<<<<<<<<<<<
1716  *                       region = None ):
1717  *         '''parse region information.
1718  */
1719     __pyx_v_end = ((PyObject *)Py_None);
1720
1721     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":61
1722  *                       start = None,
1723  *                       end = None,
1724  *                       region = None ):             # <<<<<<<<<<<<<<
1725  *         '''parse region information.
1726  * 
1727  */
1728     __pyx_v_region = ((PyObject *)Py_None);
1729     switch (PyTuple_GET_SIZE(__pyx_args)) {
1730       case  4: __pyx_v_region = PyTuple_GET_ITEM(__pyx_args, 3);
1731       case  3: __pyx_v_end = PyTuple_GET_ITEM(__pyx_args, 2);
1732       case  2: __pyx_v_start = PyTuple_GET_ITEM(__pyx_args, 1);
1733       case  1: __pyx_v_reference = PyTuple_GET_ITEM(__pyx_args, 0);
1734       case  0: break;
1735       default: goto __pyx_L5_argtuple_error;
1736     }
1737   }
1738   goto __pyx_L4_argument_unpacking_done;
1739   __pyx_L5_argtuple_error:;
1740   __Pyx_RaiseArgtupleInvalid("_parseRegion", 0, 0, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
1741   __pyx_L3_error:;
1742   __Pyx_AddTraceback("ctabix.Tabixfile._parseRegion");
1743   __Pyx_RefNannyFinishContext();
1744   return NULL;
1745   __pyx_L4_argument_unpacking_done:;
1746   __Pyx_INCREF(__pyx_v_region);
1747
1748   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":72
1749  *         Note that regions are 1-based, while start,end are python coordinates.
1750  *         '''
1751  *         ti_lazy_index_load( self.tabixfile )             # <<<<<<<<<<<<<<
1752  * 
1753  *         cdef int rtid
1754  */
1755   ti_lazy_index_load(((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->tabixfile);
1756
1757   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":78
1758  *         cdef int rend
1759  *         cdef int max_pos
1760  *         max_pos = 2 << 29             # <<<<<<<<<<<<<<
1761  * 
1762  *         rtid = rstart = rend = 0
1763  */
1764   __pyx_v_max_pos = 1073741824;
1765
1766   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":80
1767  *         max_pos = 2 << 29
1768  * 
1769  *         rtid = rstart = rend = 0             # <<<<<<<<<<<<<<
1770  * 
1771  *         # translate to a region
1772  */
1773   __pyx_v_rtid = 0;
1774   __pyx_v_rstart = 0;
1775   __pyx_v_rend = 0;
1776
1777   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":83
1778  * 
1779  *         # translate to a region
1780  *         if reference:             # <<<<<<<<<<<<<<
1781  *             if start != None and end != None:
1782  *                 region = "%s:%i-%i" % (reference, start+1, end)
1783  */
1784   __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_reference); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1785   if (__pyx_t_1) {
1786
1787     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":84
1788  *         # translate to a region
1789  *         if reference:
1790  *             if start != None and end != None:             # <<<<<<<<<<<<<<
1791  *                 region = "%s:%i-%i" % (reference, start+1, end)
1792  *             elif start == None and end != None:
1793  */
1794     __pyx_t_2 = PyObject_RichCompare(__pyx_v_start, Py_None, Py_NE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1795     __Pyx_GOTREF(__pyx_t_2);
1796     __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1797     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1798     if (__pyx_t_1) {
1799       __pyx_t_2 = PyObject_RichCompare(__pyx_v_end, Py_None, Py_NE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1800       __Pyx_GOTREF(__pyx_t_2);
1801       __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1802       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1803       __pyx_t_4 = __pyx_t_3;
1804     } else {
1805       __pyx_t_4 = __pyx_t_1;
1806     }
1807     if (__pyx_t_4) {
1808
1809       /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":85
1810  *         if reference:
1811  *             if start != None and end != None:
1812  *                 region = "%s:%i-%i" % (reference, start+1, end)             # <<<<<<<<<<<<<<
1813  *             elif start == None and end != None:
1814  *                 region = "%s:%i-%i" % (reference, 1, end)
1815  */
1816       __pyx_t_2 = PyNumber_Add(__pyx_v_start, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1817       __Pyx_GOTREF(__pyx_t_2);
1818       __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1819       __Pyx_GOTREF(__pyx_t_5);
1820       __Pyx_INCREF(__pyx_v_reference);
1821       PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_reference);
1822       __Pyx_GIVEREF(__pyx_v_reference);
1823       PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_2);
1824       __Pyx_GIVEREF(__pyx_t_2);
1825       __Pyx_INCREF(__pyx_v_end);
1826       PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_end);
1827       __Pyx_GIVEREF(__pyx_v_end);
1828       __pyx_t_2 = 0;
1829       __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_6), __pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1830       __Pyx_GOTREF(((PyObject *)__pyx_t_2));
1831       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
1832       __Pyx_DECREF(__pyx_v_region);
1833       __pyx_v_region = ((PyObject *)__pyx_t_2);
1834       __pyx_t_2 = 0;
1835       goto __pyx_L7;
1836     }
1837
1838     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":86
1839  *             if start != None and end != None:
1840  *                 region = "%s:%i-%i" % (reference, start+1, end)
1841  *             elif start == None and end != None:             # <<<<<<<<<<<<<<
1842  *                 region = "%s:%i-%i" % (reference, 1, end)
1843  *             elif end == None and start != None:
1844  */
1845     __pyx_t_2 = PyObject_RichCompare(__pyx_v_start, Py_None, Py_EQ); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1846     __Pyx_GOTREF(__pyx_t_2);
1847     __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1848     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1849     if (__pyx_t_4) {
1850       __pyx_t_2 = PyObject_RichCompare(__pyx_v_end, Py_None, Py_NE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1851       __Pyx_GOTREF(__pyx_t_2);
1852       __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1853       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1854       __pyx_t_3 = __pyx_t_1;
1855     } else {
1856       __pyx_t_3 = __pyx_t_4;
1857     }
1858     if (__pyx_t_3) {
1859
1860       /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":87
1861  *                 region = "%s:%i-%i" % (reference, start+1, end)
1862  *             elif start == None and end != None:
1863  *                 region = "%s:%i-%i" % (reference, 1, end)             # <<<<<<<<<<<<<<
1864  *             elif end == None and start != None:
1865  *                 region = "%s:%i-%i" % (reference, start+1, max_pos-1)
1866  */
1867       __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1868       __Pyx_GOTREF(__pyx_t_2);
1869       __Pyx_INCREF(__pyx_v_reference);
1870       PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_reference);
1871       __Pyx_GIVEREF(__pyx_v_reference);
1872       __Pyx_INCREF(__pyx_int_1);
1873       PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_int_1);
1874       __Pyx_GIVEREF(__pyx_int_1);
1875       __Pyx_INCREF(__pyx_v_end);
1876       PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_end);
1877       __Pyx_GIVEREF(__pyx_v_end);
1878       __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_6), __pyx_t_2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1879       __Pyx_GOTREF(((PyObject *)__pyx_t_5));
1880       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1881       __Pyx_DECREF(__pyx_v_region);
1882       __pyx_v_region = ((PyObject *)__pyx_t_5);
1883       __pyx_t_5 = 0;
1884       goto __pyx_L7;
1885     }
1886
1887     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":88
1888  *             elif start == None and end != None:
1889  *                 region = "%s:%i-%i" % (reference, 1, end)
1890  *             elif end == None and start != None:             # <<<<<<<<<<<<<<
1891  *                 region = "%s:%i-%i" % (reference, start+1, max_pos-1)
1892  *             else:
1893  */
1894     __pyx_t_5 = PyObject_RichCompare(__pyx_v_end, Py_None, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1895     __Pyx_GOTREF(__pyx_t_5);
1896     __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1897     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
1898     if (__pyx_t_3) {
1899       __pyx_t_5 = PyObject_RichCompare(__pyx_v_start, Py_None, Py_NE); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1900       __Pyx_GOTREF(__pyx_t_5);
1901       __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1902       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
1903       __pyx_t_1 = __pyx_t_4;
1904     } else {
1905       __pyx_t_1 = __pyx_t_3;
1906     }
1907     if (__pyx_t_1) {
1908
1909       /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":89
1910  *                 region = "%s:%i-%i" % (reference, 1, end)
1911  *             elif end == None and start != None:
1912  *                 region = "%s:%i-%i" % (reference, start+1, max_pos-1)             # <<<<<<<<<<<<<<
1913  *             else:
1914  *                 region = reference
1915  */
1916       __pyx_t_5 = PyNumber_Add(__pyx_v_start, __pyx_int_1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1917       __Pyx_GOTREF(__pyx_t_5);
1918       __pyx_t_2 = PyInt_FromLong((__pyx_v_max_pos - 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1919       __Pyx_GOTREF(__pyx_t_2);
1920       __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1921       __Pyx_GOTREF(__pyx_t_6);
1922       __Pyx_INCREF(__pyx_v_reference);
1923       PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_reference);
1924       __Pyx_GIVEREF(__pyx_v_reference);
1925       PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_5);
1926       __Pyx_GIVEREF(__pyx_t_5);
1927       PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_t_2);
1928       __Pyx_GIVEREF(__pyx_t_2);
1929       __pyx_t_5 = 0;
1930       __pyx_t_2 = 0;
1931       __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_6), __pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1932       __Pyx_GOTREF(((PyObject *)__pyx_t_2));
1933       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1934       __Pyx_DECREF(__pyx_v_region);
1935       __pyx_v_region = ((PyObject *)__pyx_t_2);
1936       __pyx_t_2 = 0;
1937       goto __pyx_L7;
1938     }
1939     /*else*/ {
1940
1941       /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":91
1942  *                 region = "%s:%i-%i" % (reference, start+1, max_pos-1)
1943  *             else:
1944  *                 region = reference             # <<<<<<<<<<<<<<
1945  * 
1946  *         if region:
1947  */
1948       __Pyx_INCREF(__pyx_v_reference);
1949       __Pyx_DECREF(__pyx_v_region);
1950       __pyx_v_region = __pyx_v_reference;
1951     }
1952     __pyx_L7:;
1953     goto __pyx_L6;
1954   }
1955   __pyx_L6:;
1956
1957   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":93
1958  *                 region = reference
1959  * 
1960  *         if region:             # <<<<<<<<<<<<<<
1961  *             ti_parse_region( self.tabixfile.idx, region, &rtid, &rstart, &rend)
1962  *             if rtid < 0: raise ValueError( "invalid region `%s`" % region )
1963  */
1964   __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_region); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1965   if (__pyx_t_1) {
1966
1967     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":94
1968  * 
1969  *         if region:
1970  *             ti_parse_region( self.tabixfile.idx, region, &rtid, &rstart, &rend)             # <<<<<<<<<<<<<<
1971  *             if rtid < 0: raise ValueError( "invalid region `%s`" % region )
1972  *             if rstart > rend: raise ValueError( 'invalid region: start (%i) > end (%i)' % (rstart, rend) )
1973  */
1974     __pyx_t_7 = PyBytes_AsString(__pyx_v_region); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1975     ti_parse_region(((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->tabixfile->idx, __pyx_t_7, (&__pyx_v_rtid), (&__pyx_v_rstart), (&__pyx_v_rend));
1976
1977     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":95
1978  *         if region:
1979  *             ti_parse_region( self.tabixfile.idx, region, &rtid, &rstart, &rend)
1980  *             if rtid < 0: raise ValueError( "invalid region `%s`" % region )             # <<<<<<<<<<<<<<
1981  *             if rstart > rend: raise ValueError( 'invalid region: start (%i) > end (%i)' % (rstart, rend) )
1982  *             if not 0 <= rstart < max_pos: raise ValueError( 'start out of range (%i)' % rstart )
1983  */
1984     __pyx_t_1 = (__pyx_v_rtid < 0);
1985     if (__pyx_t_1) {
1986       __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_7), __pyx_v_region); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1987       __Pyx_GOTREF(((PyObject *)__pyx_t_2));
1988       __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1989       __Pyx_GOTREF(__pyx_t_6);
1990       PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_2));
1991       __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
1992       __pyx_t_2 = 0;
1993       __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1994       __Pyx_GOTREF(__pyx_t_2);
1995       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1996       __Pyx_Raise(__pyx_t_2, 0, 0);
1997       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1998       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1999       goto __pyx_L9;
2000     }
2001     __pyx_L9:;
2002
2003     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":96
2004  *             ti_parse_region( self.tabixfile.idx, region, &rtid, &rstart, &rend)
2005  *             if rtid < 0: raise ValueError( "invalid region `%s`" % region )
2006  *             if rstart > rend: raise ValueError( 'invalid region: start (%i) > end (%i)' % (rstart, rend) )             # <<<<<<<<<<<<<<
2007  *             if not 0 <= rstart < max_pos: raise ValueError( 'start out of range (%i)' % rstart )
2008  *             if not 0 <= rend < max_pos: raise ValueError( 'end out of range (%i)' % rend )
2009  */
2010     __pyx_t_1 = (__pyx_v_rstart > __pyx_v_rend);
2011     if (__pyx_t_1) {
2012       __pyx_t_2 = PyInt_FromLong(__pyx_v_rstart); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2013       __Pyx_GOTREF(__pyx_t_2);
2014       __pyx_t_6 = PyInt_FromLong(__pyx_v_rend); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2015       __Pyx_GOTREF(__pyx_t_6);
2016       __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2017       __Pyx_GOTREF(__pyx_t_5);
2018       PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
2019       __Pyx_GIVEREF(__pyx_t_2);
2020       PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_6);
2021       __Pyx_GIVEREF(__pyx_t_6);
2022       __pyx_t_2 = 0;
2023       __pyx_t_6 = 0;
2024       __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_8), __pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2025       __Pyx_GOTREF(((PyObject *)__pyx_t_6));
2026       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2027       __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2028       __Pyx_GOTREF(__pyx_t_5);
2029       PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_6));
2030       __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
2031       __pyx_t_6 = 0;
2032       __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2033       __Pyx_GOTREF(__pyx_t_6);
2034       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2035       __Pyx_Raise(__pyx_t_6, 0, 0);
2036       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2037       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2038       goto __pyx_L10;
2039     }
2040     __pyx_L10:;
2041
2042     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":97
2043  *             if rtid < 0: raise ValueError( "invalid region `%s`" % region )
2044  *             if rstart > rend: raise ValueError( 'invalid region: start (%i) > end (%i)' % (rstart, rend) )
2045  *             if not 0 <= rstart < max_pos: raise ValueError( 'start out of range (%i)' % rstart )             # <<<<<<<<<<<<<<
2046  *             if not 0 <= rend < max_pos: raise ValueError( 'end out of range (%i)' % rend )
2047  * 
2048  */
2049     __pyx_t_1 = (0 <= __pyx_v_rstart);
2050     if (__pyx_t_1) {
2051       __pyx_t_1 = (__pyx_v_rstart < __pyx_v_max_pos);
2052     }
2053     __pyx_t_3 = (!__pyx_t_1);
2054     if (__pyx_t_3) {
2055       __pyx_t_6 = PyInt_FromLong(__pyx_v_rstart); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2056       __Pyx_GOTREF(__pyx_t_6);
2057       __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_9), __pyx_t_6); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2058       __Pyx_GOTREF(((PyObject *)__pyx_t_5));
2059       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2060       __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2061       __Pyx_GOTREF(__pyx_t_6);
2062       PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_5));
2063       __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
2064       __pyx_t_5 = 0;
2065       __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2066       __Pyx_GOTREF(__pyx_t_5);
2067       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2068       __Pyx_Raise(__pyx_t_5, 0, 0);
2069       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2070       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2071       goto __pyx_L11;
2072     }
2073     __pyx_L11:;
2074
2075     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":98
2076  *             if rstart > rend: raise ValueError( 'invalid region: start (%i) > end (%i)' % (rstart, rend) )
2077  *             if not 0 <= rstart < max_pos: raise ValueError( 'start out of range (%i)' % rstart )
2078  *             if not 0 <= rend < max_pos: raise ValueError( 'end out of range (%i)' % rend )             # <<<<<<<<<<<<<<
2079  * 
2080  *         return region, rtid, rstart, rend
2081  */
2082     __pyx_t_3 = (0 <= __pyx_v_rend);
2083     if (__pyx_t_3) {
2084       __pyx_t_3 = (__pyx_v_rend < __pyx_v_max_pos);
2085     }
2086     __pyx_t_1 = (!__pyx_t_3);
2087     if (__pyx_t_1) {
2088       __pyx_t_5 = PyInt_FromLong(__pyx_v_rend); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2089       __Pyx_GOTREF(__pyx_t_5);
2090       __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_10), __pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2091       __Pyx_GOTREF(((PyObject *)__pyx_t_6));
2092       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2093       __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2094       __Pyx_GOTREF(__pyx_t_5);
2095       PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_6));
2096       __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
2097       __pyx_t_6 = 0;
2098       __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2099       __Pyx_GOTREF(__pyx_t_6);
2100       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2101       __Pyx_Raise(__pyx_t_6, 0, 0);
2102       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2103       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2104       goto __pyx_L12;
2105     }
2106     __pyx_L12:;
2107     goto __pyx_L8;
2108   }
2109   __pyx_L8:;
2110
2111   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":100
2112  *             if not 0 <= rend < max_pos: raise ValueError( 'end out of range (%i)' % rend )
2113  * 
2114  *         return region, rtid, rstart, rend             # <<<<<<<<<<<<<<
2115  * 
2116  *     def fetch( self,
2117  */
2118   __Pyx_XDECREF(__pyx_r);
2119   __pyx_t_6 = PyInt_FromLong(__pyx_v_rtid); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2120   __Pyx_GOTREF(__pyx_t_6);
2121   __pyx_t_5 = PyInt_FromLong(__pyx_v_rstart); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2122   __Pyx_GOTREF(__pyx_t_5);
2123   __pyx_t_2 = PyInt_FromLong(__pyx_v_rend); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2124   __Pyx_GOTREF(__pyx_t_2);
2125   __pyx_t_8 = PyTuple_New(4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2126   __Pyx_GOTREF(__pyx_t_8);
2127   __Pyx_INCREF(__pyx_v_region);
2128   PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_region);
2129   __Pyx_GIVEREF(__pyx_v_region);
2130   PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_6);
2131   __Pyx_GIVEREF(__pyx_t_6);
2132   PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_5);
2133   __Pyx_GIVEREF(__pyx_t_5);
2134   PyTuple_SET_ITEM(__pyx_t_8, 3, __pyx_t_2);
2135   __Pyx_GIVEREF(__pyx_t_2);
2136   __pyx_t_6 = 0;
2137   __pyx_t_5 = 0;
2138   __pyx_t_2 = 0;
2139   __pyx_r = __pyx_t_8;
2140   __pyx_t_8 = 0;
2141   goto __pyx_L0;
2142
2143   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2144   goto __pyx_L0;
2145   __pyx_L1_error:;
2146   __Pyx_XDECREF(__pyx_t_2);
2147   __Pyx_XDECREF(__pyx_t_5);
2148   __Pyx_XDECREF(__pyx_t_6);
2149   __Pyx_XDECREF(__pyx_t_8);
2150   __Pyx_AddTraceback("ctabix.Tabixfile._parseRegion");
2151   __pyx_r = NULL;
2152   __pyx_L0:;
2153   __Pyx_DECREF(__pyx_v_region);
2154   __Pyx_XGIVEREF(__pyx_r);
2155   __Pyx_RefNannyFinishContext();
2156   return __pyx_r;
2157 }
2158
2159 /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":102
2160  *         return region, rtid, rstart, rend
2161  * 
2162  *     def fetch( self,             # <<<<<<<<<<<<<<
2163  *                reference = None,
2164  *                start = None,
2165  */
2166
2167 static PyObject *__pyx_pf_6ctabix_9Tabixfile_fetch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2168 static char __pyx_doc_6ctabix_9Tabixfile_fetch[] = "Tabixfile.fetch(self, reference=None, start=None, end=None, region=None, parser=None)\n\n               \n        fetch one or more rows 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 be supplied.\n\n        Without *reference* or *region* all entries will be fetched. \n        \n        If only *reference* is set, all reads matching on *reference* will be fetched.\n\n        If *parser* is None, the results are returned as an unparsed string.\n        Otherwise, *parser* is assumed to be a functor that will return parsed \n        data (see for example :meth:`asTuple` and :meth:`asGTF`).\n        ";
2169 static PyObject *__pyx_pf_6ctabix_9Tabixfile_fetch(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2170   PyObject *__pyx_v_reference = 0;
2171   PyObject *__pyx_v_start = 0;
2172   PyObject *__pyx_v_end = 0;
2173   PyObject *__pyx_v_region = 0;
2174   PyObject *__pyx_v_parser = 0;
2175   PyObject *__pyx_v_rtid;
2176   PyObject *__pyx_v_rstart;
2177   PyObject *__pyx_v_rend;
2178   PyObject *__pyx_r = NULL;
2179   PyObject *__pyx_t_1 = NULL;
2180   PyObject *__pyx_t_2 = NULL;
2181   int __pyx_t_3;
2182   int __pyx_t_4;
2183   PyObject *__pyx_t_5 = NULL;
2184   PyObject *__pyx_t_6 = NULL;
2185   PyObject *__pyx_t_7 = NULL;
2186   PyObject *__pyx_t_8 = NULL;
2187   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__reference,&__pyx_n_s__start,&__pyx_n_s__end,&__pyx_n_s__region,&__pyx_n_s__parser,0};
2188   __Pyx_RefNannySetupContext("fetch");
2189   if (unlikely(__pyx_kwds)) {
2190     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
2191     PyObject* values[5] = {0,0,0,0,0};
2192
2193     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":103
2194  * 
2195  *     def fetch( self,
2196  *                reference = None,             # <<<<<<<<<<<<<<
2197  *                start = None,
2198  *                end = None,
2199  */
2200     values[0] = ((PyObject *)Py_None);
2201
2202     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":104
2203  *     def fetch( self,
2204  *                reference = None,
2205  *                start = None,             # <<<<<<<<<<<<<<
2206  *                end = None,
2207  *                region = None,
2208  */
2209     values[1] = ((PyObject *)Py_None);
2210
2211     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":105
2212  *                reference = None,
2213  *                start = None,
2214  *                end = None,             # <<<<<<<<<<<<<<
2215  *                region = None,
2216  *                parser = None ):
2217  */
2218     values[2] = ((PyObject *)Py_None);
2219
2220     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":106
2221  *                start = None,
2222  *                end = None,
2223  *                region = None,             # <<<<<<<<<<<<<<
2224  *                parser = None ):
2225  *         '''
2226  */
2227     values[3] = ((PyObject *)Py_None);
2228
2229     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":107
2230  *                end = None,
2231  *                region = None,
2232  *                parser = None ):             # <<<<<<<<<<<<<<
2233  *         '''
2234  * 
2235  */
2236     values[4] = ((PyObject *)Py_None);
2237     switch (PyTuple_GET_SIZE(__pyx_args)) {
2238       case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
2239       case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
2240       case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
2241       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2242       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2243       case  0: break;
2244       default: goto __pyx_L5_argtuple_error;
2245     }
2246     switch (PyTuple_GET_SIZE(__pyx_args)) {
2247       case  0:
2248       if (kw_args > 0) {
2249         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__reference);
2250         if (value) { values[0] = value; kw_args--; }
2251       }
2252       case  1:
2253       if (kw_args > 0) {
2254         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start);
2255         if (value) { values[1] = value; kw_args--; }
2256       }
2257       case  2:
2258       if (kw_args > 0) {
2259         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end);
2260         if (value) { values[2] = value; kw_args--; }
2261       }
2262       case  3:
2263       if (kw_args > 0) {
2264         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__region);
2265         if (value) { values[3] = value; kw_args--; }
2266       }
2267       case  4:
2268       if (kw_args > 0) {
2269         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__parser);
2270         if (value) { values[4] = value; kw_args--; }
2271       }
2272     }
2273     if (unlikely(kw_args > 0)) {
2274       if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "fetch") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2275     }
2276     __pyx_v_reference = values[0];
2277     __pyx_v_start = values[1];
2278     __pyx_v_end = values[2];
2279     __pyx_v_region = values[3];
2280     __pyx_v_parser = values[4];
2281   } else {
2282
2283     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":103
2284  * 
2285  *     def fetch( self,
2286  *                reference = None,             # <<<<<<<<<<<<<<
2287  *                start = None,
2288  *                end = None,
2289  */
2290     __pyx_v_reference = ((PyObject *)Py_None);
2291
2292     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":104
2293  *     def fetch( self,
2294  *                reference = None,
2295  *                start = None,             # <<<<<<<<<<<<<<
2296  *                end = None,
2297  *                region = None,
2298  */
2299     __pyx_v_start = ((PyObject *)Py_None);
2300
2301     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":105
2302  *                reference = None,
2303  *                start = None,
2304  *                end = None,             # <<<<<<<<<<<<<<
2305  *                region = None,
2306  *                parser = None ):
2307  */
2308     __pyx_v_end = ((PyObject *)Py_None);
2309
2310     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":106
2311  *                start = None,
2312  *                end = None,
2313  *                region = None,             # <<<<<<<<<<<<<<
2314  *                parser = None ):
2315  *         '''
2316  */
2317     __pyx_v_region = ((PyObject *)Py_None);
2318
2319     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":107
2320  *                end = None,
2321  *                region = None,
2322  *                parser = None ):             # <<<<<<<<<<<<<<
2323  *         '''
2324  * 
2325  */
2326     __pyx_v_parser = ((PyObject *)Py_None);
2327     switch (PyTuple_GET_SIZE(__pyx_args)) {
2328       case  5: __pyx_v_parser = PyTuple_GET_ITEM(__pyx_args, 4);
2329       case  4: __pyx_v_region = PyTuple_GET_ITEM(__pyx_args, 3);
2330       case  3: __pyx_v_end = PyTuple_GET_ITEM(__pyx_args, 2);
2331       case  2: __pyx_v_start = PyTuple_GET_ITEM(__pyx_args, 1);
2332       case  1: __pyx_v_reference = PyTuple_GET_ITEM(__pyx_args, 0);
2333       case  0: break;
2334       default: goto __pyx_L5_argtuple_error;
2335     }
2336   }
2337   goto __pyx_L4_argument_unpacking_done;
2338   __pyx_L5_argtuple_error:;
2339   __Pyx_RaiseArgtupleInvalid("fetch", 0, 0, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2340   __pyx_L3_error:;
2341   __Pyx_AddTraceback("ctabix.Tabixfile.fetch");
2342   __Pyx_RefNannyFinishContext();
2343   return NULL;
2344   __pyx_L4_argument_unpacking_done:;
2345   __Pyx_INCREF(__pyx_v_region);
2346   __pyx_v_rtid = Py_None; __Pyx_INCREF(Py_None);
2347   __pyx_v_rstart = Py_None; __Pyx_INCREF(Py_None);
2348   __pyx_v_rend = Py_None; __Pyx_INCREF(Py_None);
2349
2350   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":121
2351  *         data (see for example :meth:`asTuple` and :meth:`asGTF`).
2352  *         '''
2353  *         ti_lazy_index_load( self.tabixfile )             # <<<<<<<<<<<<<<
2354  * 
2355  *         if not self._isOpen():
2356  */
2357   ti_lazy_index_load(((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->tabixfile);
2358
2359   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":123
2360  *         ti_lazy_index_load( self.tabixfile )
2361  * 
2362  *         if not self._isOpen():             # <<<<<<<<<<<<<<
2363  *             raise ValueError( "I/O operation on closed file" )
2364  * 
2365  */
2366   __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2367   __Pyx_GOTREF(__pyx_t_1);
2368   __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 = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2369   __Pyx_GOTREF(__pyx_t_2);
2370   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2371   __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2372   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2373   __pyx_t_4 = (!__pyx_t_3);
2374   if (__pyx_t_4) {
2375
2376     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":124
2377  * 
2378  *         if not self._isOpen():
2379  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
2380  * 
2381  *         region, rtid, rstart, rend = self._parseRegion( reference, start, end, region )
2382  */
2383     __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2384     __Pyx_GOTREF(__pyx_t_2);
2385     __Pyx_INCREF(((PyObject *)__pyx_kp_s_11));
2386     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_11));
2387     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_11));
2388     __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2389     __Pyx_GOTREF(__pyx_t_1);
2390     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2391     __Pyx_Raise(__pyx_t_1, 0, 0);
2392     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2393     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2394     goto __pyx_L6;
2395   }
2396   __pyx_L6:;
2397
2398   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":126
2399  *             raise ValueError( "I/O operation on closed file" )
2400  * 
2401  *         region, rtid, rstart, rend = self._parseRegion( reference, start, end, region )             # <<<<<<<<<<<<<<
2402  * 
2403  *         if parser == None:
2404  */
2405   __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s___parseRegion); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2406   __Pyx_GOTREF(__pyx_t_1);
2407   __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2408   __Pyx_GOTREF(__pyx_t_2);
2409   __Pyx_INCREF(__pyx_v_reference);
2410   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_reference);
2411   __Pyx_GIVEREF(__pyx_v_reference);
2412   __Pyx_INCREF(__pyx_v_start);
2413   PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_start);
2414   __Pyx_GIVEREF(__pyx_v_start);
2415   __Pyx_INCREF(__pyx_v_end);
2416   PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_end);
2417   __Pyx_GIVEREF(__pyx_v_end);
2418   __Pyx_INCREF(__pyx_v_region);
2419   PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_v_region);
2420   __Pyx_GIVEREF(__pyx_v_region);
2421   __pyx_t_5 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2422   __Pyx_GOTREF(__pyx_t_5);
2423   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2424   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2425   if (PyTuple_CheckExact(__pyx_t_5) && likely(PyTuple_GET_SIZE(__pyx_t_5) == 4)) {
2426     PyObject* tuple = __pyx_t_5;
2427     __pyx_t_2 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_2);
2428     __pyx_t_1 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_1);
2429     __pyx_t_6 = PyTuple_GET_ITEM(tuple, 2); __Pyx_INCREF(__pyx_t_6);
2430     __pyx_t_7 = PyTuple_GET_ITEM(tuple, 3); __Pyx_INCREF(__pyx_t_7);
2431     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2432     __Pyx_DECREF(__pyx_v_region);
2433     __pyx_v_region = __pyx_t_2;
2434     __pyx_t_2 = 0;
2435     __Pyx_DECREF(__pyx_v_rtid);
2436     __pyx_v_rtid = __pyx_t_1;
2437     __pyx_t_1 = 0;
2438     __Pyx_DECREF(__pyx_v_rstart);
2439     __pyx_v_rstart = __pyx_t_6;
2440     __pyx_t_6 = 0;
2441     __Pyx_DECREF(__pyx_v_rend);
2442     __pyx_v_rend = __pyx_t_7;
2443     __pyx_t_7 = 0;
2444   } else {
2445     __pyx_t_8 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2446     __Pyx_GOTREF(__pyx_t_8);
2447     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2448     __pyx_t_2 = __Pyx_UnpackItem(__pyx_t_8, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2449     __Pyx_GOTREF(__pyx_t_2);
2450     __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_8, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2451     __Pyx_GOTREF(__pyx_t_1);
2452     __pyx_t_6 = __Pyx_UnpackItem(__pyx_t_8, 2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2453     __Pyx_GOTREF(__pyx_t_6);
2454     __pyx_t_7 = __Pyx_UnpackItem(__pyx_t_8, 3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2455     __Pyx_GOTREF(__pyx_t_7);
2456     if (__Pyx_EndUnpack(__pyx_t_8, 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2457     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
2458     __Pyx_DECREF(__pyx_v_region);
2459     __pyx_v_region = __pyx_t_2;
2460     __pyx_t_2 = 0;
2461     __Pyx_DECREF(__pyx_v_rtid);
2462     __pyx_v_rtid = __pyx_t_1;
2463     __pyx_t_1 = 0;
2464     __Pyx_DECREF(__pyx_v_rstart);
2465     __pyx_v_rstart = __pyx_t_6;
2466     __pyx_t_6 = 0;
2467     __Pyx_DECREF(__pyx_v_rend);
2468     __pyx_v_rend = __pyx_t_7;
2469     __pyx_t_7 = 0;
2470   }
2471
2472   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":128
2473  *         region, rtid, rstart, rend = self._parseRegion( reference, start, end, region )
2474  * 
2475  *         if parser == None:             # <<<<<<<<<<<<<<
2476  *             if region:
2477  *                 return TabixIterator( self, rtid, rstart, rend )
2478  */
2479   __pyx_t_5 = PyObject_RichCompare(__pyx_v_parser, Py_None, Py_EQ); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2480   __Pyx_GOTREF(__pyx_t_5);
2481   __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2482   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2483   if (__pyx_t_4) {
2484
2485     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":129
2486  * 
2487  *         if parser == None:
2488  *             if region:             # <<<<<<<<<<<<<<
2489  *                 return TabixIterator( self, rtid, rstart, rend )
2490  *             else:
2491  */
2492     __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_region); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2493     if (__pyx_t_4) {
2494
2495       /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":130
2496  *         if parser == None:
2497  *             if region:
2498  *                 return TabixIterator( self, rtid, rstart, rend )             # <<<<<<<<<<<<<<
2499  *             else:
2500  *                 return TabixIterator( self, -1, 0, 0 )
2501  */
2502       __Pyx_XDECREF(__pyx_r);
2503       __pyx_t_5 = PyTuple_New(4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2504       __Pyx_GOTREF(__pyx_t_5);
2505       __Pyx_INCREF(__pyx_v_self);
2506       PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_self);
2507       __Pyx_GIVEREF(__pyx_v_self);
2508       __Pyx_INCREF(__pyx_v_rtid);
2509       PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_rtid);
2510       __Pyx_GIVEREF(__pyx_v_rtid);
2511       __Pyx_INCREF(__pyx_v_rstart);
2512       PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_rstart);
2513       __Pyx_GIVEREF(__pyx_v_rstart);
2514       __Pyx_INCREF(__pyx_v_rend);
2515       PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_v_rend);
2516       __Pyx_GIVEREF(__pyx_v_rend);
2517       __pyx_t_7 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6ctabix_TabixIterator)), __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2518       __Pyx_GOTREF(__pyx_t_7);
2519       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2520       __pyx_r = __pyx_t_7;
2521       __pyx_t_7 = 0;
2522       goto __pyx_L0;
2523       goto __pyx_L8;
2524     }
2525     /*else*/ {
2526
2527       /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":132
2528  *                 return TabixIterator( self, rtid, rstart, rend )
2529  *             else:
2530  *                 return TabixIterator( self, -1, 0, 0 )             # <<<<<<<<<<<<<<
2531  *         else:
2532  *             if region:
2533  */
2534       __Pyx_XDECREF(__pyx_r);
2535       __pyx_t_7 = PyTuple_New(4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2536       __Pyx_GOTREF(__pyx_t_7);
2537       __Pyx_INCREF(__pyx_v_self);
2538       PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_self);
2539       __Pyx_GIVEREF(__pyx_v_self);
2540       __Pyx_INCREF(__pyx_int_neg_1);
2541       PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_int_neg_1);
2542       __Pyx_GIVEREF(__pyx_int_neg_1);
2543       __Pyx_INCREF(__pyx_int_0);
2544       PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_int_0);
2545       __Pyx_GIVEREF(__pyx_int_0);
2546       __Pyx_INCREF(__pyx_int_0);
2547       PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_int_0);
2548       __Pyx_GIVEREF(__pyx_int_0);
2549       __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6ctabix_TabixIterator)), __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2550       __Pyx_GOTREF(__pyx_t_5);
2551       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
2552       __pyx_r = __pyx_t_5;
2553       __pyx_t_5 = 0;
2554       goto __pyx_L0;
2555     }
2556     __pyx_L8:;
2557     goto __pyx_L7;
2558   }
2559   /*else*/ {
2560
2561     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":134
2562  *                 return TabixIterator( self, -1, 0, 0 )
2563  *         else:
2564  *             if region:             # <<<<<<<<<<<<<<
2565  *                 return TabixIteratorParsed( self, rtid, rstart, rend, parser )
2566  *             else:
2567  */
2568     __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_region); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2569     if (__pyx_t_4) {
2570
2571       /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":135
2572  *         else:
2573  *             if region:
2574  *                 return TabixIteratorParsed( self, rtid, rstart, rend, parser )             # <<<<<<<<<<<<<<
2575  *             else:
2576  *                 return TabixIteratorParsed( self, -1, 0, 0, parser )
2577  */
2578       __Pyx_XDECREF(__pyx_r);
2579       __pyx_t_5 = PyTuple_New(5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2580       __Pyx_GOTREF(__pyx_t_5);
2581       __Pyx_INCREF(__pyx_v_self);
2582       PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_self);
2583       __Pyx_GIVEREF(__pyx_v_self);
2584       __Pyx_INCREF(__pyx_v_rtid);
2585       PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_rtid);
2586       __Pyx_GIVEREF(__pyx_v_rtid);
2587       __Pyx_INCREF(__pyx_v_rstart);
2588       PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_rstart);
2589       __Pyx_GIVEREF(__pyx_v_rstart);
2590       __Pyx_INCREF(__pyx_v_rend);
2591       PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_v_rend);
2592       __Pyx_GIVEREF(__pyx_v_rend);
2593       __Pyx_INCREF(__pyx_v_parser);
2594       PyTuple_SET_ITEM(__pyx_t_5, 4, __pyx_v_parser);
2595       __Pyx_GIVEREF(__pyx_v_parser);
2596       __pyx_t_7 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6ctabix_TabixIteratorParsed)), __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2597       __Pyx_GOTREF(__pyx_t_7);
2598       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2599       __pyx_r = __pyx_t_7;
2600       __pyx_t_7 = 0;
2601       goto __pyx_L0;
2602       goto __pyx_L9;
2603     }
2604     /*else*/ {
2605
2606       /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":137
2607  *                 return TabixIteratorParsed( self, rtid, rstart, rend, parser )
2608  *             else:
2609  *                 return TabixIteratorParsed( self, -1, 0, 0, parser )             # <<<<<<<<<<<<<<
2610  * 
2611  *     property header:
2612  */
2613       __Pyx_XDECREF(__pyx_r);
2614       __pyx_t_7 = PyTuple_New(5); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2615       __Pyx_GOTREF(__pyx_t_7);
2616       __Pyx_INCREF(__pyx_v_self);
2617       PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_self);
2618       __Pyx_GIVEREF(__pyx_v_self);
2619       __Pyx_INCREF(__pyx_int_neg_1);
2620       PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_int_neg_1);
2621       __Pyx_GIVEREF(__pyx_int_neg_1);
2622       __Pyx_INCREF(__pyx_int_0);
2623       PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_int_0);
2624       __Pyx_GIVEREF(__pyx_int_0);
2625       __Pyx_INCREF(__pyx_int_0);
2626       PyTuple_SET_ITEM(__pyx_t_7, 3, __pyx_int_0);
2627       __Pyx_GIVEREF(__pyx_int_0);
2628       __Pyx_INCREF(__pyx_v_parser);
2629       PyTuple_SET_ITEM(__pyx_t_7, 4, __pyx_v_parser);
2630       __Pyx_GIVEREF(__pyx_v_parser);
2631       __pyx_t_5 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6ctabix_TabixIteratorParsed)), __pyx_t_7, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2632       __Pyx_GOTREF(__pyx_t_5);
2633       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
2634       __pyx_r = __pyx_t_5;
2635       __pyx_t_5 = 0;
2636       goto __pyx_L0;
2637     }
2638     __pyx_L9:;
2639   }
2640   __pyx_L7:;
2641
2642   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2643   goto __pyx_L0;
2644   __pyx_L1_error:;
2645   __Pyx_XDECREF(__pyx_t_1);
2646   __Pyx_XDECREF(__pyx_t_2);
2647   __Pyx_XDECREF(__pyx_t_5);
2648   __Pyx_XDECREF(__pyx_t_6);
2649   __Pyx_XDECREF(__pyx_t_7);
2650   __Pyx_XDECREF(__pyx_t_8);
2651   __Pyx_AddTraceback("ctabix.Tabixfile.fetch");
2652   __pyx_r = NULL;
2653   __pyx_L0:;
2654   __Pyx_DECREF(__pyx_v_rtid);
2655   __Pyx_DECREF(__pyx_v_rstart);
2656   __Pyx_DECREF(__pyx_v_rend);
2657   __Pyx_DECREF(__pyx_v_region);
2658   __Pyx_XGIVEREF(__pyx_r);
2659   __Pyx_RefNannyFinishContext();
2660   return __pyx_r;
2661 }
2662
2663 /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":140
2664  * 
2665  *     property header:
2666  *         def __get__( self ):             # <<<<<<<<<<<<<<
2667  *             '''return header lines as an iterator.
2668  * 
2669  */
2670
2671 static PyObject *__pyx_pf_6ctabix_9Tabixfile_6header___get__(PyObject *__pyx_v_self); /*proto*/
2672 static PyObject *__pyx_pf_6ctabix_9Tabixfile_6header___get__(PyObject *__pyx_v_self) {
2673   PyObject *__pyx_r = NULL;
2674   PyObject *__pyx_t_1 = NULL;
2675   PyObject *__pyx_t_2 = NULL;
2676   __Pyx_RefNannySetupContext("__get__");
2677
2678   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":145
2679  *             Note that the header lines do not contain the newline '\n' character.
2680  *             '''
2681  *             return TabixHeaderIterator( self )             # <<<<<<<<<<<<<<
2682  * 
2683  *     property contigs:
2684  */
2685   __Pyx_XDECREF(__pyx_r);
2686   __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2687   __Pyx_GOTREF(__pyx_t_1);
2688   __Pyx_INCREF(__pyx_v_self);
2689   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self);
2690   __Pyx_GIVEREF(__pyx_v_self);
2691   __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_6ctabix_TabixHeaderIterator)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 145; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2692   __Pyx_GOTREF(__pyx_t_2);
2693   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2694   __pyx_r = __pyx_t_2;
2695   __pyx_t_2 = 0;
2696   goto __pyx_L0;
2697
2698   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2699   goto __pyx_L0;
2700   __pyx_L1_error:;
2701   __Pyx_XDECREF(__pyx_t_1);
2702   __Pyx_XDECREF(__pyx_t_2);
2703   __Pyx_AddTraceback("ctabix.Tabixfile.header.__get__");
2704   __pyx_r = NULL;
2705   __pyx_L0:;
2706   __Pyx_XGIVEREF(__pyx_r);
2707   __Pyx_RefNannyFinishContext();
2708   return __pyx_r;
2709 }
2710
2711 /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":149
2712  *     property contigs:
2713  *         '''chromosome names'''
2714  *         def __get__(self):             # <<<<<<<<<<<<<<
2715  *             cdef char ** sequences
2716  *             cdef int nsequences
2717  */
2718
2719 static PyObject *__pyx_pf_6ctabix_9Tabixfile_7contigs___get__(PyObject *__pyx_v_self); /*proto*/
2720 static PyObject *__pyx_pf_6ctabix_9Tabixfile_7contigs___get__(PyObject *__pyx_v_self) {
2721   char **__pyx_v_sequences;
2722   int __pyx_v_nsequences;
2723   int __pyx_v_x;
2724   PyObject *__pyx_v_result;
2725   PyObject *__pyx_r = NULL;
2726   PyObject *__pyx_t_1 = NULL;
2727   int __pyx_t_2;
2728   int __pyx_t_3;
2729   __Pyx_RefNannySetupContext("__get__");
2730   __pyx_v_result = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
2731
2732   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":153
2733  *             cdef int nsequences
2734  * 
2735  *             ti_lazy_index_load( self.tabixfile )             # <<<<<<<<<<<<<<
2736  *             sequences = ti_seqname( self.tabixfile.idx, &nsequences )
2737  *             cdef int x
2738  */
2739   ti_lazy_index_load(((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->tabixfile);
2740
2741   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":154
2742  * 
2743  *             ti_lazy_index_load( self.tabixfile )
2744  *             sequences = ti_seqname( self.tabixfile.idx, &nsequences )             # <<<<<<<<<<<<<<
2745  *             cdef int x
2746  *             result = []
2747  */
2748   __pyx_v_sequences = ti_seqname(((struct __pyx_obj_6ctabix_Tabixfile *)__pyx_v_self)->tabixfile->idx, (&__pyx_v_nsequences));
2749
2750   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":156
2751  *             sequences = ti_seqname( self.tabixfile.idx, &nsequences )
2752  *             cdef int x
2753  *             result = []             # <<<<<<<<<<<<<<
2754  *             for x from 0 <= x < nsequences:
2755  *                 result.append( sequences[x] )
2756  */
2757   __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2758   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
2759   __Pyx_DECREF(((PyObject *)__pyx_v_result));
2760   __pyx_v_result = __pyx_t_1;
2761   __pyx_t_1 = 0;
2762
2763   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":157
2764  *             cdef int x
2765  *             result = []
2766  *             for x from 0 <= x < nsequences:             # <<<<<<<<<<<<<<
2767  *                 result.append( sequences[x] )
2768  *             return result
2769  */
2770   __pyx_t_2 = __pyx_v_nsequences;
2771   for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_2; __pyx_v_x++) {
2772
2773     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":158
2774  *             result = []
2775  *             for x from 0 <= x < nsequences:
2776  *                 result.append( sequences[x] )             # <<<<<<<<<<<<<<
2777  *             return result
2778  * 
2779  */
2780     if (unlikely(__pyx_v_result == Py_None)) {
2781       PyErr_SetString(PyExc_AttributeError, "'NoneType' object has no attribute 'append'"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;} 
2782     }
2783     __pyx_t_1 = PyBytes_FromString((__pyx_v_sequences[__pyx_v_x])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2784     __Pyx_GOTREF(((PyObject *)__pyx_t_1));
2785     __pyx_t_3 = PyList_Append(((PyObject *)__pyx_v_result), ((PyObject *)__pyx_t_1)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2786     __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
2787   }
2788
2789   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":159
2790  *             for x from 0 <= x < nsequences:
2791  *                 result.append( sequences[x] )
2792  *             return result             # <<<<<<<<<<<<<<
2793  * 
2794  * cdef class TabixIterator:
2795  */
2796   __Pyx_XDECREF(__pyx_r);
2797   __Pyx_INCREF(((PyObject *)__pyx_v_result));
2798   __pyx_r = ((PyObject *)__pyx_v_result);
2799   goto __pyx_L0;
2800
2801   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2802   goto __pyx_L0;
2803   __pyx_L1_error:;
2804   __Pyx_XDECREF(__pyx_t_1);
2805   __Pyx_AddTraceback("ctabix.Tabixfile.contigs.__get__");
2806   __pyx_r = NULL;
2807   __pyx_L0:;
2808   __Pyx_DECREF(__pyx_v_result);
2809   __Pyx_XGIVEREF(__pyx_r);
2810   __Pyx_RefNannyFinishContext();
2811   return __pyx_r;
2812 }
2813
2814 /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":169
2815  *     cdef tabix_t * tabixfile
2816  * 
2817  *     def __cinit__(self, Tabixfile tabixfile,             # <<<<<<<<<<<<<<
2818  *                   int tid, int start, int end ):
2819  * 
2820  */
2821
2822 static int __pyx_pf_6ctabix_13TabixIterator___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2823 static int __pyx_pf_6ctabix_13TabixIterator___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2824   struct __pyx_obj_6ctabix_Tabixfile *__pyx_v_tabixfile = 0;
2825   int __pyx_v_tid;
2826   int __pyx_v_start;
2827   int __pyx_v_end;
2828   int __pyx_r;
2829   PyObject *__pyx_t_1 = NULL;
2830   PyObject *__pyx_t_2 = NULL;
2831   int __pyx_t_3;
2832   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__tabixfile,&__pyx_n_s__tid,&__pyx_n_s__start,&__pyx_n_s__end,0};
2833   __Pyx_RefNannySetupContext("__cinit__");
2834   if (unlikely(__pyx_kwds)) {
2835     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
2836     PyObject* values[4] = {0,0,0,0};
2837     switch (PyTuple_GET_SIZE(__pyx_args)) {
2838       case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
2839       case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
2840       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2841       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2842       case  0: break;
2843       default: goto __pyx_L5_argtuple_error;
2844     }
2845     switch (PyTuple_GET_SIZE(__pyx_args)) {
2846       case  0:
2847       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__tabixfile);
2848       if (likely(values[0])) kw_args--;
2849       else goto __pyx_L5_argtuple_error;
2850       case  1:
2851       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__tid);
2852       if (likely(values[1])) kw_args--;
2853       else {
2854         __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 4, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2855       }
2856       case  2:
2857       values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start);
2858       if (likely(values[2])) kw_args--;
2859       else {
2860         __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 4, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2861       }
2862       case  3:
2863       values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end);
2864       if (likely(values[3])) kw_args--;
2865       else {
2866         __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 4, 4, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2867       }
2868     }
2869     if (unlikely(kw_args > 0)) {
2870       if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2871     }
2872     __pyx_v_tabixfile = ((struct __pyx_obj_6ctabix_Tabixfile *)values[0]);
2873     __pyx_v_tid = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_tid == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2874     __pyx_v_start = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_start == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2875     __pyx_v_end = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_end == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2876   } else if (PyTuple_GET_SIZE(__pyx_args) != 4) {
2877     goto __pyx_L5_argtuple_error;
2878   } else {
2879     __pyx_v_tabixfile = ((struct __pyx_obj_6ctabix_Tabixfile *)PyTuple_GET_ITEM(__pyx_args, 0));
2880     __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 = 170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2881     __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 = 170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2882     __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 = 170; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2883   }
2884   goto __pyx_L4_argument_unpacking_done;
2885   __pyx_L5_argtuple_error:;
2886   __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 4, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
2887   __pyx_L3_error:;
2888   __Pyx_AddTraceback("ctabix.TabixIterator.__cinit__");
2889   __Pyx_RefNannyFinishContext();
2890   return -1;
2891   __pyx_L4_argument_unpacking_done:;
2892   if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_tabixfile), __pyx_ptype_6ctabix_Tabixfile, 1, "tabixfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 169; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2893
2894   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":172
2895  *                   int tid, int start, int end ):
2896  * 
2897  *         assert tabixfile._isOpen()             # <<<<<<<<<<<<<<
2898  * 
2899  *         # makes sure that samfile stays alive as long as the
2900  */
2901   #ifndef PYREX_WITHOUT_ASSERTIONS
2902   __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_tabixfile), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2903   __Pyx_GOTREF(__pyx_t_1);
2904   __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 = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2905   __Pyx_GOTREF(__pyx_t_2);
2906   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2907   __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2908   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2909   if (unlikely(!__pyx_t_3)) {
2910     PyErr_SetNone(PyExc_AssertionError);
2911     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 172; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2912   }
2913   #endif
2914
2915   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":176
2916  *         # makes sure that samfile stays alive as long as the
2917  *         # iterator is alive.
2918  *         self.tabixfile = tabixfile.tabixfile             # <<<<<<<<<<<<<<
2919  * 
2920  *         if tid < 0:
2921  */
2922   ((struct __pyx_obj_6ctabix_TabixIterator *)__pyx_v_self)->tabixfile = __pyx_v_tabixfile->tabixfile;
2923
2924   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":178
2925  *         self.tabixfile = tabixfile.tabixfile
2926  * 
2927  *         if tid < 0:             # <<<<<<<<<<<<<<
2928  *             # seek to start of file to ensure iteration is over
2929  *             # all entries.
2930  */
2931   __pyx_t_3 = (__pyx_v_tid < 0);
2932   if (__pyx_t_3) {
2933
2934     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":181
2935  *             # seek to start of file to ensure iteration is over
2936  *             # all entries.
2937  *             bgzf_seek( self.tabixfile.fp, 0, 0)             # <<<<<<<<<<<<<<
2938  *             self.iterator = ti_iter_first()
2939  *         else:
2940  */
2941     bgzf_seek(((struct __pyx_obj_6ctabix_TabixIterator *)__pyx_v_self)->tabixfile->fp, 0, 0);
2942
2943     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":182
2944  *             # all entries.
2945  *             bgzf_seek( self.tabixfile.fp, 0, 0)
2946  *             self.iterator = ti_iter_first()             # <<<<<<<<<<<<<<
2947  *         else:
2948  *             self.iterator = ti_queryi(self.tabixfile, tid, start, end)
2949  */
2950     ((struct __pyx_obj_6ctabix_TabixIterator *)__pyx_v_self)->iterator = ti_iter_first();
2951     goto __pyx_L6;
2952   }
2953   /*else*/ {
2954
2955     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":184
2956  *             self.iterator = ti_iter_first()
2957  *         else:
2958  *             self.iterator = ti_queryi(self.tabixfile, tid, start, end)             # <<<<<<<<<<<<<<
2959  * 
2960  *         if <void*>self.iterator == NULL:
2961  */
2962     ((struct __pyx_obj_6ctabix_TabixIterator *)__pyx_v_self)->iterator = ti_queryi(((struct __pyx_obj_6ctabix_TabixIterator *)__pyx_v_self)->tabixfile, __pyx_v_tid, __pyx_v_start, __pyx_v_end);
2963   }
2964   __pyx_L6:;
2965
2966   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":186
2967  *             self.iterator = ti_queryi(self.tabixfile, tid, start, end)
2968  * 
2969  *         if <void*>self.iterator == NULL:             # <<<<<<<<<<<<<<
2970  *             raise ValueError("malformatted query or wrong sequence name.\n")
2971  * 
2972  */
2973   __pyx_t_3 = (((void *)((struct __pyx_obj_6ctabix_TabixIterator *)__pyx_v_self)->iterator) == NULL);
2974   if (__pyx_t_3) {
2975
2976     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":187
2977  * 
2978  *         if <void*>self.iterator == NULL:
2979  *             raise ValueError("malformatted query or wrong sequence name.\n")             # <<<<<<<<<<<<<<
2980  * 
2981  *     def __iter__(self):
2982  */
2983     __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2984     __Pyx_GOTREF(__pyx_t_2);
2985     __Pyx_INCREF(((PyObject *)__pyx_kp_s_12));
2986     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_12));
2987     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_12));
2988     __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2989     __Pyx_GOTREF(__pyx_t_1);
2990     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2991     __Pyx_Raise(__pyx_t_1, 0, 0);
2992     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2993     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2994     goto __pyx_L7;
2995   }
2996   __pyx_L7:;
2997
2998   __pyx_r = 0;
2999   goto __pyx_L0;
3000   __pyx_L1_error:;
3001   __Pyx_XDECREF(__pyx_t_1);
3002   __Pyx_XDECREF(__pyx_t_2);
3003   __Pyx_AddTraceback("ctabix.TabixIterator.__cinit__");
3004   __pyx_r = -1;
3005   __pyx_L0:;
3006   __Pyx_RefNannyFinishContext();
3007   return __pyx_r;
3008 }
3009
3010 /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":189
3011  *             raise ValueError("malformatted query or wrong sequence name.\n")
3012  * 
3013  *     def __iter__(self):             # <<<<<<<<<<<<<<
3014  *         return self
3015  * 
3016  */
3017
3018 static PyObject *__pyx_pf_6ctabix_13TabixIterator___iter__(PyObject *__pyx_v_self); /*proto*/
3019 static PyObject *__pyx_pf_6ctabix_13TabixIterator___iter__(PyObject *__pyx_v_self) {
3020   PyObject *__pyx_r = NULL;
3021   __Pyx_RefNannySetupContext("__iter__");
3022
3023   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":190
3024  * 
3025  *     def __iter__(self):
3026  *         return self             # <<<<<<<<<<<<<<
3027  * 
3028  *     def __next__(self):
3029  */
3030   __Pyx_XDECREF(__pyx_r);
3031   __Pyx_INCREF(__pyx_v_self);
3032   __pyx_r = __pyx_v_self;
3033   goto __pyx_L0;
3034
3035   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3036   __pyx_L0:;
3037   __Pyx_XGIVEREF(__pyx_r);
3038   __Pyx_RefNannyFinishContext();
3039   return __pyx_r;
3040 }
3041
3042 /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":192
3043  *         return self
3044  * 
3045  *     def __next__(self):             # <<<<<<<<<<<<<<
3046  *         """python version of next().
3047  * 
3048  */
3049
3050 static PyObject *__pyx_pf_6ctabix_13TabixIterator___next__(PyObject *__pyx_v_self); /*proto*/
3051 static char __pyx_doc_6ctabix_13TabixIterator___next__[] = "python version of next().\n\n        pyrex uses this non-standard name instead of next()\n        ";
3052 struct wrapperbase __pyx_wrapperbase_6ctabix_13TabixIterator___next__;
3053 static PyObject *__pyx_pf_6ctabix_13TabixIterator___next__(PyObject *__pyx_v_self) {
3054   char *__pyx_v_s;
3055   int __pyx_v_len;
3056   PyObject *__pyx_r = NULL;
3057   int __pyx_t_1;
3058   PyObject *__pyx_t_2 = NULL;
3059   __Pyx_RefNannySetupContext("__next__");
3060
3061   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":205
3062  * 
3063  *         # simply use '#' for now.
3064  *         while 1:             # <<<<<<<<<<<<<<
3065  *             s = ti_read(self.tabixfile, self.iterator, &len)
3066  *             if s == NULL: raise StopIteration
3067  */
3068   while (1) {
3069     if (!1) break;
3070
3071     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":206
3072  *         # simply use '#' for now.
3073  *         while 1:
3074  *             s = ti_read(self.tabixfile, self.iterator, &len)             # <<<<<<<<<<<<<<
3075  *             if s == NULL: raise StopIteration
3076  *             if s[0] != '#': break
3077  */
3078     __pyx_v_s = ti_read(((struct __pyx_obj_6ctabix_TabixIterator *)__pyx_v_self)->tabixfile, ((struct __pyx_obj_6ctabix_TabixIterator *)__pyx_v_self)->iterator, (&__pyx_v_len));
3079
3080     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":207
3081  *         while 1:
3082  *             s = ti_read(self.tabixfile, self.iterator, &len)
3083  *             if s == NULL: raise StopIteration             # <<<<<<<<<<<<<<
3084  *             if s[0] != '#': break
3085  * 
3086  */
3087     __pyx_t_1 = (__pyx_v_s == NULL);
3088     if (__pyx_t_1) {
3089       __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
3090       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3091       goto __pyx_L7;
3092     }
3093     __pyx_L7:;
3094
3095     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":208
3096  *             s = ti_read(self.tabixfile, self.iterator, &len)
3097  *             if s == NULL: raise StopIteration
3098  *             if s[0] != '#': break             # <<<<<<<<<<<<<<
3099  * 
3100  *         return s
3101  */
3102     __pyx_t_1 = ((__pyx_v_s[0]) != '#');
3103     if (__pyx_t_1) {
3104       goto __pyx_L6_break;
3105       goto __pyx_L8;
3106     }
3107     __pyx_L8:;
3108   }
3109   __pyx_L6_break:;
3110
3111   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":210
3112  *             if s[0] != '#': break
3113  * 
3114  *         return s             # <<<<<<<<<<<<<<
3115  * 
3116  *     def __dealloc__(self):
3117  */
3118   __Pyx_XDECREF(__pyx_r);
3119   __pyx_t_2 = PyBytes_FromString(__pyx_v_s); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3120   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
3121   __pyx_r = ((PyObject *)__pyx_t_2);
3122   __pyx_t_2 = 0;
3123   goto __pyx_L0;
3124
3125   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3126   goto __pyx_L0;
3127   __pyx_L1_error:;
3128   __Pyx_XDECREF(__pyx_t_2);
3129   __Pyx_AddTraceback("ctabix.TabixIterator.__next__");
3130   __pyx_r = NULL;
3131   __pyx_L0:;
3132   __Pyx_XGIVEREF(__pyx_r);
3133   __Pyx_RefNannyFinishContext();
3134   return __pyx_r;
3135 }
3136
3137 /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":212
3138  *         return s
3139  * 
3140  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
3141  *         if <void*>self.iterator != NULL:
3142  *             ti_iter_destroy(self.iterator)
3143  */
3144
3145 static void __pyx_pf_6ctabix_13TabixIterator___dealloc__(PyObject *__pyx_v_self); /*proto*/
3146 static void __pyx_pf_6ctabix_13TabixIterator___dealloc__(PyObject *__pyx_v_self) {
3147   int __pyx_t_1;
3148   __Pyx_RefNannySetupContext("__dealloc__");
3149
3150   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":213
3151  * 
3152  *     def __dealloc__(self):
3153  *         if <void*>self.iterator != NULL:             # <<<<<<<<<<<<<<
3154  *             ti_iter_destroy(self.iterator)
3155  * 
3156  */
3157   __pyx_t_1 = (((void *)((struct __pyx_obj_6ctabix_TabixIterator *)__pyx_v_self)->iterator) != NULL);
3158   if (__pyx_t_1) {
3159
3160     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":214
3161  *     def __dealloc__(self):
3162  *         if <void*>self.iterator != NULL:
3163  *             ti_iter_destroy(self.iterator)             # <<<<<<<<<<<<<<
3164  * 
3165  * cdef class TabixHeaderIterator:
3166  */
3167     ti_iter_destroy(((struct __pyx_obj_6ctabix_TabixIterator *)__pyx_v_self)->iterator);
3168     goto __pyx_L5;
3169   }
3170   __pyx_L5:;
3171
3172   __Pyx_RefNannyFinishContext();
3173 }
3174
3175 /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":223
3176  *     cdef tabix_t * tabixfile
3177  * 
3178  *     def __cinit__(self, Tabixfile tabixfile ):             # <<<<<<<<<<<<<<
3179  * 
3180  *         assert tabixfile._isOpen()
3181  */
3182
3183 static int __pyx_pf_6ctabix_19TabixHeaderIterator___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3184 static int __pyx_pf_6ctabix_19TabixHeaderIterator___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3185   struct __pyx_obj_6ctabix_Tabixfile *__pyx_v_tabixfile = 0;
3186   int __pyx_r;
3187   PyObject *__pyx_t_1 = NULL;
3188   PyObject *__pyx_t_2 = NULL;
3189   int __pyx_t_3;
3190   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__tabixfile,0};
3191   __Pyx_RefNannySetupContext("__cinit__");
3192   if (unlikely(__pyx_kwds)) {
3193     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
3194     PyObject* values[1] = {0};
3195     switch (PyTuple_GET_SIZE(__pyx_args)) {
3196       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3197       case  0: break;
3198       default: goto __pyx_L5_argtuple_error;
3199     }
3200     switch (PyTuple_GET_SIZE(__pyx_args)) {
3201       case  0:
3202       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__tabixfile);
3203       if (likely(values[0])) kw_args--;
3204       else goto __pyx_L5_argtuple_error;
3205     }
3206     if (unlikely(kw_args > 0)) {
3207       if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3208     }
3209     __pyx_v_tabixfile = ((struct __pyx_obj_6ctabix_Tabixfile *)values[0]);
3210   } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
3211     goto __pyx_L5_argtuple_error;
3212   } else {
3213     __pyx_v_tabixfile = ((struct __pyx_obj_6ctabix_Tabixfile *)PyTuple_GET_ITEM(__pyx_args, 0));
3214   }
3215   goto __pyx_L4_argument_unpacking_done;
3216   __pyx_L5_argtuple_error:;
3217   __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3218   __pyx_L3_error:;
3219   __Pyx_AddTraceback("ctabix.TabixHeaderIterator.__cinit__");
3220   __Pyx_RefNannyFinishContext();
3221   return -1;
3222   __pyx_L4_argument_unpacking_done:;
3223   if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_tabixfile), __pyx_ptype_6ctabix_Tabixfile, 1, "tabixfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 223; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3224
3225   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":225
3226  *     def __cinit__(self, Tabixfile tabixfile ):
3227  * 
3228  *         assert tabixfile._isOpen()             # <<<<<<<<<<<<<<
3229  * 
3230  *         # makes sure that samfile stays alive as long as the
3231  */
3232   #ifndef PYREX_WITHOUT_ASSERTIONS
3233   __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_tabixfile), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3234   __Pyx_GOTREF(__pyx_t_1);
3235   __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 = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3236   __Pyx_GOTREF(__pyx_t_2);
3237   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3238   __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3239   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3240   if (unlikely(!__pyx_t_3)) {
3241     PyErr_SetNone(PyExc_AssertionError);
3242     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3243   }
3244   #endif
3245
3246   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":229
3247  *         # makes sure that samfile stays alive as long as the
3248  *         # iterator is alive.
3249  *         self.tabixfile = tabixfile.tabixfile             # <<<<<<<<<<<<<<
3250  * 
3251  *         self.iterator = ti_query(self.tabixfile, NULL, 0, 0)
3252  */
3253   ((struct __pyx_obj_6ctabix_TabixHeaderIterator *)__pyx_v_self)->tabixfile = __pyx_v_tabixfile->tabixfile;
3254
3255   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":231
3256  *         self.tabixfile = tabixfile.tabixfile
3257  * 
3258  *         self.iterator = ti_query(self.tabixfile, NULL, 0, 0)             # <<<<<<<<<<<<<<
3259  * 
3260  *         if <void*>self.iterator == NULL:
3261  */
3262   ((struct __pyx_obj_6ctabix_TabixHeaderIterator *)__pyx_v_self)->iterator = ti_query(((struct __pyx_obj_6ctabix_TabixHeaderIterator *)__pyx_v_self)->tabixfile, NULL, 0, 0);
3263
3264   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":233
3265  *         self.iterator = ti_query(self.tabixfile, NULL, 0, 0)
3266  * 
3267  *         if <void*>self.iterator == NULL:             # <<<<<<<<<<<<<<
3268  *             raise ValueError("can't open header.\n")
3269  * 
3270  */
3271   __pyx_t_3 = (((void *)((struct __pyx_obj_6ctabix_TabixHeaderIterator *)__pyx_v_self)->iterator) == NULL);
3272   if (__pyx_t_3) {
3273
3274     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":234
3275  * 
3276  *         if <void*>self.iterator == NULL:
3277  *             raise ValueError("can't open header.\n")             # <<<<<<<<<<<<<<
3278  * 
3279  *     def __iter__(self):
3280  */
3281     __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3282     __Pyx_GOTREF(__pyx_t_2);
3283     __Pyx_INCREF(((PyObject *)__pyx_kp_s_13));
3284     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_13));
3285     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_13));
3286     __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3287     __Pyx_GOTREF(__pyx_t_1);
3288     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3289     __Pyx_Raise(__pyx_t_1, 0, 0);
3290     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3291     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 234; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3292     goto __pyx_L6;
3293   }
3294   __pyx_L6:;
3295
3296   __pyx_r = 0;
3297   goto __pyx_L0;
3298   __pyx_L1_error:;
3299   __Pyx_XDECREF(__pyx_t_1);
3300   __Pyx_XDECREF(__pyx_t_2);
3301   __Pyx_AddTraceback("ctabix.TabixHeaderIterator.__cinit__");
3302   __pyx_r = -1;
3303   __pyx_L0:;
3304   __Pyx_RefNannyFinishContext();
3305   return __pyx_r;
3306 }
3307
3308 /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":236
3309  *             raise ValueError("can't open header.\n")
3310  * 
3311  *     def __iter__(self):             # <<<<<<<<<<<<<<
3312  *         return self
3313  * 
3314  */
3315
3316 static PyObject *__pyx_pf_6ctabix_19TabixHeaderIterator___iter__(PyObject *__pyx_v_self); /*proto*/
3317 static PyObject *__pyx_pf_6ctabix_19TabixHeaderIterator___iter__(PyObject *__pyx_v_self) {
3318   PyObject *__pyx_r = NULL;
3319   __Pyx_RefNannySetupContext("__iter__");
3320
3321   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":237
3322  * 
3323  *     def __iter__(self):
3324  *         return self             # <<<<<<<<<<<<<<
3325  * 
3326  *     def __next__(self):
3327  */
3328   __Pyx_XDECREF(__pyx_r);
3329   __Pyx_INCREF(__pyx_v_self);
3330   __pyx_r = __pyx_v_self;
3331   goto __pyx_L0;
3332
3333   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3334   __pyx_L0:;
3335   __Pyx_XGIVEREF(__pyx_r);
3336   __Pyx_RefNannyFinishContext();
3337   return __pyx_r;
3338 }
3339
3340 /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":239
3341  *         return self
3342  * 
3343  *     def __next__(self):             # <<<<<<<<<<<<<<
3344  *         """python version of next().
3345  * 
3346  */
3347
3348 static PyObject *__pyx_pf_6ctabix_19TabixHeaderIterator___next__(PyObject *__pyx_v_self); /*proto*/
3349 static char __pyx_doc_6ctabix_19TabixHeaderIterator___next__[] = "python version of next().\n\n        pyrex uses this non-standard name instead of next()\n        ";
3350 struct wrapperbase __pyx_wrapperbase_6ctabix_19TabixHeaderIterator___next__;
3351 static PyObject *__pyx_pf_6ctabix_19TabixHeaderIterator___next__(PyObject *__pyx_v_self) {
3352   char *__pyx_v_s;
3353   int __pyx_v_len;
3354   PyObject *__pyx_r = NULL;
3355   int __pyx_t_1;
3356   PyObject *__pyx_t_2 = NULL;
3357   __Pyx_RefNannySetupContext("__next__");
3358
3359   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":250
3360  *         # Getting the metachar is a pain as ti_index_t is incomplete type.
3361  *         # simply use '#' for now.
3362  *         s = ti_read(self.tabixfile, self.iterator, &len)             # <<<<<<<<<<<<<<
3363  *         if s == NULL: raise StopIteration
3364  *         # stop at first non-header line
3365  */
3366   __pyx_v_s = ti_read(((struct __pyx_obj_6ctabix_TabixHeaderIterator *)__pyx_v_self)->tabixfile, ((struct __pyx_obj_6ctabix_TabixHeaderIterator *)__pyx_v_self)->iterator, (&__pyx_v_len));
3367
3368   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":251
3369  *         # simply use '#' for now.
3370  *         s = ti_read(self.tabixfile, self.iterator, &len)
3371  *         if s == NULL: raise StopIteration             # <<<<<<<<<<<<<<
3372  *         # stop at first non-header line
3373  *         if s[0] != '#': raise StopIteration
3374  */
3375   __pyx_t_1 = (__pyx_v_s == NULL);
3376   if (__pyx_t_1) {
3377     __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
3378     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3379     goto __pyx_L5;
3380   }
3381   __pyx_L5:;
3382
3383   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":253
3384  *         if s == NULL: raise StopIteration
3385  *         # stop at first non-header line
3386  *         if s[0] != '#': raise StopIteration             # <<<<<<<<<<<<<<
3387  * 
3388  *         return s
3389  */
3390   __pyx_t_1 = ((__pyx_v_s[0]) != '#');
3391   if (__pyx_t_1) {
3392     __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
3393     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3394     goto __pyx_L6;
3395   }
3396   __pyx_L6:;
3397
3398   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":255
3399  *         if s[0] != '#': raise StopIteration
3400  * 
3401  *         return s             # <<<<<<<<<<<<<<
3402  * 
3403  *     def __dealloc__(self):
3404  */
3405   __Pyx_XDECREF(__pyx_r);
3406   __pyx_t_2 = PyBytes_FromString(__pyx_v_s); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 255; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3407   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
3408   __pyx_r = ((PyObject *)__pyx_t_2);
3409   __pyx_t_2 = 0;
3410   goto __pyx_L0;
3411
3412   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3413   goto __pyx_L0;
3414   __pyx_L1_error:;
3415   __Pyx_XDECREF(__pyx_t_2);
3416   __Pyx_AddTraceback("ctabix.TabixHeaderIterator.__next__");
3417   __pyx_r = NULL;
3418   __pyx_L0:;
3419   __Pyx_XGIVEREF(__pyx_r);
3420   __Pyx_RefNannyFinishContext();
3421   return __pyx_r;
3422 }
3423
3424 /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":257
3425  *         return s
3426  * 
3427  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
3428  *         if <void*>self.iterator != NULL:
3429  *             ti_iter_destroy(self.iterator)
3430  */
3431
3432 static void __pyx_pf_6ctabix_19TabixHeaderIterator___dealloc__(PyObject *__pyx_v_self); /*proto*/
3433 static void __pyx_pf_6ctabix_19TabixHeaderIterator___dealloc__(PyObject *__pyx_v_self) {
3434   int __pyx_t_1;
3435   __Pyx_RefNannySetupContext("__dealloc__");
3436
3437   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":258
3438  * 
3439  *     def __dealloc__(self):
3440  *         if <void*>self.iterator != NULL:             # <<<<<<<<<<<<<<
3441  *             ti_iter_destroy(self.iterator)
3442  * 
3443  */
3444   __pyx_t_1 = (((void *)((struct __pyx_obj_6ctabix_TabixHeaderIterator *)__pyx_v_self)->iterator) != NULL);
3445   if (__pyx_t_1) {
3446
3447     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":259
3448  *     def __dealloc__(self):
3449  *         if <void*>self.iterator != NULL:
3450  *             ti_iter_destroy(self.iterator)             # <<<<<<<<<<<<<<
3451  * 
3452  * #########################################################
3453  */
3454     ti_iter_destroy(((struct __pyx_obj_6ctabix_TabixHeaderIterator *)__pyx_v_self)->iterator);
3455     goto __pyx_L5;
3456   }
3457   __pyx_L5:;
3458
3459   __Pyx_RefNannyFinishContext();
3460 }
3461
3462 /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":269
3463  * cdef class asTuple(Parser):
3464  *     '''converts a :term:`tabix row` into a python tuple.'''
3465  *     def __call__(self, char * buffer, int len):             # <<<<<<<<<<<<<<
3466  *         cdef TabProxies.TupleProxy r
3467  *         r = TabProxies.TupleProxy()
3468  */
3469
3470 static PyObject *__pyx_pf_6ctabix_7asTuple___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3471 static PyObject *__pyx_pf_6ctabix_7asTuple___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3472   char *__pyx_v_buffer;
3473   int __pyx_v_len;
3474   struct __pyx_obj_10TabProxies_TupleProxy *__pyx_v_r;
3475   PyObject *__pyx_r = NULL;
3476   PyObject *__pyx_t_1 = NULL;
3477   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__buffer,&__pyx_n_s__len,0};
3478   __Pyx_RefNannySetupContext("__call__");
3479   if (unlikely(__pyx_kwds)) {
3480     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
3481     PyObject* values[2] = {0,0};
3482     switch (PyTuple_GET_SIZE(__pyx_args)) {
3483       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3484       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3485       case  0: break;
3486       default: goto __pyx_L5_argtuple_error;
3487     }
3488     switch (PyTuple_GET_SIZE(__pyx_args)) {
3489       case  0:
3490       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__buffer);
3491       if (likely(values[0])) kw_args--;
3492       else goto __pyx_L5_argtuple_error;
3493       case  1:
3494       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__len);
3495       if (likely(values[1])) kw_args--;
3496       else {
3497         __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3498       }
3499     }
3500     if (unlikely(kw_args > 0)) {
3501       if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__call__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3502     }
3503     __pyx_v_buffer = PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_buffer) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3504     __pyx_v_len = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_len == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3505   } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
3506     goto __pyx_L5_argtuple_error;
3507   } else {
3508     __pyx_v_buffer = PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_buffer) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3509     __pyx_v_len = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_len == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3510   }
3511   goto __pyx_L4_argument_unpacking_done;
3512   __pyx_L5_argtuple_error:;
3513   __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3514   __pyx_L3_error:;
3515   __Pyx_AddTraceback("ctabix.asTuple.__call__");
3516   __Pyx_RefNannyFinishContext();
3517   return NULL;
3518   __pyx_L4_argument_unpacking_done:;
3519   __pyx_v_r = ((struct __pyx_obj_10TabProxies_TupleProxy *)Py_None); __Pyx_INCREF(Py_None);
3520
3521   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":271
3522  *     def __call__(self, char * buffer, int len):
3523  *         cdef TabProxies.TupleProxy r
3524  *         r = TabProxies.TupleProxy()             # <<<<<<<<<<<<<<
3525  *         # need to copy - there were some
3526  *         # persistence issues with "present"
3527  */
3528   __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_10TabProxies_TupleProxy)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3529   __Pyx_GOTREF(__pyx_t_1);
3530   __Pyx_DECREF(((PyObject *)__pyx_v_r));
3531   __pyx_v_r = ((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_t_1);
3532   __pyx_t_1 = 0;
3533
3534   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":274
3535  *         # need to copy - there were some
3536  *         # persistence issues with "present"
3537  *         r.copy( buffer, len )             # <<<<<<<<<<<<<<
3538  *         return r
3539  * 
3540  */
3541   __pyx_t_1 = ((struct __pyx_vtabstruct_10TabProxies_TupleProxy *)__pyx_v_r->__pyx_vtab)->copy(__pyx_v_r, __pyx_v_buffer, __pyx_v_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 274; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3542   __Pyx_GOTREF(__pyx_t_1);
3543   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3544
3545   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":275
3546  *         # persistence issues with "present"
3547  *         r.copy( buffer, len )
3548  *         return r             # <<<<<<<<<<<<<<
3549  * 
3550  * cdef class asGTF(Parser):
3551  */
3552   __Pyx_XDECREF(__pyx_r);
3553   __Pyx_INCREF(((PyObject *)__pyx_v_r));
3554   __pyx_r = ((PyObject *)__pyx_v_r);
3555   goto __pyx_L0;
3556
3557   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3558   goto __pyx_L0;
3559   __pyx_L1_error:;
3560   __Pyx_XDECREF(__pyx_t_1);
3561   __Pyx_AddTraceback("ctabix.asTuple.__call__");
3562   __pyx_r = NULL;
3563   __pyx_L0:;
3564   __Pyx_DECREF((PyObject *)__pyx_v_r);
3565   __Pyx_XGIVEREF(__pyx_r);
3566   __Pyx_RefNannyFinishContext();
3567   return __pyx_r;
3568 }
3569
3570 /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":279
3571  * cdef class asGTF(Parser):
3572  *     '''converts a :term:`tabix row` into a GTF record.'''
3573  *     def __call__(self, char * buffer, int len):             # <<<<<<<<<<<<<<
3574  *         cdef TabProxies.GTFProxy r
3575  *         r = TabProxies.GTFProxy()
3576  */
3577
3578 static PyObject *__pyx_pf_6ctabix_5asGTF___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3579 static PyObject *__pyx_pf_6ctabix_5asGTF___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3580   char *__pyx_v_buffer;
3581   int __pyx_v_len;
3582   struct __pyx_obj_10TabProxies_GTFProxy *__pyx_v_r;
3583   PyObject *__pyx_r = NULL;
3584   PyObject *__pyx_t_1 = NULL;
3585   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__buffer,&__pyx_n_s__len,0};
3586   __Pyx_RefNannySetupContext("__call__");
3587   if (unlikely(__pyx_kwds)) {
3588     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
3589     PyObject* values[2] = {0,0};
3590     switch (PyTuple_GET_SIZE(__pyx_args)) {
3591       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3592       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3593       case  0: break;
3594       default: goto __pyx_L5_argtuple_error;
3595     }
3596     switch (PyTuple_GET_SIZE(__pyx_args)) {
3597       case  0:
3598       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__buffer);
3599       if (likely(values[0])) kw_args--;
3600       else goto __pyx_L5_argtuple_error;
3601       case  1:
3602       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__len);
3603       if (likely(values[1])) kw_args--;
3604       else {
3605         __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3606       }
3607     }
3608     if (unlikely(kw_args > 0)) {
3609       if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__call__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3610     }
3611     __pyx_v_buffer = PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_buffer) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3612     __pyx_v_len = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_len == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3613   } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
3614     goto __pyx_L5_argtuple_error;
3615   } else {
3616     __pyx_v_buffer = PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_buffer) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3617     __pyx_v_len = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_len == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3618   }
3619   goto __pyx_L4_argument_unpacking_done;
3620   __pyx_L5_argtuple_error:;
3621   __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 279; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3622   __pyx_L3_error:;
3623   __Pyx_AddTraceback("ctabix.asGTF.__call__");
3624   __Pyx_RefNannyFinishContext();
3625   return NULL;
3626   __pyx_L4_argument_unpacking_done:;
3627   __pyx_v_r = ((struct __pyx_obj_10TabProxies_GTFProxy *)Py_None); __Pyx_INCREF(Py_None);
3628
3629   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":281
3630  *     def __call__(self, char * buffer, int len):
3631  *         cdef TabProxies.GTFProxy r
3632  *         r = TabProxies.GTFProxy()             # <<<<<<<<<<<<<<
3633  *         r.copy( buffer, len )
3634  *         return r
3635  */
3636   __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_10TabProxies_GTFProxy)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3637   __Pyx_GOTREF(__pyx_t_1);
3638   __Pyx_DECREF(((PyObject *)__pyx_v_r));
3639   __pyx_v_r = ((struct __pyx_obj_10TabProxies_GTFProxy *)__pyx_t_1);
3640   __pyx_t_1 = 0;
3641
3642   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":282
3643  *         cdef TabProxies.GTFProxy r
3644  *         r = TabProxies.GTFProxy()
3645  *         r.copy( buffer, len )             # <<<<<<<<<<<<<<
3646  *         return r
3647  * 
3648  */
3649   __pyx_t_1 = ((struct __pyx_vtabstruct_10TabProxies_GTFProxy *)__pyx_v_r->__pyx_base.__pyx_vtab)->__pyx_base.copy(((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_r), __pyx_v_buffer, __pyx_v_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3650   __Pyx_GOTREF(__pyx_t_1);
3651   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3652
3653   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":283
3654  *         r = TabProxies.GTFProxy()
3655  *         r.copy( buffer, len )
3656  *         return r             # <<<<<<<<<<<<<<
3657  * 
3658  * cdef class asBed( Parser ):
3659  */
3660   __Pyx_XDECREF(__pyx_r);
3661   __Pyx_INCREF(((PyObject *)__pyx_v_r));
3662   __pyx_r = ((PyObject *)__pyx_v_r);
3663   goto __pyx_L0;
3664
3665   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3666   goto __pyx_L0;
3667   __pyx_L1_error:;
3668   __Pyx_XDECREF(__pyx_t_1);
3669   __Pyx_AddTraceback("ctabix.asGTF.__call__");
3670   __pyx_r = NULL;
3671   __pyx_L0:;
3672   __Pyx_DECREF((PyObject *)__pyx_v_r);
3673   __Pyx_XGIVEREF(__pyx_r);
3674   __Pyx_RefNannyFinishContext();
3675   return __pyx_r;
3676 }
3677
3678 /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":287
3679  * cdef class asBed( Parser ):
3680  *     '''converts a :term:`tabix row` into a GTF record.'''
3681  *     def __call__(self, char * buffer, int len):             # <<<<<<<<<<<<<<
3682  *         cdef TabProxies.BedProxy r
3683  *         r = TabProxies.BedProxy()
3684  */
3685
3686 static PyObject *__pyx_pf_6ctabix_5asBed___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3687 static PyObject *__pyx_pf_6ctabix_5asBed___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3688   char *__pyx_v_buffer;
3689   int __pyx_v_len;
3690   struct __pyx_obj_10TabProxies_BedProxy *__pyx_v_r;
3691   PyObject *__pyx_r = NULL;
3692   PyObject *__pyx_t_1 = NULL;
3693   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__buffer,&__pyx_n_s__len,0};
3694   __Pyx_RefNannySetupContext("__call__");
3695   if (unlikely(__pyx_kwds)) {
3696     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
3697     PyObject* values[2] = {0,0};
3698     switch (PyTuple_GET_SIZE(__pyx_args)) {
3699       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3700       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3701       case  0: break;
3702       default: goto __pyx_L5_argtuple_error;
3703     }
3704     switch (PyTuple_GET_SIZE(__pyx_args)) {
3705       case  0:
3706       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__buffer);
3707       if (likely(values[0])) kw_args--;
3708       else goto __pyx_L5_argtuple_error;
3709       case  1:
3710       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__len);
3711       if (likely(values[1])) kw_args--;
3712       else {
3713         __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3714       }
3715     }
3716     if (unlikely(kw_args > 0)) {
3717       if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__call__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3718     }
3719     __pyx_v_buffer = PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_buffer) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3720     __pyx_v_len = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_len == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3721   } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
3722     goto __pyx_L5_argtuple_error;
3723   } else {
3724     __pyx_v_buffer = PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_buffer) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3725     __pyx_v_len = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_len == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3726   }
3727   goto __pyx_L4_argument_unpacking_done;
3728   __pyx_L5_argtuple_error:;
3729   __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 287; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3730   __pyx_L3_error:;
3731   __Pyx_AddTraceback("ctabix.asBed.__call__");
3732   __Pyx_RefNannyFinishContext();
3733   return NULL;
3734   __pyx_L4_argument_unpacking_done:;
3735   __pyx_v_r = ((struct __pyx_obj_10TabProxies_BedProxy *)Py_None); __Pyx_INCREF(Py_None);
3736
3737   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":289
3738  *     def __call__(self, char * buffer, int len):
3739  *         cdef TabProxies.BedProxy r
3740  *         r = TabProxies.BedProxy()             # <<<<<<<<<<<<<<
3741  *         r.copy( buffer, len )
3742  *         return r
3743  */
3744   __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_10TabProxies_BedProxy)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3745   __Pyx_GOTREF(__pyx_t_1);
3746   __Pyx_DECREF(((PyObject *)__pyx_v_r));
3747   __pyx_v_r = ((struct __pyx_obj_10TabProxies_BedProxy *)__pyx_t_1);
3748   __pyx_t_1 = 0;
3749
3750   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":290
3751  *         cdef TabProxies.BedProxy r
3752  *         r = TabProxies.BedProxy()
3753  *         r.copy( buffer, len )             # <<<<<<<<<<<<<<
3754  *         return r
3755  * 
3756  */
3757   __pyx_t_1 = ((struct __pyx_vtabstruct_10TabProxies_BedProxy *)__pyx_v_r->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base.copy(((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_r), __pyx_v_buffer, __pyx_v_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3758   __Pyx_GOTREF(__pyx_t_1);
3759   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3760
3761   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":291
3762  *         r = TabProxies.BedProxy()
3763  *         r.copy( buffer, len )
3764  *         return r             # <<<<<<<<<<<<<<
3765  * 
3766  * cdef class asVCF( Parser ):
3767  */
3768   __Pyx_XDECREF(__pyx_r);
3769   __Pyx_INCREF(((PyObject *)__pyx_v_r));
3770   __pyx_r = ((PyObject *)__pyx_v_r);
3771   goto __pyx_L0;
3772
3773   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3774   goto __pyx_L0;
3775   __pyx_L1_error:;
3776   __Pyx_XDECREF(__pyx_t_1);
3777   __Pyx_AddTraceback("ctabix.asBed.__call__");
3778   __pyx_r = NULL;
3779   __pyx_L0:;
3780   __Pyx_DECREF((PyObject *)__pyx_v_r);
3781   __Pyx_XGIVEREF(__pyx_r);
3782   __Pyx_RefNannyFinishContext();
3783   return __pyx_r;
3784 }
3785
3786 /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":295
3787  * cdef class asVCF( Parser ):
3788  *     '''converts a :term:`tabix row` into a VCF record.'''
3789  *     def __call__(self, char * buffer, int len ):             # <<<<<<<<<<<<<<
3790  *         cdef TabProxies.VCFProxy r
3791  *         r = TabProxies.VCFProxy()
3792  */
3793
3794 static PyObject *__pyx_pf_6ctabix_5asVCF___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3795 static PyObject *__pyx_pf_6ctabix_5asVCF___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3796   char *__pyx_v_buffer;
3797   int __pyx_v_len;
3798   struct __pyx_obj_10TabProxies_VCFProxy *__pyx_v_r;
3799   PyObject *__pyx_r = NULL;
3800   PyObject *__pyx_t_1 = NULL;
3801   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__buffer,&__pyx_n_s__len,0};
3802   __Pyx_RefNannySetupContext("__call__");
3803   if (unlikely(__pyx_kwds)) {
3804     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
3805     PyObject* values[2] = {0,0};
3806     switch (PyTuple_GET_SIZE(__pyx_args)) {
3807       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3808       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3809       case  0: break;
3810       default: goto __pyx_L5_argtuple_error;
3811     }
3812     switch (PyTuple_GET_SIZE(__pyx_args)) {
3813       case  0:
3814       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__buffer);
3815       if (likely(values[0])) kw_args--;
3816       else goto __pyx_L5_argtuple_error;
3817       case  1:
3818       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__len);
3819       if (likely(values[1])) kw_args--;
3820       else {
3821         __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3822       }
3823     }
3824     if (unlikely(kw_args > 0)) {
3825       if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__call__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3826     }
3827     __pyx_v_buffer = PyBytes_AsString(values[0]); if (unlikely((!__pyx_v_buffer) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3828     __pyx_v_len = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_len == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3829   } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
3830     goto __pyx_L5_argtuple_error;
3831   } else {
3832     __pyx_v_buffer = PyBytes_AsString(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((!__pyx_v_buffer) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3833     __pyx_v_len = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_len == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3834   }
3835   goto __pyx_L4_argument_unpacking_done;
3836   __pyx_L5_argtuple_error:;
3837   __Pyx_RaiseArgtupleInvalid("__call__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3838   __pyx_L3_error:;
3839   __Pyx_AddTraceback("ctabix.asVCF.__call__");
3840   __Pyx_RefNannyFinishContext();
3841   return NULL;
3842   __pyx_L4_argument_unpacking_done:;
3843   __pyx_v_r = ((struct __pyx_obj_10TabProxies_VCFProxy *)Py_None); __Pyx_INCREF(Py_None);
3844
3845   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":297
3846  *     def __call__(self, char * buffer, int len ):
3847  *         cdef TabProxies.VCFProxy r
3848  *         r = TabProxies.VCFProxy()             # <<<<<<<<<<<<<<
3849  *         r.copy( buffer, len )
3850  *         return r
3851  */
3852   __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_10TabProxies_VCFProxy)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3853   __Pyx_GOTREF(__pyx_t_1);
3854   __Pyx_DECREF(((PyObject *)__pyx_v_r));
3855   __pyx_v_r = ((struct __pyx_obj_10TabProxies_VCFProxy *)__pyx_t_1);
3856   __pyx_t_1 = 0;
3857
3858   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":298
3859  *         cdef TabProxies.VCFProxy r
3860  *         r = TabProxies.VCFProxy()
3861  *         r.copy( buffer, len )             # <<<<<<<<<<<<<<
3862  *         return r
3863  * 
3864  */
3865   __pyx_t_1 = ((struct __pyx_vtabstruct_10TabProxies_VCFProxy *)__pyx_v_r->__pyx_base.__pyx_base.__pyx_vtab)->__pyx_base.__pyx_base.copy(((struct __pyx_obj_10TabProxies_TupleProxy *)__pyx_v_r), __pyx_v_buffer, __pyx_v_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3866   __Pyx_GOTREF(__pyx_t_1);
3867   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3868
3869   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":299
3870  *         r = TabProxies.VCFProxy()
3871  *         r.copy( buffer, len )
3872  *         return r             # <<<<<<<<<<<<<<
3873  * 
3874  * #########################################################
3875  */
3876   __Pyx_XDECREF(__pyx_r);
3877   __Pyx_INCREF(((PyObject *)__pyx_v_r));
3878   __pyx_r = ((PyObject *)__pyx_v_r);
3879   goto __pyx_L0;
3880
3881   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
3882   goto __pyx_L0;
3883   __pyx_L1_error:;
3884   __Pyx_XDECREF(__pyx_t_1);
3885   __Pyx_AddTraceback("ctabix.asVCF.__call__");
3886   __pyx_r = NULL;
3887   __pyx_L0:;
3888   __Pyx_DECREF((PyObject *)__pyx_v_r);
3889   __Pyx_XGIVEREF(__pyx_r);
3890   __Pyx_RefNannyFinishContext();
3891   return __pyx_r;
3892 }
3893
3894 /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":314
3895  *     cdef Parser parser
3896  * 
3897  *     def __cinit__(self,             # <<<<<<<<<<<<<<
3898  *                   Tabixfile tabixfile,
3899  *                   int tid,
3900  */
3901
3902 static int __pyx_pf_6ctabix_19TabixIteratorParsed___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
3903 static int __pyx_pf_6ctabix_19TabixIteratorParsed___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
3904   struct __pyx_obj_6ctabix_Tabixfile *__pyx_v_tabixfile = 0;
3905   int __pyx_v_tid;
3906   int __pyx_v_start;
3907   int __pyx_v_end;
3908   struct __pyx_obj_6ctabix_Parser *__pyx_v_parser = 0;
3909   int __pyx_r;
3910   PyObject *__pyx_t_1 = NULL;
3911   PyObject *__pyx_t_2 = NULL;
3912   int __pyx_t_3;
3913   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__tabixfile,&__pyx_n_s__tid,&__pyx_n_s__start,&__pyx_n_s__end,&__pyx_n_s__parser,0};
3914   __Pyx_RefNannySetupContext("__cinit__");
3915   if (unlikely(__pyx_kwds)) {
3916     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
3917     PyObject* values[5] = {0,0,0,0,0};
3918     switch (PyTuple_GET_SIZE(__pyx_args)) {
3919       case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
3920       case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
3921       case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
3922       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
3923       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
3924       case  0: break;
3925       default: goto __pyx_L5_argtuple_error;
3926     }
3927     switch (PyTuple_GET_SIZE(__pyx_args)) {
3928       case  0:
3929       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__tabixfile);
3930       if (likely(values[0])) kw_args--;
3931       else goto __pyx_L5_argtuple_error;
3932       case  1:
3933       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__tid);
3934       if (likely(values[1])) kw_args--;
3935       else {
3936         __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 5, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3937       }
3938       case  2:
3939       values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start);
3940       if (likely(values[2])) kw_args--;
3941       else {
3942         __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 5, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3943       }
3944       case  3:
3945       values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end);
3946       if (likely(values[3])) kw_args--;
3947       else {
3948         __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 5, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3949       }
3950       case  4:
3951       values[4] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__parser);
3952       if (likely(values[4])) kw_args--;
3953       else {
3954         __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 5, 5, 4); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3955       }
3956     }
3957     if (unlikely(kw_args > 0)) {
3958       if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3959     }
3960     __pyx_v_tabixfile = ((struct __pyx_obj_6ctabix_Tabixfile *)values[0]);
3961     __pyx_v_tid = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_tid == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3962     __pyx_v_start = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_start == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3963     __pyx_v_end = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_end == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 318; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3964     __pyx_v_parser = ((struct __pyx_obj_6ctabix_Parser *)values[4]);
3965   } else if (PyTuple_GET_SIZE(__pyx_args) != 5) {
3966     goto __pyx_L5_argtuple_error;
3967   } else {
3968     __pyx_v_tabixfile = ((struct __pyx_obj_6ctabix_Tabixfile *)PyTuple_GET_ITEM(__pyx_args, 0));
3969     __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 = 316; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3970     __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 = 317; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3971     __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 = 318; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3972     __pyx_v_parser = ((struct __pyx_obj_6ctabix_Parser *)PyTuple_GET_ITEM(__pyx_args, 4));
3973   }
3974   goto __pyx_L4_argument_unpacking_done;
3975   __pyx_L5_argtuple_error:;
3976   __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 5, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
3977   __pyx_L3_error:;
3978   __Pyx_AddTraceback("ctabix.TabixIteratorParsed.__cinit__");
3979   __Pyx_RefNannyFinishContext();
3980   return -1;
3981   __pyx_L4_argument_unpacking_done:;
3982   if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_tabixfile), __pyx_ptype_6ctabix_Tabixfile, 1, "tabixfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3983   if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parser), __pyx_ptype_6ctabix_Parser, 1, "parser", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3984
3985   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":321
3986  *                   Parser parser ):
3987  * 
3988  *         assert tabixfile._isOpen()             # <<<<<<<<<<<<<<
3989  *         self.parser = parser
3990  * 
3991  */
3992   #ifndef PYREX_WITHOUT_ASSERTIONS
3993   __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_tabixfile), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3994   __Pyx_GOTREF(__pyx_t_1);
3995   __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 = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3996   __Pyx_GOTREF(__pyx_t_2);
3997   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3998   __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
3999   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4000   if (unlikely(!__pyx_t_3)) {
4001     PyErr_SetNone(PyExc_AssertionError);
4002     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4003   }
4004   #endif
4005
4006   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":322
4007  * 
4008  *         assert tabixfile._isOpen()
4009  *         self.parser = parser             # <<<<<<<<<<<<<<
4010  * 
4011  *         # makes sure that samfile stays alive as long as the
4012  */
4013   __Pyx_INCREF(((PyObject *)__pyx_v_parser));
4014   __Pyx_GIVEREF(((PyObject *)__pyx_v_parser));
4015   __Pyx_GOTREF(((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->parser);
4016   __Pyx_DECREF(((PyObject *)((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->parser));
4017   ((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->parser = __pyx_v_parser;
4018
4019   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":326
4020  *         # makes sure that samfile stays alive as long as the
4021  *         # iterator is alive.
4022  *         self.tabixfile = tabixfile.tabixfile             # <<<<<<<<<<<<<<
4023  * 
4024  *         if tid < 0:
4025  */
4026   ((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->tabixfile = __pyx_v_tabixfile->tabixfile;
4027
4028   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":328
4029  *         self.tabixfile = tabixfile.tabixfile
4030  * 
4031  *         if tid < 0:             # <<<<<<<<<<<<<<
4032  *             # seek to start of file to ensure iteration is over
4033  *             # all entries.
4034  */
4035   __pyx_t_3 = (__pyx_v_tid < 0);
4036   if (__pyx_t_3) {
4037
4038     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":331
4039  *             # seek to start of file to ensure iteration is over
4040  *             # all entries.
4041  *             bgzf_seek( self.tabixfile.fp, 0, 0)             # <<<<<<<<<<<<<<
4042  *             self.iterator = ti_iter_first()
4043  *         else:
4044  */
4045     bgzf_seek(((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->tabixfile->fp, 0, 0);
4046
4047     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":332
4048  *             # all entries.
4049  *             bgzf_seek( self.tabixfile.fp, 0, 0)
4050  *             self.iterator = ti_iter_first()             # <<<<<<<<<<<<<<
4051  *         else:
4052  *             self.iterator = ti_queryi(self.tabixfile, tid, start, end)
4053  */
4054     ((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->iterator = ti_iter_first();
4055     goto __pyx_L6;
4056   }
4057   /*else*/ {
4058
4059     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":334
4060  *             self.iterator = ti_iter_first()
4061  *         else:
4062  *             self.iterator = ti_queryi(self.tabixfile, tid, start, end)             # <<<<<<<<<<<<<<
4063  * 
4064  *         if <void*>self.iterator == NULL:
4065  */
4066     ((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->iterator = ti_queryi(((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->tabixfile, __pyx_v_tid, __pyx_v_start, __pyx_v_end);
4067   }
4068   __pyx_L6:;
4069
4070   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":336
4071  *             self.iterator = ti_queryi(self.tabixfile, tid, start, end)
4072  * 
4073  *         if <void*>self.iterator == NULL:             # <<<<<<<<<<<<<<
4074  *             raise ValueError("malformatted query or wrong sequence name.\n")
4075  * 
4076  */
4077   __pyx_t_3 = (((void *)((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->iterator) == NULL);
4078   if (__pyx_t_3) {
4079
4080     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":337
4081  * 
4082  *         if <void*>self.iterator == NULL:
4083  *             raise ValueError("malformatted query or wrong sequence name.\n")             # <<<<<<<<<<<<<<
4084  * 
4085  *     def __iter__(self):
4086  */
4087     __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4088     __Pyx_GOTREF(__pyx_t_2);
4089     __Pyx_INCREF(((PyObject *)__pyx_kp_s_12));
4090     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_12));
4091     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_12));
4092     __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4093     __Pyx_GOTREF(__pyx_t_1);
4094     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4095     __Pyx_Raise(__pyx_t_1, 0, 0);
4096     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4097     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4098     goto __pyx_L7;
4099   }
4100   __pyx_L7:;
4101
4102   __pyx_r = 0;
4103   goto __pyx_L0;
4104   __pyx_L1_error:;
4105   __Pyx_XDECREF(__pyx_t_1);
4106   __Pyx_XDECREF(__pyx_t_2);
4107   __Pyx_AddTraceback("ctabix.TabixIteratorParsed.__cinit__");
4108   __pyx_r = -1;
4109   __pyx_L0:;
4110   __Pyx_RefNannyFinishContext();
4111   return __pyx_r;
4112 }
4113
4114 /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":339
4115  *             raise ValueError("malformatted query or wrong sequence name.\n")
4116  * 
4117  *     def __iter__(self):             # <<<<<<<<<<<<<<
4118  *         return self
4119  * 
4120  */
4121
4122 static PyObject *__pyx_pf_6ctabix_19TabixIteratorParsed___iter__(PyObject *__pyx_v_self); /*proto*/
4123 static PyObject *__pyx_pf_6ctabix_19TabixIteratorParsed___iter__(PyObject *__pyx_v_self) {
4124   PyObject *__pyx_r = NULL;
4125   __Pyx_RefNannySetupContext("__iter__");
4126
4127   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":340
4128  * 
4129  *     def __iter__(self):
4130  *         return self             # <<<<<<<<<<<<<<
4131  * 
4132  *     def __next__(self):
4133  */
4134   __Pyx_XDECREF(__pyx_r);
4135   __Pyx_INCREF(__pyx_v_self);
4136   __pyx_r = __pyx_v_self;
4137   goto __pyx_L0;
4138
4139   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
4140   __pyx_L0:;
4141   __Pyx_XGIVEREF(__pyx_r);
4142   __Pyx_RefNannyFinishContext();
4143   return __pyx_r;
4144 }
4145
4146 /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":342
4147  *         return self
4148  * 
4149  *     def __next__(self):             # <<<<<<<<<<<<<<
4150  *         """python version of next().
4151  * 
4152  */
4153
4154 static PyObject *__pyx_pf_6ctabix_19TabixIteratorParsed___next__(PyObject *__pyx_v_self); /*proto*/
4155 static char __pyx_doc_6ctabix_19TabixIteratorParsed___next__[] = "python version of next().\n\n        pyrex uses this non-standard name instead of next()\n        ";
4156 struct wrapperbase __pyx_wrapperbase_6ctabix_19TabixIteratorParsed___next__;
4157 static PyObject *__pyx_pf_6ctabix_19TabixIteratorParsed___next__(PyObject *__pyx_v_self) {
4158   char *__pyx_v_s;
4159   int __pyx_v_len;
4160   PyObject *__pyx_r = NULL;
4161   int __pyx_t_1;
4162   PyObject *__pyx_t_2 = NULL;
4163   PyObject *__pyx_t_3 = NULL;
4164   PyObject *__pyx_t_4 = NULL;
4165   __Pyx_RefNannySetupContext("__next__");
4166
4167   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":350
4168  *         cdef char * s
4169  *         cdef int len
4170  *         while 1:             # <<<<<<<<<<<<<<
4171  *             s = ti_read(self.tabixfile, self.iterator, &len)
4172  *             if s == NULL: raise StopIteration
4173  */
4174   while (1) {
4175     if (!1) break;
4176
4177     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":351
4178  *         cdef int len
4179  *         while 1:
4180  *             s = ti_read(self.tabixfile, self.iterator, &len)             # <<<<<<<<<<<<<<
4181  *             if s == NULL: raise StopIteration
4182  *             # todo: read metachar from configuration
4183  */
4184     __pyx_v_s = ti_read(((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->tabixfile, ((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->iterator, (&__pyx_v_len));
4185
4186     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":352
4187  *         while 1:
4188  *             s = ti_read(self.tabixfile, self.iterator, &len)
4189  *             if s == NULL: raise StopIteration             # <<<<<<<<<<<<<<
4190  *             # todo: read metachar from configuration
4191  *             if s[0] != '#': break
4192  */
4193     __pyx_t_1 = (__pyx_v_s == NULL);
4194     if (__pyx_t_1) {
4195       __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0);
4196       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4197       goto __pyx_L7;
4198     }
4199     __pyx_L7:;
4200
4201     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":354
4202  *             if s == NULL: raise StopIteration
4203  *             # todo: read metachar from configuration
4204  *             if s[0] != '#': break             # <<<<<<<<<<<<<<
4205  * 
4206  *         return self.parser(s, len)
4207  */
4208     __pyx_t_1 = ((__pyx_v_s[0]) != '#');
4209     if (__pyx_t_1) {
4210       goto __pyx_L6_break;
4211       goto __pyx_L8;
4212     }
4213     __pyx_L8:;
4214   }
4215   __pyx_L6_break:;
4216
4217   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":356
4218  *             if s[0] != '#': break
4219  * 
4220  *         return self.parser(s, len)             # <<<<<<<<<<<<<<
4221  * 
4222  *     def __dealloc__(self):
4223  */
4224   __Pyx_XDECREF(__pyx_r);
4225   __pyx_t_2 = PyBytes_FromString(__pyx_v_s); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4226   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
4227   __pyx_t_3 = PyInt_FromLong(__pyx_v_len); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4228   __Pyx_GOTREF(__pyx_t_3);
4229   __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4230   __Pyx_GOTREF(__pyx_t_4);
4231   PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_2));
4232   __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
4233   PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3);
4234   __Pyx_GIVEREF(__pyx_t_3);
4235   __pyx_t_2 = 0;
4236   __pyx_t_3 = 0;
4237   __pyx_t_3 = PyObject_Call(((PyObject *)((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->parser), __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4238   __Pyx_GOTREF(__pyx_t_3);
4239   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4240   __pyx_r = __pyx_t_3;
4241   __pyx_t_3 = 0;
4242   goto __pyx_L0;
4243
4244   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
4245   goto __pyx_L0;
4246   __pyx_L1_error:;
4247   __Pyx_XDECREF(__pyx_t_2);
4248   __Pyx_XDECREF(__pyx_t_3);
4249   __Pyx_XDECREF(__pyx_t_4);
4250   __Pyx_AddTraceback("ctabix.TabixIteratorParsed.__next__");
4251   __pyx_r = NULL;
4252   __pyx_L0:;
4253   __Pyx_XGIVEREF(__pyx_r);
4254   __Pyx_RefNannyFinishContext();
4255   return __pyx_r;
4256 }
4257
4258 /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":358
4259  *         return self.parser(s, len)
4260  * 
4261  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
4262  *         if <void*>self.iterator != NULL:
4263  *             ti_iter_destroy(self.iterator)
4264  */
4265
4266 static void __pyx_pf_6ctabix_19TabixIteratorParsed___dealloc__(PyObject *__pyx_v_self); /*proto*/
4267 static void __pyx_pf_6ctabix_19TabixIteratorParsed___dealloc__(PyObject *__pyx_v_self) {
4268   int __pyx_t_1;
4269   __Pyx_RefNannySetupContext("__dealloc__");
4270
4271   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":359
4272  * 
4273  *     def __dealloc__(self):
4274  *         if <void*>self.iterator != NULL:             # <<<<<<<<<<<<<<
4275  *             ti_iter_destroy(self.iterator)
4276  * 
4277  */
4278   __pyx_t_1 = (((void *)((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->iterator) != NULL);
4279   if (__pyx_t_1) {
4280
4281     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":360
4282  *     def __dealloc__(self):
4283  *         if <void*>self.iterator != NULL:
4284  *             ti_iter_destroy(self.iterator)             # <<<<<<<<<<<<<<
4285  * 
4286  * def tabix_compress( filename_in,
4287  */
4288     ti_iter_destroy(((struct __pyx_obj_6ctabix_TabixIteratorParsed *)__pyx_v_self)->iterator);
4289     goto __pyx_L5;
4290   }
4291   __pyx_L5:;
4292
4293   __Pyx_RefNannyFinishContext();
4294 }
4295
4296 /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":362
4297  *             ti_iter_destroy(self.iterator)
4298  * 
4299  * def tabix_compress( filename_in,             # <<<<<<<<<<<<<<
4300  *               filename_out,
4301  *               force = False ):
4302  */
4303
4304 static PyObject *__pyx_pf_6ctabix_tabix_compress(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
4305 static char __pyx_doc_6ctabix_tabix_compress[] = "tabix_compress(filename_in, filename_out, force=False)\n\n    compress *filename_in* writing the output to *filename_out*.\n    \n    Raise an IOError if *filename_out* already exists, unless *force* is set.\n    ";
4306 static PyObject *__pyx_pf_6ctabix_tabix_compress(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
4307   PyObject *__pyx_v_filename_in = 0;
4308   PyObject *__pyx_v_filename_out = 0;
4309   PyObject *__pyx_v_force = 0;
4310   int __pyx_v_WINDOW_SIZE;
4311   int __pyx_v_c;
4312   int __pyx_v_r;
4313   void *__pyx_v_buffer;
4314   BGZF *__pyx_v_fp;
4315   int __pyx_v_fd_src;
4316   int __pyx_v_O_RDONLY;
4317   PyObject *__pyx_r = NULL;
4318   int __pyx_t_1;
4319   int __pyx_t_2;
4320   PyObject *__pyx_t_3 = NULL;
4321   PyObject *__pyx_t_4 = NULL;
4322   PyObject *__pyx_t_5 = NULL;
4323   int __pyx_t_6;
4324   int __pyx_t_7;
4325   char *__pyx_t_8;
4326   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__filename_in,&__pyx_n_s__filename_out,&__pyx_n_s__force,0};
4327   __Pyx_RefNannySetupContext("tabix_compress");
4328   __pyx_self = __pyx_self;
4329   if (unlikely(__pyx_kwds)) {
4330     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
4331     PyObject* values[3] = {0,0,0};
4332     values[2] = __pyx_k_14;
4333     switch (PyTuple_GET_SIZE(__pyx_args)) {
4334       case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
4335       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
4336       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4337       case  0: break;
4338       default: goto __pyx_L5_argtuple_error;
4339     }
4340     switch (PyTuple_GET_SIZE(__pyx_args)) {
4341       case  0:
4342       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filename_in);
4343       if (likely(values[0])) kw_args--;
4344       else goto __pyx_L5_argtuple_error;
4345       case  1:
4346       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filename_out);
4347       if (likely(values[1])) kw_args--;
4348       else {
4349         __Pyx_RaiseArgtupleInvalid("tabix_compress", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
4350       }
4351       case  2:
4352       if (kw_args > 0) {
4353         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__force);
4354         if (value) { values[2] = value; kw_args--; }
4355       }
4356     }
4357     if (unlikely(kw_args > 0)) {
4358       if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "tabix_compress") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
4359     }
4360     __pyx_v_filename_in = values[0];
4361     __pyx_v_filename_out = values[1];
4362     __pyx_v_force = values[2];
4363   } else {
4364     __pyx_v_force = __pyx_k_14;
4365     switch (PyTuple_GET_SIZE(__pyx_args)) {
4366       case  3:
4367       __pyx_v_force = PyTuple_GET_ITEM(__pyx_args, 2);
4368       case  2:
4369       __pyx_v_filename_out = PyTuple_GET_ITEM(__pyx_args, 1);
4370       __pyx_v_filename_in = PyTuple_GET_ITEM(__pyx_args, 0);
4371       break;
4372       default: goto __pyx_L5_argtuple_error;
4373     }
4374   }
4375   goto __pyx_L4_argument_unpacking_done;
4376   __pyx_L5_argtuple_error:;
4377   __Pyx_RaiseArgtupleInvalid("tabix_compress", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 362; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
4378   __pyx_L3_error:;
4379   __Pyx_AddTraceback("ctabix.tabix_compress");
4380   __Pyx_RefNannyFinishContext();
4381   return NULL;
4382   __pyx_L4_argument_unpacking_done:;
4383
4384   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":372
4385  *     '''
4386  * 
4387  *     if not force and os.path.exists(filename_out ):             # <<<<<<<<<<<<<<
4388  *         raise IOError( "Filename '%s' already exists, use *force* to overwrite" % filename_out)
4389  * 
4390  */
4391   __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_force); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4392   __pyx_t_2 = (!__pyx_t_1);
4393   if (__pyx_t_2) {
4394     __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4395     __Pyx_GOTREF(__pyx_t_3);
4396     __pyx_t_4 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__path); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4397     __Pyx_GOTREF(__pyx_t_4);
4398     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4399     __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__exists); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4400     __Pyx_GOTREF(__pyx_t_3);
4401     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4402     __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4403     __Pyx_GOTREF(__pyx_t_4);
4404     __Pyx_INCREF(__pyx_v_filename_out);
4405     PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_filename_out);
4406     __Pyx_GIVEREF(__pyx_v_filename_out);
4407     __pyx_t_5 = PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4408     __Pyx_GOTREF(__pyx_t_5);
4409     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4410     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4411     __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4412     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
4413     __pyx_t_6 = __pyx_t_1;
4414   } else {
4415     __pyx_t_6 = __pyx_t_2;
4416   }
4417   if (__pyx_t_6) {
4418
4419     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":373
4420  * 
4421  *     if not force and os.path.exists(filename_out ):
4422  *         raise IOError( "Filename '%s' already exists, use *force* to overwrite" % filename_out)             # <<<<<<<<<<<<<<
4423  * 
4424  *     cdef int WINDOW_SIZE
4425  */
4426     __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_15), __pyx_v_filename_out); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4427     __Pyx_GOTREF(((PyObject *)__pyx_t_5));
4428     __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4429     __Pyx_GOTREF(__pyx_t_4);
4430     PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_5));
4431     __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
4432     __pyx_t_5 = 0;
4433     __pyx_t_5 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4434     __Pyx_GOTREF(__pyx_t_5);
4435     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4436     __Pyx_Raise(__pyx_t_5, 0, 0);
4437     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
4438     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4439     goto __pyx_L6;
4440   }
4441   __pyx_L6:;
4442
4443   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":382
4444  * 
4445  *     cdef int O_RDONLY
4446  *     O_RDONLY = os.O_RDONLY             # <<<<<<<<<<<<<<
4447  * 
4448  *     WINDOW_SIZE = 64 * 1024
4449  */
4450   __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4451   __Pyx_GOTREF(__pyx_t_5);
4452   __pyx_t_4 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__O_RDONLY); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4453   __Pyx_GOTREF(__pyx_t_4);
4454   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
4455   __pyx_t_7 = __Pyx_PyInt_AsInt(__pyx_t_4); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4456   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4457   __pyx_v_O_RDONLY = __pyx_t_7;
4458
4459   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":384
4460  *     O_RDONLY = os.O_RDONLY
4461  * 
4462  *     WINDOW_SIZE = 64 * 1024             # <<<<<<<<<<<<<<
4463  * 
4464  *     fp = bgzf_open( filename_out, "w")
4465  */
4466   __pyx_v_WINDOW_SIZE = 65536;
4467
4468   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":386
4469  *     WINDOW_SIZE = 64 * 1024
4470  * 
4471  *     fp = bgzf_open( filename_out, "w")             # <<<<<<<<<<<<<<
4472  *     if fp == NULL:
4473  *         raise IOError( "could not open '%s' for writing" )
4474  */
4475   __pyx_t_8 = PyBytes_AsString(__pyx_v_filename_out); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4476   __pyx_v_fp = bgzf_open(__pyx_t_8, __pyx_k__w);
4477
4478   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":387
4479  * 
4480  *     fp = bgzf_open( filename_out, "w")
4481  *     if fp == NULL:             # <<<<<<<<<<<<<<
4482  *         raise IOError( "could not open '%s' for writing" )
4483  * 
4484  */
4485   __pyx_t_6 = (__pyx_v_fp == NULL);
4486   if (__pyx_t_6) {
4487
4488     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":388
4489  *     fp = bgzf_open( filename_out, "w")
4490  *     if fp == NULL:
4491  *         raise IOError( "could not open '%s' for writing" )             # <<<<<<<<<<<<<<
4492  * 
4493  *     fd_src = open(filename_in, O_RDONLY)
4494  */
4495     __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4496     __Pyx_GOTREF(__pyx_t_4);
4497     __Pyx_INCREF(((PyObject *)__pyx_kp_s_16));
4498     PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_16));
4499     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_16));
4500     __pyx_t_5 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4501     __Pyx_GOTREF(__pyx_t_5);
4502     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4503     __Pyx_Raise(__pyx_t_5, 0, 0);
4504     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
4505     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4506     goto __pyx_L7;
4507   }
4508   __pyx_L7:;
4509
4510   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":390
4511  *         raise IOError( "could not open '%s' for writing" )
4512  * 
4513  *     fd_src = open(filename_in, O_RDONLY)             # <<<<<<<<<<<<<<
4514  *     if fd_src == 0:
4515  *         raise IOError( "could not open '%s' for reading" )
4516  */
4517   __pyx_t_8 = PyBytes_AsString(__pyx_v_filename_in); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4518   __pyx_v_fd_src = open(__pyx_t_8, __pyx_v_O_RDONLY);
4519
4520   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":391
4521  * 
4522  *     fd_src = open(filename_in, O_RDONLY)
4523  *     if fd_src == 0:             # <<<<<<<<<<<<<<
4524  *         raise IOError( "could not open '%s' for reading" )
4525  * 
4526  */
4527   __pyx_t_6 = (__pyx_v_fd_src == 0);
4528   if (__pyx_t_6) {
4529
4530     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":392
4531  *     fd_src = open(filename_in, O_RDONLY)
4532  *     if fd_src == 0:
4533  *         raise IOError( "could not open '%s' for reading" )             # <<<<<<<<<<<<<<
4534  * 
4535  *     buffer = malloc(WINDOW_SIZE)
4536  */
4537     __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4538     __Pyx_GOTREF(__pyx_t_5);
4539     __Pyx_INCREF(((PyObject *)__pyx_kp_s_17));
4540     PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_17));
4541     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_17));
4542     __pyx_t_4 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4543     __Pyx_GOTREF(__pyx_t_4);
4544     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
4545     __Pyx_Raise(__pyx_t_4, 0, 0);
4546     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4547     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4548     goto __pyx_L8;
4549   }
4550   __pyx_L8:;
4551
4552   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":394
4553  *         raise IOError( "could not open '%s' for reading" )
4554  * 
4555  *     buffer = malloc(WINDOW_SIZE)             # <<<<<<<<<<<<<<
4556  * 
4557  *     while c > 0:
4558  */
4559   __pyx_v_buffer = malloc(__pyx_v_WINDOW_SIZE);
4560
4561   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":396
4562  *     buffer = malloc(WINDOW_SIZE)
4563  * 
4564  *     while c > 0:             # <<<<<<<<<<<<<<
4565  *         c = read(fd_src, buffer, WINDOW_SIZE)
4566  *         r = bgzf_write(fp, buffer, c)
4567  */
4568   while (1) {
4569     __pyx_t_6 = (__pyx_v_c > 0);
4570     if (!__pyx_t_6) break;
4571
4572     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":397
4573  * 
4574  *     while c > 0:
4575  *         c = read(fd_src, buffer, WINDOW_SIZE)             # <<<<<<<<<<<<<<
4576  *         r = bgzf_write(fp, buffer, c)
4577  *         if r < 0:
4578  */
4579     __pyx_v_c = read(__pyx_v_fd_src, __pyx_v_buffer, __pyx_v_WINDOW_SIZE);
4580
4581     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":398
4582  *     while c > 0:
4583  *         c = read(fd_src, buffer, WINDOW_SIZE)
4584  *         r = bgzf_write(fp, buffer, c)             # <<<<<<<<<<<<<<
4585  *         if r < 0:
4586  *             free( buffer )
4587  */
4588     __pyx_v_r = bgzf_write(__pyx_v_fp, __pyx_v_buffer, __pyx_v_c);
4589
4590     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":399
4591  *         c = read(fd_src, buffer, WINDOW_SIZE)
4592  *         r = bgzf_write(fp, buffer, c)
4593  *         if r < 0:             # <<<<<<<<<<<<<<
4594  *             free( buffer )
4595  *             raise OSError("writing failed")
4596  */
4597     __pyx_t_6 = (__pyx_v_r < 0);
4598     if (__pyx_t_6) {
4599
4600       /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":400
4601  *         r = bgzf_write(fp, buffer, c)
4602  *         if r < 0:
4603  *             free( buffer )             # <<<<<<<<<<<<<<
4604  *             raise OSError("writing failed")
4605  * 
4606  */
4607       free(__pyx_v_buffer);
4608
4609       /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":401
4610  *         if r < 0:
4611  *             free( buffer )
4612  *             raise OSError("writing failed")             # <<<<<<<<<<<<<<
4613  * 
4614  *     free( buffer )
4615  */
4616       __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4617       __Pyx_GOTREF(__pyx_t_4);
4618       __Pyx_INCREF(((PyObject *)__pyx_kp_s_18));
4619       PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_kp_s_18));
4620       __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_18));
4621       __pyx_t_5 = PyObject_Call(__pyx_builtin_OSError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4622       __Pyx_GOTREF(__pyx_t_5);
4623       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4624       __Pyx_Raise(__pyx_t_5, 0, 0);
4625       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
4626       {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4627       goto __pyx_L11;
4628     }
4629     __pyx_L11:;
4630   }
4631
4632   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":403
4633  *             raise OSError("writing failed")
4634  * 
4635  *     free( buffer )             # <<<<<<<<<<<<<<
4636  *     r = bgzf_close(fp)
4637  *     if r < 0: raise OSError("writing failed")
4638  */
4639   free(__pyx_v_buffer);
4640
4641   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":404
4642  * 
4643  *     free( buffer )
4644  *     r = bgzf_close(fp)             # <<<<<<<<<<<<<<
4645  *     if r < 0: raise OSError("writing failed")
4646  * 
4647  */
4648   __pyx_v_r = bgzf_close(__pyx_v_fp);
4649
4650   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":405
4651  *     free( buffer )
4652  *     r = bgzf_close(fp)
4653  *     if r < 0: raise OSError("writing failed")             # <<<<<<<<<<<<<<
4654  * 
4655  * def tabix_index( filename,
4656  */
4657   __pyx_t_6 = (__pyx_v_r < 0);
4658   if (__pyx_t_6) {
4659     __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4660     __Pyx_GOTREF(__pyx_t_5);
4661     __Pyx_INCREF(((PyObject *)__pyx_kp_s_18));
4662     PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_kp_s_18));
4663     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_18));
4664     __pyx_t_4 = PyObject_Call(__pyx_builtin_OSError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4665     __Pyx_GOTREF(__pyx_t_4);
4666     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
4667     __Pyx_Raise(__pyx_t_4, 0, 0);
4668     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4669     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4670     goto __pyx_L12;
4671   }
4672   __pyx_L12:;
4673
4674   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
4675   goto __pyx_L0;
4676   __pyx_L1_error:;
4677   __Pyx_XDECREF(__pyx_t_3);
4678   __Pyx_XDECREF(__pyx_t_4);
4679   __Pyx_XDECREF(__pyx_t_5);
4680   __Pyx_AddTraceback("ctabix.tabix_compress");
4681   __pyx_r = NULL;
4682   __pyx_L0:;
4683   __Pyx_XGIVEREF(__pyx_r);
4684   __Pyx_RefNannyFinishContext();
4685   return __pyx_r;
4686 }
4687
4688 /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":407
4689  *     if r < 0: raise OSError("writing failed")
4690  * 
4691  * def tabix_index( filename,             # <<<<<<<<<<<<<<
4692  *                  force = False,
4693  *                  seq_col = None,
4694  */
4695
4696 static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
4697 static char __pyx_doc_6ctabix_tabix_index[] = "tabix_index(filename, force=False, seq_col=None, start_col=None, end_col=None, preset=None, meta_char='#', zerobased=False)\n\n    index tab-separated *filename* using tabix.\n\n    An existing index will not be overwritten unless\n    *force* is set.\n\n    The index will be built from coordinates\n    in columns *seq_col*, *start_col* and *end_col*.\n\n    The contents of *filename* have to be sorted by \n    contig and position - the method does not check\n    if the file is sorted.\n\n    Column indices are 0-based. Coordinates in the file\n    are assumed to be 1-based.\n\n    If *preset* is provided, the column coordinates\n    are taken from a preset. Valid values for preset\n    are \"gff\", \"bed\", \"sam\", \"vcf\", psltbl\", \"pileup\".\n    \n    Lines beginning with *meta_char* and the first\n    *line_skip* lines will be skipped.\n    \n    If *filename* does not end in \".gz\", it will be automatically\n    compressed. The original file will be removed and only the \n    compressed file will be retained. \n\n    If *filename* ends in *gz*, the file is assumed to be already\n    compressed with bgzf.\n\n    returns the filename of the compressed data\n    ";
4698 static PyObject *__pyx_pf_6ctabix_tabix_index(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
4699   PyObject *__pyx_v_filename = 0;
4700   PyObject *__pyx_v_force = 0;
4701   PyObject *__pyx_v_seq_col = 0;
4702   PyObject *__pyx_v_start_col = 0;
4703   PyObject *__pyx_v_end_col = 0;
4704   PyObject *__pyx_v_preset = 0;
4705   PyObject *__pyx_v_meta_char = 0;
4706   PyObject *__pyx_v_zerobased = 0;
4707   PyObject *__pyx_v_preset2conf;
4708   PyObject *__pyx_v_conf_data;
4709   ti_conf_t __pyx_v_conf;
4710   PyObject *__pyx_r = NULL;
4711   PyObject *__pyx_t_1 = NULL;
4712   PyObject *__pyx_t_2 = NULL;
4713   PyObject *__pyx_t_3 = NULL;
4714   int __pyx_t_4;
4715   int __pyx_t_5;
4716   PyObject *__pyx_t_6 = NULL;
4717   int __pyx_t_7;
4718   int __pyx_t_8;
4719   PyObject *__pyx_t_9 = NULL;
4720   PyObject *__pyx_t_10 = NULL;
4721   int32_t __pyx_t_11;
4722   int32_t __pyx_t_12;
4723   int32_t __pyx_t_13;
4724   int32_t __pyx_t_14;
4725   int32_t __pyx_t_15;
4726   int32_t __pyx_t_16;
4727   PyObject *__pyx_t_17 = NULL;
4728   char *__pyx_t_18;
4729   static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__filename,&__pyx_n_s__force,&__pyx_n_s__seq_col,&__pyx_n_s__start_col,&__pyx_n_s__end_col,&__pyx_n_s__preset,&__pyx_n_s__meta_char,&__pyx_n_s__zerobased,0};
4730   __Pyx_RefNannySetupContext("tabix_index");
4731   __pyx_self = __pyx_self;
4732   if (unlikely(__pyx_kwds)) {
4733     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
4734     PyObject* values[8] = {0,0,0,0,0,0,0,0};
4735     values[1] = __pyx_k_19;
4736
4737     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":409
4738  * def tabix_index( filename,
4739  *                  force = False,
4740  *                  seq_col = None,             # <<<<<<<<<<<<<<
4741  *                  start_col = None,
4742  *                  end_col = None,
4743  */
4744     values[2] = ((PyObject *)Py_None);
4745
4746     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":410
4747  *                  force = False,
4748  *                  seq_col = None,
4749  *                  start_col = None,             # <<<<<<<<<<<<<<
4750  *                  end_col = None,
4751  *                  preset = None,
4752  */
4753     values[3] = ((PyObject *)Py_None);
4754
4755     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":411
4756  *                  seq_col = None,
4757  *                  start_col = None,
4758  *                  end_col = None,             # <<<<<<<<<<<<<<
4759  *                  preset = None,
4760  *                  meta_char = "#",
4761  */
4762     values[4] = ((PyObject *)Py_None);
4763
4764     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":412
4765  *                  start_col = None,
4766  *                  end_col = None,
4767  *                  preset = None,             # <<<<<<<<<<<<<<
4768  *                  meta_char = "#",
4769  *                  zerobased = False,
4770  */
4771     values[5] = ((PyObject *)Py_None);
4772     values[6] = ((PyObject *)__pyx_kp_s_20);
4773     values[7] = __pyx_k_21;
4774     switch (PyTuple_GET_SIZE(__pyx_args)) {
4775       case  8: values[7] = PyTuple_GET_ITEM(__pyx_args, 7);
4776       case  7: values[6] = PyTuple_GET_ITEM(__pyx_args, 6);
4777       case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
4778       case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
4779       case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
4780       case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
4781       case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
4782       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4783       case  0: break;
4784       default: goto __pyx_L5_argtuple_error;
4785     }
4786     switch (PyTuple_GET_SIZE(__pyx_args)) {
4787       case  0:
4788       values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filename);
4789       if (likely(values[0])) kw_args--;
4790       else goto __pyx_L5_argtuple_error;
4791       case  1:
4792       if (kw_args > 0) {
4793         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__force);
4794         if (value) { values[1] = value; kw_args--; }
4795       }
4796       case  2:
4797       if (kw_args > 0) {
4798         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__seq_col);
4799         if (value) { values[2] = value; kw_args--; }
4800       }
4801       case  3:
4802       if (kw_args > 0) {
4803         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start_col);
4804         if (value) { values[3] = value; kw_args--; }
4805       }
4806       case  4:
4807       if (kw_args > 0) {
4808         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end_col);
4809         if (value) { values[4] = value; kw_args--; }
4810       }
4811       case  5:
4812       if (kw_args > 0) {
4813         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__preset);
4814         if (value) { values[5] = value; kw_args--; }
4815       }
4816       case  6:
4817       if (kw_args > 0) {
4818         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__meta_char);
4819         if (value) { values[6] = value; kw_args--; }
4820       }
4821       case  7:
4822       if (kw_args > 0) {
4823         PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s__zerobased);
4824         if (value) { values[7] = value; kw_args--; }
4825       }
4826     }
4827     if (unlikely(kw_args > 0)) {
4828       if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "tabix_index") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
4829     }
4830     __pyx_v_filename = values[0];
4831     __pyx_v_force = values[1];
4832     __pyx_v_seq_col = values[2];
4833     __pyx_v_start_col = values[3];
4834     __pyx_v_end_col = values[4];
4835     __pyx_v_preset = values[5];
4836     __pyx_v_meta_char = values[6];
4837     __pyx_v_zerobased = values[7];
4838   } else {
4839     __pyx_v_force = __pyx_k_19;
4840
4841     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":409
4842  * def tabix_index( filename,
4843  *                  force = False,
4844  *                  seq_col = None,             # <<<<<<<<<<<<<<
4845  *                  start_col = None,
4846  *                  end_col = None,
4847  */
4848     __pyx_v_seq_col = ((PyObject *)Py_None);
4849
4850     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":410
4851  *                  force = False,
4852  *                  seq_col = None,
4853  *                  start_col = None,             # <<<<<<<<<<<<<<
4854  *                  end_col = None,
4855  *                  preset = None,
4856  */
4857     __pyx_v_start_col = ((PyObject *)Py_None);
4858
4859     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":411
4860  *                  seq_col = None,
4861  *                  start_col = None,
4862  *                  end_col = None,             # <<<<<<<<<<<<<<
4863  *                  preset = None,
4864  *                  meta_char = "#",
4865  */
4866     __pyx_v_end_col = ((PyObject *)Py_None);
4867
4868     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":412
4869  *                  start_col = None,
4870  *                  end_col = None,
4871  *                  preset = None,             # <<<<<<<<<<<<<<
4872  *                  meta_char = "#",
4873  *                  zerobased = False,
4874  */
4875     __pyx_v_preset = ((PyObject *)Py_None);
4876     __pyx_v_meta_char = ((PyObject *)__pyx_kp_s_20);
4877     __pyx_v_zerobased = __pyx_k_21;
4878     switch (PyTuple_GET_SIZE(__pyx_args)) {
4879       case  8: __pyx_v_zerobased = PyTuple_GET_ITEM(__pyx_args, 7);
4880       case  7: __pyx_v_meta_char = PyTuple_GET_ITEM(__pyx_args, 6);
4881       case  6: __pyx_v_preset = PyTuple_GET_ITEM(__pyx_args, 5);
4882       case  5: __pyx_v_end_col = PyTuple_GET_ITEM(__pyx_args, 4);
4883       case  4: __pyx_v_start_col = PyTuple_GET_ITEM(__pyx_args, 3);
4884       case  3: __pyx_v_seq_col = PyTuple_GET_ITEM(__pyx_args, 2);
4885       case  2: __pyx_v_force = PyTuple_GET_ITEM(__pyx_args, 1);
4886       case  1: __pyx_v_filename = PyTuple_GET_ITEM(__pyx_args, 0);
4887       break;
4888       default: goto __pyx_L5_argtuple_error;
4889     }
4890   }
4891   goto __pyx_L4_argument_unpacking_done;
4892   __pyx_L5_argtuple_error:;
4893   __Pyx_RaiseArgtupleInvalid("tabix_index", 0, 1, 8, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
4894   __pyx_L3_error:;
4895   __Pyx_AddTraceback("ctabix.tabix_index");
4896   __Pyx_RefNannyFinishContext();
4897   return NULL;
4898   __pyx_L4_argument_unpacking_done:;
4899   __Pyx_INCREF(__pyx_v_filename);
4900   __Pyx_INCREF(__pyx_v_end_col);
4901   __Pyx_INCREF(__pyx_v_preset);
4902   __pyx_v_preset2conf = ((PyObject *)Py_None); __Pyx_INCREF(Py_None);
4903   __pyx_v_conf_data = Py_None; __Pyx_INCREF(Py_None);
4904
4905   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":449
4906  *     '''
4907  * 
4908  *     if not os.path.exists(filename): raise IOError("No such file '%s'" % filename)             # <<<<<<<<<<<<<<
4909  * 
4910  *     if not filename.endswith(".gz"):
4911  */
4912   __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4913   __Pyx_GOTREF(__pyx_t_1);
4914   __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__path); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4915   __Pyx_GOTREF(__pyx_t_2);
4916   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4917   __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__exists); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4918   __Pyx_GOTREF(__pyx_t_1);
4919   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4920   __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4921   __Pyx_GOTREF(__pyx_t_2);
4922   __Pyx_INCREF(__pyx_v_filename);
4923   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_filename);
4924   __Pyx_GIVEREF(__pyx_v_filename);
4925   __pyx_t_3 = PyObject_Call(__pyx_t_1, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4926   __Pyx_GOTREF(__pyx_t_3);
4927   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4928   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4929   __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4930   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4931   __pyx_t_5 = (!__pyx_t_4);
4932   if (__pyx_t_5) {
4933     __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_22), __pyx_v_filename); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4934     __Pyx_GOTREF(((PyObject *)__pyx_t_3));
4935     __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4936     __Pyx_GOTREF(__pyx_t_2);
4937     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_3));
4938     __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
4939     __pyx_t_3 = 0;
4940     __pyx_t_3 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_2, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4941     __Pyx_GOTREF(__pyx_t_3);
4942     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4943     __Pyx_Raise(__pyx_t_3, 0, 0);
4944     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4945     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4946     goto __pyx_L6;
4947   }
4948   __pyx_L6:;
4949
4950   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":451
4951  *     if not os.path.exists(filename): raise IOError("No such file '%s'" % filename)
4952  * 
4953  *     if not filename.endswith(".gz"):             # <<<<<<<<<<<<<<
4954  * 
4955  *         tabix_compress( filename, filename + ".gz", force = force )
4956  */
4957   __pyx_t_3 = PyObject_GetAttr(__pyx_v_filename, __pyx_n_s__endswith); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4958   __Pyx_GOTREF(__pyx_t_3);
4959   __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4960   __Pyx_GOTREF(__pyx_t_2);
4961   __Pyx_INCREF(((PyObject *)__pyx_kp_s_23));
4962   PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_23));
4963   __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_23));
4964   __pyx_t_1 = PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4965   __Pyx_GOTREF(__pyx_t_1);
4966   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4967   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4968   __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4969   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4970   __pyx_t_4 = (!__pyx_t_5);
4971   if (__pyx_t_4) {
4972
4973     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":453
4974  *     if not filename.endswith(".gz"):
4975  * 
4976  *         tabix_compress( filename, filename + ".gz", force = force )             # <<<<<<<<<<<<<<
4977  *         os.unlink( filename )
4978  *         filename += ".gz"
4979  */
4980     __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__tabix_compress); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4981     __Pyx_GOTREF(__pyx_t_1);
4982     __pyx_t_2 = PyNumber_Add(__pyx_v_filename, ((PyObject *)__pyx_kp_s_23)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4983     __Pyx_GOTREF(__pyx_t_2);
4984     __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4985     __Pyx_GOTREF(__pyx_t_3);
4986     __Pyx_INCREF(__pyx_v_filename);
4987     PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_filename);
4988     __Pyx_GIVEREF(__pyx_v_filename);
4989     PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
4990     __Pyx_GIVEREF(__pyx_t_2);
4991     __pyx_t_2 = 0;
4992     __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4993     __Pyx_GOTREF(((PyObject *)__pyx_t_2));
4994     if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__force), __pyx_v_force) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4995     __pyx_t_6 = PyEval_CallObjectWithKeywords(__pyx_t_1, __pyx_t_3, ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
4996     __Pyx_GOTREF(__pyx_t_6);
4997     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4998     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4999     __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
5000     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5001
5002     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":454
5003  * 
5004  *         tabix_compress( filename, filename + ".gz", force = force )
5005  *         os.unlink( filename )             # <<<<<<<<<<<<<<
5006  *         filename += ".gz"
5007  * 
5008  */
5009     __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5010     __Pyx_GOTREF(__pyx_t_6);
5011     __pyx_t_2 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__unlink); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5012     __Pyx_GOTREF(__pyx_t_2);
5013     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5014     __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5015     __Pyx_GOTREF(__pyx_t_6);
5016     __Pyx_INCREF(__pyx_v_filename);
5017     PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_filename);
5018     __Pyx_GIVEREF(__pyx_v_filename);
5019     __pyx_t_3 = PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5020     __Pyx_GOTREF(__pyx_t_3);
5021     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5022     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5023     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5024
5025     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":455
5026  *         tabix_compress( filename, filename + ".gz", force = force )
5027  *         os.unlink( filename )
5028  *         filename += ".gz"             # <<<<<<<<<<<<<<
5029  * 
5030  *     if not force and os.path.exists(filename + ".tbi" ):
5031  */
5032     __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_filename, ((PyObject *)__pyx_kp_s_23)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5033     __Pyx_GOTREF(__pyx_t_3);
5034     __Pyx_DECREF(__pyx_v_filename);
5035     __pyx_v_filename = __pyx_t_3;
5036     __pyx_t_3 = 0;
5037     goto __pyx_L7;
5038   }
5039   __pyx_L7:;
5040
5041   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":457
5042  *         filename += ".gz"
5043  * 
5044  *     if not force and os.path.exists(filename + ".tbi" ):             # <<<<<<<<<<<<<<
5045  *         raise IOError( "Filename '%s.tbi' already exists, use *force* to overwrite" )
5046  * 
5047  */
5048   __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_force); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5049   __pyx_t_5 = (!__pyx_t_4);
5050   if (__pyx_t_5) {
5051     __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5052     __Pyx_GOTREF(__pyx_t_3);
5053     __pyx_t_6 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__path); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5054     __Pyx_GOTREF(__pyx_t_6);
5055     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5056     __pyx_t_3 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__exists); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5057     __Pyx_GOTREF(__pyx_t_3);
5058     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5059     __pyx_t_6 = PyNumber_Add(__pyx_v_filename, ((PyObject *)__pyx_kp_s_2)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5060     __Pyx_GOTREF(__pyx_t_6);
5061     __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5062     __Pyx_GOTREF(__pyx_t_2);
5063     PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6);
5064     __Pyx_GIVEREF(__pyx_t_6);
5065     __pyx_t_6 = 0;
5066     __pyx_t_6 = PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5067     __Pyx_GOTREF(__pyx_t_6);
5068     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5069     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5070     __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5071     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5072     __pyx_t_7 = __pyx_t_4;
5073   } else {
5074     __pyx_t_7 = __pyx_t_5;
5075   }
5076   if (__pyx_t_7) {
5077
5078     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":458
5079  * 
5080  *     if not force and os.path.exists(filename + ".tbi" ):
5081  *         raise IOError( "Filename '%s.tbi' already exists, use *force* to overwrite" )             # <<<<<<<<<<<<<<
5082  * 
5083  *     # columns (1-based)
5084  */
5085     __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5086     __Pyx_GOTREF(__pyx_t_6);
5087     __Pyx_INCREF(((PyObject *)__pyx_kp_s_24));
5088     PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_24));
5089     __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_24));
5090     __pyx_t_2 = PyObject_Call(__pyx_builtin_IOError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5091     __Pyx_GOTREF(__pyx_t_2);
5092     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5093     __Pyx_Raise(__pyx_t_2, 0, 0);
5094     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5095     {__pyx_filename = __pyx_f[0]; __pyx_lineno = 458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5096     goto __pyx_L8;
5097   }
5098   __pyx_L8:;
5099
5100   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":463
5101  *     # preset-code, contig, start, end, metachar for commends, lines to ignore at beginning
5102  *     # 0 is a missing column
5103  *     preset2conf = {             # <<<<<<<<<<<<<<
5104  *         'gff' : ( 0, 1, 4, 5, ord('#'), 0 ),
5105  *         'bed' : ( 0x10000, 1, 2, 3, ord('#'), 0 ),
5106  */
5107   __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5108   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
5109
5110   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":464
5111  *     # 0 is a missing column
5112  *     preset2conf = {
5113  *         'gff' : ( 0, 1, 4, 5, ord('#'), 0 ),             # <<<<<<<<<<<<<<
5114  *         'bed' : ( 0x10000, 1, 2, 3, ord('#'), 0 ),
5115  *         'psltbl' : ( 0x10000, 15, 17, 18, ord('#'), 0 ),
5116  */
5117   __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5118   __Pyx_GOTREF(__pyx_t_6);
5119   __Pyx_INCREF(((PyObject *)__pyx_kp_s_20));
5120   PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_20));
5121   __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_20));
5122   __pyx_t_3 = PyObject_Call(__pyx_builtin_ord, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5123   __Pyx_GOTREF(__pyx_t_3);
5124   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5125   __pyx_t_6 = PyTuple_New(6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5126   __Pyx_GOTREF(__pyx_t_6);
5127   __Pyx_INCREF(__pyx_int_0);
5128   PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_int_0);
5129   __Pyx_GIVEREF(__pyx_int_0);
5130   __Pyx_INCREF(__pyx_int_1);
5131   PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_1);
5132   __Pyx_GIVEREF(__pyx_int_1);
5133   __Pyx_INCREF(__pyx_int_4);
5134   PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_int_4);
5135   __Pyx_GIVEREF(__pyx_int_4);
5136   __Pyx_INCREF(__pyx_int_5);
5137   PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_int_5);
5138   __Pyx_GIVEREF(__pyx_int_5);
5139   PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_t_3);
5140   __Pyx_GIVEREF(__pyx_t_3);
5141   __Pyx_INCREF(__pyx_int_0);
5142   PyTuple_SET_ITEM(__pyx_t_6, 5, __pyx_int_0);
5143   __Pyx_GIVEREF(__pyx_int_0);
5144   __pyx_t_3 = 0;
5145   if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__gff), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5146   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5147
5148   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":465
5149  *     preset2conf = {
5150  *         'gff' : ( 0, 1, 4, 5, ord('#'), 0 ),
5151  *         'bed' : ( 0x10000, 1, 2, 3, ord('#'), 0 ),             # <<<<<<<<<<<<<<
5152  *         'psltbl' : ( 0x10000, 15, 17, 18, ord('#'), 0 ),
5153  *         'sam' : ( 1, 3, 4, 0, ord('#'), 0 ),
5154  */
5155   __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5156   __Pyx_GOTREF(__pyx_t_6);
5157   __Pyx_INCREF(((PyObject *)__pyx_kp_s_20));
5158   PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_20));
5159   __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_20));
5160   __pyx_t_3 = PyObject_Call(__pyx_builtin_ord, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5161   __Pyx_GOTREF(__pyx_t_3);
5162   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5163   __pyx_t_6 = PyTuple_New(6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 465; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5164   __Pyx_GOTREF(__pyx_t_6);
5165   __Pyx_INCREF(__pyx_int_0x10000);
5166   PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_int_0x10000);
5167   __Pyx_GIVEREF(__pyx_int_0x10000);
5168   __Pyx_INCREF(__pyx_int_1);
5169   PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_1);
5170   __Pyx_GIVEREF(__pyx_int_1);
5171   __Pyx_INCREF(__pyx_int_2);
5172   PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_int_2);
5173   __Pyx_GIVEREF(__pyx_int_2);
5174   __Pyx_INCREF(__pyx_int_3);
5175   PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_int_3);
5176   __Pyx_GIVEREF(__pyx_int_3);
5177   PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_t_3);
5178   __Pyx_GIVEREF(__pyx_t_3);
5179   __Pyx_INCREF(__pyx_int_0);
5180   PyTuple_SET_ITEM(__pyx_t_6, 5, __pyx_int_0);
5181   __Pyx_GIVEREF(__pyx_int_0);
5182   __pyx_t_3 = 0;
5183   if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__bed), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5184   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5185
5186   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":466
5187  *         'gff' : ( 0, 1, 4, 5, ord('#'), 0 ),
5188  *         'bed' : ( 0x10000, 1, 2, 3, ord('#'), 0 ),
5189  *         'psltbl' : ( 0x10000, 15, 17, 18, ord('#'), 0 ),             # <<<<<<<<<<<<<<
5190  *         'sam' : ( 1, 3, 4, 0, ord('#'), 0 ),
5191  *         'vcf' : ( 2, 1, 2, 0, ord('#'), 0 ),
5192  */
5193   __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5194   __Pyx_GOTREF(__pyx_t_6);
5195   __Pyx_INCREF(((PyObject *)__pyx_kp_s_20));
5196   PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_20));
5197   __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_20));
5198   __pyx_t_3 = PyObject_Call(__pyx_builtin_ord, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5199   __Pyx_GOTREF(__pyx_t_3);
5200   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5201   __pyx_t_6 = PyTuple_New(6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5202   __Pyx_GOTREF(__pyx_t_6);
5203   __Pyx_INCREF(__pyx_int_0x10000);
5204   PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_int_0x10000);
5205   __Pyx_GIVEREF(__pyx_int_0x10000);
5206   __Pyx_INCREF(__pyx_int_15);
5207   PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_15);
5208   __Pyx_GIVEREF(__pyx_int_15);
5209   __Pyx_INCREF(__pyx_int_17);
5210   PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_int_17);
5211   __Pyx_GIVEREF(__pyx_int_17);
5212   __Pyx_INCREF(__pyx_int_18);
5213   PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_int_18);
5214   __Pyx_GIVEREF(__pyx_int_18);
5215   PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_t_3);
5216   __Pyx_GIVEREF(__pyx_t_3);
5217   __Pyx_INCREF(__pyx_int_0);
5218   PyTuple_SET_ITEM(__pyx_t_6, 5, __pyx_int_0);
5219   __Pyx_GIVEREF(__pyx_int_0);
5220   __pyx_t_3 = 0;
5221   if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__psltbl), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5222   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5223
5224   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":467
5225  *         'bed' : ( 0x10000, 1, 2, 3, ord('#'), 0 ),
5226  *         'psltbl' : ( 0x10000, 15, 17, 18, ord('#'), 0 ),
5227  *         'sam' : ( 1, 3, 4, 0, ord('#'), 0 ),             # <<<<<<<<<<<<<<
5228  *         'vcf' : ( 2, 1, 2, 0, ord('#'), 0 ),
5229  *         'pileup': (3, 1, 2, 0, ord('#'), 0 ),
5230  */
5231   __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5232   __Pyx_GOTREF(__pyx_t_6);
5233   __Pyx_INCREF(((PyObject *)__pyx_kp_s_20));
5234   PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_20));
5235   __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_20));
5236   __pyx_t_3 = PyObject_Call(__pyx_builtin_ord, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5237   __Pyx_GOTREF(__pyx_t_3);
5238   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5239   __pyx_t_6 = PyTuple_New(6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5240   __Pyx_GOTREF(__pyx_t_6);
5241   __Pyx_INCREF(__pyx_int_1);
5242   PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_int_1);
5243   __Pyx_GIVEREF(__pyx_int_1);
5244   __Pyx_INCREF(__pyx_int_3);
5245   PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_3);
5246   __Pyx_GIVEREF(__pyx_int_3);
5247   __Pyx_INCREF(__pyx_int_4);
5248   PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_int_4);
5249   __Pyx_GIVEREF(__pyx_int_4);
5250   __Pyx_INCREF(__pyx_int_0);
5251   PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_int_0);
5252   __Pyx_GIVEREF(__pyx_int_0);
5253   PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_t_3);
5254   __Pyx_GIVEREF(__pyx_t_3);
5255   __Pyx_INCREF(__pyx_int_0);
5256   PyTuple_SET_ITEM(__pyx_t_6, 5, __pyx_int_0);
5257   __Pyx_GIVEREF(__pyx_int_0);
5258   __pyx_t_3 = 0;
5259   if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__sam), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5260   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5261
5262   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":468
5263  *         'psltbl' : ( 0x10000, 15, 17, 18, ord('#'), 0 ),
5264  *         'sam' : ( 1, 3, 4, 0, ord('#'), 0 ),
5265  *         'vcf' : ( 2, 1, 2, 0, ord('#'), 0 ),             # <<<<<<<<<<<<<<
5266  *         'pileup': (3, 1, 2, 0, ord('#'), 0 ),
5267  *         }
5268  */
5269   __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5270   __Pyx_GOTREF(__pyx_t_6);
5271   __Pyx_INCREF(((PyObject *)__pyx_kp_s_20));
5272   PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_20));
5273   __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_20));
5274   __pyx_t_3 = PyObject_Call(__pyx_builtin_ord, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5275   __Pyx_GOTREF(__pyx_t_3);
5276   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5277   __pyx_t_6 = PyTuple_New(6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5278   __Pyx_GOTREF(__pyx_t_6);
5279   __Pyx_INCREF(__pyx_int_2);
5280   PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_int_2);
5281   __Pyx_GIVEREF(__pyx_int_2);
5282   __Pyx_INCREF(__pyx_int_1);
5283   PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_1);
5284   __Pyx_GIVEREF(__pyx_int_1);
5285   __Pyx_INCREF(__pyx_int_2);
5286   PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_int_2);
5287   __Pyx_GIVEREF(__pyx_int_2);
5288   __Pyx_INCREF(__pyx_int_0);
5289   PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_int_0);
5290   __Pyx_GIVEREF(__pyx_int_0);
5291   PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_t_3);
5292   __Pyx_GIVEREF(__pyx_t_3);
5293   __Pyx_INCREF(__pyx_int_0);
5294   PyTuple_SET_ITEM(__pyx_t_6, 5, __pyx_int_0);
5295   __Pyx_GIVEREF(__pyx_int_0);
5296   __pyx_t_3 = 0;
5297   if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__vcf), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5298   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5299
5300   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":469
5301  *         'sam' : ( 1, 3, 4, 0, ord('#'), 0 ),
5302  *         'vcf' : ( 2, 1, 2, 0, ord('#'), 0 ),
5303  *         'pileup': (3, 1, 2, 0, ord('#'), 0 ),             # <<<<<<<<<<<<<<
5304  *         }
5305  * 
5306  */
5307   __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5308   __Pyx_GOTREF(__pyx_t_6);
5309   __Pyx_INCREF(((PyObject *)__pyx_kp_s_20));
5310   PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_kp_s_20));
5311   __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_20));
5312   __pyx_t_3 = PyObject_Call(__pyx_builtin_ord, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5313   __Pyx_GOTREF(__pyx_t_3);
5314   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5315   __pyx_t_6 = PyTuple_New(6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5316   __Pyx_GOTREF(__pyx_t_6);
5317   __Pyx_INCREF(__pyx_int_3);
5318   PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_int_3);
5319   __Pyx_GIVEREF(__pyx_int_3);
5320   __Pyx_INCREF(__pyx_int_1);
5321   PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_int_1);
5322   __Pyx_GIVEREF(__pyx_int_1);
5323   __Pyx_INCREF(__pyx_int_2);
5324   PyTuple_SET_ITEM(__pyx_t_6, 2, __pyx_int_2);
5325   __Pyx_GIVEREF(__pyx_int_2);
5326   __Pyx_INCREF(__pyx_int_0);
5327   PyTuple_SET_ITEM(__pyx_t_6, 3, __pyx_int_0);
5328   __Pyx_GIVEREF(__pyx_int_0);
5329   PyTuple_SET_ITEM(__pyx_t_6, 4, __pyx_t_3);
5330   __Pyx_GIVEREF(__pyx_t_3);
5331   __Pyx_INCREF(__pyx_int_0);
5332   PyTuple_SET_ITEM(__pyx_t_6, 5, __pyx_int_0);
5333   __Pyx_GIVEREF(__pyx_int_0);
5334   __pyx_t_3 = 0;
5335   if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__pileup), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5336   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5337   __Pyx_DECREF(((PyObject *)__pyx_v_preset2conf));
5338   __pyx_v_preset2conf = __pyx_t_2;
5339   __pyx_t_2 = 0;
5340
5341   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":472
5342  *         }
5343  * 
5344  *     if preset:             # <<<<<<<<<<<<<<
5345  *         try:
5346  *             conf_data = preset2conf[preset]
5347  */
5348   __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_preset); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 472; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5349   if (__pyx_t_7) {
5350
5351     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":473
5352  * 
5353  *     if preset:
5354  *         try:             # <<<<<<<<<<<<<<
5355  *             conf_data = preset2conf[preset]
5356  *         except KeyError:
5357  */
5358     {
5359       PyObject *__pyx_save_exc_type, *__pyx_save_exc_value, *__pyx_save_exc_tb;
5360       __Pyx_ExceptionSave(&__pyx_save_exc_type, &__pyx_save_exc_value, &__pyx_save_exc_tb);
5361       __Pyx_XGOTREF(__pyx_save_exc_type);
5362       __Pyx_XGOTREF(__pyx_save_exc_value);
5363       __Pyx_XGOTREF(__pyx_save_exc_tb);
5364       /*try:*/ {
5365
5366         /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":474
5367  *     if preset:
5368  *         try:
5369  *             conf_data = preset2conf[preset]             # <<<<<<<<<<<<<<
5370  *         except KeyError:
5371  *             raise KeyError( "unknown preset '%s', valid presets are '%s'" % (preset, ",".join(preset2conf.keys() )))
5372  */
5373         __pyx_t_2 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_preset2conf), __pyx_v_preset); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
5374         __Pyx_GOTREF(__pyx_t_2);
5375         __Pyx_DECREF(__pyx_v_conf_data);
5376         __pyx_v_conf_data = __pyx_t_2;
5377         __pyx_t_2 = 0;
5378       }
5379       __Pyx_XDECREF(__pyx_save_exc_type); __pyx_save_exc_type = 0;
5380       __Pyx_XDECREF(__pyx_save_exc_value); __pyx_save_exc_value = 0;
5381       __Pyx_XDECREF(__pyx_save_exc_tb); __pyx_save_exc_tb = 0;
5382       goto __pyx_L17_try_end;
5383       __pyx_L10_error:;
5384       __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
5385       __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
5386       __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
5387       __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
5388
5389       /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":475
5390  *         try:
5391  *             conf_data = preset2conf[preset]
5392  *         except KeyError:             # <<<<<<<<<<<<<<
5393  *             raise KeyError( "unknown preset '%s', valid presets are '%s'" % (preset, ",".join(preset2conf.keys() )))
5394  *     else:
5395  */
5396       __pyx_t_8 = PyErr_ExceptionMatches(__pyx_builtin_KeyError);
5397       if (__pyx_t_8) {
5398         __Pyx_AddTraceback("ctabix.tabix_index");
5399         if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_6, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
5400         __Pyx_GOTREF(__pyx_t_2);
5401         __Pyx_GOTREF(__pyx_t_6);
5402         __Pyx_GOTREF(__pyx_t_3);
5403
5404         /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":476
5405  *             conf_data = preset2conf[preset]
5406  *         except KeyError:
5407  *             raise KeyError( "unknown preset '%s', valid presets are '%s'" % (preset, ",".join(preset2conf.keys() )))             # <<<<<<<<<<<<<<
5408  *     else:
5409  *         if end_col == None: end_col = -1
5410  */
5411         __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_26), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
5412         __Pyx_GOTREF(__pyx_t_1);
5413         __pyx_t_9 = PyDict_Keys(((PyObject *)__pyx_v_preset2conf)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
5414         __Pyx_GOTREF(__pyx_t_9);
5415         __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
5416         __Pyx_GOTREF(__pyx_t_10);
5417         PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9);
5418         __Pyx_GIVEREF(__pyx_t_9);
5419         __pyx_t_9 = 0;
5420         __pyx_t_9 = PyObject_Call(__pyx_t_1, __pyx_t_10, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
5421         __Pyx_GOTREF(__pyx_t_9);
5422         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5423         __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
5424         __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
5425         __Pyx_GOTREF(__pyx_t_10);
5426         __Pyx_INCREF(__pyx_v_preset);
5427         PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_preset);
5428         __Pyx_GIVEREF(__pyx_v_preset);
5429         PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_9);
5430         __Pyx_GIVEREF(__pyx_t_9);
5431         __pyx_t_9 = 0;
5432         __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_25), __pyx_t_10); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
5433         __Pyx_GOTREF(((PyObject *)__pyx_t_9));
5434         __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
5435         __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
5436         __Pyx_GOTREF(__pyx_t_10);
5437         PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)__pyx_t_9));
5438         __Pyx_GIVEREF(((PyObject *)__pyx_t_9));
5439         __pyx_t_9 = 0;
5440         __pyx_t_9 = PyObject_Call(__pyx_builtin_KeyError, __pyx_t_10, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
5441         __Pyx_GOTREF(__pyx_t_9);
5442         __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
5443         __Pyx_Raise(__pyx_t_9, 0, 0);
5444         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
5445         {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
5446         __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5447         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5448         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5449         goto __pyx_L11_exception_handled;
5450       }
5451       __pyx_L12_except_error:;
5452       __Pyx_XGIVEREF(__pyx_save_exc_type);
5453       __Pyx_XGIVEREF(__pyx_save_exc_value);
5454       __Pyx_XGIVEREF(__pyx_save_exc_tb);
5455       __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
5456       goto __pyx_L1_error;
5457       __pyx_L11_exception_handled:;
5458       __Pyx_XGIVEREF(__pyx_save_exc_type);
5459       __Pyx_XGIVEREF(__pyx_save_exc_value);
5460       __Pyx_XGIVEREF(__pyx_save_exc_tb);
5461       __Pyx_ExceptionReset(__pyx_save_exc_type, __pyx_save_exc_value, __pyx_save_exc_tb);
5462       __pyx_L17_try_end:;
5463     }
5464     goto __pyx_L9;
5465   }
5466   /*else*/ {
5467
5468     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":478
5469  *             raise KeyError( "unknown preset '%s', valid presets are '%s'" % (preset, ",".join(preset2conf.keys() )))
5470  *     else:
5471  *         if end_col == None: end_col = -1             # <<<<<<<<<<<<<<
5472  *         preset = 0
5473  * 
5474  */
5475     __pyx_t_3 = PyObject_RichCompare(__pyx_v_end_col, Py_None, Py_EQ); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5476     __Pyx_GOTREF(__pyx_t_3);
5477     __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 478; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5478     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5479     if (__pyx_t_7) {
5480       __Pyx_INCREF(__pyx_int_neg_1);
5481       __Pyx_DECREF(__pyx_v_end_col);
5482       __pyx_v_end_col = __pyx_int_neg_1;
5483       goto __pyx_L20;
5484     }
5485     __pyx_L20:;
5486
5487     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":479
5488  *     else:
5489  *         if end_col == None: end_col = -1
5490  *         preset = 0             # <<<<<<<<<<<<<<
5491  * 
5492  *         # note that tabix internally works with 0-based coordinates and open/closed intervals.
5493  */
5494     __Pyx_INCREF(__pyx_int_0);
5495     __Pyx_DECREF(__pyx_v_preset);
5496     __pyx_v_preset = __pyx_int_0;
5497
5498     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":486
5499  *         # -1 is subtracted from the start coordinate. To avoid doing this, set
5500  *         # the TI_FLAG_UCSC=0x10000 flag:
5501  *         if zerobased: preset = preset | 0x10000             # <<<<<<<<<<<<<<
5502  * 
5503  *         conf_data = (preset, seq_col+1, start_col+1, end_col+1, ord(meta_char), 0)
5504  */
5505     __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_zerobased); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5506     if (__pyx_t_7) {
5507       __pyx_t_3 = PyNumber_Or(__pyx_v_preset, __pyx_int_0x10000); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5508       __Pyx_GOTREF(__pyx_t_3);
5509       __Pyx_DECREF(__pyx_v_preset);
5510       __pyx_v_preset = __pyx_t_3;
5511       __pyx_t_3 = 0;
5512       goto __pyx_L21;
5513     }
5514     __pyx_L21:;
5515
5516     /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":488
5517  *         if zerobased: preset = preset | 0x10000
5518  * 
5519  *         conf_data = (preset, seq_col+1, start_col+1, end_col+1, ord(meta_char), 0)             # <<<<<<<<<<<<<<
5520  * 
5521  *     cdef ti_conf_t conf
5522  */
5523     __pyx_t_3 = PyNumber_Add(__pyx_v_seq_col, __pyx_int_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5524     __Pyx_GOTREF(__pyx_t_3);
5525     __pyx_t_6 = PyNumber_Add(__pyx_v_start_col, __pyx_int_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5526     __Pyx_GOTREF(__pyx_t_6);
5527     __pyx_t_2 = PyNumber_Add(__pyx_v_end_col, __pyx_int_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5528     __Pyx_GOTREF(__pyx_t_2);
5529     __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5530     __Pyx_GOTREF(__pyx_t_9);
5531     __Pyx_INCREF(__pyx_v_meta_char);
5532     PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_meta_char);
5533     __Pyx_GIVEREF(__pyx_v_meta_char);
5534     __pyx_t_10 = PyObject_Call(__pyx_builtin_ord, __pyx_t_9, NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5535     __Pyx_GOTREF(__pyx_t_10);
5536     __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
5537     __pyx_t_9 = PyTuple_New(6); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5538     __Pyx_GOTREF(__pyx_t_9);
5539     __Pyx_INCREF(__pyx_v_preset);
5540     PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_preset);
5541     __Pyx_GIVEREF(__pyx_v_preset);
5542     PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_3);
5543     __Pyx_GIVEREF(__pyx_t_3);
5544     PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_t_6);
5545     __Pyx_GIVEREF(__pyx_t_6);
5546     PyTuple_SET_ITEM(__pyx_t_9, 3, __pyx_t_2);
5547     __Pyx_GIVEREF(__pyx_t_2);
5548     PyTuple_SET_ITEM(__pyx_t_9, 4, __pyx_t_10);
5549     __Pyx_GIVEREF(__pyx_t_10);
5550     __Pyx_INCREF(__pyx_int_0);
5551     PyTuple_SET_ITEM(__pyx_t_9, 5, __pyx_int_0);
5552     __Pyx_GIVEREF(__pyx_int_0);
5553     __pyx_t_3 = 0;
5554     __pyx_t_6 = 0;
5555     __pyx_t_2 = 0;
5556     __pyx_t_10 = 0;
5557     __Pyx_DECREF(__pyx_v_conf_data);
5558     __pyx_v_conf_data = __pyx_t_9;
5559     __pyx_t_9 = 0;
5560   }
5561   __pyx_L9:;
5562
5563   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":491
5564  * 
5565  *     cdef ti_conf_t conf
5566  *     conf.preset, conf.sc, conf.bc, conf.ec, conf.meta_char, conf.line_skip = conf_data             # <<<<<<<<<<<<<<
5567  * 
5568  *     ti_index_build( filename, &conf)
5569  */
5570   if (PyTuple_CheckExact(__pyx_v_conf_data) && likely(PyTuple_GET_SIZE(__pyx_v_conf_data) == 6)) {
5571     PyObject* tuple = __pyx_v_conf_data;
5572     __pyx_t_9 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_9);
5573     __pyx_t_11 = __Pyx_PyInt_from_py_int32_t(__pyx_t_9); if (unlikely((__pyx_t_11 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5574     __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
5575     __pyx_t_10 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_10);
5576     __pyx_t_12 = __Pyx_PyInt_from_py_int32_t(__pyx_t_10); if (unlikely((__pyx_t_12 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5577     __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
5578     __pyx_t_2 = PyTuple_GET_ITEM(tuple, 2); __Pyx_INCREF(__pyx_t_2);
5579     __pyx_t_13 = __Pyx_PyInt_from_py_int32_t(__pyx_t_2); if (unlikely((__pyx_t_13 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5580     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5581     __pyx_t_6 = PyTuple_GET_ITEM(tuple, 3); __Pyx_INCREF(__pyx_t_6);
5582     __pyx_t_14 = __Pyx_PyInt_from_py_int32_t(__pyx_t_6); if (unlikely((__pyx_t_14 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5583     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5584     __pyx_t_3 = PyTuple_GET_ITEM(tuple, 4); __Pyx_INCREF(__pyx_t_3);
5585     __pyx_t_15 = __Pyx_PyInt_from_py_int32_t(__pyx_t_3); if (unlikely((__pyx_t_15 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5586     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5587     __pyx_t_1 = PyTuple_GET_ITEM(tuple, 5); __Pyx_INCREF(__pyx_t_1);
5588     __pyx_t_16 = __Pyx_PyInt_from_py_int32_t(__pyx_t_1); if (unlikely((__pyx_t_16 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5589     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5590     __pyx_v_conf.preset = __pyx_t_11;
5591     __pyx_v_conf.sc = __pyx_t_12;
5592     __pyx_v_conf.bc = __pyx_t_13;
5593     __pyx_v_conf.ec = __pyx_t_14;
5594     __pyx_v_conf.meta_char = __pyx_t_15;
5595     __pyx_v_conf.line_skip = __pyx_t_16;
5596   } else {
5597     __pyx_t_17 = PyObject_GetIter(__pyx_v_conf_data); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5598     __Pyx_GOTREF(__pyx_t_17);
5599     __pyx_t_9 = __Pyx_UnpackItem(__pyx_t_17, 0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5600     __Pyx_GOTREF(__pyx_t_9);
5601     __pyx_t_16 = __Pyx_PyInt_from_py_int32_t(__pyx_t_9); if (unlikely((__pyx_t_16 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5602     __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
5603     __pyx_t_10 = __Pyx_UnpackItem(__pyx_t_17, 1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5604     __Pyx_GOTREF(__pyx_t_10);
5605     __pyx_t_15 = __Pyx_PyInt_from_py_int32_t(__pyx_t_10); if (unlikely((__pyx_t_15 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5606     __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
5607     __pyx_t_2 = __Pyx_UnpackItem(__pyx_t_17, 2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5608     __Pyx_GOTREF(__pyx_t_2);
5609     __pyx_t_14 = __Pyx_PyInt_from_py_int32_t(__pyx_t_2); if (unlikely((__pyx_t_14 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5610     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5611     __pyx_t_6 = __Pyx_UnpackItem(__pyx_t_17, 3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5612     __Pyx_GOTREF(__pyx_t_6);
5613     __pyx_t_13 = __Pyx_PyInt_from_py_int32_t(__pyx_t_6); if (unlikely((__pyx_t_13 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5614     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
5615     __pyx_t_3 = __Pyx_UnpackItem(__pyx_t_17, 4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5616     __Pyx_GOTREF(__pyx_t_3);
5617     __pyx_t_12 = __Pyx_PyInt_from_py_int32_t(__pyx_t_3); if (unlikely((__pyx_t_12 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5618     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5619     __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_17, 5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5620     __Pyx_GOTREF(__pyx_t_1);
5621     __pyx_t_11 = __Pyx_PyInt_from_py_int32_t(__pyx_t_1); if (unlikely((__pyx_t_11 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5622     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5623     if (__Pyx_EndUnpack(__pyx_t_17, 6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5624     __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
5625     __pyx_v_conf.preset = __pyx_t_16;
5626     __pyx_v_conf.sc = __pyx_t_15;
5627     __pyx_v_conf.bc = __pyx_t_14;
5628     __pyx_v_conf.ec = __pyx_t_13;
5629     __pyx_v_conf.meta_char = __pyx_t_12;
5630     __pyx_v_conf.line_skip = __pyx_t_11;
5631   }
5632
5633   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":493
5634  *     conf.preset, conf.sc, conf.bc, conf.ec, conf.meta_char, conf.line_skip = conf_data
5635  * 
5636  *     ti_index_build( filename, &conf)             # <<<<<<<<<<<<<<
5637  * 
5638  *     return filename
5639  */
5640   __pyx_t_18 = PyBytes_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_18) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
5641   ti_index_build(__pyx_t_18, (&__pyx_v_conf));
5642
5643   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":495
5644  *     ti_index_build( filename, &conf)
5645  * 
5646  *     return filename             # <<<<<<<<<<<<<<
5647  * 
5648  * __all__ = ["tabix_index",
5649  */
5650   __Pyx_XDECREF(__pyx_r);
5651   __Pyx_INCREF(__pyx_v_filename);
5652   __pyx_r = __pyx_v_filename;
5653   goto __pyx_L0;
5654
5655   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5656   goto __pyx_L0;
5657   __pyx_L1_error:;
5658   __Pyx_XDECREF(__pyx_t_1);
5659   __Pyx_XDECREF(__pyx_t_2);
5660   __Pyx_XDECREF(__pyx_t_3);
5661   __Pyx_XDECREF(__pyx_t_6);
5662   __Pyx_XDECREF(__pyx_t_9);
5663   __Pyx_XDECREF(__pyx_t_10);
5664   __Pyx_XDECREF(__pyx_t_17);
5665   __Pyx_AddTraceback("ctabix.tabix_index");
5666   __pyx_r = NULL;
5667   __pyx_L0:;
5668   __Pyx_DECREF(__pyx_v_preset2conf);
5669   __Pyx_DECREF(__pyx_v_conf_data);
5670   __Pyx_DECREF(__pyx_v_filename);
5671   __Pyx_DECREF(__pyx_v_end_col);
5672   __Pyx_DECREF(__pyx_v_preset);
5673   __Pyx_XGIVEREF(__pyx_r);
5674   __Pyx_RefNannyFinishContext();
5675   return __pyx_r;
5676 }
5677
5678 static PyObject *__pyx_tp_new_6ctabix_Tabixfile(PyTypeObject *t, PyObject *a, PyObject *k) {
5679   PyObject *o = (*t->tp_alloc)(t, 0);
5680   if (!o) return 0;
5681   if (__pyx_pf_6ctabix_9Tabixfile___cinit__(o, a, k) < 0) {
5682     Py_DECREF(o); o = 0;
5683   }
5684   return o;
5685 }
5686
5687 static void __pyx_tp_dealloc_6ctabix_Tabixfile(PyObject *o) {
5688   (*Py_TYPE(o)->tp_free)(o);
5689 }
5690
5691 static PyObject *__pyx_getprop_6ctabix_9Tabixfile_header(PyObject *o, void *x) {
5692   return __pyx_pf_6ctabix_9Tabixfile_6header___get__(o);
5693 }
5694
5695 static PyObject *__pyx_getprop_6ctabix_9Tabixfile_contigs(PyObject *o, void *x) {
5696   return __pyx_pf_6ctabix_9Tabixfile_7contigs___get__(o);
5697 }
5698
5699 static PyMethodDef __pyx_methods_6ctabix_Tabixfile[] = {
5700   {__Pyx_NAMESTR("_isOpen"), (PyCFunction)__pyx_pf_6ctabix_9Tabixfile__isOpen, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_6ctabix_9Tabixfile__isOpen)},
5701   {__Pyx_NAMESTR("_open"), (PyCFunction)__pyx_pf_6ctabix_9Tabixfile__open, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6ctabix_9Tabixfile__open)},
5702   {__Pyx_NAMESTR("_parseRegion"), (PyCFunction)__pyx_pf_6ctabix_9Tabixfile__parseRegion, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6ctabix_9Tabixfile__parseRegion)},
5703   {__Pyx_NAMESTR("fetch"), (PyCFunction)__pyx_pf_6ctabix_9Tabixfile_fetch, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6ctabix_9Tabixfile_fetch)},
5704   {0, 0, 0, 0}
5705 };
5706
5707 static struct PyGetSetDef __pyx_getsets_6ctabix_Tabixfile[] = {
5708   {(char *)"header", __pyx_getprop_6ctabix_9Tabixfile_header, 0, 0, 0},
5709   {(char *)"contigs", __pyx_getprop_6ctabix_9Tabixfile_contigs, 0, __Pyx_DOCSTR(__pyx_k_27), 0},
5710   {0, 0, 0, 0, 0}
5711 };
5712
5713 static PyNumberMethods __pyx_tp_as_number_Tabixfile = {
5714   0, /*nb_add*/
5715   0, /*nb_subtract*/
5716   0, /*nb_multiply*/
5717   #if PY_MAJOR_VERSION < 3
5718   0, /*nb_divide*/
5719   #endif
5720   0, /*nb_remainder*/
5721   0, /*nb_divmod*/
5722   0, /*nb_power*/
5723   0, /*nb_negative*/
5724   0, /*nb_positive*/
5725   0, /*nb_absolute*/
5726   0, /*nb_nonzero*/
5727   0, /*nb_invert*/
5728   0, /*nb_lshift*/
5729   0, /*nb_rshift*/
5730   0, /*nb_and*/
5731   0, /*nb_xor*/
5732   0, /*nb_or*/
5733   #if PY_MAJOR_VERSION < 3
5734   0, /*nb_coerce*/
5735   #endif
5736   0, /*nb_int*/
5737   #if PY_MAJOR_VERSION < 3
5738   0, /*nb_long*/
5739   #else
5740   0, /*reserved*/
5741   #endif
5742   0, /*nb_float*/
5743   #if PY_MAJOR_VERSION < 3
5744   0, /*nb_oct*/
5745   #endif
5746   #if PY_MAJOR_VERSION < 3
5747   0, /*nb_hex*/
5748   #endif
5749   0, /*nb_inplace_add*/
5750   0, /*nb_inplace_subtract*/
5751   0, /*nb_inplace_multiply*/
5752   #if PY_MAJOR_VERSION < 3
5753   0, /*nb_inplace_divide*/
5754   #endif
5755   0, /*nb_inplace_remainder*/
5756   0, /*nb_inplace_power*/
5757   0, /*nb_inplace_lshift*/
5758   0, /*nb_inplace_rshift*/
5759   0, /*nb_inplace_and*/
5760   0, /*nb_inplace_xor*/
5761   0, /*nb_inplace_or*/
5762   0, /*nb_floor_divide*/
5763   0, /*nb_true_divide*/
5764   0, /*nb_inplace_floor_divide*/
5765   0, /*nb_inplace_true_divide*/
5766   #if PY_VERSION_HEX >= 0x02050000
5767   0, /*nb_index*/
5768   #endif
5769 };
5770
5771 static PySequenceMethods __pyx_tp_as_sequence_Tabixfile = {
5772   0, /*sq_length*/
5773   0, /*sq_concat*/
5774   0, /*sq_repeat*/
5775   0, /*sq_item*/
5776   0, /*sq_slice*/
5777   0, /*sq_ass_item*/
5778   0, /*sq_ass_slice*/
5779   0, /*sq_contains*/
5780   0, /*sq_inplace_concat*/
5781   0, /*sq_inplace_repeat*/
5782 };
5783
5784 static PyMappingMethods __pyx_tp_as_mapping_Tabixfile = {
5785   0, /*mp_length*/
5786   0, /*mp_subscript*/
5787   0, /*mp_ass_subscript*/
5788 };
5789
5790 static PyBufferProcs __pyx_tp_as_buffer_Tabixfile = {
5791   #if PY_MAJOR_VERSION < 3
5792   0, /*bf_getreadbuffer*/
5793   #endif
5794   #if PY_MAJOR_VERSION < 3
5795   0, /*bf_getwritebuffer*/
5796   #endif
5797   #if PY_MAJOR_VERSION < 3
5798   0, /*bf_getsegcount*/
5799   #endif
5800   #if PY_MAJOR_VERSION < 3
5801   0, /*bf_getcharbuffer*/
5802   #endif
5803   #if PY_VERSION_HEX >= 0x02060000
5804   0, /*bf_getbuffer*/
5805   #endif
5806   #if PY_VERSION_HEX >= 0x02060000
5807   0, /*bf_releasebuffer*/
5808   #endif
5809 };
5810
5811 PyTypeObject __pyx_type_6ctabix_Tabixfile = {
5812   PyVarObject_HEAD_INIT(0, 0)
5813   __Pyx_NAMESTR("ctabix.Tabixfile"), /*tp_name*/
5814   sizeof(struct __pyx_obj_6ctabix_Tabixfile), /*tp_basicsize*/
5815   0, /*tp_itemsize*/
5816   __pyx_tp_dealloc_6ctabix_Tabixfile, /*tp_dealloc*/
5817   0, /*tp_print*/
5818   0, /*tp_getattr*/
5819   0, /*tp_setattr*/
5820   #if PY_MAJOR_VERSION < 3
5821   0, /*tp_compare*/
5822   #else
5823   0, /*reserved*/
5824   #endif
5825   0, /*tp_repr*/
5826   &__pyx_tp_as_number_Tabixfile, /*tp_as_number*/
5827   &__pyx_tp_as_sequence_Tabixfile, /*tp_as_sequence*/
5828   &__pyx_tp_as_mapping_Tabixfile, /*tp_as_mapping*/
5829   0, /*tp_hash*/
5830   0, /*tp_call*/
5831   0, /*tp_str*/
5832   0, /*tp_getattro*/
5833   0, /*tp_setattro*/
5834   &__pyx_tp_as_buffer_Tabixfile, /*tp_as_buffer*/
5835   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
5836   __Pyx_DOCSTR("*(filename, mode='r')*\n\n    opens a :term:`tabix file` for reading. A missing\n    index (*filename* + \".tbi\") will raise an exception.\n    "), /*tp_doc*/
5837   0, /*tp_traverse*/
5838   0, /*tp_clear*/
5839   0, /*tp_richcompare*/
5840   0, /*tp_weaklistoffset*/
5841   0, /*tp_iter*/
5842   0, /*tp_iternext*/
5843   __pyx_methods_6ctabix_Tabixfile, /*tp_methods*/
5844   0, /*tp_members*/
5845   __pyx_getsets_6ctabix_Tabixfile, /*tp_getset*/
5846   0, /*tp_base*/
5847   0, /*tp_dict*/
5848   0, /*tp_descr_get*/
5849   0, /*tp_descr_set*/
5850   0, /*tp_dictoffset*/
5851   0, /*tp_init*/
5852   0, /*tp_alloc*/
5853   __pyx_tp_new_6ctabix_Tabixfile, /*tp_new*/
5854   0, /*tp_free*/
5855   0, /*tp_is_gc*/
5856   0, /*tp_bases*/
5857   0, /*tp_mro*/
5858   0, /*tp_cache*/
5859   0, /*tp_subclasses*/
5860   0, /*tp_weaklist*/
5861   0, /*tp_del*/
5862   #if PY_VERSION_HEX >= 0x02060000
5863   0, /*tp_version_tag*/
5864   #endif
5865 };
5866
5867 static PyObject *__pyx_tp_new_6ctabix_Parser(PyTypeObject *t, PyObject *a, PyObject *k) {
5868   PyObject *o = (*t->tp_alloc)(t, 0);
5869   if (!o) return 0;
5870   return o;
5871 }
5872
5873 static void __pyx_tp_dealloc_6ctabix_Parser(PyObject *o) {
5874   (*Py_TYPE(o)->tp_free)(o);
5875 }
5876
5877 static PyMethodDef __pyx_methods_6ctabix_Parser[] = {
5878   {0, 0, 0, 0}
5879 };
5880
5881 static PyNumberMethods __pyx_tp_as_number_Parser = {
5882   0, /*nb_add*/
5883   0, /*nb_subtract*/
5884   0, /*nb_multiply*/
5885   #if PY_MAJOR_VERSION < 3
5886   0, /*nb_divide*/
5887   #endif
5888   0, /*nb_remainder*/
5889   0, /*nb_divmod*/
5890   0, /*nb_power*/
5891   0, /*nb_negative*/
5892   0, /*nb_positive*/
5893   0, /*nb_absolute*/
5894   0, /*nb_nonzero*/
5895   0, /*nb_invert*/
5896   0, /*nb_lshift*/
5897   0, /*nb_rshift*/
5898   0, /*nb_and*/
5899   0, /*nb_xor*/
5900   0, /*nb_or*/
5901   #if PY_MAJOR_VERSION < 3
5902   0, /*nb_coerce*/
5903   #endif
5904   0, /*nb_int*/
5905   #if PY_MAJOR_VERSION < 3
5906   0, /*nb_long*/
5907   #else
5908   0, /*reserved*/
5909   #endif
5910   0, /*nb_float*/
5911   #if PY_MAJOR_VERSION < 3
5912   0, /*nb_oct*/
5913   #endif
5914   #if PY_MAJOR_VERSION < 3
5915   0, /*nb_hex*/
5916   #endif
5917   0, /*nb_inplace_add*/
5918   0, /*nb_inplace_subtract*/
5919   0, /*nb_inplace_multiply*/
5920   #if PY_MAJOR_VERSION < 3
5921   0, /*nb_inplace_divide*/
5922   #endif
5923   0, /*nb_inplace_remainder*/
5924   0, /*nb_inplace_power*/
5925   0, /*nb_inplace_lshift*/
5926   0, /*nb_inplace_rshift*/
5927   0, /*nb_inplace_and*/
5928   0, /*nb_inplace_xor*/
5929   0, /*nb_inplace_or*/
5930   0, /*nb_floor_divide*/
5931   0, /*nb_true_divide*/
5932   0, /*nb_inplace_floor_divide*/
5933   0, /*nb_inplace_true_divide*/
5934   #if PY_VERSION_HEX >= 0x02050000
5935   0, /*nb_index*/
5936   #endif
5937 };
5938
5939 static PySequenceMethods __pyx_tp_as_sequence_Parser = {
5940   0, /*sq_length*/
5941   0, /*sq_concat*/
5942   0, /*sq_repeat*/
5943   0, /*sq_item*/
5944   0, /*sq_slice*/
5945   0, /*sq_ass_item*/
5946   0, /*sq_ass_slice*/
5947   0, /*sq_contains*/
5948   0, /*sq_inplace_concat*/
5949   0, /*sq_inplace_repeat*/
5950 };
5951
5952 static PyMappingMethods __pyx_tp_as_mapping_Parser = {
5953   0, /*mp_length*/
5954   0, /*mp_subscript*/
5955   0, /*mp_ass_subscript*/
5956 };
5957
5958 static PyBufferProcs __pyx_tp_as_buffer_Parser = {
5959   #if PY_MAJOR_VERSION < 3
5960   0, /*bf_getreadbuffer*/
5961   #endif
5962   #if PY_MAJOR_VERSION < 3
5963   0, /*bf_getwritebuffer*/
5964   #endif
5965   #if PY_MAJOR_VERSION < 3
5966   0, /*bf_getsegcount*/
5967   #endif
5968   #if PY_MAJOR_VERSION < 3
5969   0, /*bf_getcharbuffer*/
5970   #endif
5971   #if PY_VERSION_HEX >= 0x02060000
5972   0, /*bf_getbuffer*/
5973   #endif
5974   #if PY_VERSION_HEX >= 0x02060000
5975   0, /*bf_releasebuffer*/
5976   #endif
5977 };
5978
5979 PyTypeObject __pyx_type_6ctabix_Parser = {
5980   PyVarObject_HEAD_INIT(0, 0)
5981   __Pyx_NAMESTR("ctabix.Parser"), /*tp_name*/
5982   sizeof(struct __pyx_obj_6ctabix_Parser), /*tp_basicsize*/
5983   0, /*tp_itemsize*/
5984   __pyx_tp_dealloc_6ctabix_Parser, /*tp_dealloc*/
5985   0, /*tp_print*/
5986   0, /*tp_getattr*/
5987   0, /*tp_setattr*/
5988   #if PY_MAJOR_VERSION < 3
5989   0, /*tp_compare*/
5990   #else
5991   0, /*reserved*/
5992   #endif
5993   0, /*tp_repr*/
5994   &__pyx_tp_as_number_Parser, /*tp_as_number*/
5995   &__pyx_tp_as_sequence_Parser, /*tp_as_sequence*/
5996   &__pyx_tp_as_mapping_Parser, /*tp_as_mapping*/
5997   0, /*tp_hash*/
5998   0, /*tp_call*/
5999   0, /*tp_str*/
6000   0, /*tp_getattro*/
6001   0, /*tp_setattro*/
6002   &__pyx_tp_as_buffer_Parser, /*tp_as_buffer*/
6003   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
6004   0, /*tp_doc*/
6005   0, /*tp_traverse*/
6006   0, /*tp_clear*/
6007   0, /*tp_richcompare*/
6008   0, /*tp_weaklistoffset*/
6009   0, /*tp_iter*/
6010   0, /*tp_iternext*/
6011   __pyx_methods_6ctabix_Parser, /*tp_methods*/
6012   0, /*tp_members*/
6013   0, /*tp_getset*/
6014   0, /*tp_base*/
6015   0, /*tp_dict*/
6016   0, /*tp_descr_get*/
6017   0, /*tp_descr_set*/
6018   0, /*tp_dictoffset*/
6019   0, /*tp_init*/
6020   0, /*tp_alloc*/
6021   __pyx_tp_new_6ctabix_Parser, /*tp_new*/
6022   0, /*tp_free*/
6023   0, /*tp_is_gc*/
6024   0, /*tp_bases*/
6025   0, /*tp_mro*/
6026   0, /*tp_cache*/
6027   0, /*tp_subclasses*/
6028   0, /*tp_weaklist*/
6029   0, /*tp_del*/
6030   #if PY_VERSION_HEX >= 0x02060000
6031   0, /*tp_version_tag*/
6032   #endif
6033 };
6034
6035 static PyObject *__pyx_tp_new_6ctabix_TabixIterator(PyTypeObject *t, PyObject *a, PyObject *k) {
6036   PyObject *o = (*t->tp_alloc)(t, 0);
6037   if (!o) return 0;
6038   if (__pyx_pf_6ctabix_13TabixIterator___cinit__(o, a, k) < 0) {
6039     Py_DECREF(o); o = 0;
6040   }
6041   return o;
6042 }
6043
6044 static void __pyx_tp_dealloc_6ctabix_TabixIterator(PyObject *o) {
6045   {
6046     PyObject *etype, *eval, *etb;
6047     PyErr_Fetch(&etype, &eval, &etb);
6048     ++Py_REFCNT(o);
6049     __pyx_pf_6ctabix_13TabixIterator___dealloc__(o);
6050     if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
6051     --Py_REFCNT(o);
6052     PyErr_Restore(etype, eval, etb);
6053   }
6054   (*Py_TYPE(o)->tp_free)(o);
6055 }
6056
6057 static PyMethodDef __pyx_methods_6ctabix_TabixIterator[] = {
6058   {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_6ctabix_13TabixIterator___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_6ctabix_13TabixIterator___next__)},
6059   {0, 0, 0, 0}
6060 };
6061
6062 static PyNumberMethods __pyx_tp_as_number_TabixIterator = {
6063   0, /*nb_add*/
6064   0, /*nb_subtract*/
6065   0, /*nb_multiply*/
6066   #if PY_MAJOR_VERSION < 3
6067   0, /*nb_divide*/
6068   #endif
6069   0, /*nb_remainder*/
6070   0, /*nb_divmod*/
6071   0, /*nb_power*/
6072   0, /*nb_negative*/
6073   0, /*nb_positive*/
6074   0, /*nb_absolute*/
6075   0, /*nb_nonzero*/
6076   0, /*nb_invert*/
6077   0, /*nb_lshift*/
6078   0, /*nb_rshift*/
6079   0, /*nb_and*/
6080   0, /*nb_xor*/
6081   0, /*nb_or*/
6082   #if PY_MAJOR_VERSION < 3
6083   0, /*nb_coerce*/
6084   #endif
6085   0, /*nb_int*/
6086   #if PY_MAJOR_VERSION < 3
6087   0, /*nb_long*/
6088   #else
6089   0, /*reserved*/
6090   #endif
6091   0, /*nb_float*/
6092   #if PY_MAJOR_VERSION < 3
6093   0, /*nb_oct*/
6094   #endif
6095   #if PY_MAJOR_VERSION < 3
6096   0, /*nb_hex*/
6097   #endif
6098   0, /*nb_inplace_add*/
6099   0, /*nb_inplace_subtract*/
6100   0, /*nb_inplace_multiply*/
6101   #if PY_MAJOR_VERSION < 3
6102   0, /*nb_inplace_divide*/
6103   #endif
6104   0, /*nb_inplace_remainder*/
6105   0, /*nb_inplace_power*/
6106   0, /*nb_inplace_lshift*/
6107   0, /*nb_inplace_rshift*/
6108   0, /*nb_inplace_and*/
6109   0, /*nb_inplace_xor*/
6110   0, /*nb_inplace_or*/
6111   0, /*nb_floor_divide*/
6112   0, /*nb_true_divide*/
6113   0, /*nb_inplace_floor_divide*/
6114   0, /*nb_inplace_true_divide*/
6115   #if PY_VERSION_HEX >= 0x02050000
6116   0, /*nb_index*/
6117   #endif
6118 };
6119
6120 static PySequenceMethods __pyx_tp_as_sequence_TabixIterator = {
6121   0, /*sq_length*/
6122   0, /*sq_concat*/
6123   0, /*sq_repeat*/
6124   0, /*sq_item*/
6125   0, /*sq_slice*/
6126   0, /*sq_ass_item*/
6127   0, /*sq_ass_slice*/
6128   0, /*sq_contains*/
6129   0, /*sq_inplace_concat*/
6130   0, /*sq_inplace_repeat*/
6131 };
6132
6133 static PyMappingMethods __pyx_tp_as_mapping_TabixIterator = {
6134   0, /*mp_length*/
6135   0, /*mp_subscript*/
6136   0, /*mp_ass_subscript*/
6137 };
6138
6139 static PyBufferProcs __pyx_tp_as_buffer_TabixIterator = {
6140   #if PY_MAJOR_VERSION < 3
6141   0, /*bf_getreadbuffer*/
6142   #endif
6143   #if PY_MAJOR_VERSION < 3
6144   0, /*bf_getwritebuffer*/
6145   #endif
6146   #if PY_MAJOR_VERSION < 3
6147   0, /*bf_getsegcount*/
6148   #endif
6149   #if PY_MAJOR_VERSION < 3
6150   0, /*bf_getcharbuffer*/
6151   #endif
6152   #if PY_VERSION_HEX >= 0x02060000
6153   0, /*bf_getbuffer*/
6154   #endif
6155   #if PY_VERSION_HEX >= 0x02060000
6156   0, /*bf_releasebuffer*/
6157   #endif
6158 };
6159
6160 PyTypeObject __pyx_type_6ctabix_TabixIterator = {
6161   PyVarObject_HEAD_INIT(0, 0)
6162   __Pyx_NAMESTR("ctabix.TabixIterator"), /*tp_name*/
6163   sizeof(struct __pyx_obj_6ctabix_TabixIterator), /*tp_basicsize*/
6164   0, /*tp_itemsize*/
6165   __pyx_tp_dealloc_6ctabix_TabixIterator, /*tp_dealloc*/
6166   0, /*tp_print*/
6167   0, /*tp_getattr*/
6168   0, /*tp_setattr*/
6169   #if PY_MAJOR_VERSION < 3
6170   0, /*tp_compare*/
6171   #else
6172   0, /*reserved*/
6173   #endif
6174   0, /*tp_repr*/
6175   &__pyx_tp_as_number_TabixIterator, /*tp_as_number*/
6176   &__pyx_tp_as_sequence_TabixIterator, /*tp_as_sequence*/
6177   &__pyx_tp_as_mapping_TabixIterator, /*tp_as_mapping*/
6178   0, /*tp_hash*/
6179   0, /*tp_call*/
6180   0, /*tp_str*/
6181   0, /*tp_getattro*/
6182   0, /*tp_setattro*/
6183   &__pyx_tp_as_buffer_TabixIterator, /*tp_as_buffer*/
6184   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
6185   __Pyx_DOCSTR("iterates over rows in *tabixfile* in region\n    given by *tid*, *start* and *end*.\n    "), /*tp_doc*/
6186   0, /*tp_traverse*/
6187   0, /*tp_clear*/
6188   0, /*tp_richcompare*/
6189   0, /*tp_weaklistoffset*/
6190   __pyx_pf_6ctabix_13TabixIterator___iter__, /*tp_iter*/
6191   __pyx_pf_6ctabix_13TabixIterator___next__, /*tp_iternext*/
6192   __pyx_methods_6ctabix_TabixIterator, /*tp_methods*/
6193   0, /*tp_members*/
6194   0, /*tp_getset*/
6195   0, /*tp_base*/
6196   0, /*tp_dict*/
6197   0, /*tp_descr_get*/
6198   0, /*tp_descr_set*/
6199   0, /*tp_dictoffset*/
6200   0, /*tp_init*/
6201   0, /*tp_alloc*/
6202   __pyx_tp_new_6ctabix_TabixIterator, /*tp_new*/
6203   0, /*tp_free*/
6204   0, /*tp_is_gc*/
6205   0, /*tp_bases*/
6206   0, /*tp_mro*/
6207   0, /*tp_cache*/
6208   0, /*tp_subclasses*/
6209   0, /*tp_weaklist*/
6210   0, /*tp_del*/
6211   #if PY_VERSION_HEX >= 0x02060000
6212   0, /*tp_version_tag*/
6213   #endif
6214 };
6215
6216 static PyObject *__pyx_tp_new_6ctabix_TabixHeaderIterator(PyTypeObject *t, PyObject *a, PyObject *k) {
6217   PyObject *o = (*t->tp_alloc)(t, 0);
6218   if (!o) return 0;
6219   if (__pyx_pf_6ctabix_19TabixHeaderIterator___cinit__(o, a, k) < 0) {
6220     Py_DECREF(o); o = 0;
6221   }
6222   return o;
6223 }
6224
6225 static void __pyx_tp_dealloc_6ctabix_TabixHeaderIterator(PyObject *o) {
6226   {
6227     PyObject *etype, *eval, *etb;
6228     PyErr_Fetch(&etype, &eval, &etb);
6229     ++Py_REFCNT(o);
6230     __pyx_pf_6ctabix_19TabixHeaderIterator___dealloc__(o);
6231     if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
6232     --Py_REFCNT(o);
6233     PyErr_Restore(etype, eval, etb);
6234   }
6235   (*Py_TYPE(o)->tp_free)(o);
6236 }
6237
6238 static PyMethodDef __pyx_methods_6ctabix_TabixHeaderIterator[] = {
6239   {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_6ctabix_19TabixHeaderIterator___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_6ctabix_19TabixHeaderIterator___next__)},
6240   {0, 0, 0, 0}
6241 };
6242
6243 static PyNumberMethods __pyx_tp_as_number_TabixHeaderIterator = {
6244   0, /*nb_add*/
6245   0, /*nb_subtract*/
6246   0, /*nb_multiply*/
6247   #if PY_MAJOR_VERSION < 3
6248   0, /*nb_divide*/
6249   #endif
6250   0, /*nb_remainder*/
6251   0, /*nb_divmod*/
6252   0, /*nb_power*/
6253   0, /*nb_negative*/
6254   0, /*nb_positive*/
6255   0, /*nb_absolute*/
6256   0, /*nb_nonzero*/
6257   0, /*nb_invert*/
6258   0, /*nb_lshift*/
6259   0, /*nb_rshift*/
6260   0, /*nb_and*/
6261   0, /*nb_xor*/
6262   0, /*nb_or*/
6263   #if PY_MAJOR_VERSION < 3
6264   0, /*nb_coerce*/
6265   #endif
6266   0, /*nb_int*/
6267   #if PY_MAJOR_VERSION < 3
6268   0, /*nb_long*/
6269   #else
6270   0, /*reserved*/
6271   #endif
6272   0, /*nb_float*/
6273   #if PY_MAJOR_VERSION < 3
6274   0, /*nb_oct*/
6275   #endif
6276   #if PY_MAJOR_VERSION < 3
6277   0, /*nb_hex*/
6278   #endif
6279   0, /*nb_inplace_add*/
6280   0, /*nb_inplace_subtract*/
6281   0, /*nb_inplace_multiply*/
6282   #if PY_MAJOR_VERSION < 3
6283   0, /*nb_inplace_divide*/
6284   #endif
6285   0, /*nb_inplace_remainder*/
6286   0, /*nb_inplace_power*/
6287   0, /*nb_inplace_lshift*/
6288   0, /*nb_inplace_rshift*/
6289   0, /*nb_inplace_and*/
6290   0, /*nb_inplace_xor*/
6291   0, /*nb_inplace_or*/
6292   0, /*nb_floor_divide*/
6293   0, /*nb_true_divide*/
6294   0, /*nb_inplace_floor_divide*/
6295   0, /*nb_inplace_true_divide*/
6296   #if PY_VERSION_HEX >= 0x02050000
6297   0, /*nb_index*/
6298   #endif
6299 };
6300
6301 static PySequenceMethods __pyx_tp_as_sequence_TabixHeaderIterator = {
6302   0, /*sq_length*/
6303   0, /*sq_concat*/
6304   0, /*sq_repeat*/
6305   0, /*sq_item*/
6306   0, /*sq_slice*/
6307   0, /*sq_ass_item*/
6308   0, /*sq_ass_slice*/
6309   0, /*sq_contains*/
6310   0, /*sq_inplace_concat*/
6311   0, /*sq_inplace_repeat*/
6312 };
6313
6314 static PyMappingMethods __pyx_tp_as_mapping_TabixHeaderIterator = {
6315   0, /*mp_length*/
6316   0, /*mp_subscript*/
6317   0, /*mp_ass_subscript*/
6318 };
6319
6320 static PyBufferProcs __pyx_tp_as_buffer_TabixHeaderIterator = {
6321   #if PY_MAJOR_VERSION < 3
6322   0, /*bf_getreadbuffer*/
6323   #endif
6324   #if PY_MAJOR_VERSION < 3
6325   0, /*bf_getwritebuffer*/
6326   #endif
6327   #if PY_MAJOR_VERSION < 3
6328   0, /*bf_getsegcount*/
6329   #endif
6330   #if PY_MAJOR_VERSION < 3
6331   0, /*bf_getcharbuffer*/
6332   #endif
6333   #if PY_VERSION_HEX >= 0x02060000
6334   0, /*bf_getbuffer*/
6335   #endif
6336   #if PY_VERSION_HEX >= 0x02060000
6337   0, /*bf_releasebuffer*/
6338   #endif
6339 };
6340
6341 PyTypeObject __pyx_type_6ctabix_TabixHeaderIterator = {
6342   PyVarObject_HEAD_INIT(0, 0)
6343   __Pyx_NAMESTR("ctabix.TabixHeaderIterator"), /*tp_name*/
6344   sizeof(struct __pyx_obj_6ctabix_TabixHeaderIterator), /*tp_basicsize*/
6345   0, /*tp_itemsize*/
6346   __pyx_tp_dealloc_6ctabix_TabixHeaderIterator, /*tp_dealloc*/
6347   0, /*tp_print*/
6348   0, /*tp_getattr*/
6349   0, /*tp_setattr*/
6350   #if PY_MAJOR_VERSION < 3
6351   0, /*tp_compare*/
6352   #else
6353   0, /*reserved*/
6354   #endif
6355   0, /*tp_repr*/
6356   &__pyx_tp_as_number_TabixHeaderIterator, /*tp_as_number*/
6357   &__pyx_tp_as_sequence_TabixHeaderIterator, /*tp_as_sequence*/
6358   &__pyx_tp_as_mapping_TabixHeaderIterator, /*tp_as_mapping*/
6359   0, /*tp_hash*/
6360   0, /*tp_call*/
6361   0, /*tp_str*/
6362   0, /*tp_getattro*/
6363   0, /*tp_setattro*/
6364   &__pyx_tp_as_buffer_TabixHeaderIterator, /*tp_as_buffer*/
6365   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
6366   __Pyx_DOCSTR("return header lines.\n    "), /*tp_doc*/
6367   0, /*tp_traverse*/
6368   0, /*tp_clear*/
6369   0, /*tp_richcompare*/
6370   0, /*tp_weaklistoffset*/
6371   __pyx_pf_6ctabix_19TabixHeaderIterator___iter__, /*tp_iter*/
6372   __pyx_pf_6ctabix_19TabixHeaderIterator___next__, /*tp_iternext*/
6373   __pyx_methods_6ctabix_TabixHeaderIterator, /*tp_methods*/
6374   0, /*tp_members*/
6375   0, /*tp_getset*/
6376   0, /*tp_base*/
6377   0, /*tp_dict*/
6378   0, /*tp_descr_get*/
6379   0, /*tp_descr_set*/
6380   0, /*tp_dictoffset*/
6381   0, /*tp_init*/
6382   0, /*tp_alloc*/
6383   __pyx_tp_new_6ctabix_TabixHeaderIterator, /*tp_new*/
6384   0, /*tp_free*/
6385   0, /*tp_is_gc*/
6386   0, /*tp_bases*/
6387   0, /*tp_mro*/
6388   0, /*tp_cache*/
6389   0, /*tp_subclasses*/
6390   0, /*tp_weaklist*/
6391   0, /*tp_del*/
6392   #if PY_VERSION_HEX >= 0x02060000
6393   0, /*tp_version_tag*/
6394   #endif
6395 };
6396
6397 static PyObject *__pyx_tp_new_6ctabix_asTuple(PyTypeObject *t, PyObject *a, PyObject *k) {
6398   PyObject *o = __pyx_tp_new_6ctabix_Parser(t, a, k);
6399   if (!o) return 0;
6400   return o;
6401 }
6402
6403 static PyMethodDef __pyx_methods_6ctabix_asTuple[] = {
6404   {0, 0, 0, 0}
6405 };
6406
6407 static PyNumberMethods __pyx_tp_as_number_asTuple = {
6408   0, /*nb_add*/
6409   0, /*nb_subtract*/
6410   0, /*nb_multiply*/
6411   #if PY_MAJOR_VERSION < 3
6412   0, /*nb_divide*/
6413   #endif
6414   0, /*nb_remainder*/
6415   0, /*nb_divmod*/
6416   0, /*nb_power*/
6417   0, /*nb_negative*/
6418   0, /*nb_positive*/
6419   0, /*nb_absolute*/
6420   0, /*nb_nonzero*/
6421   0, /*nb_invert*/
6422   0, /*nb_lshift*/
6423   0, /*nb_rshift*/
6424   0, /*nb_and*/
6425   0, /*nb_xor*/
6426   0, /*nb_or*/
6427   #if PY_MAJOR_VERSION < 3
6428   0, /*nb_coerce*/
6429   #endif
6430   0, /*nb_int*/
6431   #if PY_MAJOR_VERSION < 3
6432   0, /*nb_long*/
6433   #else
6434   0, /*reserved*/
6435   #endif
6436   0, /*nb_float*/
6437   #if PY_MAJOR_VERSION < 3
6438   0, /*nb_oct*/
6439   #endif
6440   #if PY_MAJOR_VERSION < 3
6441   0, /*nb_hex*/
6442   #endif
6443   0, /*nb_inplace_add*/
6444   0, /*nb_inplace_subtract*/
6445   0, /*nb_inplace_multiply*/
6446   #if PY_MAJOR_VERSION < 3
6447   0, /*nb_inplace_divide*/
6448   #endif
6449   0, /*nb_inplace_remainder*/
6450   0, /*nb_inplace_power*/
6451   0, /*nb_inplace_lshift*/
6452   0, /*nb_inplace_rshift*/
6453   0, /*nb_inplace_and*/
6454   0, /*nb_inplace_xor*/
6455   0, /*nb_inplace_or*/
6456   0, /*nb_floor_divide*/
6457   0, /*nb_true_divide*/
6458   0, /*nb_inplace_floor_divide*/
6459   0, /*nb_inplace_true_divide*/
6460   #if PY_VERSION_HEX >= 0x02050000
6461   0, /*nb_index*/
6462   #endif
6463 };
6464
6465 static PySequenceMethods __pyx_tp_as_sequence_asTuple = {
6466   0, /*sq_length*/
6467   0, /*sq_concat*/
6468   0, /*sq_repeat*/
6469   0, /*sq_item*/
6470   0, /*sq_slice*/
6471   0, /*sq_ass_item*/
6472   0, /*sq_ass_slice*/
6473   0, /*sq_contains*/
6474   0, /*sq_inplace_concat*/
6475   0, /*sq_inplace_repeat*/
6476 };
6477
6478 static PyMappingMethods __pyx_tp_as_mapping_asTuple = {
6479   0, /*mp_length*/
6480   0, /*mp_subscript*/
6481   0, /*mp_ass_subscript*/
6482 };
6483
6484 static PyBufferProcs __pyx_tp_as_buffer_asTuple = {
6485   #if PY_MAJOR_VERSION < 3
6486   0, /*bf_getreadbuffer*/
6487   #endif
6488   #if PY_MAJOR_VERSION < 3
6489   0, /*bf_getwritebuffer*/
6490   #endif
6491   #if PY_MAJOR_VERSION < 3
6492   0, /*bf_getsegcount*/
6493   #endif
6494   #if PY_MAJOR_VERSION < 3
6495   0, /*bf_getcharbuffer*/
6496   #endif
6497   #if PY_VERSION_HEX >= 0x02060000
6498   0, /*bf_getbuffer*/
6499   #endif
6500   #if PY_VERSION_HEX >= 0x02060000
6501   0, /*bf_releasebuffer*/
6502   #endif
6503 };
6504
6505 PyTypeObject __pyx_type_6ctabix_asTuple = {
6506   PyVarObject_HEAD_INIT(0, 0)
6507   __Pyx_NAMESTR("ctabix.asTuple"), /*tp_name*/
6508   sizeof(struct __pyx_obj_6ctabix_asTuple), /*tp_basicsize*/
6509   0, /*tp_itemsize*/
6510   __pyx_tp_dealloc_6ctabix_Parser, /*tp_dealloc*/
6511   0, /*tp_print*/
6512   0, /*tp_getattr*/
6513   0, /*tp_setattr*/
6514   #if PY_MAJOR_VERSION < 3
6515   0, /*tp_compare*/
6516   #else
6517   0, /*reserved*/
6518   #endif
6519   0, /*tp_repr*/
6520   &__pyx_tp_as_number_asTuple, /*tp_as_number*/
6521   &__pyx_tp_as_sequence_asTuple, /*tp_as_sequence*/
6522   &__pyx_tp_as_mapping_asTuple, /*tp_as_mapping*/
6523   0, /*tp_hash*/
6524   __pyx_pf_6ctabix_7asTuple___call__, /*tp_call*/
6525   0, /*tp_str*/
6526   0, /*tp_getattro*/
6527   0, /*tp_setattro*/
6528   &__pyx_tp_as_buffer_asTuple, /*tp_as_buffer*/
6529   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
6530   __Pyx_DOCSTR("converts a :term:`tabix row` into a python tuple."), /*tp_doc*/
6531   0, /*tp_traverse*/
6532   0, /*tp_clear*/
6533   0, /*tp_richcompare*/
6534   0, /*tp_weaklistoffset*/
6535   0, /*tp_iter*/
6536   0, /*tp_iternext*/
6537   __pyx_methods_6ctabix_asTuple, /*tp_methods*/
6538   0, /*tp_members*/
6539   0, /*tp_getset*/
6540   0, /*tp_base*/
6541   0, /*tp_dict*/
6542   0, /*tp_descr_get*/
6543   0, /*tp_descr_set*/
6544   0, /*tp_dictoffset*/
6545   0, /*tp_init*/
6546   0, /*tp_alloc*/
6547   __pyx_tp_new_6ctabix_asTuple, /*tp_new*/
6548   0, /*tp_free*/
6549   0, /*tp_is_gc*/
6550   0, /*tp_bases*/
6551   0, /*tp_mro*/
6552   0, /*tp_cache*/
6553   0, /*tp_subclasses*/
6554   0, /*tp_weaklist*/
6555   0, /*tp_del*/
6556   #if PY_VERSION_HEX >= 0x02060000
6557   0, /*tp_version_tag*/
6558   #endif
6559 };
6560
6561 static PyObject *__pyx_tp_new_6ctabix_asGTF(PyTypeObject *t, PyObject *a, PyObject *k) {
6562   PyObject *o = __pyx_tp_new_6ctabix_Parser(t, a, k);
6563   if (!o) return 0;
6564   return o;
6565 }
6566
6567 static PyMethodDef __pyx_methods_6ctabix_asGTF[] = {
6568   {0, 0, 0, 0}
6569 };
6570
6571 static PyNumberMethods __pyx_tp_as_number_asGTF = {
6572   0, /*nb_add*/
6573   0, /*nb_subtract*/
6574   0, /*nb_multiply*/
6575   #if PY_MAJOR_VERSION < 3
6576   0, /*nb_divide*/
6577   #endif
6578   0, /*nb_remainder*/
6579   0, /*nb_divmod*/
6580   0, /*nb_power*/
6581   0, /*nb_negative*/
6582   0, /*nb_positive*/
6583   0, /*nb_absolute*/
6584   0, /*nb_nonzero*/
6585   0, /*nb_invert*/
6586   0, /*nb_lshift*/
6587   0, /*nb_rshift*/
6588   0, /*nb_and*/
6589   0, /*nb_xor*/
6590   0, /*nb_or*/
6591   #if PY_MAJOR_VERSION < 3
6592   0, /*nb_coerce*/
6593   #endif
6594   0, /*nb_int*/
6595   #if PY_MAJOR_VERSION < 3
6596   0, /*nb_long*/
6597   #else
6598   0, /*reserved*/
6599   #endif
6600   0, /*nb_float*/
6601   #if PY_MAJOR_VERSION < 3
6602   0, /*nb_oct*/
6603   #endif
6604   #if PY_MAJOR_VERSION < 3
6605   0, /*nb_hex*/
6606   #endif
6607   0, /*nb_inplace_add*/
6608   0, /*nb_inplace_subtract*/
6609   0, /*nb_inplace_multiply*/
6610   #if PY_MAJOR_VERSION < 3
6611   0, /*nb_inplace_divide*/
6612   #endif
6613   0, /*nb_inplace_remainder*/
6614   0, /*nb_inplace_power*/
6615   0, /*nb_inplace_lshift*/
6616   0, /*nb_inplace_rshift*/
6617   0, /*nb_inplace_and*/
6618   0, /*nb_inplace_xor*/
6619   0, /*nb_inplace_or*/
6620   0, /*nb_floor_divide*/
6621   0, /*nb_true_divide*/
6622   0, /*nb_inplace_floor_divide*/
6623   0, /*nb_inplace_true_divide*/
6624   #if PY_VERSION_HEX >= 0x02050000
6625   0, /*nb_index*/
6626   #endif
6627 };
6628
6629 static PySequenceMethods __pyx_tp_as_sequence_asGTF = {
6630   0, /*sq_length*/
6631   0, /*sq_concat*/
6632   0, /*sq_repeat*/
6633   0, /*sq_item*/
6634   0, /*sq_slice*/
6635   0, /*sq_ass_item*/
6636   0, /*sq_ass_slice*/
6637   0, /*sq_contains*/
6638   0, /*sq_inplace_concat*/
6639   0, /*sq_inplace_repeat*/
6640 };
6641
6642 static PyMappingMethods __pyx_tp_as_mapping_asGTF = {
6643   0, /*mp_length*/
6644   0, /*mp_subscript*/
6645   0, /*mp_ass_subscript*/
6646 };
6647
6648 static PyBufferProcs __pyx_tp_as_buffer_asGTF = {
6649   #if PY_MAJOR_VERSION < 3
6650   0, /*bf_getreadbuffer*/
6651   #endif
6652   #if PY_MAJOR_VERSION < 3
6653   0, /*bf_getwritebuffer*/
6654   #endif
6655   #if PY_MAJOR_VERSION < 3
6656   0, /*bf_getsegcount*/
6657   #endif
6658   #if PY_MAJOR_VERSION < 3
6659   0, /*bf_getcharbuffer*/
6660   #endif
6661   #if PY_VERSION_HEX >= 0x02060000
6662   0, /*bf_getbuffer*/
6663   #endif
6664   #if PY_VERSION_HEX >= 0x02060000
6665   0, /*bf_releasebuffer*/
6666   #endif
6667 };
6668
6669 PyTypeObject __pyx_type_6ctabix_asGTF = {
6670   PyVarObject_HEAD_INIT(0, 0)
6671   __Pyx_NAMESTR("ctabix.asGTF"), /*tp_name*/
6672   sizeof(struct __pyx_obj_6ctabix_asGTF), /*tp_basicsize*/
6673   0, /*tp_itemsize*/
6674   __pyx_tp_dealloc_6ctabix_Parser, /*tp_dealloc*/
6675   0, /*tp_print*/
6676   0, /*tp_getattr*/
6677   0, /*tp_setattr*/
6678   #if PY_MAJOR_VERSION < 3
6679   0, /*tp_compare*/
6680   #else
6681   0, /*reserved*/
6682   #endif
6683   0, /*tp_repr*/
6684   &__pyx_tp_as_number_asGTF, /*tp_as_number*/
6685   &__pyx_tp_as_sequence_asGTF, /*tp_as_sequence*/
6686   &__pyx_tp_as_mapping_asGTF, /*tp_as_mapping*/
6687   0, /*tp_hash*/
6688   __pyx_pf_6ctabix_5asGTF___call__, /*tp_call*/
6689   0, /*tp_str*/
6690   0, /*tp_getattro*/
6691   0, /*tp_setattro*/
6692   &__pyx_tp_as_buffer_asGTF, /*tp_as_buffer*/
6693   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
6694   __Pyx_DOCSTR("converts a :term:`tabix row` into a GTF record."), /*tp_doc*/
6695   0, /*tp_traverse*/
6696   0, /*tp_clear*/
6697   0, /*tp_richcompare*/
6698   0, /*tp_weaklistoffset*/
6699   0, /*tp_iter*/
6700   0, /*tp_iternext*/
6701   __pyx_methods_6ctabix_asGTF, /*tp_methods*/
6702   0, /*tp_members*/
6703   0, /*tp_getset*/
6704   0, /*tp_base*/
6705   0, /*tp_dict*/
6706   0, /*tp_descr_get*/
6707   0, /*tp_descr_set*/
6708   0, /*tp_dictoffset*/
6709   0, /*tp_init*/
6710   0, /*tp_alloc*/
6711   __pyx_tp_new_6ctabix_asGTF, /*tp_new*/
6712   0, /*tp_free*/
6713   0, /*tp_is_gc*/
6714   0, /*tp_bases*/
6715   0, /*tp_mro*/
6716   0, /*tp_cache*/
6717   0, /*tp_subclasses*/
6718   0, /*tp_weaklist*/
6719   0, /*tp_del*/
6720   #if PY_VERSION_HEX >= 0x02060000
6721   0, /*tp_version_tag*/
6722   #endif
6723 };
6724
6725 static PyObject *__pyx_tp_new_6ctabix_asBed(PyTypeObject *t, PyObject *a, PyObject *k) {
6726   PyObject *o = __pyx_tp_new_6ctabix_Parser(t, a, k);
6727   if (!o) return 0;
6728   return o;
6729 }
6730
6731 static PyMethodDef __pyx_methods_6ctabix_asBed[] = {
6732   {0, 0, 0, 0}
6733 };
6734
6735 static PyNumberMethods __pyx_tp_as_number_asBed = {
6736   0, /*nb_add*/
6737   0, /*nb_subtract*/
6738   0, /*nb_multiply*/
6739   #if PY_MAJOR_VERSION < 3
6740   0, /*nb_divide*/
6741   #endif
6742   0, /*nb_remainder*/
6743   0, /*nb_divmod*/
6744   0, /*nb_power*/
6745   0, /*nb_negative*/
6746   0, /*nb_positive*/
6747   0, /*nb_absolute*/
6748   0, /*nb_nonzero*/
6749   0, /*nb_invert*/
6750   0, /*nb_lshift*/
6751   0, /*nb_rshift*/
6752   0, /*nb_and*/
6753   0, /*nb_xor*/
6754   0, /*nb_or*/
6755   #if PY_MAJOR_VERSION < 3
6756   0, /*nb_coerce*/
6757   #endif
6758   0, /*nb_int*/
6759   #if PY_MAJOR_VERSION < 3
6760   0, /*nb_long*/
6761   #else
6762   0, /*reserved*/
6763   #endif
6764   0, /*nb_float*/
6765   #if PY_MAJOR_VERSION < 3
6766   0, /*nb_oct*/
6767   #endif
6768   #if PY_MAJOR_VERSION < 3
6769   0, /*nb_hex*/
6770   #endif
6771   0, /*nb_inplace_add*/
6772   0, /*nb_inplace_subtract*/
6773   0, /*nb_inplace_multiply*/
6774   #if PY_MAJOR_VERSION < 3
6775   0, /*nb_inplace_divide*/
6776   #endif
6777   0, /*nb_inplace_remainder*/
6778   0, /*nb_inplace_power*/
6779   0, /*nb_inplace_lshift*/
6780   0, /*nb_inplace_rshift*/
6781   0, /*nb_inplace_and*/
6782   0, /*nb_inplace_xor*/
6783   0, /*nb_inplace_or*/
6784   0, /*nb_floor_divide*/
6785   0, /*nb_true_divide*/
6786   0, /*nb_inplace_floor_divide*/
6787   0, /*nb_inplace_true_divide*/
6788   #if PY_VERSION_HEX >= 0x02050000
6789   0, /*nb_index*/
6790   #endif
6791 };
6792
6793 static PySequenceMethods __pyx_tp_as_sequence_asBed = {
6794   0, /*sq_length*/
6795   0, /*sq_concat*/
6796   0, /*sq_repeat*/
6797   0, /*sq_item*/
6798   0, /*sq_slice*/
6799   0, /*sq_ass_item*/
6800   0, /*sq_ass_slice*/
6801   0, /*sq_contains*/
6802   0, /*sq_inplace_concat*/
6803   0, /*sq_inplace_repeat*/
6804 };
6805
6806 static PyMappingMethods __pyx_tp_as_mapping_asBed = {
6807   0, /*mp_length*/
6808   0, /*mp_subscript*/
6809   0, /*mp_ass_subscript*/
6810 };
6811
6812 static PyBufferProcs __pyx_tp_as_buffer_asBed = {
6813   #if PY_MAJOR_VERSION < 3
6814   0, /*bf_getreadbuffer*/
6815   #endif
6816   #if PY_MAJOR_VERSION < 3
6817   0, /*bf_getwritebuffer*/
6818   #endif
6819   #if PY_MAJOR_VERSION < 3
6820   0, /*bf_getsegcount*/
6821   #endif
6822   #if PY_MAJOR_VERSION < 3
6823   0, /*bf_getcharbuffer*/
6824   #endif
6825   #if PY_VERSION_HEX >= 0x02060000
6826   0, /*bf_getbuffer*/
6827   #endif
6828   #if PY_VERSION_HEX >= 0x02060000
6829   0, /*bf_releasebuffer*/
6830   #endif
6831 };
6832
6833 PyTypeObject __pyx_type_6ctabix_asBed = {
6834   PyVarObject_HEAD_INIT(0, 0)
6835   __Pyx_NAMESTR("ctabix.asBed"), /*tp_name*/
6836   sizeof(struct __pyx_obj_6ctabix_asBed), /*tp_basicsize*/
6837   0, /*tp_itemsize*/
6838   __pyx_tp_dealloc_6ctabix_Parser, /*tp_dealloc*/
6839   0, /*tp_print*/
6840   0, /*tp_getattr*/
6841   0, /*tp_setattr*/
6842   #if PY_MAJOR_VERSION < 3
6843   0, /*tp_compare*/
6844   #else
6845   0, /*reserved*/
6846   #endif
6847   0, /*tp_repr*/
6848   &__pyx_tp_as_number_asBed, /*tp_as_number*/
6849   &__pyx_tp_as_sequence_asBed, /*tp_as_sequence*/
6850   &__pyx_tp_as_mapping_asBed, /*tp_as_mapping*/
6851   0, /*tp_hash*/
6852   __pyx_pf_6ctabix_5asBed___call__, /*tp_call*/
6853   0, /*tp_str*/
6854   0, /*tp_getattro*/
6855   0, /*tp_setattro*/
6856   &__pyx_tp_as_buffer_asBed, /*tp_as_buffer*/
6857   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
6858   __Pyx_DOCSTR("converts a :term:`tabix row` into a GTF record."), /*tp_doc*/
6859   0, /*tp_traverse*/
6860   0, /*tp_clear*/
6861   0, /*tp_richcompare*/
6862   0, /*tp_weaklistoffset*/
6863   0, /*tp_iter*/
6864   0, /*tp_iternext*/
6865   __pyx_methods_6ctabix_asBed, /*tp_methods*/
6866   0, /*tp_members*/
6867   0, /*tp_getset*/
6868   0, /*tp_base*/
6869   0, /*tp_dict*/
6870   0, /*tp_descr_get*/
6871   0, /*tp_descr_set*/
6872   0, /*tp_dictoffset*/
6873   0, /*tp_init*/
6874   0, /*tp_alloc*/
6875   __pyx_tp_new_6ctabix_asBed, /*tp_new*/
6876   0, /*tp_free*/
6877   0, /*tp_is_gc*/
6878   0, /*tp_bases*/
6879   0, /*tp_mro*/
6880   0, /*tp_cache*/
6881   0, /*tp_subclasses*/
6882   0, /*tp_weaklist*/
6883   0, /*tp_del*/
6884   #if PY_VERSION_HEX >= 0x02060000
6885   0, /*tp_version_tag*/
6886   #endif
6887 };
6888
6889 static PyObject *__pyx_tp_new_6ctabix_asVCF(PyTypeObject *t, PyObject *a, PyObject *k) {
6890   PyObject *o = __pyx_tp_new_6ctabix_Parser(t, a, k);
6891   if (!o) return 0;
6892   return o;
6893 }
6894
6895 static PyMethodDef __pyx_methods_6ctabix_asVCF[] = {
6896   {0, 0, 0, 0}
6897 };
6898
6899 static PyNumberMethods __pyx_tp_as_number_asVCF = {
6900   0, /*nb_add*/
6901   0, /*nb_subtract*/
6902   0, /*nb_multiply*/
6903   #if PY_MAJOR_VERSION < 3
6904   0, /*nb_divide*/
6905   #endif
6906   0, /*nb_remainder*/
6907   0, /*nb_divmod*/
6908   0, /*nb_power*/
6909   0, /*nb_negative*/
6910   0, /*nb_positive*/
6911   0, /*nb_absolute*/
6912   0, /*nb_nonzero*/
6913   0, /*nb_invert*/
6914   0, /*nb_lshift*/
6915   0, /*nb_rshift*/
6916   0, /*nb_and*/
6917   0, /*nb_xor*/
6918   0, /*nb_or*/
6919   #if PY_MAJOR_VERSION < 3
6920   0, /*nb_coerce*/
6921   #endif
6922   0, /*nb_int*/
6923   #if PY_MAJOR_VERSION < 3
6924   0, /*nb_long*/
6925   #else
6926   0, /*reserved*/
6927   #endif
6928   0, /*nb_float*/
6929   #if PY_MAJOR_VERSION < 3
6930   0, /*nb_oct*/
6931   #endif
6932   #if PY_MAJOR_VERSION < 3
6933   0, /*nb_hex*/
6934   #endif
6935   0, /*nb_inplace_add*/
6936   0, /*nb_inplace_subtract*/
6937   0, /*nb_inplace_multiply*/
6938   #if PY_MAJOR_VERSION < 3
6939   0, /*nb_inplace_divide*/
6940   #endif
6941   0, /*nb_inplace_remainder*/
6942   0, /*nb_inplace_power*/
6943   0, /*nb_inplace_lshift*/
6944   0, /*nb_inplace_rshift*/
6945   0, /*nb_inplace_and*/
6946   0, /*nb_inplace_xor*/
6947   0, /*nb_inplace_or*/
6948   0, /*nb_floor_divide*/
6949   0, /*nb_true_divide*/
6950   0, /*nb_inplace_floor_divide*/
6951   0, /*nb_inplace_true_divide*/
6952   #if PY_VERSION_HEX >= 0x02050000
6953   0, /*nb_index*/
6954   #endif
6955 };
6956
6957 static PySequenceMethods __pyx_tp_as_sequence_asVCF = {
6958   0, /*sq_length*/
6959   0, /*sq_concat*/
6960   0, /*sq_repeat*/
6961   0, /*sq_item*/
6962   0, /*sq_slice*/
6963   0, /*sq_ass_item*/
6964   0, /*sq_ass_slice*/
6965   0, /*sq_contains*/
6966   0, /*sq_inplace_concat*/
6967   0, /*sq_inplace_repeat*/
6968 };
6969
6970 static PyMappingMethods __pyx_tp_as_mapping_asVCF = {
6971   0, /*mp_length*/
6972   0, /*mp_subscript*/
6973   0, /*mp_ass_subscript*/
6974 };
6975
6976 static PyBufferProcs __pyx_tp_as_buffer_asVCF = {
6977   #if PY_MAJOR_VERSION < 3
6978   0, /*bf_getreadbuffer*/
6979   #endif
6980   #if PY_MAJOR_VERSION < 3
6981   0, /*bf_getwritebuffer*/
6982   #endif
6983   #if PY_MAJOR_VERSION < 3
6984   0, /*bf_getsegcount*/
6985   #endif
6986   #if PY_MAJOR_VERSION < 3
6987   0, /*bf_getcharbuffer*/
6988   #endif
6989   #if PY_VERSION_HEX >= 0x02060000
6990   0, /*bf_getbuffer*/
6991   #endif
6992   #if PY_VERSION_HEX >= 0x02060000
6993   0, /*bf_releasebuffer*/
6994   #endif
6995 };
6996
6997 PyTypeObject __pyx_type_6ctabix_asVCF = {
6998   PyVarObject_HEAD_INIT(0, 0)
6999   __Pyx_NAMESTR("ctabix.asVCF"), /*tp_name*/
7000   sizeof(struct __pyx_obj_6ctabix_asVCF), /*tp_basicsize*/
7001   0, /*tp_itemsize*/
7002   __pyx_tp_dealloc_6ctabix_Parser, /*tp_dealloc*/
7003   0, /*tp_print*/
7004   0, /*tp_getattr*/
7005   0, /*tp_setattr*/
7006   #if PY_MAJOR_VERSION < 3
7007   0, /*tp_compare*/
7008   #else
7009   0, /*reserved*/
7010   #endif
7011   0, /*tp_repr*/
7012   &__pyx_tp_as_number_asVCF, /*tp_as_number*/
7013   &__pyx_tp_as_sequence_asVCF, /*tp_as_sequence*/
7014   &__pyx_tp_as_mapping_asVCF, /*tp_as_mapping*/
7015   0, /*tp_hash*/
7016   __pyx_pf_6ctabix_5asVCF___call__, /*tp_call*/
7017   0, /*tp_str*/
7018   0, /*tp_getattro*/
7019   0, /*tp_setattro*/
7020   &__pyx_tp_as_buffer_asVCF, /*tp_as_buffer*/
7021   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER, /*tp_flags*/
7022   __Pyx_DOCSTR("converts a :term:`tabix row` into a VCF record."), /*tp_doc*/
7023   0, /*tp_traverse*/
7024   0, /*tp_clear*/
7025   0, /*tp_richcompare*/
7026   0, /*tp_weaklistoffset*/
7027   0, /*tp_iter*/
7028   0, /*tp_iternext*/
7029   __pyx_methods_6ctabix_asVCF, /*tp_methods*/
7030   0, /*tp_members*/
7031   0, /*tp_getset*/
7032   0, /*tp_base*/
7033   0, /*tp_dict*/
7034   0, /*tp_descr_get*/
7035   0, /*tp_descr_set*/
7036   0, /*tp_dictoffset*/
7037   0, /*tp_init*/
7038   0, /*tp_alloc*/
7039   __pyx_tp_new_6ctabix_asVCF, /*tp_new*/
7040   0, /*tp_free*/
7041   0, /*tp_is_gc*/
7042   0, /*tp_bases*/
7043   0, /*tp_mro*/
7044   0, /*tp_cache*/
7045   0, /*tp_subclasses*/
7046   0, /*tp_weaklist*/
7047   0, /*tp_del*/
7048   #if PY_VERSION_HEX >= 0x02060000
7049   0, /*tp_version_tag*/
7050   #endif
7051 };
7052
7053 static PyObject *__pyx_tp_new_6ctabix_TabixIteratorParsed(PyTypeObject *t, PyObject *a, PyObject *k) {
7054   struct __pyx_obj_6ctabix_TabixIteratorParsed *p;
7055   PyObject *o = (*t->tp_alloc)(t, 0);
7056   if (!o) return 0;
7057   p = ((struct __pyx_obj_6ctabix_TabixIteratorParsed *)o);
7058   p->parser = ((struct __pyx_obj_6ctabix_Parser *)Py_None); Py_INCREF(Py_None);
7059   if (__pyx_pf_6ctabix_19TabixIteratorParsed___cinit__(o, a, k) < 0) {
7060     Py_DECREF(o); o = 0;
7061   }
7062   return o;
7063 }
7064
7065 static void __pyx_tp_dealloc_6ctabix_TabixIteratorParsed(PyObject *o) {
7066   struct __pyx_obj_6ctabix_TabixIteratorParsed *p = (struct __pyx_obj_6ctabix_TabixIteratorParsed *)o;
7067   {
7068     PyObject *etype, *eval, *etb;
7069     PyErr_Fetch(&etype, &eval, &etb);
7070     ++Py_REFCNT(o);
7071     __pyx_pf_6ctabix_19TabixIteratorParsed___dealloc__(o);
7072     if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
7073     --Py_REFCNT(o);
7074     PyErr_Restore(etype, eval, etb);
7075   }
7076   Py_XDECREF(((PyObject *)p->parser));
7077   (*Py_TYPE(o)->tp_free)(o);
7078 }
7079
7080 static int __pyx_tp_traverse_6ctabix_TabixIteratorParsed(PyObject *o, visitproc v, void *a) {
7081   int e;
7082   struct __pyx_obj_6ctabix_TabixIteratorParsed *p = (struct __pyx_obj_6ctabix_TabixIteratorParsed *)o;
7083   if (p->parser) {
7084     e = (*v)(((PyObject*)p->parser), a); if (e) return e;
7085   }
7086   return 0;
7087 }
7088
7089 static int __pyx_tp_clear_6ctabix_TabixIteratorParsed(PyObject *o) {
7090   struct __pyx_obj_6ctabix_TabixIteratorParsed *p = (struct __pyx_obj_6ctabix_TabixIteratorParsed *)o;
7091   PyObject* tmp;
7092   tmp = ((PyObject*)p->parser);
7093   p->parser = ((struct __pyx_obj_6ctabix_Parser *)Py_None); Py_INCREF(Py_None);
7094   Py_XDECREF(tmp);
7095   return 0;
7096 }
7097
7098 static PyMethodDef __pyx_methods_6ctabix_TabixIteratorParsed[] = {
7099   {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pf_6ctabix_19TabixIteratorParsed___next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_6ctabix_19TabixIteratorParsed___next__)},
7100   {0, 0, 0, 0}
7101 };
7102
7103 static PyNumberMethods __pyx_tp_as_number_TabixIteratorParsed = {
7104   0, /*nb_add*/
7105   0, /*nb_subtract*/
7106   0, /*nb_multiply*/
7107   #if PY_MAJOR_VERSION < 3
7108   0, /*nb_divide*/
7109   #endif
7110   0, /*nb_remainder*/
7111   0, /*nb_divmod*/
7112   0, /*nb_power*/
7113   0, /*nb_negative*/
7114   0, /*nb_positive*/
7115   0, /*nb_absolute*/
7116   0, /*nb_nonzero*/
7117   0, /*nb_invert*/
7118   0, /*nb_lshift*/
7119   0, /*nb_rshift*/
7120   0, /*nb_and*/
7121   0, /*nb_xor*/
7122   0, /*nb_or*/
7123   #if PY_MAJOR_VERSION < 3
7124   0, /*nb_coerce*/
7125   #endif
7126   0, /*nb_int*/
7127   #if PY_MAJOR_VERSION < 3
7128   0, /*nb_long*/
7129   #else
7130   0, /*reserved*/
7131   #endif
7132   0, /*nb_float*/
7133   #if PY_MAJOR_VERSION < 3
7134   0, /*nb_oct*/
7135   #endif
7136   #if PY_MAJOR_VERSION < 3
7137   0, /*nb_hex*/
7138   #endif
7139   0, /*nb_inplace_add*/
7140   0, /*nb_inplace_subtract*/
7141   0, /*nb_inplace_multiply*/
7142   #if PY_MAJOR_VERSION < 3
7143   0, /*nb_inplace_divide*/
7144   #endif
7145   0, /*nb_inplace_remainder*/
7146   0, /*nb_inplace_power*/
7147   0, /*nb_inplace_lshift*/
7148   0, /*nb_inplace_rshift*/
7149   0, /*nb_inplace_and*/
7150   0, /*nb_inplace_xor*/
7151   0, /*nb_inplace_or*/
7152   0, /*nb_floor_divide*/
7153   0, /*nb_true_divide*/
7154   0, /*nb_inplace_floor_divide*/
7155   0, /*nb_inplace_true_divide*/
7156   #if PY_VERSION_HEX >= 0x02050000
7157   0, /*nb_index*/
7158   #endif
7159 };
7160
7161 static PySequenceMethods __pyx_tp_as_sequence_TabixIteratorParsed = {
7162   0, /*sq_length*/
7163   0, /*sq_concat*/
7164   0, /*sq_repeat*/
7165   0, /*sq_item*/
7166   0, /*sq_slice*/
7167   0, /*sq_ass_item*/
7168   0, /*sq_ass_slice*/
7169   0, /*sq_contains*/
7170   0, /*sq_inplace_concat*/
7171   0, /*sq_inplace_repeat*/
7172 };
7173
7174 static PyMappingMethods __pyx_tp_as_mapping_TabixIteratorParsed = {
7175   0, /*mp_length*/
7176   0, /*mp_subscript*/
7177   0, /*mp_ass_subscript*/
7178 };
7179
7180 static PyBufferProcs __pyx_tp_as_buffer_TabixIteratorParsed = {
7181   #if PY_MAJOR_VERSION < 3
7182   0, /*bf_getreadbuffer*/
7183   #endif
7184   #if PY_MAJOR_VERSION < 3
7185   0, /*bf_getwritebuffer*/
7186   #endif
7187   #if PY_MAJOR_VERSION < 3
7188   0, /*bf_getsegcount*/
7189   #endif
7190   #if PY_MAJOR_VERSION < 3
7191   0, /*bf_getcharbuffer*/
7192   #endif
7193   #if PY_VERSION_HEX >= 0x02060000
7194   0, /*bf_getbuffer*/
7195   #endif
7196   #if PY_VERSION_HEX >= 0x02060000
7197   0, /*bf_releasebuffer*/
7198   #endif
7199 };
7200
7201 PyTypeObject __pyx_type_6ctabix_TabixIteratorParsed = {
7202   PyVarObject_HEAD_INIT(0, 0)
7203   __Pyx_NAMESTR("ctabix.TabixIteratorParsed"), /*tp_name*/
7204   sizeof(struct __pyx_obj_6ctabix_TabixIteratorParsed), /*tp_basicsize*/
7205   0, /*tp_itemsize*/
7206   __pyx_tp_dealloc_6ctabix_TabixIteratorParsed, /*tp_dealloc*/
7207   0, /*tp_print*/
7208   0, /*tp_getattr*/
7209   0, /*tp_setattr*/
7210   #if PY_MAJOR_VERSION < 3
7211   0, /*tp_compare*/
7212   #else
7213   0, /*reserved*/
7214   #endif
7215   0, /*tp_repr*/
7216   &__pyx_tp_as_number_TabixIteratorParsed, /*tp_as_number*/
7217   &__pyx_tp_as_sequence_TabixIteratorParsed, /*tp_as_sequence*/
7218   &__pyx_tp_as_mapping_TabixIteratorParsed, /*tp_as_mapping*/
7219   0, /*tp_hash*/
7220   0, /*tp_call*/
7221   0, /*tp_str*/
7222   0, /*tp_getattro*/
7223   0, /*tp_setattro*/
7224   &__pyx_tp_as_buffer_TabixIteratorParsed, /*tp_as_buffer*/
7225   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
7226   __Pyx_DOCSTR("iterates over mapped reads in a region.\n\n    Returns parsed data.\n    "), /*tp_doc*/
7227   __pyx_tp_traverse_6ctabix_TabixIteratorParsed, /*tp_traverse*/
7228   __pyx_tp_clear_6ctabix_TabixIteratorParsed, /*tp_clear*/
7229   0, /*tp_richcompare*/
7230   0, /*tp_weaklistoffset*/
7231   __pyx_pf_6ctabix_19TabixIteratorParsed___iter__, /*tp_iter*/
7232   __pyx_pf_6ctabix_19TabixIteratorParsed___next__, /*tp_iternext*/
7233   __pyx_methods_6ctabix_TabixIteratorParsed, /*tp_methods*/
7234   0, /*tp_members*/
7235   0, /*tp_getset*/
7236   0, /*tp_base*/
7237   0, /*tp_dict*/
7238   0, /*tp_descr_get*/
7239   0, /*tp_descr_set*/
7240   0, /*tp_dictoffset*/
7241   0, /*tp_init*/
7242   0, /*tp_alloc*/
7243   __pyx_tp_new_6ctabix_TabixIteratorParsed, /*tp_new*/
7244   0, /*tp_free*/
7245   0, /*tp_is_gc*/
7246   0, /*tp_bases*/
7247   0, /*tp_mro*/
7248   0, /*tp_cache*/
7249   0, /*tp_subclasses*/
7250   0, /*tp_weaklist*/
7251   0, /*tp_del*/
7252   #if PY_VERSION_HEX >= 0x02060000
7253   0, /*tp_version_tag*/
7254   #endif
7255 };
7256
7257 static PyMethodDef __pyx_methods[] = {
7258   {__Pyx_NAMESTR("tabix_compress"), (PyCFunction)__pyx_pf_6ctabix_tabix_compress, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6ctabix_tabix_compress)},
7259   {__Pyx_NAMESTR("tabix_index"), (PyCFunction)__pyx_pf_6ctabix_tabix_index, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_6ctabix_tabix_index)},
7260   {0, 0, 0, 0}
7261 };
7262
7263 #if PY_MAJOR_VERSION >= 3
7264 static struct PyModuleDef __pyx_moduledef = {
7265     PyModuleDef_HEAD_INIT,
7266     __Pyx_NAMESTR("ctabix"),
7267     0, /* m_doc */
7268     -1, /* m_size */
7269     __pyx_methods /* m_methods */,
7270     NULL, /* m_reload */
7271     NULL, /* m_traverse */
7272     NULL, /* m_clear */
7273     NULL /* m_free */
7274 };
7275 #endif
7276
7277 static __Pyx_StringTabEntry __pyx_string_tab[] = {
7278   {&__pyx_kp_s_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 0, 1, 0},
7279   {&__pyx_kp_s_10, __pyx_k_10, sizeof(__pyx_k_10), 0, 0, 1, 0},
7280   {&__pyx_kp_s_11, __pyx_k_11, sizeof(__pyx_k_11), 0, 0, 1, 0},
7281   {&__pyx_kp_s_12, __pyx_k_12, sizeof(__pyx_k_12), 0, 0, 1, 0},
7282   {&__pyx_kp_s_13, __pyx_k_13, sizeof(__pyx_k_13), 0, 0, 1, 0},
7283   {&__pyx_kp_s_15, __pyx_k_15, sizeof(__pyx_k_15), 0, 0, 1, 0},
7284   {&__pyx_kp_s_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 1, 0},
7285   {&__pyx_kp_s_17, __pyx_k_17, sizeof(__pyx_k_17), 0, 0, 1, 0},
7286   {&__pyx_kp_s_18, __pyx_k_18, sizeof(__pyx_k_18), 0, 0, 1, 0},
7287   {&__pyx_kp_s_2, __pyx_k_2, sizeof(__pyx_k_2), 0, 0, 1, 0},
7288   {&__pyx_kp_s_20, __pyx_k_20, sizeof(__pyx_k_20), 0, 0, 1, 0},
7289   {&__pyx_kp_s_22, __pyx_k_22, sizeof(__pyx_k_22), 0, 0, 1, 0},
7290   {&__pyx_kp_s_23, __pyx_k_23, sizeof(__pyx_k_23), 0, 0, 1, 0},
7291   {&__pyx_kp_s_24, __pyx_k_24, sizeof(__pyx_k_24), 0, 0, 1, 0},
7292   {&__pyx_kp_s_25, __pyx_k_25, sizeof(__pyx_k_25), 0, 0, 1, 0},
7293   {&__pyx_kp_s_26, __pyx_k_26, sizeof(__pyx_k_26), 0, 0, 1, 0},
7294   {&__pyx_kp_u_28, __pyx_k_28, sizeof(__pyx_k_28), 0, 1, 0, 0},
7295   {&__pyx_kp_u_29, __pyx_k_29, sizeof(__pyx_k_29), 0, 1, 0, 0},
7296   {&__pyx_kp_s_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 0, 1, 0},
7297   {&__pyx_kp_u_30, __pyx_k_30, sizeof(__pyx_k_30), 0, 1, 0, 0},
7298   {&__pyx_kp_u_31, __pyx_k_31, sizeof(__pyx_k_31), 0, 1, 0, 0},
7299   {&__pyx_kp_u_32, __pyx_k_32, sizeof(__pyx_k_32), 0, 1, 0, 0},
7300   {&__pyx_kp_u_33, __pyx_k_33, sizeof(__pyx_k_33), 0, 1, 0, 0},
7301   {&__pyx_kp_u_34, __pyx_k_34, sizeof(__pyx_k_34), 0, 1, 0, 0},
7302   {&__pyx_kp_u_35, __pyx_k_35, sizeof(__pyx_k_35), 0, 1, 0, 0},
7303   {&__pyx_kp_u_36, __pyx_k_36, sizeof(__pyx_k_36), 0, 1, 0, 0},
7304   {&__pyx_kp_u_37, __pyx_k_37, sizeof(__pyx_k_37), 0, 1, 0, 0},
7305   {&__pyx_kp_s_4, __pyx_k_4, sizeof(__pyx_k_4), 0, 0, 1, 0},
7306   {&__pyx_kp_s_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 0, 1, 0},
7307   {&__pyx_kp_s_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 1, 0},
7308   {&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0},
7309   {&__pyx_kp_s_8, __pyx_k_8, sizeof(__pyx_k_8), 0, 0, 1, 0},
7310   {&__pyx_kp_s_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 1, 0},
7311   {&__pyx_n_s__IOError, __pyx_k__IOError, sizeof(__pyx_k__IOError), 0, 0, 1, 1},
7312   {&__pyx_n_s__KeyError, __pyx_k__KeyError, sizeof(__pyx_k__KeyError), 0, 0, 1, 1},
7313   {&__pyx_n_s__OSError, __pyx_k__OSError, sizeof(__pyx_k__OSError), 0, 0, 1, 1},
7314   {&__pyx_n_s__O_RDONLY, __pyx_k__O_RDONLY, sizeof(__pyx_k__O_RDONLY), 0, 0, 1, 1},
7315   {&__pyx_n_s__StopIteration, __pyx_k__StopIteration, sizeof(__pyx_k__StopIteration), 0, 0, 1, 1},
7316   {&__pyx_n_s__TabixHeaderIterator, __pyx_k__TabixHeaderIterator, sizeof(__pyx_k__TabixHeaderIterator), 0, 0, 1, 1},
7317   {&__pyx_n_s__TabixIterator, __pyx_k__TabixIterator, sizeof(__pyx_k__TabixIterator), 0, 0, 1, 1},
7318   {&__pyx_n_s__TabixIteratorParsed, __pyx_k__TabixIteratorParsed, sizeof(__pyx_k__TabixIteratorParsed), 0, 0, 1, 1},
7319   {&__pyx_n_s__Tabixfile, __pyx_k__Tabixfile, sizeof(__pyx_k__Tabixfile), 0, 0, 1, 1},
7320   {&__pyx_n_s__ValueError, __pyx_k__ValueError, sizeof(__pyx_k__ValueError), 0, 0, 1, 1},
7321   {&__pyx_n_s____all__, __pyx_k____all__, sizeof(__pyx_k____all__), 0, 0, 1, 1},
7322   {&__pyx_n_s____get__, __pyx_k____get__, sizeof(__pyx_k____get__), 0, 0, 1, 1},
7323   {&__pyx_n_s____main__, __pyx_k____main__, sizeof(__pyx_k____main__), 0, 0, 1, 1},
7324   {&__pyx_n_s____next__, __pyx_k____next__, sizeof(__pyx_k____next__), 0, 0, 1, 1},
7325   {&__pyx_n_s____test__, __pyx_k____test__, sizeof(__pyx_k____test__), 0, 0, 1, 1},
7326   {&__pyx_n_s___isOpen, __pyx_k___isOpen, sizeof(__pyx_k___isOpen), 0, 0, 1, 1},
7327   {&__pyx_n_s___open, __pyx_k___open, sizeof(__pyx_k___open), 0, 0, 1, 1},
7328   {&__pyx_n_s___parseRegion, __pyx_k___parseRegion, sizeof(__pyx_k___parseRegion), 0, 0, 1, 1},
7329   {&__pyx_n_s__asBed, __pyx_k__asBed, sizeof(__pyx_k__asBed), 0, 0, 1, 1},
7330   {&__pyx_n_s__asGTF, __pyx_k__asGTF, sizeof(__pyx_k__asGTF), 0, 0, 1, 1},
7331   {&__pyx_n_s__asTuple, __pyx_k__asTuple, sizeof(__pyx_k__asTuple), 0, 0, 1, 1},
7332   {&__pyx_n_s__asVCF, __pyx_k__asVCF, sizeof(__pyx_k__asVCF), 0, 0, 1, 1},
7333   {&__pyx_n_s__bc, __pyx_k__bc, sizeof(__pyx_k__bc), 0, 0, 1, 1},
7334   {&__pyx_n_s__bed, __pyx_k__bed, sizeof(__pyx_k__bed), 0, 0, 1, 1},
7335   {&__pyx_n_s__buffer, __pyx_k__buffer, sizeof(__pyx_k__buffer), 0, 0, 1, 1},
7336   {&__pyx_n_s__close, __pyx_k__close, sizeof(__pyx_k__close), 0, 0, 1, 1},
7337   {&__pyx_n_s__copy, __pyx_k__copy, sizeof(__pyx_k__copy), 0, 0, 1, 1},
7338   {&__pyx_n_s__ctypes, __pyx_k__ctypes, sizeof(__pyx_k__ctypes), 0, 0, 1, 1},
7339   {&__pyx_n_s__ec, __pyx_k__ec, sizeof(__pyx_k__ec), 0, 0, 1, 1},
7340   {&__pyx_n_s__end, __pyx_k__end, sizeof(__pyx_k__end), 0, 0, 1, 1},
7341   {&__pyx_n_s__end_col, __pyx_k__end_col, sizeof(__pyx_k__end_col), 0, 0, 1, 1},
7342   {&__pyx_n_s__endswith, __pyx_k__endswith, sizeof(__pyx_k__endswith), 0, 0, 1, 1},
7343   {&__pyx_n_s__exists, __pyx_k__exists, sizeof(__pyx_k__exists), 0, 0, 1, 1},
7344   {&__pyx_n_s__fetch, __pyx_k__fetch, sizeof(__pyx_k__fetch), 0, 0, 1, 1},
7345   {&__pyx_n_s__filename, __pyx_k__filename, sizeof(__pyx_k__filename), 0, 0, 1, 1},
7346   {&__pyx_n_s__filename_in, __pyx_k__filename_in, sizeof(__pyx_k__filename_in), 0, 0, 1, 1},
7347   {&__pyx_n_s__filename_out, __pyx_k__filename_out, sizeof(__pyx_k__filename_out), 0, 0, 1, 1},
7348   {&__pyx_n_s__force, __pyx_k__force, sizeof(__pyx_k__force), 0, 0, 1, 1},
7349   {&__pyx_n_s__fp, __pyx_k__fp, sizeof(__pyx_k__fp), 0, 0, 1, 1},
7350   {&__pyx_n_s__gff, __pyx_k__gff, sizeof(__pyx_k__gff), 0, 0, 1, 1},
7351   {&__pyx_n_s__gzip, __pyx_k__gzip, sizeof(__pyx_k__gzip), 0, 0, 1, 1},
7352   {&__pyx_n_s__header, __pyx_k__header, sizeof(__pyx_k__header), 0, 0, 1, 1},
7353   {&__pyx_n_s__idx, __pyx_k__idx, sizeof(__pyx_k__idx), 0, 0, 1, 1},
7354   {&__pyx_n_s__iterator, __pyx_k__iterator, sizeof(__pyx_k__iterator), 0, 0, 1, 1},
7355   {&__pyx_n_s__itertools, __pyx_k__itertools, sizeof(__pyx_k__itertools), 0, 0, 1, 1},
7356   {&__pyx_n_s__join, __pyx_k__join, sizeof(__pyx_k__join), 0, 0, 1, 1},
7357   {&__pyx_n_s__keys, __pyx_k__keys, sizeof(__pyx_k__keys), 0, 0, 1, 1},
7358   {&__pyx_n_s__len, __pyx_k__len, sizeof(__pyx_k__len), 0, 0, 1, 1},
7359   {&__pyx_n_s__line_skip, __pyx_k__line_skip, sizeof(__pyx_k__line_skip), 0, 0, 1, 1},
7360   {&__pyx_n_s__meta_char, __pyx_k__meta_char, sizeof(__pyx_k__meta_char), 0, 0, 1, 1},
7361   {&__pyx_n_s__mode, __pyx_k__mode, sizeof(__pyx_k__mode), 0, 0, 1, 1},
7362   {&__pyx_n_s__ord, __pyx_k__ord, sizeof(__pyx_k__ord), 0, 0, 1, 1},
7363   {&__pyx_n_s__os, __pyx_k__os, sizeof(__pyx_k__os), 0, 0, 1, 1},
7364   {&__pyx_n_s__parser, __pyx_k__parser, sizeof(__pyx_k__parser), 0, 0, 1, 1},
7365   {&__pyx_n_s__path, __pyx_k__path, sizeof(__pyx_k__path), 0, 0, 1, 1},
7366   {&__pyx_n_s__pileup, __pyx_k__pileup, sizeof(__pyx_k__pileup), 0, 0, 1, 1},
7367   {&__pyx_n_s__preset, __pyx_k__preset, sizeof(__pyx_k__preset), 0, 0, 1, 1},
7368   {&__pyx_n_s__psltbl, __pyx_k__psltbl, sizeof(__pyx_k__psltbl), 0, 0, 1, 1},
7369   {&__pyx_n_s__r, __pyx_k__r, sizeof(__pyx_k__r), 0, 0, 1, 1},
7370   {&__pyx_n_s__reference, __pyx_k__reference, sizeof(__pyx_k__reference), 0, 0, 1, 1},
7371   {&__pyx_n_s__region, __pyx_k__region, sizeof(__pyx_k__region), 0, 0, 1, 1},
7372   {&__pyx_n_s__sam, __pyx_k__sam, sizeof(__pyx_k__sam), 0, 0, 1, 1},
7373   {&__pyx_n_s__sc, __pyx_k__sc, sizeof(__pyx_k__sc), 0, 0, 1, 1},
7374   {&__pyx_n_s__seq_col, __pyx_k__seq_col, sizeof(__pyx_k__seq_col), 0, 0, 1, 1},
7375   {&__pyx_n_s__start, __pyx_k__start, sizeof(__pyx_k__start), 0, 0, 1, 1},
7376   {&__pyx_n_s__start_col, __pyx_k__start_col, sizeof(__pyx_k__start_col), 0, 0, 1, 1},
7377   {&__pyx_n_s__struct, __pyx_k__struct, sizeof(__pyx_k__struct), 0, 0, 1, 1},
7378   {&__pyx_n_s__sys, __pyx_k__sys, sizeof(__pyx_k__sys), 0, 0, 1, 1},
7379   {&__pyx_n_s__tabix_compress, __pyx_k__tabix_compress, sizeof(__pyx_k__tabix_compress), 0, 0, 1, 1},
7380   {&__pyx_n_s__tabix_index, __pyx_k__tabix_index, sizeof(__pyx_k__tabix_index), 0, 0, 1, 1},
7381   {&__pyx_n_s__tabixfile, __pyx_k__tabixfile, sizeof(__pyx_k__tabixfile), 0, 0, 1, 1},
7382   {&__pyx_n_s__tempfile, __pyx_k__tempfile, sizeof(__pyx_k__tempfile), 0, 0, 1, 1},
7383   {&__pyx_n_s__tid, __pyx_k__tid, sizeof(__pyx_k__tid), 0, 0, 1, 1},
7384   {&__pyx_n_s__types, __pyx_k__types, sizeof(__pyx_k__types), 0, 0, 1, 1},
7385   {&__pyx_n_s__unlink, __pyx_k__unlink, sizeof(__pyx_k__unlink), 0, 0, 1, 1},
7386   {&__pyx_n_s__vcf, __pyx_k__vcf, sizeof(__pyx_k__vcf), 0, 0, 1, 1},
7387   {&__pyx_n_s__w, __pyx_k__w, sizeof(__pyx_k__w), 0, 0, 1, 1},
7388   {&__pyx_n_s__zerobased, __pyx_k__zerobased, sizeof(__pyx_k__zerobased), 0, 0, 1, 1},
7389   {0, 0, 0, 0, 0, 0, 0}
7390 };
7391 static int __Pyx_InitCachedBuiltins(void) {
7392   __pyx_builtin_IOError = __Pyx_GetName(__pyx_b, __pyx_n_s__IOError); if (!__pyx_builtin_IOError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 46; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7393   __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7394   __pyx_builtin_StopIteration = __Pyx_GetName(__pyx_b, __pyx_n_s__StopIteration); if (!__pyx_builtin_StopIteration) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7395   __pyx_builtin_OSError = __Pyx_GetName(__pyx_b, __pyx_n_s__OSError); if (!__pyx_builtin_OSError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7396   __pyx_builtin_ord = __Pyx_GetName(__pyx_b, __pyx_n_s__ord); if (!__pyx_builtin_ord) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7397   __pyx_builtin_KeyError = __Pyx_GetName(__pyx_b, __pyx_n_s__KeyError); if (!__pyx_builtin_KeyError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 475; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7398   return 0;
7399   __pyx_L1_error:;
7400   return -1;
7401 }
7402
7403 static int __Pyx_InitGlobals(void) {
7404   if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
7405   __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;};
7406   __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;};
7407   __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;};
7408   __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
7409   __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;};
7410   __pyx_int_5 = PyInt_FromLong(5); if (unlikely(!__pyx_int_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
7411   __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
7412   __pyx_int_15 = PyInt_FromLong(15); if (unlikely(!__pyx_int_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
7413   __pyx_int_17 = PyInt_FromLong(17); if (unlikely(!__pyx_int_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
7414   __pyx_int_18 = PyInt_FromLong(18); if (unlikely(!__pyx_int_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
7415   __pyx_int_0x10000 = PyInt_FromLong(0x10000); if (unlikely(!__pyx_int_0x10000)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
7416   return 0;
7417   __pyx_L1_error:;
7418   return -1;
7419 }
7420
7421 #if PY_MAJOR_VERSION < 3
7422 PyMODINIT_FUNC initctabix(void); /*proto*/
7423 PyMODINIT_FUNC initctabix(void)
7424 #else
7425 PyMODINIT_FUNC PyInit_ctabix(void); /*proto*/
7426 PyMODINIT_FUNC PyInit_ctabix(void)
7427 #endif
7428 {
7429   PyObject *__pyx_t_1 = NULL;
7430   PyObject *__pyx_t_2 = NULL;
7431   PyObject *__pyx_t_3 = NULL;
7432   #if CYTHON_REFNANNY
7433   void* __pyx_refnanny = NULL;
7434   __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
7435   if (!__Pyx_RefNanny) {
7436       PyErr_Clear();
7437       __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
7438       if (!__Pyx_RefNanny)
7439           Py_FatalError("failed to import 'refnanny' module");
7440   }
7441   __pyx_refnanny = __Pyx_RefNanny->SetupContext("PyMODINIT_FUNC PyInit_ctabix(void)", __LINE__, __FILE__);
7442   #endif
7443   __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;}
7444   __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;}
7445   #ifdef __pyx_binding_PyCFunctionType_USED
7446   if (__pyx_binding_PyCFunctionType_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7447   #endif
7448   /*--- Library function declarations ---*/
7449   /*--- Threads initialization code ---*/
7450   #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
7451   #ifdef WITH_THREAD /* Python build with threading support? */
7452   PyEval_InitThreads();
7453   #endif
7454   #endif
7455   /*--- Module creation code ---*/
7456   #if PY_MAJOR_VERSION < 3
7457   __pyx_m = Py_InitModule4(__Pyx_NAMESTR("ctabix"), __pyx_methods, 0, 0, PYTHON_API_VERSION);
7458   #else
7459   __pyx_m = PyModule_Create(&__pyx_moduledef);
7460   #endif
7461   if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
7462   #if PY_MAJOR_VERSION < 3
7463   Py_INCREF(__pyx_m);
7464   #endif
7465   __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME));
7466   if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
7467   if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
7468   /*--- Initialize various global constants etc. ---*/
7469   if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7470   if (__pyx_module_is_main_ctabix) {
7471     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;};
7472   }
7473   /*--- Builtin init code ---*/
7474   if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7475   /*--- Global init code ---*/
7476   /*--- Function export code ---*/
7477   /*--- Type init code ---*/
7478   if (PyType_Ready(&__pyx_type_6ctabix_Tabixfile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7479   if (__Pyx_SetAttrString(__pyx_m, "Tabixfile", (PyObject *)&__pyx_type_6ctabix_Tabixfile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7480   __pyx_ptype_6ctabix_Tabixfile = &__pyx_type_6ctabix_Tabixfile;
7481   if (PyType_Ready(&__pyx_type_6ctabix_Parser) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7482   if (__Pyx_SetAttrString(__pyx_m, "Parser", (PyObject *)&__pyx_type_6ctabix_Parser) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7483   __pyx_ptype_6ctabix_Parser = &__pyx_type_6ctabix_Parser;
7484   if (PyType_Ready(&__pyx_type_6ctabix_TabixIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7485   {
7486     PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_6ctabix_TabixIterator, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7487     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
7488       __pyx_wrapperbase_6ctabix_13TabixIterator___next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
7489       __pyx_wrapperbase_6ctabix_13TabixIterator___next__.doc = __pyx_doc_6ctabix_13TabixIterator___next__;
7490       ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_6ctabix_13TabixIterator___next__;
7491     }
7492   }
7493   if (__Pyx_SetAttrString(__pyx_m, "TabixIterator", (PyObject *)&__pyx_type_6ctabix_TabixIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7494   __pyx_ptype_6ctabix_TabixIterator = &__pyx_type_6ctabix_TabixIterator;
7495   if (PyType_Ready(&__pyx_type_6ctabix_TabixHeaderIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7496   {
7497     PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_6ctabix_TabixHeaderIterator, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7498     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
7499       __pyx_wrapperbase_6ctabix_19TabixHeaderIterator___next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
7500       __pyx_wrapperbase_6ctabix_19TabixHeaderIterator___next__.doc = __pyx_doc_6ctabix_19TabixHeaderIterator___next__;
7501       ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_6ctabix_19TabixHeaderIterator___next__;
7502     }
7503   }
7504   if (__Pyx_SetAttrString(__pyx_m, "TabixHeaderIterator", (PyObject *)&__pyx_type_6ctabix_TabixHeaderIterator) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7505   __pyx_ptype_6ctabix_TabixHeaderIterator = &__pyx_type_6ctabix_TabixHeaderIterator;
7506   __pyx_type_6ctabix_asTuple.tp_base = __pyx_ptype_6ctabix_Parser;
7507   if (PyType_Ready(&__pyx_type_6ctabix_asTuple) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7508   if (__Pyx_SetAttrString(__pyx_m, "asTuple", (PyObject *)&__pyx_type_6ctabix_asTuple) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7509   __pyx_ptype_6ctabix_asTuple = &__pyx_type_6ctabix_asTuple;
7510   __pyx_type_6ctabix_asGTF.tp_base = __pyx_ptype_6ctabix_Parser;
7511   if (PyType_Ready(&__pyx_type_6ctabix_asGTF) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7512   if (__Pyx_SetAttrString(__pyx_m, "asGTF", (PyObject *)&__pyx_type_6ctabix_asGTF) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7513   __pyx_ptype_6ctabix_asGTF = &__pyx_type_6ctabix_asGTF;
7514   __pyx_type_6ctabix_asBed.tp_base = __pyx_ptype_6ctabix_Parser;
7515   if (PyType_Ready(&__pyx_type_6ctabix_asBed) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7516   if (__Pyx_SetAttrString(__pyx_m, "asBed", (PyObject *)&__pyx_type_6ctabix_asBed) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7517   __pyx_ptype_6ctabix_asBed = &__pyx_type_6ctabix_asBed;
7518   __pyx_type_6ctabix_asVCF.tp_base = __pyx_ptype_6ctabix_Parser;
7519   if (PyType_Ready(&__pyx_type_6ctabix_asVCF) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7520   if (__Pyx_SetAttrString(__pyx_m, "asVCF", (PyObject *)&__pyx_type_6ctabix_asVCF) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 293; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7521   __pyx_ptype_6ctabix_asVCF = &__pyx_type_6ctabix_asVCF;
7522   if (PyType_Ready(&__pyx_type_6ctabix_TabixIteratorParsed) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7523   {
7524     PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_6ctabix_TabixIteratorParsed, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7525     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
7526       __pyx_wrapperbase_6ctabix_19TabixIteratorParsed___next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
7527       __pyx_wrapperbase_6ctabix_19TabixIteratorParsed___next__.doc = __pyx_doc_6ctabix_19TabixIteratorParsed___next__;
7528       ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_6ctabix_19TabixIteratorParsed___next__;
7529     }
7530   }
7531   if (__Pyx_SetAttrString(__pyx_m, "TabixIteratorParsed", (PyObject *)&__pyx_type_6ctabix_TabixIteratorParsed) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7532   __pyx_ptype_6ctabix_TabixIteratorParsed = &__pyx_type_6ctabix_TabixIteratorParsed;
7533   /*--- Type import code ---*/
7534   __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[1]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7535   __pyx_ptype_10TabProxies_TupleProxy = __Pyx_ImportType("TabProxies", "TupleProxy", sizeof(struct __pyx_obj_10TabProxies_TupleProxy), 1); if (unlikely(!__pyx_ptype_10TabProxies_TupleProxy)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7536   if (__Pyx_GetVtable(__pyx_ptype_10TabProxies_TupleProxy->tp_dict, &__pyx_vtabptr_10TabProxies_TupleProxy) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7537   __pyx_ptype_10TabProxies_GTFProxy = __Pyx_ImportType("TabProxies", "GTFProxy", sizeof(struct __pyx_obj_10TabProxies_GTFProxy), 1); if (unlikely(!__pyx_ptype_10TabProxies_GTFProxy)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7538   if (__Pyx_GetVtable(__pyx_ptype_10TabProxies_GTFProxy->tp_dict, &__pyx_vtabptr_10TabProxies_GTFProxy) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7539   __pyx_ptype_10TabProxies_NamedTupleProxy = __Pyx_ImportType("TabProxies", "NamedTupleProxy", sizeof(struct __pyx_obj_10TabProxies_NamedTupleProxy), 1); if (unlikely(!__pyx_ptype_10TabProxies_NamedTupleProxy)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7540   if (__Pyx_GetVtable(__pyx_ptype_10TabProxies_NamedTupleProxy->tp_dict, &__pyx_vtabptr_10TabProxies_NamedTupleProxy) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7541   __pyx_ptype_10TabProxies_BedProxy = __Pyx_ImportType("TabProxies", "BedProxy", sizeof(struct __pyx_obj_10TabProxies_BedProxy), 1); if (unlikely(!__pyx_ptype_10TabProxies_BedProxy)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7542   if (__Pyx_GetVtable(__pyx_ptype_10TabProxies_BedProxy->tp_dict, &__pyx_vtabptr_10TabProxies_BedProxy) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7543   __pyx_ptype_10TabProxies_VCFProxy = __Pyx_ImportType("TabProxies", "VCFProxy", sizeof(struct __pyx_obj_10TabProxies_VCFProxy), 1); if (unlikely(!__pyx_ptype_10TabProxies_VCFProxy)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7544   if (__Pyx_GetVtable(__pyx_ptype_10TabProxies_VCFProxy->tp_dict, &__pyx_vtabptr_10TabProxies_VCFProxy) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7545   /*--- Function import code ---*/
7546   /*--- Execution code ---*/
7547
7548   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":4
7549  * # adds doc-strings for sphinx
7550  * 
7551  * import tempfile, os, sys, types, itertools, struct, ctypes, gzip             # <<<<<<<<<<<<<<
7552  * from cpython cimport PyString_FromStringAndSize, PyString_AS_STRING
7553  * cimport TabProxies
7554  */
7555   __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;}
7556   __Pyx_GOTREF(__pyx_t_1);
7557   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;}
7558   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7559   __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__os), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7560   __Pyx_GOTREF(__pyx_t_1);
7561   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__os, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7562   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7563   __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__sys), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7564   __Pyx_GOTREF(__pyx_t_1);
7565   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__sys, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7566   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7567   __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__types), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7568   __Pyx_GOTREF(__pyx_t_1);
7569   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__types, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7570   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7571   __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__itertools), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7572   __Pyx_GOTREF(__pyx_t_1);
7573   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__itertools, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7574   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7575   __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__struct), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7576   __Pyx_GOTREF(__pyx_t_1);
7577   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__struct, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7578   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7579   __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__ctypes), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7580   __Pyx_GOTREF(__pyx_t_1);
7581   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__ctypes, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7582   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7583   __pyx_t_1 = __Pyx_Import(((PyObject *)__pyx_n_s__gzip), 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7584   __Pyx_GOTREF(__pyx_t_1);
7585   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__gzip, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7586   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7587
7588   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":364
7589  * def tabix_compress( filename_in,
7590  *               filename_out,
7591  *               force = False ):             # <<<<<<<<<<<<<<
7592  * 
7593  *     '''
7594  */
7595   __pyx_t_1 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7596   __Pyx_GOTREF(__pyx_t_1);
7597   __pyx_k_14 = __pyx_t_1;
7598   __Pyx_GIVEREF(__pyx_t_1);
7599   __pyx_t_1 = 0;
7600
7601   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":408
7602  * 
7603  * def tabix_index( filename,
7604  *                  force = False,             # <<<<<<<<<<<<<<
7605  *                  seq_col = None,
7606  *                  start_col = None,
7607  */
7608   __pyx_t_1 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7609   __Pyx_GOTREF(__pyx_t_1);
7610   __pyx_k_19 = __pyx_t_1;
7611   __Pyx_GIVEREF(__pyx_t_1);
7612   __pyx_t_1 = 0;
7613
7614   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":414
7615  *                  preset = None,
7616  *                  meta_char = "#",
7617  *                  zerobased = False,             # <<<<<<<<<<<<<<
7618  *                 ):
7619  *     '''
7620  */
7621   __pyx_t_1 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7622   __Pyx_GOTREF(__pyx_t_1);
7623   __pyx_k_21 = __pyx_t_1;
7624   __Pyx_GIVEREF(__pyx_t_1);
7625   __pyx_t_1 = 0;
7626
7627   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":497
7628  *     return filename
7629  * 
7630  * __all__ = ["tabix_index",             # <<<<<<<<<<<<<<
7631  *            "tabix_compress",
7632  *            "Tabixfile",
7633  */
7634   __pyx_t_1 = PyList_New(7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7635   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
7636   __Pyx_INCREF(((PyObject *)__pyx_n_s__tabix_index));
7637   PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__tabix_index));
7638   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__tabix_index));
7639   __Pyx_INCREF(((PyObject *)__pyx_n_s__tabix_compress));
7640   PyList_SET_ITEM(__pyx_t_1, 1, ((PyObject *)__pyx_n_s__tabix_compress));
7641   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__tabix_compress));
7642   __Pyx_INCREF(((PyObject *)__pyx_n_s__Tabixfile));
7643   PyList_SET_ITEM(__pyx_t_1, 2, ((PyObject *)__pyx_n_s__Tabixfile));
7644   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Tabixfile));
7645   __Pyx_INCREF(((PyObject *)__pyx_n_s__asTuple));
7646   PyList_SET_ITEM(__pyx_t_1, 3, ((PyObject *)__pyx_n_s__asTuple));
7647   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__asTuple));
7648   __Pyx_INCREF(((PyObject *)__pyx_n_s__asGTF));
7649   PyList_SET_ITEM(__pyx_t_1, 4, ((PyObject *)__pyx_n_s__asGTF));
7650   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__asGTF));
7651   __Pyx_INCREF(((PyObject *)__pyx_n_s__asVCF));
7652   PyList_SET_ITEM(__pyx_t_1, 5, ((PyObject *)__pyx_n_s__asVCF));
7653   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__asVCF));
7654   __Pyx_INCREF(((PyObject *)__pyx_n_s__asBed));
7655   PyList_SET_ITEM(__pyx_t_1, 6, ((PyObject *)__pyx_n_s__asBed));
7656   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__asBed));
7657   if (PyObject_SetAttr(__pyx_m, __pyx_n_s____all__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7658   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
7659
7660   /* "/ifs/devel/pysam/pysam/pysam/ctabix.pyx":1
7661  * # cython: embedsignature=True             # <<<<<<<<<<<<<<
7662  * # adds doc-strings for sphinx
7663  * 
7664  */
7665   __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7666   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
7667   __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Tabixfile); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7668   __Pyx_GOTREF(__pyx_t_2);
7669   __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s___isOpen); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7670   __Pyx_GOTREF(__pyx_t_3);
7671   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7672   __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7673   __Pyx_GOTREF(__pyx_t_2);
7674   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7675   if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_28), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7676   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7677   __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Tabixfile); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7678   __Pyx_GOTREF(__pyx_t_2);
7679   __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s___open); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7680   __Pyx_GOTREF(__pyx_t_3);
7681   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7682   __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7683   __Pyx_GOTREF(__pyx_t_2);
7684   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7685   if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_29), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7686   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7687   __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Tabixfile); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7688   __Pyx_GOTREF(__pyx_t_2);
7689   __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s___parseRegion); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7690   __Pyx_GOTREF(__pyx_t_3);
7691   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7692   __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7693   __Pyx_GOTREF(__pyx_t_2);
7694   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7695   if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_30), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7696   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7697   __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Tabixfile); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7698   __Pyx_GOTREF(__pyx_t_2);
7699   __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__fetch); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7700   __Pyx_GOTREF(__pyx_t_3);
7701   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7702   __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7703   __Pyx_GOTREF(__pyx_t_2);
7704   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7705   if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_31), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7706   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7707   __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__Tabixfile); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7708   __Pyx_GOTREF(__pyx_t_2);
7709   __pyx_t_3 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__header); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7710   __Pyx_GOTREF(__pyx_t_3);
7711   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7712   __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s____get__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7713   __Pyx_GOTREF(__pyx_t_2);
7714   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7715   __pyx_t_3 = __Pyx_GetAttrString(__pyx_t_2, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7716   __Pyx_GOTREF(__pyx_t_3);
7717   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7718   if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_32), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7719   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7720   __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__TabixIterator); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7721   __Pyx_GOTREF(__pyx_t_3);
7722   __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s____next__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7723   __Pyx_GOTREF(__pyx_t_2);
7724   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7725   __pyx_t_3 = __Pyx_GetAttrString(__pyx_t_2, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7726   __Pyx_GOTREF(__pyx_t_3);
7727   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7728   if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_33), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7729   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7730   __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__TabixHeaderIterator); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7731   __Pyx_GOTREF(__pyx_t_3);
7732   __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s____next__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7733   __Pyx_GOTREF(__pyx_t_2);
7734   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7735   __pyx_t_3 = __Pyx_GetAttrString(__pyx_t_2, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7736   __Pyx_GOTREF(__pyx_t_3);
7737   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7738   if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_34), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7739   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7740   __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__TabixIteratorParsed); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7741   __Pyx_GOTREF(__pyx_t_3);
7742   __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s____next__); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7743   __Pyx_GOTREF(__pyx_t_2);
7744   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7745   __pyx_t_3 = __Pyx_GetAttrString(__pyx_t_2, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7746   __Pyx_GOTREF(__pyx_t_3);
7747   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7748   if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_35), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7749   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7750   __pyx_t_3 = PyObject_GetAttr(__pyx_m, __pyx_n_s__tabix_compress); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7751   __Pyx_GOTREF(__pyx_t_3);
7752   __pyx_t_2 = __Pyx_GetAttrString(__pyx_t_3, "__doc__"); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7753   __Pyx_GOTREF(__pyx_t_2);
7754   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7755   if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_36), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7756   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7757   __pyx_t_2 = PyObject_GetAttr(__pyx_m, __pyx_n_s__tabix_index); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7758   __Pyx_GOTREF(__pyx_t_2);
7759   __pyx_t_3 = __Pyx_GetAttrString(__pyx_t_2, "__doc__"); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7760   __Pyx_GOTREF(__pyx_t_3);
7761   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7762   if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_kp_u_37), __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7763   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7764   if (PyObject_SetAttr(__pyx_m, __pyx_n_s____test__, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
7765   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
7766
7767   /* "/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
7768  * 
7769  * cdef extern from "Python.h":             # <<<<<<<<<<<<<<
7770  *     # The C structure of the objects used to describe built-in types.
7771  * 
7772  */
7773   goto __pyx_L0;
7774   __pyx_L1_error:;
7775   __Pyx_XDECREF(__pyx_t_1);
7776   __Pyx_XDECREF(__pyx_t_2);
7777   __Pyx_XDECREF(__pyx_t_3);
7778   if (__pyx_m) {
7779     __Pyx_AddTraceback("init ctabix");
7780     Py_DECREF(__pyx_m); __pyx_m = 0;
7781   } else if (!PyErr_Occurred()) {
7782     PyErr_SetString(PyExc_ImportError, "init ctabix");
7783   }
7784   __pyx_L0:;
7785   __Pyx_RefNannyFinishContext();
7786   #if PY_MAJOR_VERSION < 3
7787   return;
7788   #else
7789   return __pyx_m;
7790   #endif
7791 }
7792
7793 /* Runtime support code */
7794
7795 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) {
7796     PyObject *result;
7797     result = PyObject_GetAttr(dict, name);
7798     if (!result)
7799         PyErr_SetObject(PyExc_NameError, name);
7800     return result;
7801 }
7802
7803 static CYTHON_INLINE int __Pyx_CheckKeywordStrings(
7804     PyObject *kwdict,
7805     const char* function_name,
7806     int kw_allowed)
7807 {
7808     PyObject* key = 0;
7809     Py_ssize_t pos = 0;
7810     while (PyDict_Next(kwdict, &pos, &key, 0)) {
7811         #if PY_MAJOR_VERSION < 3
7812         if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key)))
7813         #else
7814         if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key)))
7815         #endif
7816             goto invalid_keyword_type;
7817     }
7818     if ((!kw_allowed) && unlikely(key))
7819         goto invalid_keyword;
7820     return 1;
7821 invalid_keyword_type:
7822     PyErr_Format(PyExc_TypeError,
7823         "%s() keywords must be strings", function_name);
7824     return 0;
7825 invalid_keyword:
7826     PyErr_Format(PyExc_TypeError,
7827     #if PY_MAJOR_VERSION < 3
7828         "%s() got an unexpected keyword argument '%s'",
7829         function_name, PyString_AsString(key));
7830     #else
7831         "%s() got an unexpected keyword argument '%U'",
7832         function_name, key);
7833     #endif
7834     return 0;
7835 }
7836
7837 static void __Pyx_RaiseDoubleKeywordsError(
7838     const char* func_name,
7839     PyObject* kw_name)
7840 {
7841     PyErr_Format(PyExc_TypeError,
7842         #if PY_MAJOR_VERSION >= 3
7843         "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
7844         #else
7845         "%s() got multiple values for keyword argument '%s'", func_name,
7846         PyString_AS_STRING(kw_name));
7847         #endif
7848 }
7849
7850 static void __Pyx_RaiseArgtupleInvalid(
7851     const char* func_name,
7852     int exact,
7853     Py_ssize_t num_min,
7854     Py_ssize_t num_max,
7855     Py_ssize_t num_found)
7856 {
7857     Py_ssize_t num_expected;
7858     const char *number, *more_or_less;
7859
7860     if (num_found < num_min) {
7861         num_expected = num_min;
7862         more_or_less = "at least";
7863     } else {
7864         num_expected = num_max;
7865         more_or_less = "at most";
7866     }
7867     if (exact) {
7868         more_or_less = "exactly";
7869     }
7870     number = (num_expected == 1) ? "" : "s";
7871     PyErr_Format(PyExc_TypeError,
7872         #if PY_VERSION_HEX < 0x02050000
7873             "%s() takes %s %d positional argument%s (%d given)",
7874         #else
7875             "%s() takes %s %zd positional argument%s (%zd given)",
7876         #endif
7877         func_name, more_or_less, num_expected, number, num_found);
7878 }
7879
7880 static int __Pyx_ParseOptionalKeywords(
7881     PyObject *kwds,
7882     PyObject **argnames[],
7883     PyObject *kwds2,
7884     PyObject *values[],
7885     Py_ssize_t num_pos_args,
7886     const char* function_name)
7887 {
7888     PyObject *key = 0, *value = 0;
7889     Py_ssize_t pos = 0;
7890     PyObject*** name;
7891     PyObject*** first_kw_arg = argnames + num_pos_args;
7892
7893     while (PyDict_Next(kwds, &pos, &key, &value)) {
7894         name = first_kw_arg;
7895         while (*name && (**name != key)) name++;
7896         if (*name) {
7897             values[name-argnames] = value;
7898         } else {
7899             #if PY_MAJOR_VERSION < 3
7900             if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key))) {
7901             #else
7902             if (unlikely(!PyUnicode_CheckExact(key)) && unlikely(!PyUnicode_Check(key))) {
7903             #endif
7904                 goto invalid_keyword_type;
7905             } else {
7906                 for (name = first_kw_arg; *name; name++) {
7907                     #if PY_MAJOR_VERSION >= 3
7908                     if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
7909                         PyUnicode_Compare(**name, key) == 0) break;
7910                     #else
7911                     if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
7912                         _PyString_Eq(**name, key)) break;
7913                     #endif
7914                 }
7915                 if (*name) {
7916                     values[name-argnames] = value;
7917                 } else {
7918                     /* unexpected keyword found */
7919                     for (name=argnames; name != first_kw_arg; name++) {
7920                         if (**name == key) goto arg_passed_twice;
7921                         #if PY_MAJOR_VERSION >= 3
7922                         if (PyUnicode_GET_SIZE(**name) == PyUnicode_GET_SIZE(key) &&
7923                             PyUnicode_Compare(**name, key) == 0) goto arg_passed_twice;
7924                         #else
7925                         if (PyString_GET_SIZE(**name) == PyString_GET_SIZE(key) &&
7926                             _PyString_Eq(**name, key)) goto arg_passed_twice;
7927                         #endif
7928                     }
7929                     if (kwds2) {
7930                         if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
7931                     } else {
7932                         goto invalid_keyword;
7933                     }
7934                 }
7935             }
7936         }
7937     }
7938     return 0;
7939 arg_passed_twice:
7940     __Pyx_RaiseDoubleKeywordsError(function_name, **name);
7941     goto bad;
7942 invalid_keyword_type:
7943     PyErr_Format(PyExc_TypeError,
7944         "%s() keywords must be strings", function_name);
7945     goto bad;
7946 invalid_keyword:
7947     PyErr_Format(PyExc_TypeError,
7948     #if PY_MAJOR_VERSION < 3
7949         "%s() got an unexpected keyword argument '%s'",
7950         function_name, PyString_AsString(key));
7951     #else
7952         "%s() got an unexpected keyword argument '%U'",
7953         function_name, key);
7954     #endif
7955 bad:
7956     return -1;
7957 }
7958
7959
7960 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
7961     PyErr_Format(PyExc_ValueError,
7962         #if PY_VERSION_HEX < 0x02050000
7963                  "need more than %d value%s to unpack", (int)index,
7964         #else
7965                  "need more than %zd value%s to unpack", index,
7966         #endif
7967                  (index == 1) ? "" : "s");
7968 }
7969
7970 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
7971     PyErr_Format(PyExc_ValueError,
7972         #if PY_VERSION_HEX < 0x02050000
7973             "too many values to unpack (expected %d)", (int)expected);
7974         #else
7975             "too many values to unpack (expected %zd)", expected);
7976         #endif
7977 }
7978
7979 static PyObject *__Pyx_UnpackItem(PyObject *iter, Py_ssize_t index) {
7980     PyObject *item;
7981     if (!(item = PyIter_Next(iter))) {
7982         if (!PyErr_Occurred()) {
7983             __Pyx_RaiseNeedMoreValuesError(index);
7984         }
7985     }
7986     return item;
7987 }
7988
7989 static int __Pyx_EndUnpack(PyObject *iter, Py_ssize_t expected) {
7990     PyObject *item;
7991     if ((item = PyIter_Next(iter))) {
7992         Py_DECREF(item);
7993         __Pyx_RaiseTooManyValuesError(expected);
7994         return -1;
7995     }
7996     else if (!PyErr_Occurred())
7997         return 0;
7998     else
7999         return -1;
8000 }
8001
8002 static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
8003     const char *name, int exact)
8004 {
8005     if (!type) {
8006         PyErr_Format(PyExc_SystemError, "Missing type object");
8007         return 0;
8008     }
8009     if (none_allowed && obj == Py_None) return 1;
8010     else if (exact) {
8011         if (Py_TYPE(obj) == type) return 1;
8012     }
8013     else {
8014         if (PyObject_TypeCheck(obj, type)) return 1;
8015     }
8016     PyErr_Format(PyExc_TypeError,
8017         "Argument '%s' has incorrect type (expected %s, got %s)",
8018         name, type->tp_name, Py_TYPE(obj)->tp_name);
8019     return 0;
8020 }
8021
8022 static CYTHON_INLINE void __Pyx_RaiseNoneIndexingError(void) {
8023     PyErr_SetString(PyExc_TypeError, "'NoneType' object is unsubscriptable");
8024 }
8025
8026 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
8027     PyObject *local_type, *local_value, *local_tb;
8028     PyObject *tmp_type, *tmp_value, *tmp_tb;
8029     PyThreadState *tstate = PyThreadState_GET();
8030     local_type = tstate->curexc_type;
8031     local_value = tstate->curexc_value;
8032     local_tb = tstate->curexc_traceback;
8033     tstate->curexc_type = 0;
8034     tstate->curexc_value = 0;
8035     tstate->curexc_traceback = 0;
8036     PyErr_NormalizeException(&local_type, &local_value, &local_tb);
8037     if (unlikely(tstate->curexc_type))
8038         goto bad;
8039     #if PY_MAJOR_VERSION >= 3
8040     if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
8041         goto bad;
8042     #endif
8043     *type = local_type;
8044     *value = local_value;
8045     *tb = local_tb;
8046     Py_INCREF(local_type);
8047     Py_INCREF(local_value);
8048     Py_INCREF(local_tb);
8049     tmp_type = tstate->exc_type;
8050     tmp_value = tstate->exc_value;
8051     tmp_tb = tstate->exc_traceback;
8052     tstate->exc_type = local_type;
8053     tstate->exc_value = local_value;
8054     tstate->exc_traceback = local_tb;
8055     /* Make sure tstate is in a consistent state when we XDECREF
8056        these objects (XDECREF may run arbitrary code). */
8057     Py_XDECREF(tmp_type);
8058     Py_XDECREF(tmp_value);
8059     Py_XDECREF(tmp_tb);
8060     return 0;
8061 bad:
8062     *type = 0;
8063     *value = 0;
8064     *tb = 0;
8065     Py_XDECREF(local_type);
8066     Py_XDECREF(local_value);
8067     Py_XDECREF(local_tb);
8068     return -1;
8069 }
8070
8071
8072 static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) {
8073     PyThreadState *tstate = PyThreadState_GET();
8074     *type = tstate->exc_type;
8075     *value = tstate->exc_value;
8076     *tb = tstate->exc_traceback;
8077     Py_XINCREF(*type);
8078     Py_XINCREF(*value);
8079     Py_XINCREF(*tb);
8080 }
8081
8082 static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) {
8083     PyObject *tmp_type, *tmp_value, *tmp_tb;
8084     PyThreadState *tstate = PyThreadState_GET();
8085     tmp_type = tstate->exc_type;
8086     tmp_value = tstate->exc_value;
8087     tmp_tb = tstate->exc_traceback;
8088     tstate->exc_type = type;
8089     tstate->exc_value = value;
8090     tstate->exc_traceback = tb;
8091     Py_XDECREF(tmp_type);
8092     Py_XDECREF(tmp_value);
8093     Py_XDECREF(tmp_tb);
8094 }
8095
8096 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) {
8097     PyObject *py_import = 0;
8098     PyObject *empty_list = 0;
8099     PyObject *module = 0;
8100     PyObject *global_dict = 0;
8101     PyObject *empty_dict = 0;
8102     PyObject *list;
8103     py_import = __Pyx_GetAttrString(__pyx_b, "__import__");
8104     if (!py_import)
8105         goto bad;
8106     if (from_list)
8107         list = from_list;
8108     else {
8109         empty_list = PyList_New(0);
8110         if (!empty_list)
8111             goto bad;
8112         list = empty_list;
8113     }
8114     global_dict = PyModule_GetDict(__pyx_m);
8115     if (!global_dict)
8116         goto bad;
8117     empty_dict = PyDict_New();
8118     if (!empty_dict)
8119         goto bad;
8120     module = PyObject_CallFunctionObjArgs(py_import,
8121         name, global_dict, empty_dict, list, NULL);
8122 bad:
8123     Py_XDECREF(empty_list);
8124     Py_XDECREF(py_import);
8125     Py_XDECREF(empty_dict);
8126     return module;
8127 }
8128
8129 static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
8130     PyObject *tmp_type, *tmp_value, *tmp_tb;
8131     PyThreadState *tstate = PyThreadState_GET();
8132
8133     tmp_type = tstate->curexc_type;
8134     tmp_value = tstate->curexc_value;
8135     tmp_tb = tstate->curexc_traceback;
8136     tstate->curexc_type = type;
8137     tstate->curexc_value = value;
8138     tstate->curexc_traceback = tb;
8139     Py_XDECREF(tmp_type);
8140     Py_XDECREF(tmp_value);
8141     Py_XDECREF(tmp_tb);
8142 }
8143
8144 static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
8145     PyThreadState *tstate = PyThreadState_GET();
8146     *type = tstate->curexc_type;
8147     *value = tstate->curexc_value;
8148     *tb = tstate->curexc_traceback;
8149
8150     tstate->curexc_type = 0;
8151     tstate->curexc_value = 0;
8152     tstate->curexc_traceback = 0;
8153 }
8154
8155
8156 #if PY_MAJOR_VERSION < 3
8157 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
8158     Py_XINCREF(type);
8159     Py_XINCREF(value);
8160     Py_XINCREF(tb);
8161     /* First, check the traceback argument, replacing None with NULL. */
8162     if (tb == Py_None) {
8163         Py_DECREF(tb);
8164         tb = 0;
8165     }
8166     else if (tb != NULL && !PyTraceBack_Check(tb)) {
8167         PyErr_SetString(PyExc_TypeError,
8168             "raise: arg 3 must be a traceback or None");
8169         goto raise_error;
8170     }
8171     /* Next, replace a missing value with None */
8172     if (value == NULL) {
8173         value = Py_None;
8174         Py_INCREF(value);
8175     }
8176     #if PY_VERSION_HEX < 0x02050000
8177     if (!PyClass_Check(type))
8178     #else
8179     if (!PyType_Check(type))
8180     #endif
8181     {
8182         /* Raising an instance.  The value should be a dummy. */
8183         if (value != Py_None) {
8184             PyErr_SetString(PyExc_TypeError,
8185                 "instance exception may not have a separate value");
8186             goto raise_error;
8187         }
8188         /* Normalize to raise <class>, <instance> */
8189         Py_DECREF(value);
8190         value = type;
8191         #if PY_VERSION_HEX < 0x02050000
8192             if (PyInstance_Check(type)) {
8193                 type = (PyObject*) ((PyInstanceObject*)type)->in_class;
8194                 Py_INCREF(type);
8195             }
8196             else {
8197                 type = 0;
8198                 PyErr_SetString(PyExc_TypeError,
8199                     "raise: exception must be an old-style class or instance");
8200                 goto raise_error;
8201             }
8202         #else
8203             type = (PyObject*) Py_TYPE(type);
8204             Py_INCREF(type);
8205             if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
8206                 PyErr_SetString(PyExc_TypeError,
8207                     "raise: exception class must be a subclass of BaseException");
8208                 goto raise_error;
8209             }
8210         #endif
8211     }
8212
8213     __Pyx_ErrRestore(type, value, tb);
8214     return;
8215 raise_error:
8216     Py_XDECREF(value);
8217     Py_XDECREF(type);
8218     Py_XDECREF(tb);
8219     return;
8220 }
8221
8222 #else /* Python 3+ */
8223
8224 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
8225     if (tb == Py_None) {
8226         tb = 0;
8227     } else if (tb && !PyTraceBack_Check(tb)) {
8228         PyErr_SetString(PyExc_TypeError,
8229             "raise: arg 3 must be a traceback or None");
8230         goto bad;
8231     }
8232     if (value == Py_None)
8233         value = 0;
8234
8235     if (PyExceptionInstance_Check(type)) {
8236         if (value) {
8237             PyErr_SetString(PyExc_TypeError,
8238                 "instance exception may not have a separate value");
8239             goto bad;
8240         }
8241         value = type;
8242         type = (PyObject*) Py_TYPE(value);
8243     } else if (!PyExceptionClass_Check(type)) {
8244         PyErr_SetString(PyExc_TypeError,
8245             "raise: exception class must be a subclass of BaseException");
8246         goto bad;
8247     }
8248
8249     PyErr_SetObject(type, value);
8250
8251     if (tb) {
8252         PyThreadState *tstate = PyThreadState_GET();
8253         PyObject* tmp_tb = tstate->curexc_traceback;
8254         if (tb != tmp_tb) {
8255             Py_INCREF(tb);
8256             tstate->curexc_traceback = tb;
8257             Py_XDECREF(tmp_tb);
8258         }
8259     }
8260
8261 bad:
8262     return;
8263 }
8264 #endif
8265
8266 static CYTHON_INLINE int32_t __Pyx_PyInt_from_py_int32_t(PyObject* x) {
8267     const int32_t neg_one = (int32_t)-1, const_zero = (int32_t)0;
8268     const int is_unsigned = const_zero < neg_one;
8269     if (sizeof(int32_t) == sizeof(char)) {
8270         if (is_unsigned)
8271             return (int32_t)__Pyx_PyInt_AsUnsignedChar(x);
8272         else
8273             return (int32_t)__Pyx_PyInt_AsSignedChar(x);
8274     } else if (sizeof(int32_t) == sizeof(short)) {
8275         if (is_unsigned)
8276             return (int32_t)__Pyx_PyInt_AsUnsignedShort(x);
8277         else
8278             return (int32_t)__Pyx_PyInt_AsSignedShort(x);
8279     } else if (sizeof(int32_t) == sizeof(int)) {
8280         if (is_unsigned)
8281             return (int32_t)__Pyx_PyInt_AsUnsignedInt(x);
8282         else
8283             return (int32_t)__Pyx_PyInt_AsSignedInt(x);
8284     } else if (sizeof(int32_t) == sizeof(long)) {
8285         if (is_unsigned)
8286             return (int32_t)__Pyx_PyInt_AsUnsignedLong(x);
8287         else
8288             return (int32_t)__Pyx_PyInt_AsSignedLong(x);
8289     } else if (sizeof(int32_t) == sizeof(PY_LONG_LONG)) {
8290         if (is_unsigned)
8291             return (int32_t)__Pyx_PyInt_AsUnsignedLongLong(x);
8292         else
8293             return (int32_t)__Pyx_PyInt_AsSignedLongLong(x);
8294     }  else {
8295         int32_t val;
8296         PyObject *v = __Pyx_PyNumber_Int(x);
8297         #if PY_VERSION_HEX < 0x03000000
8298         if (likely(v) && !PyLong_Check(v)) {
8299             PyObject *tmp = v;
8300             v = PyNumber_Long(tmp);
8301             Py_DECREF(tmp);
8302         }
8303         #endif
8304         if (likely(v)) {
8305             int one = 1; int is_little = (int)*(unsigned char *)&one;
8306             unsigned char *bytes = (unsigned char *)&val;
8307             int ret = _PyLong_AsByteArray((PyLongObject *)v,
8308                                           bytes, sizeof(val),
8309                                           is_little, !is_unsigned);
8310             Py_DECREF(v);
8311             if (likely(!ret))
8312                 return val;
8313         }
8314         return (int32_t)-1;
8315     }
8316 }
8317
8318 static CYTHON_INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject* x) {
8319     const unsigned char neg_one = (unsigned char)-1, const_zero = 0;
8320     const int is_unsigned = neg_one > const_zero;
8321     if (sizeof(unsigned char) < sizeof(long)) {
8322         long val = __Pyx_PyInt_AsLong(x);
8323         if (unlikely(val != (long)(unsigned char)val)) {
8324             if (!unlikely(val == -1 && PyErr_Occurred())) {
8325                 PyErr_SetString(PyExc_OverflowError,
8326                     (is_unsigned && unlikely(val < 0)) ?
8327                     "can't convert negative value to unsigned char" :
8328                     "value too large to convert to unsigned char");
8329             }
8330             return (unsigned char)-1;
8331         }
8332         return (unsigned char)val;
8333     }
8334     return (unsigned char)__Pyx_PyInt_AsUnsignedLong(x);
8335 }
8336
8337 static CYTHON_INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject* x) {
8338     const unsigned short neg_one = (unsigned short)-1, const_zero = 0;
8339     const int is_unsigned = neg_one > const_zero;
8340     if (sizeof(unsigned short) < sizeof(long)) {
8341         long val = __Pyx_PyInt_AsLong(x);
8342         if (unlikely(val != (long)(unsigned short)val)) {
8343             if (!unlikely(val == -1 && PyErr_Occurred())) {
8344                 PyErr_SetString(PyExc_OverflowError,
8345                     (is_unsigned && unlikely(val < 0)) ?
8346                     "can't convert negative value to unsigned short" :
8347                     "value too large to convert to unsigned short");
8348             }
8349             return (unsigned short)-1;
8350         }
8351         return (unsigned short)val;
8352     }
8353     return (unsigned short)__Pyx_PyInt_AsUnsignedLong(x);
8354 }
8355
8356 static CYTHON_INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject* x) {
8357     const unsigned int neg_one = (unsigned int)-1, const_zero = 0;
8358     const int is_unsigned = neg_one > const_zero;
8359     if (sizeof(unsigned int) < sizeof(long)) {
8360         long val = __Pyx_PyInt_AsLong(x);
8361         if (unlikely(val != (long)(unsigned int)val)) {
8362             if (!unlikely(val == -1 && PyErr_Occurred())) {
8363                 PyErr_SetString(PyExc_OverflowError,
8364                     (is_unsigned && unlikely(val < 0)) ?
8365                     "can't convert negative value to unsigned int" :
8366                     "value too large to convert to unsigned int");
8367             }
8368             return (unsigned int)-1;
8369         }
8370         return (unsigned int)val;
8371     }
8372     return (unsigned int)__Pyx_PyInt_AsUnsignedLong(x);
8373 }
8374
8375 static CYTHON_INLINE char __Pyx_PyInt_AsChar(PyObject* x) {
8376     const char neg_one = (char)-1, const_zero = 0;
8377     const int is_unsigned = neg_one > const_zero;
8378     if (sizeof(char) < sizeof(long)) {
8379         long val = __Pyx_PyInt_AsLong(x);
8380         if (unlikely(val != (long)(char)val)) {
8381             if (!unlikely(val == -1 && PyErr_Occurred())) {
8382                 PyErr_SetString(PyExc_OverflowError,
8383                     (is_unsigned && unlikely(val < 0)) ?
8384                     "can't convert negative value to char" :
8385                     "value too large to convert to char");
8386             }
8387             return (char)-1;
8388         }
8389         return (char)val;
8390     }
8391     return (char)__Pyx_PyInt_AsLong(x);
8392 }
8393
8394 static CYTHON_INLINE short __Pyx_PyInt_AsShort(PyObject* x) {
8395     const short neg_one = (short)-1, const_zero = 0;
8396     const int is_unsigned = neg_one > const_zero;
8397     if (sizeof(short) < sizeof(long)) {
8398         long val = __Pyx_PyInt_AsLong(x);
8399         if (unlikely(val != (long)(short)val)) {
8400             if (!unlikely(val == -1 && PyErr_Occurred())) {
8401                 PyErr_SetString(PyExc_OverflowError,
8402                     (is_unsigned && unlikely(val < 0)) ?
8403                     "can't convert negative value to short" :
8404                     "value too large to convert to short");
8405             }
8406             return (short)-1;
8407         }
8408         return (short)val;
8409     }
8410     return (short)__Pyx_PyInt_AsLong(x);
8411 }
8412
8413 static CYTHON_INLINE int __Pyx_PyInt_AsInt(PyObject* x) {
8414     const int neg_one = (int)-1, const_zero = 0;
8415     const int is_unsigned = neg_one > const_zero;
8416     if (sizeof(int) < sizeof(long)) {
8417         long val = __Pyx_PyInt_AsLong(x);
8418         if (unlikely(val != (long)(int)val)) {
8419             if (!unlikely(val == -1 && PyErr_Occurred())) {
8420                 PyErr_SetString(PyExc_OverflowError,
8421                     (is_unsigned && unlikely(val < 0)) ?
8422                     "can't convert negative value to int" :
8423                     "value too large to convert to int");
8424             }
8425             return (int)-1;
8426         }
8427         return (int)val;
8428     }
8429     return (int)__Pyx_PyInt_AsLong(x);
8430 }
8431
8432 static CYTHON_INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject* x) {
8433     const signed char neg_one = (signed char)-1, const_zero = 0;
8434     const int is_unsigned = neg_one > const_zero;
8435     if (sizeof(signed char) < sizeof(long)) {
8436         long val = __Pyx_PyInt_AsLong(x);
8437         if (unlikely(val != (long)(signed char)val)) {
8438             if (!unlikely(val == -1 && PyErr_Occurred())) {
8439                 PyErr_SetString(PyExc_OverflowError,
8440                     (is_unsigned && unlikely(val < 0)) ?
8441                     "can't convert negative value to signed char" :
8442                     "value too large to convert to signed char");
8443             }
8444             return (signed char)-1;
8445         }
8446         return (signed char)val;
8447     }
8448     return (signed char)__Pyx_PyInt_AsSignedLong(x);
8449 }
8450
8451 static CYTHON_INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject* x) {
8452     const signed short neg_one = (signed short)-1, const_zero = 0;
8453     const int is_unsigned = neg_one > const_zero;
8454     if (sizeof(signed short) < sizeof(long)) {
8455         long val = __Pyx_PyInt_AsLong(x);
8456         if (unlikely(val != (long)(signed short)val)) {
8457             if (!unlikely(val == -1 && PyErr_Occurred())) {
8458                 PyErr_SetString(PyExc_OverflowError,
8459                     (is_unsigned && unlikely(val < 0)) ?
8460                     "can't convert negative value to signed short" :
8461                     "value too large to convert to signed short");
8462             }
8463             return (signed short)-1;
8464         }
8465         return (signed short)val;
8466     }
8467     return (signed short)__Pyx_PyInt_AsSignedLong(x);
8468 }
8469
8470 static CYTHON_INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject* x) {
8471     const signed int neg_one = (signed int)-1, const_zero = 0;
8472     const int is_unsigned = neg_one > const_zero;
8473     if (sizeof(signed int) < sizeof(long)) {
8474         long val = __Pyx_PyInt_AsLong(x);
8475         if (unlikely(val != (long)(signed int)val)) {
8476             if (!unlikely(val == -1 && PyErr_Occurred())) {
8477                 PyErr_SetString(PyExc_OverflowError,
8478                     (is_unsigned && unlikely(val < 0)) ?
8479                     "can't convert negative value to signed int" :
8480                     "value too large to convert to signed int");
8481             }
8482             return (signed int)-1;
8483         }
8484         return (signed int)val;
8485     }
8486     return (signed int)__Pyx_PyInt_AsSignedLong(x);
8487 }
8488
8489 static CYTHON_INLINE int __Pyx_PyInt_AsLongDouble(PyObject* x) {
8490     const int neg_one = (int)-1, const_zero = 0;
8491     const int is_unsigned = neg_one > const_zero;
8492     if (sizeof(int) < sizeof(long)) {
8493         long val = __Pyx_PyInt_AsLong(x);
8494         if (unlikely(val != (long)(int)val)) {
8495             if (!unlikely(val == -1 && PyErr_Occurred())) {
8496                 PyErr_SetString(PyExc_OverflowError,
8497                     (is_unsigned && unlikely(val < 0)) ?
8498                     "can't convert negative value to int" :
8499                     "value too large to convert to int");
8500             }
8501             return (int)-1;
8502         }
8503         return (int)val;
8504     }
8505     return (int)__Pyx_PyInt_AsLong(x);
8506 }
8507
8508 static CYTHON_INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject* x) {
8509     const unsigned long neg_one = (unsigned long)-1, const_zero = 0;
8510     const int is_unsigned = neg_one > const_zero;
8511 #if PY_VERSION_HEX < 0x03000000
8512     if (likely(PyInt_Check(x))) {
8513         long val = PyInt_AS_LONG(x);
8514         if (is_unsigned && unlikely(val < 0)) {
8515             PyErr_SetString(PyExc_OverflowError,
8516                             "can't convert negative value to unsigned long");
8517             return (unsigned long)-1;
8518         }
8519         return (unsigned long)val;
8520     } else
8521 #endif
8522     if (likely(PyLong_Check(x))) {
8523         if (is_unsigned) {
8524             if (unlikely(Py_SIZE(x) < 0)) {
8525                 PyErr_SetString(PyExc_OverflowError,
8526                                 "can't convert negative value to unsigned long");
8527                 return (unsigned long)-1;
8528             }
8529             return PyLong_AsUnsignedLong(x);
8530         } else {
8531             return PyLong_AsLong(x);
8532         }
8533     } else {
8534         unsigned long val;
8535         PyObject *tmp = __Pyx_PyNumber_Int(x);
8536         if (!tmp) return (unsigned long)-1;
8537         val = __Pyx_PyInt_AsUnsignedLong(tmp);
8538         Py_DECREF(tmp);
8539         return val;
8540     }
8541 }
8542
8543 static CYTHON_INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject* x) {
8544     const unsigned PY_LONG_LONG neg_one = (unsigned PY_LONG_LONG)-1, const_zero = 0;
8545     const int is_unsigned = neg_one > const_zero;
8546 #if PY_VERSION_HEX < 0x03000000
8547     if (likely(PyInt_Check(x))) {
8548         long val = PyInt_AS_LONG(x);
8549         if (is_unsigned && unlikely(val < 0)) {
8550             PyErr_SetString(PyExc_OverflowError,
8551                             "can't convert negative value to unsigned PY_LONG_LONG");
8552             return (unsigned PY_LONG_LONG)-1;
8553         }
8554         return (unsigned PY_LONG_LONG)val;
8555     } else
8556 #endif
8557     if (likely(PyLong_Check(x))) {
8558         if (is_unsigned) {
8559             if (unlikely(Py_SIZE(x) < 0)) {
8560                 PyErr_SetString(PyExc_OverflowError,
8561                                 "can't convert negative value to unsigned PY_LONG_LONG");
8562                 return (unsigned PY_LONG_LONG)-1;
8563             }
8564             return PyLong_AsUnsignedLongLong(x);
8565         } else {
8566             return PyLong_AsLongLong(x);
8567         }
8568     } else {
8569         unsigned PY_LONG_LONG val;
8570         PyObject *tmp = __Pyx_PyNumber_Int(x);
8571         if (!tmp) return (unsigned PY_LONG_LONG)-1;
8572         val = __Pyx_PyInt_AsUnsignedLongLong(tmp);
8573         Py_DECREF(tmp);
8574         return val;
8575     }
8576 }
8577
8578 static CYTHON_INLINE long __Pyx_PyInt_AsLong(PyObject* x) {
8579     const long neg_one = (long)-1, const_zero = 0;
8580     const int is_unsigned = neg_one > const_zero;
8581 #if PY_VERSION_HEX < 0x03000000
8582     if (likely(PyInt_Check(x))) {
8583         long val = PyInt_AS_LONG(x);
8584         if (is_unsigned && unlikely(val < 0)) {
8585             PyErr_SetString(PyExc_OverflowError,
8586                             "can't convert negative value to long");
8587             return (long)-1;
8588         }
8589         return (long)val;
8590     } else
8591 #endif
8592     if (likely(PyLong_Check(x))) {
8593         if (is_unsigned) {
8594             if (unlikely(Py_SIZE(x) < 0)) {
8595                 PyErr_SetString(PyExc_OverflowError,
8596                                 "can't convert negative value to long");
8597                 return (long)-1;
8598             }
8599             return PyLong_AsUnsignedLong(x);
8600         } else {
8601             return PyLong_AsLong(x);
8602         }
8603     } else {
8604         long val;
8605         PyObject *tmp = __Pyx_PyNumber_Int(x);
8606         if (!tmp) return (long)-1;
8607         val = __Pyx_PyInt_AsLong(tmp);
8608         Py_DECREF(tmp);
8609         return val;
8610     }
8611 }
8612
8613 static CYTHON_INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject* x) {
8614     const PY_LONG_LONG neg_one = (PY_LONG_LONG)-1, const_zero = 0;
8615     const int is_unsigned = neg_one > const_zero;
8616 #if PY_VERSION_HEX < 0x03000000
8617     if (likely(PyInt_Check(x))) {
8618         long val = PyInt_AS_LONG(x);
8619         if (is_unsigned && unlikely(val < 0)) {
8620             PyErr_SetString(PyExc_OverflowError,
8621                             "can't convert negative value to PY_LONG_LONG");
8622             return (PY_LONG_LONG)-1;
8623         }
8624         return (PY_LONG_LONG)val;
8625     } else
8626 #endif
8627     if (likely(PyLong_Check(x))) {
8628         if (is_unsigned) {
8629             if (unlikely(Py_SIZE(x) < 0)) {
8630                 PyErr_SetString(PyExc_OverflowError,
8631                                 "can't convert negative value to PY_LONG_LONG");
8632                 return (PY_LONG_LONG)-1;
8633             }
8634             return PyLong_AsUnsignedLongLong(x);
8635         } else {
8636             return PyLong_AsLongLong(x);
8637         }
8638     } else {
8639         PY_LONG_LONG val;
8640         PyObject *tmp = __Pyx_PyNumber_Int(x);
8641         if (!tmp) return (PY_LONG_LONG)-1;
8642         val = __Pyx_PyInt_AsLongLong(tmp);
8643         Py_DECREF(tmp);
8644         return val;
8645     }
8646 }
8647
8648 static CYTHON_INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject* x) {
8649     const signed long neg_one = (signed long)-1, const_zero = 0;
8650     const int is_unsigned = neg_one > const_zero;
8651 #if PY_VERSION_HEX < 0x03000000
8652     if (likely(PyInt_Check(x))) {
8653         long val = PyInt_AS_LONG(x);
8654         if (is_unsigned && unlikely(val < 0)) {
8655             PyErr_SetString(PyExc_OverflowError,
8656                             "can't convert negative value to signed long");
8657             return (signed long)-1;
8658         }
8659         return (signed long)val;
8660     } else
8661 #endif
8662     if (likely(PyLong_Check(x))) {
8663         if (is_unsigned) {
8664             if (unlikely(Py_SIZE(x) < 0)) {
8665                 PyErr_SetString(PyExc_OverflowError,
8666                                 "can't convert negative value to signed long");
8667                 return (signed long)-1;
8668             }
8669             return PyLong_AsUnsignedLong(x);
8670         } else {
8671             return PyLong_AsLong(x);
8672         }
8673     } else {
8674         signed long val;
8675         PyObject *tmp = __Pyx_PyNumber_Int(x);
8676         if (!tmp) return (signed long)-1;
8677         val = __Pyx_PyInt_AsSignedLong(tmp);
8678         Py_DECREF(tmp);
8679         return val;
8680     }
8681 }
8682
8683 static CYTHON_INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject* x) {
8684     const signed PY_LONG_LONG neg_one = (signed PY_LONG_LONG)-1, const_zero = 0;
8685     const int is_unsigned = neg_one > const_zero;
8686 #if PY_VERSION_HEX < 0x03000000
8687     if (likely(PyInt_Check(x))) {
8688         long val = PyInt_AS_LONG(x);
8689         if (is_unsigned && unlikely(val < 0)) {
8690             PyErr_SetString(PyExc_OverflowError,
8691                             "can't convert negative value to signed PY_LONG_LONG");
8692             return (signed PY_LONG_LONG)-1;
8693         }
8694         return (signed PY_LONG_LONG)val;
8695     } else
8696 #endif
8697     if (likely(PyLong_Check(x))) {
8698         if (is_unsigned) {
8699             if (unlikely(Py_SIZE(x) < 0)) {
8700                 PyErr_SetString(PyExc_OverflowError,
8701                                 "can't convert negative value to signed PY_LONG_LONG");
8702                 return (signed PY_LONG_LONG)-1;
8703             }
8704             return PyLong_AsUnsignedLongLong(x);
8705         } else {
8706             return PyLong_AsLongLong(x);
8707         }
8708     } else {
8709         signed PY_LONG_LONG val;
8710         PyObject *tmp = __Pyx_PyNumber_Int(x);
8711         if (!tmp) return (signed PY_LONG_LONG)-1;
8712         val = __Pyx_PyInt_AsSignedLongLong(tmp);
8713         Py_DECREF(tmp);
8714         return val;
8715     }
8716 }
8717
8718 #ifndef __PYX_HAVE_RT_ImportType
8719 #define __PYX_HAVE_RT_ImportType
8720 static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
8721     long size, int strict)
8722 {
8723     PyObject *py_module = 0;
8724     PyObject *result = 0;
8725     PyObject *py_name = 0;
8726     char warning[200];
8727
8728     py_module = __Pyx_ImportModule(module_name);
8729     if (!py_module)
8730         goto bad;
8731     #if PY_MAJOR_VERSION < 3
8732     py_name = PyString_FromString(class_name);
8733     #else
8734     py_name = PyUnicode_FromString(class_name);
8735     #endif
8736     if (!py_name)
8737         goto bad;
8738     result = PyObject_GetAttr(py_module, py_name);
8739     Py_DECREF(py_name);
8740     py_name = 0;
8741     Py_DECREF(py_module);
8742     py_module = 0;
8743     if (!result)
8744         goto bad;
8745     if (!PyType_Check(result)) {
8746         PyErr_Format(PyExc_TypeError, 
8747             "%s.%s is not a type object",
8748             module_name, class_name);
8749         goto bad;
8750     }
8751     if (!strict && ((PyTypeObject *)result)->tp_basicsize > size) {
8752         PyOS_snprintf(warning, sizeof(warning), 
8753             "%s.%s size changed, may indicate binary incompatibility",
8754             module_name, class_name);
8755         #if PY_VERSION_HEX < 0x02050000
8756         PyErr_Warn(NULL, warning);
8757         #else
8758         PyErr_WarnEx(NULL, warning, 0);
8759         #endif
8760     }
8761     else if (((PyTypeObject *)result)->tp_basicsize != size) {
8762         PyErr_Format(PyExc_ValueError, 
8763             "%s.%s has the wrong size, try recompiling",
8764             module_name, class_name);
8765         goto bad;
8766     }
8767     return (PyTypeObject *)result;
8768 bad:
8769     Py_XDECREF(py_module);
8770     Py_XDECREF(result);
8771     return 0;
8772 }
8773 #endif
8774
8775 #ifndef __PYX_HAVE_RT_ImportModule
8776 #define __PYX_HAVE_RT_ImportModule
8777 static PyObject *__Pyx_ImportModule(const char *name) {
8778     PyObject *py_name = 0;
8779     PyObject *py_module = 0;
8780
8781     #if PY_MAJOR_VERSION < 3
8782     py_name = PyString_FromString(name);
8783     #else
8784     py_name = PyUnicode_FromString(name);
8785     #endif
8786     if (!py_name)
8787         goto bad;
8788     py_module = PyImport_Import(py_name);
8789     Py_DECREF(py_name);
8790     return py_module;
8791 bad:
8792     Py_XDECREF(py_name);
8793     return 0;
8794 }
8795 #endif
8796
8797 static int __Pyx_GetVtable(PyObject *dict, void *vtabptr) {
8798     PyObject *ob = PyMapping_GetItemString(dict, (char *)"__pyx_vtable__");
8799     if (!ob)
8800         goto bad;
8801 #if PY_VERSION_HEX >= 0x02070000 && !(PY_MAJOR_VERSION==3&&PY_MINOR_VERSION==0)
8802     *(void **)vtabptr = PyCapsule_GetPointer(ob, 0);
8803 #else
8804     *(void **)vtabptr = PyCObject_AsVoidPtr(ob);
8805 #endif
8806     if (!*(void **)vtabptr)
8807         goto bad;
8808     Py_DECREF(ob);
8809     return 0;
8810 bad:
8811     Py_XDECREF(ob);
8812     return -1;
8813 }
8814
8815 #include "compile.h"
8816 #include "frameobject.h"
8817 #include "traceback.h"
8818
8819 static void __Pyx_AddTraceback(const char *funcname) {
8820     PyObject *py_srcfile = 0;
8821     PyObject *py_funcname = 0;
8822     PyObject *py_globals = 0;
8823     PyCodeObject *py_code = 0;
8824     PyFrameObject *py_frame = 0;
8825
8826     #if PY_MAJOR_VERSION < 3
8827     py_srcfile = PyString_FromString(__pyx_filename);
8828     #else
8829     py_srcfile = PyUnicode_FromString(__pyx_filename);
8830     #endif
8831     if (!py_srcfile) goto bad;
8832     if (__pyx_clineno) {
8833         #if PY_MAJOR_VERSION < 3
8834         py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
8835         #else
8836         py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, __pyx_clineno);
8837         #endif
8838     }
8839     else {
8840         #if PY_MAJOR_VERSION < 3
8841         py_funcname = PyString_FromString(funcname);
8842         #else
8843         py_funcname = PyUnicode_FromString(funcname);
8844         #endif
8845     }
8846     if (!py_funcname) goto bad;
8847     py_globals = PyModule_GetDict(__pyx_m);
8848     if (!py_globals) goto bad;
8849     py_code = PyCode_New(
8850         0,            /*int argcount,*/
8851         #if PY_MAJOR_VERSION >= 3
8852         0,            /*int kwonlyargcount,*/
8853         #endif
8854         0,            /*int nlocals,*/
8855         0,            /*int stacksize,*/
8856         0,            /*int flags,*/
8857         __pyx_empty_bytes, /*PyObject *code,*/
8858         __pyx_empty_tuple,  /*PyObject *consts,*/
8859         __pyx_empty_tuple,  /*PyObject *names,*/
8860         __pyx_empty_tuple,  /*PyObject *varnames,*/
8861         __pyx_empty_tuple,  /*PyObject *freevars,*/
8862         __pyx_empty_tuple,  /*PyObject *cellvars,*/
8863         py_srcfile,   /*PyObject *filename,*/
8864         py_funcname,  /*PyObject *name,*/
8865         __pyx_lineno,   /*int firstlineno,*/
8866         __pyx_empty_bytes  /*PyObject *lnotab*/
8867     );
8868     if (!py_code) goto bad;
8869     py_frame = PyFrame_New(
8870         PyThreadState_GET(), /*PyThreadState *tstate,*/
8871         py_code,             /*PyCodeObject *code,*/
8872         py_globals,          /*PyObject *globals,*/
8873         0                    /*PyObject *locals*/
8874     );
8875     if (!py_frame) goto bad;
8876     py_frame->f_lineno = __pyx_lineno;
8877     PyTraceBack_Here(py_frame);
8878 bad:
8879     Py_XDECREF(py_srcfile);
8880     Py_XDECREF(py_funcname);
8881     Py_XDECREF(py_code);
8882     Py_XDECREF(py_frame);
8883 }
8884
8885 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
8886     while (t->p) {
8887         #if PY_MAJOR_VERSION < 3
8888         if (t->is_unicode) {
8889             *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
8890         } else if (t->intern) {
8891             *t->p = PyString_InternFromString(t->s);
8892         } else {
8893             *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
8894         }
8895         #else  /* Python 3+ has unicode identifiers */
8896         if (t->is_unicode | t->is_str) {
8897             if (t->intern) {
8898                 *t->p = PyUnicode_InternFromString(t->s);
8899             } else if (t->encoding) {
8900                 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
8901             } else {
8902                 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
8903             }
8904         } else {
8905             *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
8906         }
8907         #endif
8908         if (!*t->p)
8909             return -1;
8910         ++t;
8911     }
8912     return 0;
8913 }
8914
8915 /* Type Conversion Functions */
8916
8917 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
8918    int is_true = x == Py_True;
8919    if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
8920    else return PyObject_IsTrue(x);
8921 }
8922
8923 static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
8924   PyNumberMethods *m;
8925   const char *name = NULL;
8926   PyObject *res = NULL;
8927 #if PY_VERSION_HEX < 0x03000000
8928   if (PyInt_Check(x) || PyLong_Check(x))
8929 #else
8930   if (PyLong_Check(x))
8931 #endif
8932     return Py_INCREF(x), x;
8933   m = Py_TYPE(x)->tp_as_number;
8934 #if PY_VERSION_HEX < 0x03000000
8935   if (m && m->nb_int) {
8936     name = "int";
8937     res = PyNumber_Int(x);
8938   }
8939   else if (m && m->nb_long) {
8940     name = "long";
8941     res = PyNumber_Long(x);
8942   }
8943 #else
8944   if (m && m->nb_int) {
8945     name = "int";
8946     res = PyNumber_Long(x);
8947   }
8948 #endif
8949   if (res) {
8950 #if PY_VERSION_HEX < 0x03000000
8951     if (!PyInt_Check(res) && !PyLong_Check(res)) {
8952 #else
8953     if (!PyLong_Check(res)) {
8954 #endif
8955       PyErr_Format(PyExc_TypeError,
8956                    "__%s__ returned non-%s (type %.200s)",
8957                    name, name, Py_TYPE(res)->tp_name);
8958       Py_DECREF(res);
8959       return NULL;
8960     }
8961   }
8962   else if (!PyErr_Occurred()) {
8963     PyErr_SetString(PyExc_TypeError,
8964                     "an integer is required");
8965   }
8966   return res;
8967 }
8968
8969 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
8970   Py_ssize_t ival;
8971   PyObject* x = PyNumber_Index(b);
8972   if (!x) return -1;
8973   ival = PyInt_AsSsize_t(x);
8974   Py_DECREF(x);
8975   return ival;
8976 }
8977
8978 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
8979 #if PY_VERSION_HEX < 0x02050000
8980    if (ival <= LONG_MAX)
8981        return PyInt_FromLong((long)ival);
8982    else {
8983        unsigned char *bytes = (unsigned char *) &ival;
8984        int one = 1; int little = (int)*(unsigned char*)&one;
8985        return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0);
8986    }
8987 #else
8988    return PyInt_FromSize_t(ival);
8989 #endif
8990 }
8991
8992 static CYTHON_INLINE size_t __Pyx_PyInt_AsSize_t(PyObject* x) {
8993    unsigned PY_LONG_LONG val = __Pyx_PyInt_AsUnsignedLongLong(x);
8994    if (unlikely(val == (unsigned PY_LONG_LONG)-1 && PyErr_Occurred())) {
8995        return (size_t)-1;
8996    } else if (unlikely(val != (unsigned PY_LONG_LONG)(size_t)val)) {
8997        PyErr_SetString(PyExc_OverflowError,
8998                        "value too large to convert to size_t");
8999        return (size_t)-1;
9000    }
9001    return (size_t)val;
9002 }
9003
9004
9005 #endif /* Py_PYTHON_H */