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